From 7eea9fe72280fb02b0c54ed8dd464d18a8841bd2 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Thu, 10 Oct 2024 15:07:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20NICE=20CI=20=EC=9D=B8=EC=A6=9D=ED=86=A1?= =?UTF-8?q?=20=EB=B0=98=EC=98=81=20=EC=99=84=EB=A3=8C=20=20=20=20=20=20=20?= =?UTF-8?q?close=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cron/cron.txt | 1 + db/mens-iup-query.sql | 19 +--- .../xit/ens/modules/nice/model/NiceCiDTO.java | 54 +---------- .../nice/presentation/NiceCiController.java | 7 ++ .../nice/service/NiceCiAcceptService.java | 1 + .../nice/service/NiceCiCloseService.java | 91 +++++++++++++++++++ .../nice/service/NiceCiSendBulkService.java | 1 + .../nice/service/NiceCiStatBulkService.java | 1 + .../modules/iup-niceci-mapper.xml | 36 +++++--- 9 files changed, 135 insertions(+), 76 deletions(-) create mode 100644 src/main/java/cokr/xit/ens/modules/nice/service/NiceCiCloseService.java diff --git a/cron/cron.txt b/cron/cron.txt index 30a124f..6e9f04b 100644 --- a/cron/cron.txt +++ b/cron/cron.txt @@ -32,6 +32,7 @@ # FIXME: NICE CI 인증톡 추가 */1 9-18 * * * curl -X POST https://phts-manager.koti.re.kr/nice/talk/send/bulk/all */30 9-21 * * * curl -X POST https://phts-manager.koti.re.kr/nice/talk/stat/bulk/all +0 9-21 * * * curl -X POST https://phts-manager.koti.re.kr/nice/talk/stat/closed #---------------------------------------------# # [ENS] 로그 데이터 삭제 스케줄러 diff --git a/db/mens-iup-query.sql b/db/mens-iup-query.sql index df8dfe1..6988b4b 100644 --- a/db/mens-iup-query.sql +++ b/db/mens-iup-query.sql @@ -296,17 +296,8 @@ SELECT -SELECT tidx.data_id - , tix.SEND_TYPE - , tix.RUN_DT - , tix.EXPIRES_DT - , '' AS prcsYn - , tnssr.IHIDNUM - FROM tb_nice_sms_sndng_requst tnssr - JOIN TB_INPUT_DATA_XIT tidx - ON tnssr.DATA_ID = tidx.data_id - JOIN TB_INPUT_XIT tix - ON tidx.LNK_INPUT_ID = tix.LNK_INPUT_ID - WHERE 1=1 - AND tnssr.ihidnum = '8312181111111' -- #{ihidnum} -- 응답받은 주민번호 - -- AND REGEXP_REPLACE(tnssr.sndng_mssage, '[[:space:]]+', '') = REGEXP_REPLACE(#{sndngMssage}, '[[:space:]]+', '') -- 응답받은 발송메시지 +select * + from TB_SEND_RESULT + where 1=1 + and LNK_INPUT_ID = 20211006000001 + and SEND_STTUS_CD = 'FAIL'; diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java index 47e85c5..eac3adb 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiDTO.java @@ -44,60 +44,16 @@ public class NiceCiDTO { */ private Long lnkInputId; + /** + * 진행 상태 + */ + private String reqStatusCd; + /** * 안내장 코드 */ private String jobCd; - // private String signguCode; - // private String ffnlgCode; - // private String profile; - // - // /** - // * 통합 발송 마스터 id - // */ - // private String unitySndngMastrId; - // /** - // * 통합 발송 마스터 id - // */ - // private String unitySndngDetailId; - // /** - // * 발송 마스터 id - // */ - // private String sndngMastrId; - // - // /** - // * 발송상세ID - // */ - // private String sndngDetailId; - // - // /** - // * 템플릿ID - // */ - // private String tmplatId; - // - // /** - // * 발송 건수 - // */ - // private int sndngCo; - // - // private String sndngProcessSttus; - // /** - // * 발송 처리 상태 - // */ - // private String newSndngProcessSttus; - // - // private String try1; - // private String try2; - // private String try3; - // private int tryCnt; - // private int trySeq; - // private String sndngSeCode; - // private String sndngDt; - // private String sndngDt2; - // private String sndngDt3; - // private String try2Minute; - // private String try3Minute; private String errorCode; private String errorMessage; diff --git a/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java b/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java index 75c646b..46573f7 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java +++ b/src/main/java/cokr/xit/ens/modules/nice/presentation/NiceCiController.java @@ -30,6 +30,7 @@ public class NiceCiController { private final NiceCiAcceptService niceCiAcceptService; private final NiceCiSendBulkService niceCiSendService; private final NiceCiStatBulkService niceCiStatBulkService; + private final NiceCiCloseService niceCiCloseService; @Operation(summary = "접수") @PostMapping(value = "/accept/all", produces = MediaType.APPLICATION_JSON_VALUE) @@ -48,4 +49,10 @@ public class NiceCiController { public ResponseEntity findBulkStatus() { return new ResponseEntity<>(niceCiStatBulkService.findBulkStatus(), HttpStatus.OK); } + + @Operation(summary = "마감(종료)") + @PostMapping(value = "/stat/closed", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity cloased() { + return new ResponseEntity<>(niceCiCloseService.close(), HttpStatus.OK); + } } diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java index dc1f7f3..700ee53 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiAcceptService.java @@ -87,6 +87,7 @@ public class NiceCiAcceptService { final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder() .sendType(IupSendTypeCd.NI.getCode()) .prcsCd(IupPrcsCd.TGRG.getCode()) + .reqStatusCd("ACCEPT") .build(); final List list = niceCiMapper.selectInputXits(niceCiParam); diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiCloseService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiCloseService.java new file mode 100644 index 0000000..db1601a --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiCloseService.java @@ -0,0 +1,91 @@ +package cokr.xit.ens.modules.nice.service; + +import java.util.*; + +import org.apache.commons.lang3.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.*; + +import cokr.xit.ens.biz.iup.code.*; +import cokr.xit.ens.core.aop.*; +import cokr.xit.ens.core.exception.code.*; +import cokr.xit.ens.modules.nice.mapper.*; +import cokr.xit.ens.modules.nice.model.*; +import cokr.xit.ens.modules.nice.service.support.*; +import lombok.*; +import lombok.extern.slf4j.*; + +/** + *
+ * description :
+ * packageName : cokr.xit.ens.modules.nice.service
+ * fileName    : NiceCiStatBulkService
+ * author      : limju
+ * date        : 2024 9월 27
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024 9월 27   limju       최초 생성
+ *
+ * 
+ */ +@Slf4j +@Service +@RequiredArgsConstructor +public class NiceCiCloseService { + @Value("${contract.niceCi.orgId}") + private String ORG_ID; + + @Value("${contract.niceCi.isStatusFail}") + private boolean IS_STATUS_FAIL; + + private final NiceCiApiService niceCiApiService; + private final NiceCiNewTransactionService niceCiNewTransactionService; + + private final INiceCiMapper niceCiMapper; + + /** + *
+     * -- 1. 대상 조회
+     * SELECT *
+     * FROM tb_input_xit tix
+     * WHERE tix.send_type='NI'
+     *   AND tix.prcs_cd='IPCP';
+     *   AND tix.expires_dt < SYSDATE - 1;
+     *
+     * -- tb_input_xit 테이블 prcs_cd='CLOS' / 실패(update error) 시 prcs_cd='FAIL'
+     * @return EnsResponseVO
+     * 
+ */ + public EnsResponseVO close() { + final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder() + .sendType(IupSendTypeCd.NI.getCode()) + .prcsCd(IupPrcsCd.IPCP.getCode()) + .reqStatusCd("CLOS") + .build(); + + final List list = niceCiMapper.selectInputXits(niceCiParam); + if(list.isEmpty()){ + return EnsResponseVO.errBuilder() + .errCode(EnsErrCd.ERR404) + .errMsg(EnsErrCd.ERR404.getCodeNm()) + .build(); + } + + for(NiceCiDTO.InputXit xit : list) { + + try { + xit.setPrcsCd("CLOS"); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + } catch (Exception e) { + xit.setPrcsCd("FAIL"); + xit.setErrMsg(ObjectUtils.isNotEmpty(e.getCause()) ? e.getCause().getMessage() : e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + } + } + + return EnsResponseVO.okBuilder() + //.resultInfo(niceCiMapper.selectAcceptTgts(null)) + .build(); + } +} diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiSendBulkService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiSendBulkService.java index b5c8055..2b39626 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiSendBulkService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiSendBulkService.java @@ -64,6 +64,7 @@ public class NiceCiSendBulkService { final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder() .sendType(IupSendTypeCd.NI.getCode()) .prcsCd(IupPrcsCd.GRUC.getCode()) + .reqStatusCd("SEND") .build(); final List list = niceCiMapper.selectInputXits(niceCiParam); diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiStatBulkService.java b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiStatBulkService.java index cba0595..2078b9d 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiStatBulkService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/NiceCiStatBulkService.java @@ -75,6 +75,7 @@ public class NiceCiStatBulkService { NiceCiDTO.NiceCiParam.builder() .sendType(IupSendTypeCd.NI.getCode()) .prcsCd(IupPrcsCd.IPCP.getCode()) + .reqStatusCd("STATUS") .build() ) .orElseThrow(() -> new EnsException(EnsErrCd.MAKE521, "검색기간 설정 조회 실패")); diff --git a/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml index f09df7f..6fca624 100644 --- a/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml +++ b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml @@ -2,10 +2,10 @@ + - + - + + + /** iup-niceci-mapper|updatePrcsCdAndErrorOfInputXit-prcsCd and errorupdate|julim */ + UPDATE tb_input_xit + SET prcs_cd = #{prcsCd} + , err_msg = SUBSTR(#{errMsg}, 0, 1000) + , upd_dt = sysdate + , upd_id = 'ENS_SYS' + WHERE lnk_input_id = #{lnkInputId} + + + + + + + + /** iup-niceci-mapper|insertBill-NICE CI 청구서 생성|julim */ INSERT INTO ens_bill ( @@ -159,15 +179,6 @@ WHERE lnk_input_id = #{lnkInputId} - - /** iup-niceci-mapper|updatePrcsCdAndErrorOfInputXit-prcsCd and errorupdate|julim */ - UPDATE tb_input_xit - SET prcs_cd = #{prcsCd} - , err_msg = SUBSTR(#{errMsg}, 0, 1000) - WHERE lnk_input_id = #{lnkInputId} - - -