diff --git a/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java b/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java index 056845a..ca1cb79 100644 --- a/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java +++ b/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java @@ -23,5 +23,5 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper; public interface IBizKtMmsMapper { int updateRlaybsnmKtInfo(final CmmEnsRlaybsnmDTO dto); int updateKtBcDtl(final KtMsgRsltReqData dto); - int saveCntcSndngResult(final KtMsgRsltReqData dto); + int saveKtCntcSndngResult(final KtMsgRsltReqData dto); } diff --git a/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java b/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java index cc68c25..11244db 100644 --- a/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java +++ b/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java @@ -94,56 +94,6 @@ public class BizKtMmsService extends EgovAbstractServiceImpl implements IBizKtMm return resDTO; } - -// @Override -// public KtCommonResponse mainSend(final KtMnsRequest reqDTO) { -// List mainSendReqs = new ArrayList<>(); -// -// KtMainSendReqData reqData = KtMainSendReqData.builder() -// .srcKey("db") -// .srcSeq("1") -// .ci("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678") -// .mmsDtlCnts("db") -// // TODO:: mybatis에서 처리 - SHA2(teusd.unity_sndng_detail_id, 256) -// //.docHash(Base64.getEncoder().encodeToString("db".getBytes(StandardCharsets.UTF_8))) -// .docHash("db") -// .mmsTitle("") -// .url(SignguCode.TRAFFIC.getCode().equals(reqDTO.getSignguCode())? DP_CALLBACK_URL : ME_CALLBACK_URL) //distInfoCrtYn - N이면 필수 -// .mmsBinary("") -// .fileFmat("") -// .mdn("") -// .distInfoCrtYn("Y") -// //.infoCfrmStr("") -// .build(); -// mainSendReqs.add(reqData); -// -// List> parts = ListUtils.partition(mainSendReqs, MAX_KT_SEND_CNT); -// KtCommonResponse ktTokenResponse = null; -// -// for(List reqs : parts) { -// ktTokenResponse = ktMmsService.mainSend( -// KtMainSendRequest.builder() -// .signguCode(reqDTO.getSignguCode()) -// .ffnlgCode(reqDTO.getFfnlgCode()) -// //.serviceCd("cache") -// //.serviceKey("cache") -// .msgCd("db") -// //.msgType("2") -// .makeDt("123456789012db") -// .sndnExTime("123456789012db") -// .exTime("123456789012db") -// //.mType("4") -// .sndnTotCnt(reqs.size()) //-> 요청건수 count -// .mmsBinary("db") -// .fileFmat("db") -// .testSndnYn("N") -// .reqs(reqs) -// .build() -// ); -// } -// return ktTokenResponse; -// } - /** *
      * 사전/본 문자 발송/수신 결과 전송
@@ -174,7 +124,7 @@ public class BizKtMmsService extends EgovAbstractServiceImpl implements IBizKtMm
                     String.format("존재 하지 않는 발송 대상(src_key[%s], mms_sndg_rslt_sqno[%s]) 입니다",
                         dto.getSrcKey(), dto.getMmsSndgRsltSqno())));
             }
-            mapper.saveCntcSndngResult(dto);
+            mapper.saveKtCntcSndngResult(dto);
         }
         if(!errors.isEmpty()) return throwError(errors);
 
diff --git a/mens-api/src/main/resources/config/application-local.yml b/mens-api/src/main/resources/config/application-local.yml
index cd8f2de..13bbb93 100644
--- a/mens-api/src/main/resources/config/application-local.yml
+++ b/mens-api/src/main/resources/config/application-local.yml
@@ -65,8 +65,8 @@ app:
   url: 'http://localhost:${server.port}${server.servlet.context-path:}/'
   data:
     root:
-      path: /Users/minuk/data
-      #path: d:/data
+      #path: /Users/minuk/data
+      path: d:/data
 
   #---------------------------------------------------------------
   # log 설정
diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
index 5564c42..12a1f32 100644
--- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
+++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
@@ -42,7 +42,7 @@
        WHERE unity_sndng_detail_id = #{srcKey}
   
 
