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 @@
-