From b161e104970a8506114b0ae35eee5b91e454ab2f Mon Sep 17 00:00:00 2001 From: sjh88 Date: Fri, 20 Oct 2023 11:26:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=97=91=EC=85=80=20=EC=96=91=EC=8B=9D?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EB=93=B1=EB=A1=9D=20Init=20=20-=20Cntc?= =?UTF-8?q?DTO=20batch=EC=97=90=EC=84=9C=20core=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/biz/cmm/mapper/ICmmEnsFileMapper.java | 27 ++++ .../biz/cmm/service/CmmEnsFileService.java | 121 +++++++++++++++++- .../mapper/biz/ens-cmm-file-mysql-mapper.xml | 78 +++++++++++ .../xit/biz/ens/mapper/IEnsBatchMapper.java | 2 +- .../xit/biz/ens/service/EnsBatchService.java | 2 +- .../biz/ens/model/cmm/CmmEnsFileInfDTO.java | 46 +++++-- .../kr/xit/biz/ens/model/cntc}/CntcDTO.java | 19 ++- 7 files changed, 270 insertions(+), 25 deletions(-) create mode 100644 mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsFileMapper.java create mode 100644 mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-file-mysql-mapper.xml rename {mens-batch/src/main/java/kr/xit/biz/ens/model => mens-core/src/main/java/kr/xit/biz/ens/model/cntc}/CntcDTO.java (94%) diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsFileMapper.java b/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsFileMapper.java new file mode 100644 index 0000000..ed3f89b --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsFileMapper.java @@ -0,0 +1,27 @@ +package kr.xit.biz.cmm.mapper; + +import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO; +import kr.xit.biz.ens.model.cntc.CntcDTO; +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +/** + *
+ * description : 전자고지 File mapper
+ *
+ * packageName : kr.xit.biz.cmm.mapper
+ * fileName    : ICmmEnsFileMapper
+ * author      : seojh
+ * date        : 2023-10-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2023-10-19    seojh       최초 생성
+ *
+ * 
+ */ +@Mapper +public interface ICmmEnsFileMapper { + int insertCntcSndngMst(CntcDTO.SndngMst dto); + int insertCntcSndngDtl(CntcDTO.SndngDtl dto); + int insertCi(CmmEnsFileInfDTO.FmcInfExcelRslt dto); +} diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java index ee679b7..05af6ad 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsFileService.java @@ -12,13 +12,18 @@ import javax.transaction.Transactional; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; + +import kr.xit.biz.cmm.mapper.ICmmEnsFileMapper; +import kr.xit.biz.common.ApiConstants; import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcExcelUpload; import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcInfExcel; import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcInfExcelRslt; +import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.util.ApiWebClientUtil; +import kr.xit.core.support.utils.Checks; import kr.xit.core.support.xlsx.StreamingReader; import kr.xit.ens.nice.service.INiceCiService; import lombok.RequiredArgsConstructor; @@ -29,6 +34,9 @@ import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import static egovframework.com.cmm.util.EgovDateUtil.formatDate; +import static egovframework.com.cmm.util.EgovDateUtil.formatTime; + /** *
  * description :
@@ -53,6 +61,8 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
 
     private final INiceCiService niceCiService;
 
+    private final ICmmEnsFileMapper mapper;
+
     private final ApiWebClientUtil webClient;
     private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
 
@@ -75,7 +85,7 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
         List rslts = getConvertCis(fileReq, fmcExcels);
 
         // TODO :: CNTC 테이블 insert
-        String msg = makeCntc(rslts);
+        String msg = makeCntc(rslts, fmcExcels, fileReq.getRegister());
 
 
 
@@ -262,17 +272,45 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
      * @return String
      * 
*/ - private String makeCntc(final List rslts){ + private String makeCntc(final List rslts, final List fmcExcels, String register){ + int Mst = 0; int errCnt = 0; + int excelCnt = fmcExcels.size(); + String unitySndngMastrId = ""; + for(FmcInfExcel dto : fmcExcels){ + //최초 1회 CNTC master 생성 + if(StringUtils.isNotEmpty(dto.getUnitySndngMastrId()) && Mst == 0){ + unitySndngMastrId = dto.getUnitySndngMastrId(); + mapper.insertCntcSndngMst( + CntcDTO.SndngMst.builder() + .unitySndngMastrId(dto.getUnitySndngMastrId()) + .tmplatId(dto.getTmplatId()) + .sndngDt(dto.getSndngDt()) + .sndngCo(excelCnt) + .sndngProcessSttus(ApiConstants.SndngProcessStatus.ACCEPT.getCode()) + .register(register) + .build() + ); + Mst++; + } + String mpc = jsonCn1(dto); + //CNTC detail 생성 + mapper.insertCntcSndngDtl( + CntcDTO.SndngDtl.builder() + .unitySndngMastrId(unitySndngMastrId) + .unitySndngDetailId(dto.getUnitySndngDetailId()) + .tmplatId(dto.getTmplatId()) + .mobilePageCn(mpc) + .register(register) + .build() + ); + } - // TODO::CNTC master 생성 - - - // TODO : CNTC detail 생성 for(FmcInfExcelRslt dto : rslts){ if(StringUtils.isNotEmpty(dto.getCode())){ errCnt++; } + mapper.insertCi(dto); } return String.format( @@ -281,4 +319,75 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn rslts.size()-errCnt, errCnt); } + + private String jsonCn1(FmcInfExcel dto){ + String jsonCn = "{" + + "\"details\": [" + + "{" + + "\"title\": \"서울시설공단 고지서\"," + + "\"item_type\": \"SUBJECT_TEXT\"," + + "\"elements\": [" + + "\"\"" + + "]" + + "}," + + "{" + + "\"title\": \"내용\"," + + "\"item_type\": \"KEY_VALUE\"," + + "\"properties\": {" + + "}," + + "\"elements\": [" + + "{" + + "\"key\": \"수취인\"," + + "\"value\": \""+ Checks.checkVal(dto.getRecevNm(),"") +"\"," + + "\"level\": 1" + + "}," + + "{" + + "\"key\": \"고지서\"," + + "\"value\": \""+ Checks.checkVal(dto.getGojiNm(),"") +"("+ Checks.checkVal(dto.getGojiGubun(),"") +")"+"\"," + + "\"level\": 1" + + "}," + + "{" + + "\"key\": \"고지서 상세\"," + + "\"value\": \""+ Checks.checkVal(dto.getGojiDetailNm(),"") +"\"," + + "\"level\": 1" + + "}," + + "{" + + "\"key\": \"납세번호\"," + + "\"value\": \""+ Checks.checkVal(dto.getTaxNum1(),"") + Checks.checkVal(dto.getTaxNum2(),"") + Checks.checkVal(dto.getTaxNum3(),"") + Checks.checkVal(dto.getTaxNum4(),"") +"\"," + + "\"level\": 1" + + "}," + + "{" + + "\"key\": \""+ Checks.checkVal(dto.getNapAmountNm1(),"") +"\"," + + "\"value\": \""+ Checks.checkVal(dto.getNapAmount1(),"") +"\"," + + "\"level\": 1" + + "}," + + "{" + + "\"key\": \""+ Checks.checkVal(dto.getNapGubun1(),"") +"\"," + + "\"value\": \""+ Checks.checkVal(formatDate(dto.getNapPd().substring(0,8), "-"),"") +"까지\"," + + "\"level\": 1" + + "}" + + "]" + + "}," + + "{" + + "\"title\": \"세외수입 납부방법 안내\"," + + "\"item_type\": \"TABLE\"," + + "\"elements\": {" + + "\"head\": [" + + "\"가상계좌\\\\납부\"," + + "\"모바일\\\\n어플\"" + + "]," + + "\"rows\": [" + + "[" + + "\"고지서에 기재된 가상계좌로 이체,납부\\\\n고지서 금액과 일치해야 이체 가능\"" + + "]," + + "[" + + "\"앱,PLAY스토어에서 (서울시 세금납부) 앱 설치\\\\n계좌이체(전 은행), 신용카드, 간편결제 납부\"" + + "]" + + "]" + + "}" + + "}" + + "]" + +"}"; + return jsonCn; + } } diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-file-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-file-mysql-mapper.xml new file mode 100644 index 0000000..909267c --- /dev/null +++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-file-mysql-mapper.xml @@ -0,0 +1,78 @@ + + + + + + /** ens-cmm-file-mysql-mapper|insertCntcSndngMst-연계발송마스터 생성|seojh */ + INSERT + INTO tb_cntc_sndng_mastr ( + unity_sndng_mastr_id, /* 통합발송마스터 id */ + signgu_code, /* 시군구코드 */ + ffnlg_code, /* 과태료코드 */ + tmplat_id, /* 템플릿ID */ + sndng_ty_code, /* 발송유형 코드 */ + sndng_co, /* 발송 건수 */ + sndng_process_sttus, /* 발송처리 상태 */ + sndng_dt, /* 발송일시 */ + clos_dt, /* 마감일시 */ + regist_dt, + register + ) + SELECT #{unitySndngMastrId} + , tetm.signgu_code + , tetm.ffnlg_code + , tetm.tmplat_id + , tetm.sndng_ty_code + , #{sndngCo} + , #{sndngProcessSttus} + , #{sndngDt} + , date_format(date_add(#{sndngDt}, interval +1 day), '%Y%m%d%H%i%S') + , now() + , #{register} + FROM tb_ens_tmplat_manage tetm + WHERE tmplat_id = #{tmplatId} + + + + /** ens-cmm-file-mysql-mapper|insertCntcSndngDtl-연계발송상세 생성|seojh */ + INSERT + INTO tb_cntc_sndng_detail ( + unity_sndng_detail_id, /* 통합발송 상세ID */ + unity_sndng_mastr_id, /* 통합발송 마스터ID */ + signgu_code, /* 시군구 코드 */ + ffnlg_code, /* 과태료 코드 */ + mobile_page_cn, /* 모바일 페이지 내용 */ + regist_dt, + register + ) + SELECT #{unitySndngDetailId} + , #{unitySndngMastrId} + , tetm.signgu_code + , tetm.ffnlg_code + , #{mobilePageCn} + , now() + , #{register} + FROM tb_ens_tmplat_manage tetm + WHERE tmplat_id = #{tmplatId} + + + + /** ens-cmm-file-mysql-mapper|insertCi-CI자료 생성|seojh */ + INSERT + INTO tb_ens_ci ( + unity_sndng_detail_id, + ci, + result_cd, + regist_dt, + register + ) VALUES ( + #{unitySndngDetailId} + , NVL(#{ci1}, #{ci2}) + , #{code} + , now() + , #{register} + ) + + + diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java b/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java index d2cb3ff..8aa0c68 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java @@ -3,11 +3,11 @@ package kr.xit.biz.ens.mapper; import java.util.List; import java.util.Optional; +import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatus; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; -import kr.xit.biz.ens.model.CntcDTO; import kr.xit.biz.ens.model.EnsDTO; /** diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java index e5cea4b..b589fc9 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchService.java @@ -20,9 +20,9 @@ import javax.validation.Validator; import kr.xit.biz.common.ApiConstants; import kr.xit.biz.common.ApiConstants.SndngSeCode; import kr.xit.biz.ens.mapper.IEnsBatchMapper; -import kr.xit.biz.ens.model.CntcDTO; import kr.xit.biz.ens.model.EnsDTO; import kr.xit.biz.ens.model.EnsDTO.SendKakaoTgt; +import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendReq; diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileInfDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileInfDTO.java index 7eb5dca..ee5df37 100644 --- a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileInfDTO.java +++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileInfDTO.java @@ -1,7 +1,10 @@ package kr.xit.biz.ens.model.cmm; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; import javax.validation.constraints.Size; @@ -14,6 +17,8 @@ import lombok.experimental.SuperBuilder; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.web.multipart.MultipartFile; +import java.time.LocalDateTime; + /** *
  * description : 전자고지 파일 연계 DTO
@@ -46,27 +51,35 @@ public class CmmEnsFileInfDTO {
          * 시스템구분코드 : 필수
          * 공영주차장|장사시설
          */
-        @Schema(requiredMode = RequiredMode.REQUIRED, title = "시스템구분코드", example = "???", description = "시스템구분코드")
-        @NotEmpty(message = "시스템 구분은 필수 입니다")
-        @Size(max = 5)
-        private String sysSeCode;
+//        @Schema(requiredMode = RequiredMode.REQUIRED, title = "시스템구분코드", example = "???", description = "시스템구분코드")
+//        @NotEmpty(message = "시스템 구분은 필수 입니다")
+//        @Size(max = 5)
+//        private String sysSeCode;
 
         /**
          * 발송구분코드 : 필수
          * KKO-MY-DOC|KT-SMS|E-GREEN
          */
-        @Schema(requiredMode = RequiredMode.REQUIRED, title = "발송구분코드", example = "KKO-MY-DOC", description = "KKO-MY-DOC|KT-SMS|E-GREEN")
-        @NotEmpty(message = "발송구분은 필수 입니다")
-        @Size(max = 10)
-        private String sndngSeCode;
+//        @Schema(requiredMode = RequiredMode.REQUIRED, title = "발송구분코드", example = "KKO-MY-DOC", description = "KKO-MY-DOC|KT-SMS|E-GREEN")
+//        @NotEmpty(message = "발송구분은 필수 입니다")
+//        @Size(max = 10)
+//        private String sndngSeCode;
 
         /**
          * 발송일시 : 필수
          * 전자문서를 발송할 일시 - yyyyMMdd
          */
-        @Schema(requiredMode = RequiredMode.REQUIRED, title = "발송일시", example = "20230905", description = "발송일시")
-        @Size(min = 8, max = 8, message = "발송일은 필수 입니다")
-        private String sndngDt;
+//        @Schema(requiredMode = RequiredMode.REQUIRED, title = "발송일시", example = "20230905", description = "발송일시")
+//        @Size(min = 8, max = 8, message = "발송일은 필수 입니다")
+//        private String sndngDt;
+
+        /**
+         * 등록자 : 필수
+         * 전자문서를 발송할 일시 - yyyyMMdd
+         */
+        @Schema(requiredMode = RequiredMode.REQUIRED, title = "등록자", example = "userid", description = "등록자")
+        @Size(message = "등록자는 필수 입니다")
+        private String register;
 
         /**
          * excel file : 필수
@@ -511,5 +524,16 @@ public class CmmEnsFileInfDTO {
          */
         @Schema(requiredMode = RequiredMode.REQUIRED, title = "message")
         private String message;
+
+        /**
+         * 등록 일시
+         */
+        @JsonDeserialize(using = LocalDateDeserializer.class)
+        @JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss")
+        private LocalDateTime registDt;
+        /**
+         * 등록자
+         */
+        private String register;
     }
 }
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/model/CntcDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java
similarity index 94%
rename from mens-batch/src/main/java/kr/xit/biz/ens/model/CntcDTO.java
rename to mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java
index 0e000a1..b4f0d3b 100644
--- a/mens-batch/src/main/java/kr/xit/biz/ens/model/CntcDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java
@@ -1,12 +1,14 @@
-package kr.xit.biz.ens.model;
+package kr.xit.biz.ens.model.cntc;
 
-import java.io.Serializable;
-
-import kr.xit.core.biz.model.AuditFields;
-import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO;
-import lombok.*;
+import kr.xit.biz.common.AuditFields;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import lombok.experimental.SuperBuilder;
 
+import java.io.Serializable;
+
 /**
  * 
  * description : tb_cntc_ Entity DTO
@@ -143,6 +145,11 @@ public class CntcDTO {
          * 외부 문서 식별 번호
          */
         private String externalDocumentUuid;
+
+        /**
+         * 템플릿 ID
+         */
+        private String tmplatId;
     }
 
     @Data