diff --git a/db/mens_traffic.sql b/db/mens_traffic.sql index 9602789..02d98a1 100644 --- a/db/mens_traffic.sql +++ b/db/mens_traffic.sql @@ -84,5 +84,8 @@ where teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc='; select DATE_FORMAT(DATE_ADD(clos_dt, INTERVAL 1 DAY), '%Y-%m-%dT%H:%i:%s') - , DATE_FORMAT(clos_dt, '%Y-%m-%dT%H:%i:%s') + , DATE_FORMAT(null, '%Y-%m-%dT%H:%i:%s') + , DATE_FORMAT('', '%Y-%m-%dT%H:%i:%s') + , DATE_FORMAT('2024-09-05T23:59:59', '%Y%m%d%H%i%s') +, sysdate() from tb_ens_unity_sndng_mastr; 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 e94f1f4..be3d348 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 @@ -13,6 +13,7 @@ import kr.xit.biz.ens.model.cmm.TmplatManage; import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; +import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; /** @@ -336,24 +337,41 @@ public interface IEnsBatchMapper { /** *
-     * 카카오 문서 상태 조회 대상 목록 조회
+     * 카카오페이 문서 상태 조회 대상 목록 조회
      * - tb_ens_sndng_mastr, tb_ens_kakao_my_doc
      * @param dto EnsDTO.BatchEnsRequest
      * @return List
      * 