-  
+  
 
     /** ens-mysql-mapper|saveCntcSndngResult-연계발송결과반영|julim  */
     
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 f34040b..b19c6e9 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
@@ -12,6 +12,7 @@ import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatus;
 import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken;
 import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData;
 import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResMapping;
+import kr.xit.biz.ens.model.pplus.PplusDTO.PplusResult;
 import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
 
 /**
@@ -359,12 +360,18 @@ public interface IEnsBatchMapper {
 
     /**
      * 등기번호 존재 여부 체크
-     * @param rgistNo
+     * @param t T
      * @return int
      */
-    int selectCountRgistNo(final String rgistNo);
+     int selectCountRgistNo(final T t);
     int updatePplusRgistNo(final PpStatusResMapping dto);
-    List selectPplusRgistNos(final String unitySndngMastrId);
+
+    /**
+     * 통합발송상세 ID 목록 조회 - 시작 ~ 종료 등기번호로
+     * @param t T
+     * @return List
+     */
+     List selectPplusUnitySndngDetailIdsByRgistNo(final T t);
     int updatePplusDlvrStatusFromEPostByRgistNo(final EpostTraceResTrackInfo dto);
     //----------------------------------------------------------------------
     // status
@@ -394,11 +401,18 @@ public interface IEnsBatchMapper {
     int updateCntcSndngResultByKkoMyDoc(final CntcDTO.SndngResult dto);
 
     /**
-     * 연계결과 처리 - KT-BC
-     * - tb_cntc_sndng_result
-     * @param dto KtMainSendReqData
+     * Post plus 상태조회 결과 반영 대상 조회
+     * @param unitySndngMstId String
+     * @return List
+     */
+    List selectPplusResultTgtsByUnitySndngMstId(final String unitySndngMstId);
+
+    /**
+     * Post plus 상태 조회 결과 반영
+     * @param dto PplusResult
+     * @return int
      */
-    void saveCntcSndngResult(KtMainSendReqData dto);
+    int savePplusCntcSndngResult(final PplusResult dto);
     //----------------------------------------------------------------------
     // result
     //----------------------------------------------------------------------
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java
index 7f37fce..438f309 100644
--- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java
+++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java
@@ -4,7 +4,9 @@ import static kr.xit.core.support.utils.JsonUtils.toObjByObj;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import kr.xit.biz.common.ApiConstants;
 import kr.xit.biz.common.ApiConstants.SndngSeCode;
 import kr.xit.biz.ens.cmm.CmmEnsBizUtils;
@@ -20,6 +22,7 @@ import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatusResponses;
 import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusRequest;
 import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResMapping;
 import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResponse;
+import kr.xit.biz.ens.model.pplus.PplusDTO.PplusResult;
 import kr.xit.core.exception.BizRuntimeException;
 import kr.xit.core.model.ApiResponseDTO;
 import kr.xit.core.spring.util.ApiWebClientUtil;
@@ -233,6 +236,21 @@ public class EnsBatchStatusService extends EgovAbstractServiceImpl implements IE
                 if("일반".equals(dlvr)){
                     if("제작발송완료".equals(processSttus)) resMapDTO.setDlvrSttus("배달");
                     mapper.updatePplusSndStatus(resMapDTO);
+
+                    List rsltTgts = mapper.selectPplusResultTgtsByUnitySndngMstId(unitySndngMstId);
+                    rsltTgts.forEach( unitySndngDetailId -> mapper.savePplusCntcSndngResult(
+                            PplusResult.builder()
+                                .unitySndngDetailId(unitySndngMstId)
+                                .signguCode(reqDTO.getSignguCode())
+                                .ffnlgCode(reqDTO.getFfnlgCode())
+                                .dlvrSttus(resMapDTO.getDlvrSttus())
+                                .rgistNo(null)
+                                .senderData(resDTO.get신청일자())
+                                .receiveDate(null)
+                                .build()
+                        )
+                    );
+
                 }
 
                 if(Arrays.asList("등기","준등기","익일특급").contains(processSttus)){
@@ -244,7 +262,7 @@ public class EnsBatchStatusService extends EgovAbstractServiceImpl implements IE
 
                     // 제작발송완료 -> 종적추적
                     if("제작발송완료".equals(processSttus)){
-                        epostTrace(unitySndngMstId, reqDTO);
+                        epostTrace(reqDTO, resDTO);
                     }
                 }
 
@@ -262,8 +280,12 @@ public class EnsBatchStatusService extends EgovAbstractServiceImpl implements IE
      * @param unitySndngMstId
      */
     private void setPostPlusRgistNo(PpStatusResponse resDTO, String unitySndngMstId) {
-        if(mapper.selectCountRgistNo(resDTO.get시작등기번호()) == 0) {
-            int dlvCnt = Integer.valueOf(resDTO.get발송건수());
+        int dlvCnt = Integer.valueOf(resDTO.get발송건수());
+        Map pMap = new HashMap<>();
+        pMap.put("startRgistNo", resDTO.get시작등기번호());
+        pMap.put("endRgistNo", resDTO.get종료등기번호());
+
+        if(mapper.selectCountRgistNo(pMap) != dlvCnt) {
             int startRgistNo = Integer.parseInt(resDTO.get시작등기번호());
             int endRgistNo = Integer.parseInt(resDTO.get종료등기번호());
 
@@ -286,44 +308,58 @@ public class EnsBatchStatusService extends EgovAbstractServiceImpl implements IE
         }
     }
 
-    private void epostTrace(final String unitySndngMstId, final SndngMssageParam reqDTO){
-        final List rgistNos = mapper.selectPplusRgistNos(unitySndngMstId);
+    private void epostTrace(final SndngMssageParam reqDTO, final PpStatusResponse resDTO){
+        Map pMap = new HashMap<>();
+        pMap.put("startRgistNo", resDTO.get시작등기번호());
+        pMap.put("endRgistNo", resDTO.get종료등기번호());
+        final List lists = mapper.selectPplusUnitySndngDetailIdsByRgistNo(pMap);
+
         //final List rgistNos = List.of("1900472677718","1900472677695");
-        if(!rgistNos.isEmpty()){
+        if(!lists.isEmpty()){
             final String url = apiHost + apiEpostTrace;
 
-            rgistNos.forEach( rgistNo -> {
+            lists.forEach( dto -> {
                 ApiResponseDTO apiResult = apiWebClient.exchange(
                     url,
                     HttpMethod.POST,
                     EpostTraceRequest.builder()
                         .signguCode(reqDTO.getSignguCode())
                         .ffnlgCode(reqDTO.getFfnlgCode())
-                        .rgist(rgistNo)
+                        .rgist(dto.getRgistNo())
                         .build(),
                     ApiResponseDTO.class,
                     CmmEnsBizUtils.getHeadeMap());
 
                 if(apiResult.getData() != null) {
-                    final EpostTraceResponse resDTO = JsonUtils.toObjByObj(apiResult.getData(),
+                    final EpostTraceResponse epostResDTO = JsonUtils.toObjByObj(apiResult.getData(),
                         EpostTraceResponse.class);
                     //final String unitySndngMstId = resDTO.get연계식별키();
-                    System.out.println(""+resDTO);
+                    System.out.println(""+epostResDTO);
+
+                    dto.setSignguCode(reqDTO.getSignguCode());
+                    dto.setFfnlgCode(reqDTO.getFfnlgCode());
 
                     try{
-                        assert resDTO != null;
-                        EpostTraceResTrackInfo traceDTO = resDTO.result();
+                        assert epostResDTO != null;
+                        EpostTraceResTrackInfo traceDTO = epostResDTO.result();
                         mapper.updatePplusDlvrStatusFromEPostByRgistNo(traceDTO);
 
+                        dto.setDlvrSttus(traceDTO.getTrackState());
+                        dto.setSenderData(traceDTO.getSenderData());
+                        dto.setReceiveDate(traceDTO.getReceiveDate());
+                        mapper.savePplusCntcSndngResult(dto);
+
                     }catch (BizRuntimeException e){
                         //TODO :: error 처리 확인 필요
                         mapper.updatePplusDlvrStatusFromEPostByRgistNo(
                             EpostTraceResTrackInfo.builder()
-                                .regiNo(rgistNo)
+                                .regiNo(dto.getRgistNo())
                                 .trackState(e.getMessage())
                                 .build()
                         );
+                        dto.setErrorCn(e.getMessage());
                     }
+                    mapper.savePplusCntcSndngResult(dto);
 
                 }
             });
diff --git a/mens-batch/src/main/resources/config/application-local.yml b/mens-batch/src/main/resources/config/application-local.yml
index 4ea376a..7229543 100644
--- a/mens-batch/src/main/resources/config/application-local.yml
+++ b/mens-batch/src/main/resources/config/application-local.yml
@@ -73,8 +73,8 @@ app:
   url: 'http://localhost:${server.port}${server.servlet.context-path:}/'
   data:
     root:
-      path: /Users/minuk/data
-      #path: d:/data
+      #path: /Users/minuk/data
+      path: d:/data
 
   #---------------------------------------------------------------
   # log 설정
diff --git a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
index e0507cd..83329e5 100644
--- a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
+++ b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
@@ -840,6 +840,18 @@
 		 WHERE unity_sndng_mastr_id = #{unitySndngMastrId}
 	
 
+	
+		/** ens-kt-mysql-mapper|updateKtBcMst-kt 메세지 수신결과 마스터 반영|julim  */
+		UPDATE tb_ens_kt_bc_mastr
+			 SET result_cd = #{resultCd}
+				 , result_dt = #{resultDt}
+				 , error_msg = #{errorMssage}
+				 , updt_dt = NOW()
+				 , updusr = 'batch'
+		 WHERE sndng_mastr_id = #{sndngMastrId}
+			 AND signgu_code = #{signguCode}
+			 AND ffnlg_code = #{ffnlgCode}
+	
 	
 	
 	
@@ -929,7 +941,8 @@
 		/** ens-mysql-mapper|selectCountRgistNo-Post plus 등기번호 조회|julim  */
 		Select count(sndng_detail_id)
 		  FROM tb_ens_post_plus
-		 WHERE rgist_no = #{rgistNo}
+		 WHERE rgist_no >= #{startRgistNo}
+		   AND rgist_no <= #{endRgistNo}
 	
 
 	
@@ -946,13 +959,13 @@
 															  AND tepp.sn = #{sn})
 	
 
-	
+		/** ens-mysql-mapper|selectPplusUnitySndngDetailIdsByRgistNo-Post plus 통합발송상세ID 목록 조회|julim  */
+		SELECT tepp.unity_sndng_detail_id
+		     , tepp.rgist_no
+		  FROM tb_ens_post_plus tepp
+		 WHERE rgist_no >= #{startRgistNo}
+			 AND rgist_no <= #{endRgistNo}
 	
 
 	
@@ -960,7 +973,7 @@
 		UPDATE tb_ens_post_plus
 			 SET dlvr_sttus = SUBSTR(#{trackStatus}, 1, 20)
 			   , dlvr_de = REPLACE(#{receiveDate}, "-", "")
-			   , receive_name = #{receiveName}
+			   , recevie_name = #{receiveName}
 		     , updt_dt = now()
 		     , updusr = 'batch'
 		WHERE rgist_no = #{regiNo}
@@ -1018,8 +1031,17 @@
 		                                 WHERE tekmd.document_binder_uuid = #{documentBinderUuid})
 	
 
-	
-		/** ens-mysql-mapper|saveCntcSndngResult-연계발송결과반영|julim  */
+	
+
+	
+		/** ens-mysql-mapper|savePplusCntcSndngResult-Post plus 연계발송결과반영|julim  */
 		INSERT
 			INTO tb_cntc_sndng_result (
 				unity_sndng_detail_id,		/* 통합 발송 상세 ID*/
@@ -1027,32 +1049,31 @@
 				signgu_code,							/* 시군구코드 */
 				ffnlg_code,								/* 과태료코드 */
 				sndng_result_sttus,
+			  rgist_no,
 				requst_dt,								/* 송신(요청) 일시 */
 				inqire_dt,								/* 수신(조회) 일시 */
-				readng_dt,								/* 최초열람일시 */
-				-- error_cn,									/* 에러내용 */
+				error_cn,									/* 에러내용 */
 				regist_dt,
 				register
 			) VALUES (
-			  #{unitySndngDetailId}
+				#{unitySndngDetailId}
 				, #{sndngSeCode}				/* 발송구분코드 - KAKAO-MY-DOC|KT-BC */
-				, (SELECT tgt.signgu_code, tgt.ffnlg_code FROM tb_ens_unity_sndng_detail tgt WHERE tgt.unity_sndng_detail_id = #{src_key})					/* 시군구코드 */
-				, (SELECT tgt.ffnlg_code FROM tb_ens_unity_sndng_detail tgt WHERE tgt.unity_sndng_detail_id = #{src_key})						/* 과태료코드 */
-				, #{sndngResultSttus}
-				, #{mmsSndgTmst}		/* 송신(요청) 일시 */
-				, #{mmsRcvTmst}		/* 수신(조회) 일시 */
-				, #{mmsRdgTmst}		/* 최초열람일시 */
-				-- , #{errorCn}						/* 에러내용 */
+				, #{signguCode}				  /* 시군구코드 */
+				, #{ffnlgcode}					/* 과태료코드 */
+				, #{dlvrSttus}
+			  , #{rgistNo}
+				, #{senderData}				  /* 송신(요청) 일시 */
+				, #{receiveDate}				/* 수신(조회) 일시 */
+				, #{errorCn}						/* 에러내용 */
 				, now()
 				, 'batch'
 			)
 			ON DUPLICATE KEY UPDATE
-				sndng_result_sttus = IFNULL(#{sndngResultSttus}, sndng_result_sttus)
-				, requst_dt = IFNULL(#{mmsSndgTmst}, requst_dt)   /* 송신(요청) 일시 */
-				, inqire_dt =	IFNULL(#{mmsRcvTmst}, inqire_dt)		/* 수신(조회) 일시 */
-				, readng_dt =	IFNULL(#{mmsRdgTmst}, readng_dt)		/* 최초열람일시 */
+				sndng_result_sttus = IFNULL(#{dlvrSttus}, sndng_result_sttus)
+			  , requst_dt = IFNULL(#{senderData}, requst_dt)   /* 송신(요청) 일시 */
+				, inqire_dt =	IFNULL(#{receiveDate}, inqire_dt)		/* 수신(조회) 일시 */
 				, updt_dt = now()
-		    , updusr = 'batch'
+				, updusr = 'batch'
 	
 	
 	
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/pplus/PplusDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/pplus/PplusDTO.java
index d98adb7..7d5f08b 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/pplus/PplusDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/pplus/PplusDTO.java
@@ -8,7 +8,6 @@ import javax.validation.constraints.Size;
 import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
 import kr.xit.core.model.IApiResponse;
 import lombok.AllArgsConstructor;
-import lombok.Builder;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
@@ -717,7 +716,7 @@ public class PplusDTO {
     @Data
     @NoArgsConstructor
     @AllArgsConstructor
-    @Builder
+    @SuperBuilder
     public static class PpStatusResMapping {
         /**
          * 
@@ -757,4 +756,54 @@ public class PplusDTO {
          */
         private String rgistNo;
     }
+
+
+    @Schema(name = "PplusResult", description = "Postplus 상태 조회 결과 Mapping DTO")
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @SuperBuilder
+    @EqualsAndHashCode(callSuper = true)
+    public static class PplusResult extends PpStatusResMapping {
+        /**
+         * 
+         * 통합발송 상세ID
+         * 
+ */ + private String unitySndngDetailId; + + /** + * 시군구 코드 + */ + private String signguCode; + /** + * 과태료 코드 + */ + private String ffnlgCode; + + /** + *
+         * 보낸 날자 : 필수 - 10자리
+         * 발신일자 yyyy-mm-dd
+         * 
+ */ + private String senderData; + + /** + *
+         * 받는 사람 : 필수 - max 50
+         * 
+ */ + private String receiveName; + + /** + *
+         * 받은 날자 : 필수 - 10자리
+         * 수신일자 yyyy-mm-dd
+         * 
+ */ + private String receiveDate; + + private String errorCn; + } }