*/ - List selectKakaoStatusTgts(final SndngMssageParam dto); + List selectKakaopayStatusTgts(final SndngMssageParam dto); + /** + *
+     * 카카오톡 문서 상태 조회 대상 목록 조회
+     * - tb_ens_sndng_mastr, tb_ens_kakao_d10
+     * @param dto EnsDTO.BatchEnsRequest
+     * @return List
+     * 
+ */ + List selectKakaotalkStatusTgts(final SndngMssageParam dto); /** *
-     * 카카오 문서 상태 조회 결과 반영
+     * 카카오페이 문서 상태 조회 결과 반영
      * - tb_ens_kakao_my_doc
      * @param dto EnsDTO.KakaoMyDoc
      * @return int
      * 
*/ - // FIXME: kakao v1 or v2 - int updateKakaoStatusInfo(final KkopayDocBulkDTO.BulkStatus dto); + int updateKakaopayStatusInfo(final KkopayDocBulkDTO.BulkStatus dto); + /** + *
+     * 카카오톡 문서 상태 조회 결과 반영
+     * - tb_ens_kakao_d10
+     * @param dto EnsDTO.KakaoMyDoc
+     * @return int
+     * 
+ */ + int updateKakaotalkStatusInfo(final KkotalkDTO.EnvelopeStatusResponse dto); //---------------------------------------------------------------------- // status //---------------------------------------------------------------------- @@ -374,12 +392,19 @@ public interface IEnsBatchMapper { int insertCntcSndngResult(final CntcDTO.SndngResult dto); /** - * 연계발송결과반영 - 카카오 + * 연계발송결과반영 - 카카오페이 * - tb_cntc_sndng_result, tb_ens_kakao_my_doc * @param dto SndngResult * @return int */ - int updateCntcSndngResultByKkoMyDoc(final CntcDTO.SndngResult dto); + int updateCntcSndngResultByKkopay(final CntcDTO.SndngResult dto); + /** + * 연계발송결과반영 - 카카오톡 + * - tb_cntc_sndng_result, tb_ens_kakao_d10 + * @param dto SndngResult + * @return int + */ + int updateCntcSndngResultByKkotalk(final CntcDTO.SndngResult 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 41284c2..0717945 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 @@ -23,6 +23,7 @@ import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocAttrDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; +import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.service.AbstractService; @@ -51,8 +52,12 @@ import lombok.RequiredArgsConstructor; public class EnsBatchStatusService extends AbstractService implements IEnsBatchStatusService { @Value("${app.contract.host}") private String apiHost; + @Value("${app.contract.kakao.api.pay.bulkstatus}") - private String apiKkoBulkStatus; + private String apiKkopayBulkStatus; + + @Value("${app.contract.kakao.api.talk.bulkstatus}") + private String apiKkotalkBulkStatus; @Value("${app.contract.kakao.bulk-max-cnt}") private int bulkKkoMaxCnt; @@ -97,10 +102,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS * 모바일 페이지 생성 : tb_ens_mobile_page_manage * 연계발송결과 생성 : tb_cntc_sndng_result */ - case KAKAO -> statusKakao(dto); + case KAKAO -> statusKakaopay(dto); case KAKAO_NEW - -> statusKakao(dto); + -> statusKakaotalk(dto); //break; case KT_BC -> {} @@ -122,10 +127,10 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS * @param dto BatchEnsRequest * */ - private void statusKakao(final SndngMssageParam dto) { - final String url = apiHost + apiKkoBulkStatus; + private void statusKakaopay(final SndngMssageParam dto) { + final String url = apiHost + apiKkopayBulkStatus; - final List docsBinderUuids = mapper.selectKakaoStatusTgts(dto); + final List docsBinderUuids = mapper.selectKakaopayStatusTgts(dto); final List> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt); @SuppressWarnings("rawtypes") @@ -153,27 +158,92 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS // 결과 반영 resList.forEach(o -> o.getDocuments().forEach(t -> { - mapper.updateKakaoStatusInfo(t); + mapper.updateKakaopayStatusInfo(t); KkopayDocAttrDTO.DocStatus statusData = t.getStatus_data(); if(Checks.isNotEmpty(statusData)) { - mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder() - .documentBinderUuid(t.getDocument_binder_uuid()) - .sndngResultSttus(StringUtils.defaultString( - String.valueOf(statusData.getDoc_box_status()), "FAIL")) - .requstDt(Checks.isEmpty(statusData.getDoc_box_sent_at()) ? null - : statusData.getDoc_box_sent_at().toString()) - .inqireDt(Checks.isEmpty(statusData.getDoc_box_received_at()) ? null - : statusData.getDoc_box_received_at().toString()) - .readngDt(Checks.isEmpty(statusData.getDoc_box_read_at()) ? null - : statusData.getDoc_box_read_at().toString()) - .errorCn(t.getError_message()) - .build()); + mapper.updateCntcSndngResultByKkopay( + CntcDTO.SndngResult.builder() + .docKeyId(t.getDocument_binder_uuid()) + .sndngResultSttus(StringUtils.defaultString( + String.valueOf(statusData.getDoc_box_status()), "FAIL")) + .requstDt(Checks.isEmpty(statusData.getDoc_box_sent_at()) ? null + : statusData.getDoc_box_sent_at().toString()) + .inqireDt(Checks.isEmpty(statusData.getDoc_box_received_at()) ? null + : statusData.getDoc_box_received_at().toString()) + .readngDt(Checks.isEmpty(statusData.getDoc_box_read_at()) ? null + : statusData.getDoc_box_read_at().toString()) + .errorCn(t.getError_message()) + .build()); + }else{ + mapper.updateCntcSndngResultByKkopay( + CntcDTO.SndngResult.builder() + .docKeyId(t.getDocument_binder_uuid()) + .sndngResultSttus(t.getError_code()) + .errorCn(t.getError_message()) + .build()); + } + }) + ); + } + + /** + *
+     * 문서중개자 전송후 상태 조회
+     *
+     * @param dto BatchEnsRequest
+     * 
+ */ + private void statusKakaotalk(final SndngMssageParam dto) { + final String url = apiHost + apiKkotalkBulkStatus; + + final List envelopeIds = mapper.selectKakaotalkStatusTgts(dto); + final List> partitions = ListUtils.partition(envelopeIds, bulkKkoMaxCnt); + + @SuppressWarnings("rawtypes") + final List apiResults = partitions.stream() + .map(envelopes -> apiWebClient.exchange( + url, + HttpMethod.POST, + KkotalkDTO.BulkStatusRequest.builder() + .signguCode(dto.getSignguCode()) + .ffnlgCode(dto.getFfnlgCode()) + .envelopes(envelopes) + .build(), + ApiResponseDTO.class, + CmmEnsBizUtils.getHeadeMap()) + ).toList(); + + final List resList = new ArrayList<>(); + //noinspection rawtypes + for(ApiResponseDTO apiResult : apiResults) { + if(apiResult.getData() != null) { + resList.add(toObjByObj(apiResult.getData(), KkotalkDTO.BulkStatusResponse.class)); + } + } + + // 결과 반영 + resList.forEach(o -> + o.getEnvelopeStatus().forEach(t -> { + mapper.updateKakaotalkStatusInfo(t); + //EnvelopeStatus statusData = t; + if(Checks.isNotEmpty(t)) { + mapper.updateCntcSndngResultByKkotalk( + CntcDTO.SndngResult.builder() + .docKeyId(t.getEnvelopeId()) + .sndngResultSttus(StringUtils.defaultString( + String.valueOf(t.getStatus()), "FAIL")) + .requstDt(t.getSentAt()) + .inqireDt(t.getReceivedAt()) + .readngDt(t.getReadAt()) + .errorCn(t.getErrorMessage()) + .build()); }else{ - mapper.updateCntcSndngResultByKkoMyDoc(CntcDTO.SndngResult.builder() - .documentBinderUuid(t.getDocument_binder_uuid()) - .sndngResultSttus(t.getError_code()) - .errorCn(t.getError_message()) - .build()); + mapper.updateCntcSndngResultByKkotalk( + CntcDTO.SndngResult.builder() + .docKeyId(t.getEnvelopeId()) + .sndngResultSttus(t.getErrorCode()) + .errorCn(t.getErrorMessage()) + .build()); } }) ); 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 aa0fb02..c1e5450 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 @@ -1015,38 +1015,51 @@ - + /** ens-mysql-mapper|selectKakaopayStatusTgts-카카오페이 문서 상태 조회 대상 목록 조회|julim */ + SELECT tekmd.document_binder_uuid FROM tb_ens_sndng_mastr tesm JOIN tb_ens_kakao_my_doc tekmd ON tesm.sndng_mastr_id = tekmd.sndng_mastr_id WHERE tesm.sndng_process_sttus IN ('send-ok', 'sending1', 'sending2') AND tesm.unity_sndng_mastr_id = #{unitySndngMastrId} AND IFNULL(tekmd.document_binder_uuid, '') != '' - AND tesm.signgu_code = #{signguCode} - AND tesm.ffnlg_code = #{ffnlgCode} + AND tesm.signgu_code = #{signguCode} + AND tesm.ffnlg_code = #{ffnlgCode} - - /** ens-mysql-mapper|updateKakaoStatusInfo-카카오 문서 상태 조회 결과 반영|julim */ + + + + /** ens-mysql-mapper|updateKakaopayStatusInfo-카카오페이 문서 상태 조회 결과 반영|julim */ UPDATE tb_ens_kakao_my_doc SET doc_box_status = #{status_data.doc_box_status} /* 진행상태 */ , doc_box_sent_at = #{status_data.doc_box_sent_at} /* 송신시간 */ @@ -1060,10 +1073,31 @@ , updt_dt = now() , updusr = 'batch' WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id - FROM tb_ens_kakao_my_doc tekmd - WHERE tekmd.document_binder_uuid = #{document_binder_uuid}) + FROM tb_ens_kakao_my_doc tekmd + WHERE tekmd.document_binder_uuid = #{document_binder_uuid}) + + /** ens-mysql-mapper|updateKakaotalkStatusInfo-카카오톡 문서 상태 조회 결과 반영|jhseo */ + UPDATE tb_ens_kakao_d10 + SET status = #{status} /* 진행상태 */ + , sent_at = #{sentAt} /* 문서 송신 일시 */ + , received_at = #{receivedAt} /* 문서 수신 일시 */ + , read_at = #{readAt} /* 문서 열람 일시 */ + , read_expires_at = #{readExpiredAt} /* 문서 열람 만료 일시 */ + , authenticated_at = #{authenticatedAt} /* 문서 열람 인증 일시 */ + , ott_verified_at = #{ottVerifiedAt} /* 토큰 검증 일시 */ + , is_notification_unavailable = #{isNotificationUnavailable} /* 사용자의 알림톡 수신 가능 여부 */ + , user_notified_at = #{userNotifiedAt} /* 사용자의 알림톡 수신 일시 */ + , distribution_received_at = #{distributionReceivedAt} /* 유통정보의 수신 시각 */ + , error_code = #{errorCode} /* 에러 코드 */ + , error_message = #{errorMessage} /* 에러 메시지 */ + , updt_dt = now() + , updusr = 'batch' + WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id + FROM tb_ens_kakao_d10 tekmd + WHERE tekmd.envelope_id = #{envelopeId}) + @@ -1102,19 +1136,34 @@ WHERE unity_sndng_detail_id = #{unitySndngDetailId} - - /** ens-mysql-mapper|updateCntcSndngResult-연계발송결과반영|julim */ + + /** ens-mysql-mapper|updateCntcSndngResultByKkopay-카카오페이 연계발송결과반영|julim */ UPDATE tb_cntc_sndng_result SET sndng_result_sttus = #{sndngResultSttus} - , requst_dt = from_unixtime(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */ - , inqire_dt = from_unixtime(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */ - , readng_dt = from_unixtime(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */ - , error_cn = #{errorCn} - , updt_dt = now() - , updusr = 'batch' + , requst_dt = from_unixtime(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */ + , inqire_dt = from_unixtime(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */ + , readng_dt = from_unixtime(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */ + , error_cn = #{errorCn} + , updt_dt = now() + , updusr = 'batch' WHERE unity_sndng_detail_id = (SELECT tekmd.unity_sndng_detail_id FROM tb_ens_kakao_my_doc tekmd - WHERE tekmd.document_binder_uuid = #{documentBinderUuid}) + WHERE tekmd.document_binder_uuid = #{docKeyId}) + + + + /** ens-mysql-mapper|updateCntcSndngResultByKkotalk-카카오톡 연계발송결과반영|jhseo */ + UPDATE tb_cntc_sndng_result + SET sndng_result_sttus = #{sndngResultSttus} + , requst_dt = DATE_FORMAT(#{requstDt}, '%Y%m%d%H%i%s') /* 송신(요청) 일시 */ + , inqire_dt = DATE_FORMAT(#{inqireDt}, '%Y%m%d%H%i%s') /* 수신(조회) 일시 */ + , readng_dt = DATE_FORMAT(#{readngDt}, '%Y%m%d%H%i%s') /* 최초열람일시 */ + , error_cn = #{errorCn} + , updt_dt = now() + , updusr = 'batch' + WHERE unity_sndng_detail_id = (SELECT tekd.unity_sndng_detail_id + FROM tb_ens_kakao_d10 tekd + WHERE tekd.envelope_id = #{docKeyId}) diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java index 281e323..e40a1e2 100644 --- a/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java +++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cntc/CntcDTO.java @@ -1,13 +1,19 @@ package kr.xit.biz.ens.model.cntc; +import java.io.Serializable; + +import org.hibernate.validator.constraints.Length; + import com.fasterxml.jackson.annotation.JsonInclude; + import io.swagger.v3.oas.annotations.media.Schema; import kr.xit.biz.common.AuditFields; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; import lombok.experimental.SuperBuilder; -import org.hibernate.validator.constraints.Length; - -import java.io.Serializable; /** *
@@ -199,7 +205,7 @@ public class CntcDTO {
         /**
          * documentBinderUuid
          */
-        private String documentBinderUuid;
+        private String docKeyId;
     }
 
     @Data