From acf7794a75aa8589f3b68e1c147fb942d62b6b77 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Tue, 8 Oct 2024 15:00:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20NICE=20CI=20=EC=9D=B8=EC=A6=9D=ED=86=A1?= =?UTF-8?q?=20=EC=A7=84=ED=96=89=20=20=20=20=20=20=20send,=20status=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/ddl.sql | 10 +- db/mens-iup-query.sql | 16 +- .../cokr/xit/ens/core/utils/DateUtil.java | 2 +- .../modules/nice/mapper/INiceCiMapper.java | 12 +- .../modules/nice/model/NiceCiApiCommon.java | 4 +- .../modules/nice/model/NiceCiApiResult.java | 55 +++-- ...iceCiApiDTO.java => NiceCiApiSendDTO.java} | 8 +- ...istoryDTO.java => NiceCiApiStatusDTO.java} | 159 ++++++------- .../xit/ens/modules/nice/model/NiceCiDTO.java | 2 + .../nice/service/NiceCiAcceptService.java | 8 +- .../nice/service/NiceCiSendBulkService.java | 60 ++--- .../nice/service/NiceCiStatBulkService.java | 224 ++++++++++++------ .../service/support/NiceCiApiService.java | 79 +++--- src/main/resources/config/conf-contract.yml | 2 + .../modules/iup-niceci-mapper.xml | 200 ++++++++++++++-- 15 files changed, 553 insertions(+), 288 deletions(-) rename src/main/java/cokr/xit/ens/modules/nice/model/{NiceCiApiDTO.java => NiceCiApiSendDTO.java} (99%) rename src/main/java/cokr/xit/ens/modules/nice/model/{NiceCiApiHistoryDTO.java => NiceCiApiStatusDTO.java} (71%) diff --git a/db/ddl.sql b/db/ddl.sql index f85dcab..78de370 100644 --- a/db/ddl.sql +++ b/db/ddl.sql @@ -201,7 +201,7 @@ ALTER TABLE TB_NICE_SMS_SNDNG_INQIRE_REPTI CREATE TABLE TB_NICE_SMS_SNDNG_INQIRE_REQUS ( NICE_SMS_SNDNG_INQIRE_ID CHAR(10) NOT NULL , - TRNSC_ID VARCHAR2(9) NULL , + TRNSC_ID VARCHAR2(10) NULL , SPCLTY_GROUPCODE VARCHAR2(9) NULL , DELNG_ASORTCODE NUMBER(4) NULL , DELNG_SECODE NUMBER(5) NULL , @@ -236,7 +236,7 @@ ALTER TABLE TB_NICE_SMS_SNDNG_INQIRE_REQUS CREATE TABLE TB_NICE_SMS_SNDNG_INQIRE_RSPNS ( NICE_SMS_SNDNG_INQIRE_ID CHAR(10) NOT NULL , - TRNSC_ID VARCHAR2(9) NULL , + TRNSC_ID VARCHAR2(10) NULL , SPCLTY_GROUPCODE VARCHAR2(9) NULL , DELNG_ASORTCODE NUMBER(4) NULL , DELNG_SECODE NUMBER(5) NULL , @@ -266,7 +266,7 @@ CREATE TABLE TB_NICE_SMS_SNDNG_REQUST ( NICE_SMS_SNDNG_REQUST_ID CHAR(10) NOT NULL , DATA_ID VARCHAR2(30) NULL , - TRNSC_ID VARCHAR2(9) NULL , + TRNSC_ID VARCHAR2(10) NULL , SPCLTY_GROUPCODE VARCHAR2(9) NULL , DELNG_ASORTCODE NUMBER(4) NULL , DELNG_SECODE NUMBER(5) NULL , @@ -311,7 +311,7 @@ ALTER TABLE TB_NICE_SMS_SNDNG_REQUST CREATE TABLE TB_NICE_SMS_SNDNG_RSPNS ( NICE_SMS_SNDNG_REQUST_ID CHAR(10) NOT NULL , - TRNSC_ID VARCHAR2(9) NULL , + TRNSC_ID VARCHAR2(10) NULL , SPCLTY_GROUPCODE VARCHAR2(9) NULL , DELNG_ASORTCODE NUMBER(4) NULL , DELNG_SECODE NUMBER(5) NULL , @@ -502,4 +502,4 @@ CREATE SEQUENCE SEQ_NICE_SMS_SNDNG_INQIRE_ID START WITH 1 INCREMENT BY 1 MAXVALU -- 나이스 알림톡 템플릿 코드 컬럼 추가 -ALTER TABLE ENS_TMPLT_MNG ADD NTCNTALK_TMPLAT_CODE VARCHAR2(100); \ No newline at end of file +ALTER TABLE ENS_TMPLT_MNG ADD NTCNTALK_TMPLAT_CODE VARCHAR2(100); diff --git a/db/mens-iup-query.sql b/db/mens-iup-query.sql index 4e88629..b58f800 100644 --- a/db/mens-iup-query.sql +++ b/db/mens-iup-query.sql @@ -241,18 +241,6 @@ WHERE tix.send_type='NI' -- 2. tb_input_xit 테이블 prcs_cd='CLOS' / 실패 시 prcs_cd='FAIL' - -INSERT - INTO - ens_bill - ( bill_id, bill_uid, biller_user_key, BILL_SE_CD, org_cd, regist_dt ) - VALUES - ( 7, 'billUid', 'billerUserKey', 'kkk', '0002', sysdate ); - -commit; - - - -- 요청 전문 : {"data":{"biller_user_key":"EL3020202408060407773","expire_at":"20241010235900","parameters":{"orgCd":"0001"},"custom_url":{"notice_url":"https://phts-manager.koti.re.kr/iup/kakao/notice","prepay_url":"https://phts-manager.koti.re.kr/iup/kakao/prepay","pay_result_url":"https://phts-manager.koti.re.kr/iup/kakao/pay-result"}}} -- 응답 전문 : {"res_code":"OK","message":"정상응답","data":{"url":"https://billgates-web.kakao.com/r/platform/pages/paynow/search/1832/11/0b7bc3fa-4845-40eb-9b23-62b0eb806655"}} @@ -288,8 +276,10 @@ where id = 99999999999999999999;; -- eom.org_nm, etm.message, etm.ntcntalk_tmplat_code -SELECT * +SELECT etm.* FROM ens_org_mng eom JOIN ens_tmplt_mng etm ON eom.ORG_CD = etm.ORG_CD WHERE etm.tmplt_cd='A0001'; + + diff --git a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java index a429383..bdfe039 100644 --- a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java +++ b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java @@ -530,7 +530,7 @@ public class DateUtil { public static String getNowTimeMicrosecond() { ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Seoul")); // 6자리 나노초까지 포함된 포맷 지정 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSSSSS"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSSSS"); return now.format(formatter); } diff --git a/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java b/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java index 401b5f6..483e270 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java +++ b/src/main/java/cokr/xit/ens/modules/nice/mapper/INiceCiMapper.java @@ -31,12 +31,18 @@ public interface INiceCiMapper { //int saveBill(final NiceCiDTO.BillDTO billDTO); int saveBillKko(final NiceCiDTO.BillKkoDTO billKkoDTO); int updatePayUrlOfDataInput(final NiceCiDTO.InputDataXit inputDataXit); - int updatePrcsCdOfInputXit(final NiceCiDTO.InputXit inputXit); + int updatePrcsCdAndErrorOfInputXit(final NiceCiDTO.InputXit inputXit); Optional selectKkoBpApiUrlFromEnsOrgMng(final String orgCd); Optional selectNiceCiRequestId(); Optional selectTmpltMsg(final String tmpltId); - int insertNiceSmsSndngRequest(final NiceCiApiDTO.Request requestDTO); - int insertNiceSmsSndngResponse(final NiceCiApiDTO.Response responseDTO); + int insertNiceSmsSndngRequest(final NiceCiApiSendDTO.Request requestDTO); + int insertNiceSmsSndngResponse(final NiceCiApiSendDTO.Response responseDTO); + + Optional selectNiceCiInqireId(); + int insertNiceSmsSndngInquireRequest(final NiceCiApiStatusDTO.Request requestDTO); + int insertNiceSmsSndngInquireResponse(final NiceCiApiStatusDTO.Response responseDTO); + int insertNiceSmsSndngInquireResponseRepeat(final List resultList); + } diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiCommon.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiCommon.java index 7c83257..118a0eb 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiCommon.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiCommon.java @@ -199,7 +199,7 @@ public class NiceCiApiCommon { @Size(min = 1, max = 1, message = "조회동의사유는 1자리 입니다") private String inqireAgreResn = "4"; - public String ofString() { + public String ofString(boolean isSend) { StringBuilder sb = new StringBuilder(); sb.append(spcltyGroupcode); sb.append(delngAsortcode); @@ -213,7 +213,7 @@ public class NiceCiApiCommon { sb.append(niceSpcltyManageno); sb.append(niceSpcltyTrnsmistime); sb.append(blnk); - sb.append(inqireAgreResn); + if(isSend) sb.append(inqireAgreResn); return sb.toString(); } diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiResult.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiResult.java index 152ebf9..39c6b4d 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiResult.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiResult.java @@ -10,7 +10,7 @@ import lombok.*; *
  * description :
  * packageName : cokr.xit.ens.modules.nice.model
- * fileName    : NiceCiResult
+ * fileName    : NiceCiApiResult
  * author      : limju
  * date        : 2024 9월 25
  * ======================================================================
@@ -29,15 +29,20 @@ public class NiceCiApiResult {
     //------------------------------------------------------------------------------------
     // 연락처 이력 조회시만
     //------------------------------------------------------------------------------------
+    /**
+     * nice sms 발송 요청 ID - 업무 PK
+     */
+    private String niceSmsSndngInqireId;
+
     /**
      * 
      * 연락처 이력 조회시 사용 - 조회일시 - 20 자리
      * YYYYMMDDHHMMSS(14)+microSecond(6)
      * 
*/ - private String queryDt; - public void setQueryDt(String queryDt) { - this.queryDt = StringUtils.trim(queryDt); + private String inqireDt; + public void setInqireDt(String inqireDt) { + this.inqireDt = StringUtils.trim(inqireDt); } //------------------------------------------------------------------------------------ // 연락처 이력 조회시만 @@ -49,7 +54,7 @@ public class NiceCiApiResult { * 1(개인) 고정 *
*/ - private String indvdlBsnmCprSe = "1"; + private String indvdlBsnmCprSe; /** *
@@ -128,9 +133,9 @@ public class NiceCiApiResult {
      * 4: 연락처 죄회 없이 발송요청 (31894전문)
      * 
*/ - private String smsSndReqCode; + private String smsSndngRequstSe; public void setSmsSndReq(String smsSndReqCode) { - this.smsSndReqCode = StringUtils.trim(smsSndReqCode); + this.smsSndngRequstSe = StringUtils.trim(smsSndReqCode); } /** @@ -140,9 +145,9 @@ public class NiceCiApiResult { * NiceCiUtils.leftKr, substringKr 메소드 사용 * */ - private String sndMessage; - public void setSndMessage(String sndMessage) { - this.sndMessage = StringUtils.trim(sndMessage); + private String sndngMssage; + public void setSndngMssage(String sndngMssage) { + this.sndngMssage = StringUtils.trim(sndngMssage); } /** @@ -151,9 +156,9 @@ public class NiceCiApiResult { * 발송요청구분(smsSndReqCode)가 1, 2, 3인 경우 필수 * */ - private String sndPhoneNo; - public void setSndPhoneNo(String sndPhoneNo) { - this.sndPhoneNo = StringUtils.trim(sndPhoneNo); + private String dsptchNo; + public void setDsptchNo(String dsptchNo) { + this.dsptchNo = StringUtils.trim(dsptchNo); } //------------------------------------------------------------------------------------ // 연락처 이력 조회시만 @@ -168,7 +173,7 @@ public class NiceCiApiResult { * 3: 3 순위 연락처로 발송 * */ - private String smsSndngCttpcRank = "1"; + private String smsSndngCttpcRank; /** *
@@ -198,9 +203,9 @@ public class NiceCiApiResult {
      * 연락처 이력 조회시 사용 - 처리자ID : 9 자리
      * 
*/ - private String procId; - public void setProcId(String procId) { - this.procId = StringUtils.trim(procId); + private String opetrId; + public void setOpetrId(String opetrId) { + this.opetrId = StringUtils.trim(opetrId); } /** @@ -212,7 +217,7 @@ public class NiceCiApiResult { * 3: 3순위 이내 조회 * */ - private String contactSearchCode = "3"; + private String cttpcInqireSe; /** *
@@ -221,7 +226,7 @@ public class NiceCiApiResult {
      * 진행중 건, 오류로 인한 미발송 건의 경우에도 0 제공
      * 
*/ - private String msgSndRsltDivCode; + private String mssageSndngResultSe; //------------------------------------------------------------------------------------ // 연락처 이력 조회시만 //------------------------------------------------------------------------------------ @@ -292,7 +297,7 @@ public class NiceCiApiResult { return null; } - public static NiceCiApiResult parseHistory(String tgtString) { + public static NiceCiApiResult parseStatus(String tgtString) { // 1150 final int[] parseLength = { 20, // 조회일시 - 이력조회시만 사용 @@ -320,7 +325,7 @@ public class NiceCiApiResult { int idx = 0; // 이력조회시만 사용 //////////////////////////////////////////////////////// - result.setQueryDt(StringUtils.left(tgtString, parseLength[idx])); + result.setInqireDt(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); // 이력조회시만 사용 //////////////////////////////////////////////////////// @@ -346,9 +351,9 @@ public class NiceCiApiResult { tgtString = tgtString.substring(parseLength[idx++]); // 이력조회시만 사용 //////////////////////////////////////////////////////// - result.setSmsSndReqCode(StringUtils.left(tgtString, parseLength[idx])); + result.setSmsSndngRequstSe(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); - result.setSndMessage(NiceCiUtils.leftKr(tgtString, parseLength[idx])); + result.setSndngMssage(NiceCiUtils.leftKr(tgtString, parseLength[idx])); tgtString = NiceCiUtils.substringKr(tgtString, parseLength[idx++]); result.setSmsSndngCttpcNo(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); @@ -364,9 +369,9 @@ public class NiceCiApiResult { tgtString = tgtString.substring(parseLength[idx++]); // 이력조회시만 사용 //////////////////////////////////////////////////////// - result.setProcId(StringUtils.left(tgtString, parseLength[idx])); + result.setOpetrId(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); - result.setContactSearchCode(StringUtils.left(tgtString, parseLength[idx])); + result.setCttpcInqireSe(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); result.setResultSe(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiSendDTO.java similarity index 99% rename from src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java rename to src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiSendDTO.java index 5009034..30985b4 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiSendDTO.java @@ -19,7 +19,7 @@ import lombok.*; * Builder 패턴 사용 X * -> setter를 사용 필드 길이 고정 필요 * packageName : cokr.xit.ens.modules.nice.model - * fileName : NiceDTO + * fileName : NiceCiApiSendDTO * author : limju * date : 2024 9월 23 * ====================================================================== @@ -29,9 +29,9 @@ import lombok.*; * * */ -public class NiceCiApiDTO { +public class NiceCiApiSendDTO { - @Schema(name = "Request(Nice CI) API DTO", description = "NICE CI API 요청 전문 DTO") + @Schema(name = "Request(Nice CI Send) API DTO", description = "NICE CI API Send 요청 전문 DTO") @Data @NoArgsConstructor @AllArgsConstructor @@ -224,7 +224,7 @@ public class NiceCiApiDTO { StringBuilder sb = new StringBuilder(); //sb.append(trCode); // 공통부 - sb.append(niceCommon.ofString()); + sb.append(niceCommon.ofString(true)); // 개별요청부 sb.append(inqireResn); diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiHistoryDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiStatusDTO.java similarity index 71% rename from src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiHistoryDTO.java rename to src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiStatusDTO.java index 6e4bba7..0bac38b 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiHistoryDTO.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiStatusDTO.java @@ -20,7 +20,7 @@ import lombok.*; * Builder 패턴 사용 X * -> setter를 사용 필드 길이 고정 필요 * packageName : cokr.xit.ens.modules.nice.model - * fileName : NiceDTO + * fileName : NiceCiApiStatusDTO * author : limju * date : 2024 9월 23 * ====================================================================== @@ -30,7 +30,7 @@ import lombok.*; * * */ -public class NiceCiApiHistoryDTO { +public class NiceCiApiStatusDTO { @Schema(name = "Request(Nice CI History) API DTO", description = "NICE CI API 이력 요청 전문 DTO") @Data @@ -51,10 +51,15 @@ public class NiceCiApiHistoryDTO { */ //@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "TR Code", example = " ") //@Size(min = 10, max = 10, message = "트랜잭션 코드는 10자리 입니다.") - private String trCode = StringUtils.EMPTY; - public void setTrCode(String trCode) { - this.trCode = StringUtils.leftPad(nvl(trCode), 10, StringUtils.SPACE); + private String trnscId = StringUtils.EMPTY; + public void setTrnscId(String trnscId) { + this.trnscId = StringUtils.leftPad(nvl(trnscId), 10, StringUtils.SPACE); } + + /** + * nice sms 발송 요청 ID - 업무 PK + */ + private String niceSmsSndngInqireId; //---------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------- @@ -63,15 +68,6 @@ public class NiceCiApiHistoryDTO { @Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Valid NiceCiApiCommon niceCommon; - - /** - *
-         * 공란 - 17 자리
-         * 
- */ - @Schema(title = "공란", example = " ") - @Size(min = 17, max = 17, message = "공란(16자리)") - private String commonEmptyField = StringUtils.rightPad(StringUtils.EMPTY, 17, StringUtils.SPACE); //---------------------------------------------------------------------------------------------- // 공통부 : 100 자리 //---------------------------------------------------------------------------------------------- @@ -88,9 +84,9 @@ public class NiceCiApiHistoryDTO { */ @Schema(title = "검색기간 from", example = " ") @Size(min = 20, max = 20, message = "검색기간 from") - private String fromDt = StringUtils.rightPad(StringUtils.EMPTY, 20, StringUtils.SPACE); - public void setFromDt(String fromDt) { - this.fromDt = StringUtils.rightPad(nvl(fromDt), 20, StringUtils.SPACE); + private String searchPdFrom = StringUtils.rightPad(StringUtils.EMPTY, 20, StringUtils.SPACE); + public void setSearchPdFrom(String searchPdFrom) { + this.searchPdFrom = StringUtils.rightPad(nvl(searchPdFrom), 20, StringUtils.SPACE); } /** @@ -101,9 +97,9 @@ public class NiceCiApiHistoryDTO { */ @Schema(title = "검색기간 to", example = " ") @Size(min = 20, max = 20, message = "검색기간 to") - private String toDt = StringUtils.rightPad(StringUtils.EMPTY, 20, StringUtils.SPACE); - public void setToDt(String toDt) { - this.toDt = StringUtils.rightPad(nvl(toDt), 20, StringUtils.SPACE); + private String searchPdTo = StringUtils.rightPad(StringUtils.EMPTY, 20, StringUtils.SPACE); + public void setSearchPdTo(String searchPdTo) { + this.searchPdTo = StringUtils.rightPad(nvl(searchPdTo), 20, StringUtils.SPACE); } /** @@ -114,7 +110,7 @@ public class NiceCiApiHistoryDTO { */ @Schema(title = "개인/사업자/법인구분", example = "1") @Size(min = 1, max = 1, message = "개인/사업자/법인구분은 1자리 입니다.") - private String idDiv = "1"; + private String indvdlBsnmCprSe = "1"; /** *
@@ -122,26 +118,26 @@ public class NiceCiApiHistoryDTO {
          * 
*/ @Schema(title = "주민번호", example = " ") - @Size(min = 13, max = 13, message = "주민번호는 13자리 입니다.") - private String jumin = StringUtils.rightPad(StringUtils.EMPTY, 13, StringUtils.SPACE); - public void setJumin(String jumin) { - this.jumin = StringUtils.rightPad(nvl(jumin), 13, StringUtils.SPACE); + //@Size(min = 13, max = 13, message = "주민번호는 13자리 입니다.") + private String ihidnum = StringUtils.rightPad(StringUtils.EMPTY, 13, StringUtils.SPACE); + public void setIhidnum(String ihidnum) { + this.ihidnum = StringUtils.rightPad(nvl(ihidnum), 13, StringUtils.SPACE); } /** *
          * 결과구분코드 - 2자리
          * "  " - 전체조회
-         * 00 -	정상(SMS미발송시 조회정상, SMS발송시 발송정상)
+         * 00 - 정상(SMS미발송시 조회정상, SMS발송시 발송정상)
          * 01 - 연락처조회 실패건(주민번호오류/데이터없음/기타오류 건)
          * 10 - 진행중(연락처조회 정상건 중 SMS발송 이전)
          * 
*/ @Schema(title = "결과구분코드", example = " ", allowableValues = {" ", "00", "01", "10"}) @Size(min = 2, max = 2, message = "결과구분코드는 2자리 입니다.") - private String rsltDivCode = " "; - public void setRsltDivCode(String rsltDivCode) { - this.rsltDivCode = StringUtils.rightPad(nvl(rsltDivCode), 2, StringUtils.SPACE); + private String resultSe = " "; + public void setResultSe(String resultSe) { + this.resultSe = StringUtils.rightPad(nvl(resultSe), 2, StringUtils.SPACE); } /** @@ -156,7 +152,7 @@ public class NiceCiApiHistoryDTO { */ @Schema(title = "SMS발송요청구분", example = " ", allowableValues = {"0", "1", "2", "3", "4"}) @Size(min = 1, max = 1, message = "SMS발송요청구분은 1자리 입니다.") - private String smsSndReqCode = "0"; + private String smsSndngRequstSe = "0"; /** *
@@ -165,10 +161,10 @@ public class NiceCiApiHistoryDTO {
          * 
*/ @Schema(title = "요청건수", example = " ") - @Pattern(regexp = "^\\s{10}$|\\d{10}", message = "요청건수는 10자리(max 100)입니다") - private String reqCnt = StringUtils.rightPad(StringUtils.EMPTY, 10, StringUtils.SPACE); - public void setReqCnt(String reqCnt){ - this.reqCnt = StringUtils.rightPad(nvl(reqCnt), 10, StringUtils.SPACE); + @Pattern(regexp = "^[\\s\\S]{10}$", message = "요청건수는 10자리(max 100)입니다") + private String requstCo = StringUtils.rightPad(StringUtils.EMPTY, 10, StringUtils.SPACE); + public void setRequstCo(String requstCo){ + this.requstCo = StringUtils.rightPad(nvl(requstCo), 10, StringUtils.SPACE); } /** @@ -178,10 +174,11 @@ public class NiceCiApiHistoryDTO { * */ @Schema(title = "누적수신건수", example = " ") - @Max(value = 100, message = "누적수신건수는 최대 10자리 입니다.") - private String accRecvCnt = "0000000000"; - public void setAccRecvCnt(String accRecvCnt) { - this.accRecvCnt = StringUtils.rightPad(nvl(accRecvCnt), 10, StringUtils.SPACE); + @Size(min = 10, max = 10, message = "누적수신건수는 10자리 입니다.") + @Pattern(regexp = "^\\d{10}$", message = "요청건수는 10자리(max 100)입니다") + private String accmltRecptnCo = "0000000000"; + public void setAccmltRecptnCo(String accmltRecptnCo) { + this.accmltRecptnCo = StringUtils.rightPad(nvl(accmltRecptnCo), 10, StringUtils.SPACE); } /** @@ -191,35 +188,38 @@ public class NiceCiApiHistoryDTO { */ @Schema(title = "공란", example = " ") @Size(min = 23, max = 23, message = "공란(23자리)") - private String privateEmptyField = StringUtils.rightPad(StringUtils.EMPTY, 23, StringUtils.SPACE); + private String indvdlzRequstBlnk = StringUtils.rightPad(StringUtils.EMPTY, 23, StringUtils.SPACE); + public void setIndvdlzRequstBlnk(String indvdlzRequstBlnk) { + this.indvdlzRequstBlnk = StringUtils.rightPad(nvl(indvdlzRequstBlnk), 23, StringUtils.SPACE); + } //---------------------------------------------------------------------------------------------- // 개별요청부 : 100 자리 //---------------------------------------------------------------------------------------------- public String ofString() { StringBuilder sb = new StringBuilder(); - sb.append(trCode); + sb.append(trnscId); + // 공통부 - sb.append(niceCommon.ofString()); - sb.append(commonEmptyField); + sb.append(niceCommon.ofString(false)); // 개별요청부 - sb.append(fromDt); - sb.append(toDt); - sb.append(idDiv); - sb.append(jumin); - sb.append(rsltDivCode); - sb.append(smsSndReqCode); - sb.append(reqCnt); - sb.append(accRecvCnt); - sb.append(privateEmptyField); + sb.append(searchPdFrom); + sb.append(searchPdTo); + sb.append(indvdlBsnmCprSe); + sb.append(ihidnum); + sb.append(resultSe); + sb.append(smsSndngRequstSe); + sb.append(requstCo); + sb.append(accmltRecptnCo); + sb.append(indvdlzRequstBlnk); // FIXME: 인코딩확인후 적용 return new String(sb.toString().getBytes(), StandardCharsets.UTF_8); } } - @Schema(name = "Response(Nice CI History) DTO", description = "NICE CI 이력 응답 전문 DTO") + @Schema(name = "Response(Nice CI Status) DTO", description = "NICE CI 상태(이력) 응답 전문 DTO") @Data @NoArgsConstructor @AllArgsConstructor @@ -235,25 +235,20 @@ public class NiceCiApiHistoryDTO { * 회원사 고유키 - 요청시 필수 max: 9 * */ - private String trCode; - public void setTrCode(String trCode) { - this.trCode = StringUtils.trim(trCode); + private String trnscId; + public void setTrnscId(String trnscId) { + this.trnscId = StringUtils.trim(trnscId); } + /** + * nice sms 발송 요청 ID - 업무 PK + */ + private String niceSmsSndngInqireId; + //---------------------------------------------------------------------------------------------- // 공통부 : 100 자리 //---------------------------------------------------------------------------------------------- NiceCiApiCommon niceCommon; - - /** - *
-         * 공란 - 16 자리
-         * 
- */ - private String commonEmptyField; - public void setCommonEmptyField(String commonEmptyField) { - this.commonEmptyField = StringUtils.trim(commonEmptyField); - } //---------------------------------------------------------------------------------------------- // 공통부 : 100 자리 //---------------------------------------------------------------------------------------------- @@ -266,9 +261,9 @@ public class NiceCiApiHistoryDTO { * 총건수: 10자리 * */ - private String totalCnt; - public void setTotalCnt(String totalCnt) { - this.totalCnt = StringUtils.trim(totalCnt); + private String totCo; + public void setTotCo(String totCo) { + this.totCo = StringUtils.trim(totCo); } /** @@ -276,9 +271,9 @@ public class NiceCiApiHistoryDTO { * 누적건수: 10자리 * */ - private String accCnt; - public void setAccCnt(String accCnt) { - this.accCnt = StringUtils.trim(accCnt); + private String accmltCo; + public void setAccmltCo(String accmltCo) { + this.accmltCo = StringUtils.trim(accmltCo); } /** @@ -287,9 +282,9 @@ public class NiceCiApiHistoryDTO { * 최대 100건 * */ - private String resCnt; - public void setResCnt(String resCnt) { - this.resCnt = StringUtils.trim(resCnt); + private String rspnsCo; + public void setRspnsCo(String rspnsCo) { + this.rspnsCo = StringUtils.trim(rspnsCo); } //---------------------------------------------------------------------------------------------- // 개별응답부 : 30 자리 @@ -307,8 +302,7 @@ public class NiceCiApiHistoryDTO { final int repeatLength = 1150; final int[] parseLength = { 10, // tr-code - 83, // 공통부 - 17, // 공란 + 100, // 공통부 10, // 총건수 10, // 누적건수 10, // 응답건수 @@ -319,22 +313,19 @@ public class NiceCiApiHistoryDTO { if (StringUtils.isNotBlank(tgtString) && NiceCiUtils.lengthKr(tgtString) >= 1290) { Response nr = new Response(); int idx = 0; - nr.setTrCode(StringUtils.left(tgtString, parseLength[idx])); + nr.setTrnscId(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); nr.setNiceCommon(NiceCiApiCommon.parse(tgtString)); tgtString = tgtString.substring(parseLength[idx++]); - nr.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx])); - tgtString = tgtString.substring(parseLength[idx++]); - - nr.setTotalCnt(StringUtils.left(tgtString, parseLength[idx])); + nr.setTotCo(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); - nr.setAccCnt(StringUtils.left(tgtString, parseLength[idx])); + nr.setAccmltCo(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); - nr.setResCnt(StringUtils.left(tgtString, parseLength[idx])); + nr.setRspnsCo(StringUtils.left(tgtString, parseLength[idx])); tgtString = tgtString.substring(parseLength[idx++]); if(NiceCiUtils.lengthKr(tgtString) % repeatLength == 0){ @@ -343,7 +334,7 @@ public class NiceCiApiHistoryDTO { List resResults = IntStream.range(0, repeat) .mapToObj(i -> { String currentString = NiceCiUtils.substringKr(finalTgtString, i * repeatLength); - return NiceCiApiResult.parseHistory(currentString); + return NiceCiApiResult.parseStatus(currentString); }) .collect(Collectors.toList()); nr.setNiceCiResults(resResults); 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 3849282..b317dbb 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 @@ -448,6 +448,8 @@ public class NiceCiDTO { private String ntcntalkTmplatCode; + private String orgNm; + private String registId; private LocalDateTime registDt; 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 5971c04..5f57398 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 @@ -158,19 +158,21 @@ public class NiceCiAcceptService { } xit.setPrcsCd(IupPrcsCd.GRUC.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); // FIXME: API 호출 에러 } catch (EnsException e) { if(EnsErrCd.API_COMM_ERROR.equals(e.getErrCd())){ xit.setPrcsCd(IupPrcsCd.TGRF.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); } } catch (Exception e){ xit.setPrcsCd(IupPrcsCd.TGRF.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); } } 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 e845a36..e3542af 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 @@ -13,7 +13,6 @@ import cokr.xit.ens.core.aop.*; import cokr.xit.ens.core.exception.*; import cokr.xit.ens.core.exception.code.*; import cokr.xit.ens.core.utils.*; -import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*; import cokr.xit.ens.modules.nice.mapper.*; import cokr.xit.ens.modules.nice.model.*; import cokr.xit.ens.modules.nice.service.support.*; @@ -68,13 +67,8 @@ public class NiceCiSendBulkService { for(NiceCiDTO.InputXit xit : list) { final NiceCiDTO.TmpltMngDTO tmpltMngDTO = niceCiMapper.selectTmpltMsg(xit.getJobCd()) .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); - final String sndMsg = tmpltMngDTO.getMessage();//.replace("~~@@!!", "#{").replace("!!@@~~", "}"); - final String ntcntalkTmplatCode = tmpltMngDTO.getNtcntalkTmplatCode(); - final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(xit.getOrgCd()) - .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); NiceCiDTO.BillHistDTO billHistDTO = null; - try { List inputDataXits = xit.getInputDataXits(); for (NiceCiDTO.InputDataXit data : inputDataXits) { @@ -84,16 +78,15 @@ public class NiceCiSendBulkService { () -> new EnsException(EnsErrCd.MAKE521, EnsErrCd.MAKE521.getCodeNm()) ); - - NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request(); + NiceCiApiSendDTO.Request ciRequest = new NiceCiApiSendDTO.Request(); NiceCiApiCommon nCommon = new NiceCiApiCommon(); - NiceCiApiDTO.QueryRequest queryRequest = new NiceCiApiDTO.QueryRequest(); - NiceCiApiDTO.ButtonRequest btnRequest = new NiceCiApiDTO.ButtonRequest(); + NiceCiApiSendDTO.QueryRequest queryRequest = new NiceCiApiSendDTO.QueryRequest(); + NiceCiApiSendDTO.ButtonRequest btnRequest = new NiceCiApiSendDTO.ButtonRequest(); // 공통부 set setNiceCiApiRequestCommon(nCommon, niceSmsReqId); // 개별부 set - setNiceCiApiPrivateReq(ciRequest, ntcntalkTmplatCode, sndMsg, data); + setNiceCiApiPrivateReq(ciRequest, tmpltMngDTO, data); // 조회요청반복부 set setQueryRequest(queryRequest, data); // 버튼요청반복부 set @@ -103,35 +96,44 @@ public class NiceCiSendBulkService { ciRequest.getQueryRequests().add(queryRequest); ciRequest.getButtonRequests().add(btnRequest); - ciRequest.setNiceSmsSndngRequstId(niceSmsReqId); ciRequest.setDataId(data.getDataId()); niceCiMapper.insertNiceSmsSndngRequest(ciRequest); // FIXME : 연계 이후 확인 필요 EnsResponseVO responseVO = niceCiApiService.requestSendBulk(ciRequest); - NiceCiApiDTO.Response resDTO = (NiceCiApiDTO.Response)responseVO.getResultInfo(); - //NiceCiApiDTO.Response resDTO = new NiceCiApiDTO.Response(); + if (!EnsErrCd.OK.equals(responseVO.getErrCode())) + throw new EnsException(responseVO.getErrCode(), responseVO.getErrMsg()); + NiceCiApiSendDTO.Response resDTO = (NiceCiApiSendDTO.Response)responseVO.getResultInfo(); resDTO.setNiceSmsSndngRequstId(niceSmsReqId); niceCiMapper.insertNiceSmsSndngResponse(resDTO); log.info(responseVO.toString()); - return responseVO; } xit.setPrcsCd(IupPrcsCd.IPCP.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); // FIXME: API 호출 에러 } catch (EnsException e) { - + // FIXME : API 통신에러 인경우 skip - 재시도 되어야 if(EnsErrCd.API_COMM_ERROR.equals(e.getErrCd())){ xit.setPrcsCd(IupPrcsCd.FAIL.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + + return EnsResponseVO.errBuilder() + .errCode(e.getErrCd()) + .errMsg(e.getMessage()) + .build(); } + xit.setPrcsCd(IupPrcsCd.FAIL.getCode()); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); } catch (Exception e){ xit.setPrcsCd(IupPrcsCd.FAIL.getCode()); - niceCiMapper.updatePrcsCdOfInputXit(xit); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); } } return EnsResponseVO.okBuilder() @@ -175,12 +177,11 @@ public class NiceCiSendBulkService { /** * 개별요청부 set - * @param ciRequest NiceCiApiDTO.Request - * @param ntcntalkTmplatCode template ID - * @param sndMsg 전송메세지 템플릿 + * @param ciRequest NiceCiApiSendDTO.Request + * @param tmpltMngDTO NiceCiDTO.TmpltMngDTO * @param data NiceCiDTO.InputDataXit data */ - private void setNiceCiApiPrivateReq(final NiceCiApiDTO.Request ciRequest, final String ntcntalkTmplatCode, String sndMsg, final NiceCiDTO.InputDataXit data){ + private void setNiceCiApiPrivateReq(final NiceCiApiSendDTO.Request ciRequest, NiceCiDTO.TmpltMngDTO tmpltMngDTO, final NiceCiDTO.InputDataXit data){ //////////////////////////////////////////////////////////// // 개별요청부 START //////////////////////////////////////////////////////////// @@ -200,11 +201,14 @@ public class NiceCiSendBulkService { ciRequest.setInqireRequstCo(1); // 조회요청건수 Map map = gson.fromJson(data.getMsgData(), Map.class); + String sndMsg = tmpltMngDTO.getMessage(); for(Map.Entry entry : map.entrySet()){ sndMsg = sndMsg.replace(entry.getKey(), entry.getValue()); } + sndMsg = sndMsg.replace("~~@@!!ORG_NM!!@@~~", tmpltMngDTO.getOrgNm()); + sndMsg = sndMsg.replace("~~@@!!TARGET_NAME!!@@~~", data.getName()); ciRequest.setSndngMssage(sndMsg); // 발송메세지 - ciRequest.setNtcntalkTmplatCode(ntcntalkTmplatCode); // 알림톡 템플릿 코드 + ciRequest.setNtcntalkTmplatCode(tmpltMngDTO.getNtcntalkTmplatCode()); // 알림톡 템플릿 코드 //////////////////////////////////////////////////////////// // 개별요청부 END //////////////////////////////////////////////////////////// @@ -212,10 +216,10 @@ public class NiceCiSendBulkService { /** * 조회요청 반복부 set - * @param queryRequest NiceCiApiDTO.QueryRequest + * @param queryRequest NiceCiApiSendDTO.QueryRequest * @param data NiceCiDTO.InputDataXit */ - private void setQueryRequest(final NiceCiApiDTO.QueryRequest queryRequest, final NiceCiDTO.InputDataXit data) { + private void setQueryRequest(final NiceCiApiSendDTO.QueryRequest queryRequest, final NiceCiDTO.InputDataXit data) { //--------------------------------------------------------- // 조회요청 반복부 : default START //--------------------------------------------------------- @@ -229,10 +233,10 @@ public class NiceCiSendBulkService { /** * 버튼요청 반복부 set - * @param btnRequest NiceCiApiDTO.ButtonRequest + * @param btnRequest NiceCiApiSendDTO.ButtonRequest * @param data NiceCiDTO.InputDataXit */ - private void setBtnRequest(final NiceCiApiDTO.ButtonRequest btnRequest, final NiceCiDTO.InputDataXit data) { + private void setBtnRequest(final NiceCiApiSendDTO.ButtonRequest btnRequest, final NiceCiDTO.InputDataXit data) { //--------------------------------------------------------- // 버튼요청 반복부 : default START //--------------------------------------------------------- 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 7869fc1..8a12516 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 @@ -1,6 +1,7 @@ package cokr.xit.ens.modules.nice.service; import java.util.*; +import java.util.stream.*; import org.apache.commons.lang3.*; import org.springframework.beans.factory.annotation.Value; @@ -8,8 +9,9 @@ import org.springframework.stereotype.*; import cokr.xit.ens.biz.iup.code.*; import cokr.xit.ens.core.aop.*; +import cokr.xit.ens.core.exception.*; import cokr.xit.ens.core.exception.code.*; -import cokr.xit.ens.modules.nice.cmm.*; +import cokr.xit.ens.core.utils.*; import cokr.xit.ens.modules.nice.mapper.*; import cokr.xit.ens.modules.nice.model.*; import cokr.xit.ens.modules.nice.service.support.*; @@ -37,35 +39,14 @@ public class NiceCiStatBulkService { @Value("${contract.niceCi.orgId}") private String ORG_ID; - @Value("${contract.niceCi.clientId}") - private String CLIENT_ID; + @Value("${contract.niceCi.isStatusFail}") + private boolean IS_STATUS_FAIL; private final NiceCiApiService niceCiApiService; private final INiceCiMapper niceCiMapper; - final String msg = "민자도로 관리지원센터에서 김해찬님께 발송한 미납통행료 고지서가 도착했습니다.\n" - + "\n" - + "민자도로 미납통행료 고지서\n" - + "\n" - + "□ 차량번호 : 19너0914\n" - + "□ 미납발생 노선 : 서울-문산\n" - + "□ 미납발생 기간 : 2021년 04월 12일~2023년 08월 30일\n" - + "□ 납부금액 : 819,500원(42건)\n" - + "□ 납부기한 : 2024년10월01일\n" - + "□ 납부방법 : \n" - + "① 하단의 (납부하기) 클릭\n" - + "② 가상계좌 납부\n" - + "-(가상계좌) : 농협은행 792000-36-986609\n" - + "국민은행 731190-72-253083\n" - + "우리은행 283752-73-918780\n" - + "신한은행 562146-27-470101\n" - + "\n" - + "※ 알림톡 수신 시 종이고지서는 발송되지 않습니다.\n" - + "\n" - + "문의처 : 044-211-3377"; - - public EnsResponseVO findBulkStatus() { + public EnsResponseVO findBulkStatus() { final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder() .sendType(IupSendTypeCd.NI.getCode()) .prcsCd(IupPrcsCd.IPCP.getCode()) @@ -79,46 +60,157 @@ public class NiceCiStatBulkService { .build(); } - NiceCiApiHistoryDTO.Request ciRequest = new NiceCiApiHistoryDTO.Request(); - //ciRequest.setTrCode("0000006150"); - // // 공통부 - // - // // 개별요청부 - // nr.setQueryReason(StringUtils.EMPTY); - // nr.setQueryReqCnt(46); - // nr.setSmsSndReqCode("1"); - String tmp = NiceCiUtils.rightPadKr(msg, 2000, StringUtils.SPACE); - System.out.println( - String.format("[%s] kr length - %d, utf-8 length - %d", tmp, NiceCiUtils.lengthKr(tmp), tmp.length())); - // nr.setSndPhoneNo("010"); - // nr.setContactSearchCode("1"); - - // 공통부 - NiceCiApiCommon nc = new NiceCiApiCommon(); - // nc.setGrpCode("grpCode"); - //nc.setTrType("Type"); - nc.setTrClassification("31895"); // 거래구분 - nc.setOrgId(ORG_ID); // 참가기관Id - property 에서 - nc.setOrgMngNo("0000000103"); // 기관관리번호 - nc.setOrgSndDt("20240919"); - - NiceCiApiDTO.QueryRequest qr = new NiceCiApiDTO.QueryRequest(); - NiceCiApiDTO.ButtonRequest br = new NiceCiApiDTO.ButtonRequest(); - - ciRequest.setNiceCommon(nc); - - // nc.setNiceMngNo(StringUtils.EMPTY); - // nc.setNiceSndDt(StringUtils.EMPTY); - String ciTxt = ciRequest.ofString(); - String ft = String.format("%s%s", StringUtils.leftPad(String.valueOf(NiceCiUtils.lengthKr(ciTxt)), 10, "0"), - ciTxt); - System.out.println( - String.format("[%s] kr length - %d, utf-8 length - %d", ft, NiceCiUtils.lengthKr(ft), ft.length())); - - // String rtnMsg = niceCiApiService.requestSendBulk(ciRequest); - // NiceCiDTO.Response resDTO = NiceCiDTO.Response.parse(rtnMsg); - EnsResponseVO responseVO = niceCiApiService.findBulkStatus(ciRequest); - log.info(responseVO.toString()); - return responseVO; + list.forEach(d -> { + niceCiParam.setLnkInputId(d.getLnkInputId()); + d.setInputDataXits(niceCiMapper.selectNiceCiAcceptDatas(niceCiParam)); + }); + + for(NiceCiDTO.InputXit xit : list) { + + + try { + List inputDataXits = xit.getInputDataXits(); + for (NiceCiDTO.InputDataXit data : inputDataXits) { + + // 기관전문관리번호, TB_NICE_SMS_SNDNG_REQUEST - NICE_SMS_SNDNG_REQUST_ID + final String niceSmsInqId = niceCiMapper.selectNiceCiInqireId().orElseThrow( + () -> new EnsException(EnsErrCd.MAKE521, EnsErrCd.MAKE521.getCodeNm()) + ); + + NiceCiApiStatusDTO.Request ciRequest = new NiceCiApiStatusDTO.Request(); + NiceCiApiCommon nCommon = new NiceCiApiCommon(); + + // 공통부 set + setNiceCiApiRequestCommon(nCommon, niceSmsInqId); + ciRequest.setNiceCommon(nCommon); + + // 개별요청부 set + setNiceCiApiPrivateReq(ciRequest); + + // API request 저장 + ciRequest.setNiceSmsSndngInqireId(niceSmsInqId); + niceCiMapper.insertNiceSmsSndngInquireRequest(ciRequest); + + EnsResponseVO responseVO = niceCiApiService.findBulkStatus(ciRequest); + if (!EnsErrCd.OK.equals(responseVO.getErrCode())) + throw new EnsException(responseVO.getErrCode(), responseVO.getErrMsg()); + + NiceCiApiStatusDTO.Response resDTO = (NiceCiApiStatusDTO.Response)responseVO.getResultInfo(); + resDTO.setNiceSmsSndngInqireId(niceSmsInqId); + + // API response 저장 + niceCiMapper.insertNiceSmsSndngInquireResponse(resDTO); + + // API response 반복부 저장 + niceCiMapper.insertNiceSmsSndngInquireResponseRepeat( + resDTO.getNiceCiResults() + .stream().peek(d -> d.setNiceSmsSndngInqireId(niceSmsInqId)) + .collect(Collectors.toList())); + + log.info(responseVO.toString()); + } + } catch (EnsException e) { + // FIXME : API 통신에러 인경우 skip - 재시도 되어야 + if(EnsErrCd.API_COMM_ERROR.equals(e.getErrCd())){ + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + return EnsResponseVO.errBuilder() + .errCode(e.getErrCd()) + .errMsg(e.getMessage()) + .build(); + } + if(IS_STATUS_FAIL) xit.setPrcsCd(IupPrcsCd.FAIL.getCode()); + xit.setErrMsg(e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + + } catch (Exception e){ + if(IS_STATUS_FAIL) xit.setPrcsCd(IupPrcsCd.FAIL.getCode()); + xit.setErrMsg(ObjectUtils.isNotEmpty(e.getCause())? e.getCause().getMessage() : e.getMessage()); + niceCiMapper.updatePrcsCdAndErrorOfInputXit(xit); + } + + } + return EnsResponseVO.okBuilder() + //.resultInfo(niceCiMapper.selectAcceptTgts(null)) + .build(); + } + + /** + * 공통부 set + * @param nCommon NiceCiApiCommon + * @param niceSmsReqId 기관전문관리번호 - 업무 PK + */ + private void setNiceCiApiRequestCommon(final NiceCiApiCommon nCommon, final String niceSmsReqId) { + //////////////////////////////////////////////////////////// + // 공통부 START + //////////////////////////////////////////////////////////// + //--------------------------------------------------------- + // 공통부 : default start + //--------------------------------------------------------- + // nCommon.setGrpCode("NICEIF "); // 전문그룹코드 + // nCommon.setTrType("0200"); // 거래종별코드 + // nCommon.setSndAndRcvFlag("B"); // 송수신플래그 + // nCommon.setDeviceClassification("503"); // 단말기구분 + // nCommon.setRsltCode(" "); // 응답코드 + // nCommon.setNiceMngNo(""); // NICE 전문관리번호 + // nCommon.setNiceSndDt(""); // NICE 전문 전송시간 + // ciRequest.setCommonEmptyField(""); // 공란 - 16자리 + // ciRequest.setQueryConsentReason("1"); // 조회동의사유 + //---------------------------------------------------------- + // 공통부 : default end + //---------------------------------------------------------- + nCommon.setDelngSecode("31893"); // 거래구분코드 + nCommon.setPartcptInsttId(ORG_ID); // 참가기관ID - property 에서 + nCommon.setInsttSpcltyManageno(niceSmsReqId); // 기관전문관리번호 - LPAD(SEQ_NICE_SMS_SNDNG_REQUST_ID, 10, '0') + nCommon.setInsttSpcltyTrnsmistime(DateUtil.getTodayAndNowTime("yyyyMMddHHmmss")); // 기관전문전송시간 + nCommon.setBlnk(StringUtils.rightPad(StringUtils.EMPTY, 17, StringUtils.SPACE)); // 공란 16자리 + //////////////////////////////////////////////////////////// + // 공통부 END + //////////////////////////////////////////////////////////// + } + + + /** + * 개별요청부 set + * @param ciRequest NiceCiApiDTO.Request + */ + private void setNiceCiApiPrivateReq(final NiceCiApiStatusDTO.Request ciRequest){ + //////////////////////////////////////////////////////////// + // 개별요청부 START + //////////////////////////////////////////////////////////// + //---------------------------------------------------------- + // 개별요청부 : default start + //---------------------------------------------------------- + // ciRequest.setIndvdlBsnmCprSe("1"); // 개인/사업자/법인구분 + // ciRequest.setIhidnum(""); // 주민번호 : blank + // FIXME : 값 확인 필요 + // 결과구분 + // " "-전체, "00" - 정상((SMS미발송시 조회정상, SMS발송시 발송정상) + // 01 - 연락처조회 실패건(주민번호오류/데이터없음/기타오류 건) + // 10 - 진행중(연락처조회 정상건 중 SMS발송 이전) + // ciRequest.setResultSe(" "); + // FIXME : 값 확인 필요 + // SMS발송요청구분 + // 0 : 미요청, + // 1: 1순위연락처로 발송, + // 2: 1 ~ 2 순위중 최우선 순위로 1개 발송 + // 3: 1 ~ 3 순위중 최우선 순위로 1개 발송 + // 4: 1{1순위로 요청건} + 2{1~2순위로 요청건} + 3{1~3 순위로 요청건} + // ciRequest.setSmsSndngRequstSe("3"); // SMS발송요청구분코드 + // FIXME : 값 확인 필요 + // 누적수신건수 : 최초조회시 "0000000000" + // ciRequest.setAccmltRecptnCo("0000000000"); + // ciRequest.setIndvdlzRequstBlnk(""); // 공란 - 23자리 + //--------------------------------------------------------- + // 개별요청부 : default end + //--------------------------------------------------------- + + ciRequest.setSearchPdFrom(DateUtil.getNowTimeMicrosecond()); // 검색기간 - from + ciRequest.setSearchPdTo(DateUtil.getNowTimeMicrosecond()); // 검색기간 - to + ciRequest.setRequstCo("?"); // 요청건수 + //ciRequest.setAccmltRecptnCo(); // 누적수신건수 + //////////////////////////////////////////////////////////// + // 개별요청부 END + //////////////////////////////////////////////////////////// } } diff --git a/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java b/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java index f9eebd3..ddb12b0 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java +++ b/src/main/java/cokr/xit/ens/modules/nice/service/support/NiceCiApiService.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.*; import cokr.xit.ens.core.aop.*; +import cokr.xit.ens.core.exception.*; import cokr.xit.ens.core.exception.code.*; import cokr.xit.ens.modules.nice.cmm.*; import cokr.xit.ens.modules.nice.model.*; @@ -49,9 +50,9 @@ public class NiceCiApiService { private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); - public EnsResponseVO requestSendBulk(final NiceCiApiDTO.Request reqDTO) { + public EnsResponseVO requestSendBulk(final NiceCiApiSendDTO.Request reqDTO) { List errors = new ArrayList<>(); - final Set> list = validator.validate(reqDTO); + final Set> list = validator.validate(reqDTO); if (!list.isEmpty()) { errors.addAll(list.stream() .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) @@ -65,29 +66,33 @@ public class NiceCiApiService { .errMsg(errors.toString()) .build(); } + + log.info("API call parameter :: {}", reqDTO); String ciTxt = reqDTO.ofString(); String ft = String.format("%s%s", StringUtils.leftPad(String.valueOf(NiceCiUtils.lengthKr(ciTxt)), 10, "0"), ciTxt); - log.info("[{}] kr length - {}, utf-8 length - {}", ft, NiceCiUtils.lengthKr(ft), ft.length()); + log.info("kr length - {}, utf-8 length - {}", NiceCiUtils.lengthKr(ft), ft.length()); final String rtnMsg; try { - rtnMsg = sendNiceCiSocket(ft, 0); + //rtnMsg = sendNiceCiSocket(ft); + // FIXME: test를 위해 임시 사용 - return msg get + rtnMsg = getTestData( 0); } catch (Exception e) { return EnsResponseVO.errBuilder() .errCode(EnsErrCd.API_COMM_ERROR) .errMsg(e.getMessage()) .build(); } - NiceCiApiDTO.Response resDTO = NiceCiApiDTO.Response.parse(rtnMsg); + NiceCiApiSendDTO.Response resDTO = NiceCiApiSendDTO.Response.parse(rtnMsg); return EnsResponseVO.okBuilder() .resultInfo(resDTO) .build(); } - public EnsResponseVO findBulkStatus(final NiceCiApiHistoryDTO.Request reqDTO) { + public EnsResponseVO findBulkStatus(final NiceCiApiStatusDTO.Request reqDTO) { List errors = new ArrayList<>(); - final Set> list = validator.validate(reqDTO); + final Set> list = validator.validate(reqDTO); if (!list.isEmpty()) { errors.addAll(list.stream() .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) @@ -101,28 +106,31 @@ public class NiceCiApiService { .errMsg(errors.toString()) .build(); } + + log.info("API call parameter :: {}", reqDTO); String ciTxt = reqDTO.ofString(); String ft = String.format("%s%s", StringUtils.leftPad(String.valueOf(NiceCiUtils.lengthKr(ciTxt)), 10, "0"), ciTxt); - log.info("[{}] kr length - {}, utf-8 length - {}", ft, NiceCiUtils.lengthKr(ft), ft.length()); + log.info("kr length - {}, utf-8 length - {}", NiceCiUtils.lengthKr(ft), ft.length()); final String rtnMsg; try { - rtnMsg = sendNiceCiSocket(ft, 1); - } catch (Exception e) { + //rtnMsg = sendNiceCiSocket(ft); + // FIXME: test를 위해 임시 사용 - return msg get + rtnMsg = getTestData( 1); + } catch (EnsException e) { return EnsResponseVO.errBuilder() - .errCode(EnsErrCd.API_COMM_ERROR) + .errCode(e.getErrCd()) .errMsg(e.getMessage()) .build(); } - NiceCiApiHistoryDTO.Response resDTO = NiceCiApiHistoryDTO.Response.parse(rtnMsg); + NiceCiApiStatusDTO.Response resDTO = NiceCiApiStatusDTO.Response.parse(rtnMsg); return EnsResponseVO.okBuilder() .resultInfo(resDTO) .build(); } - // FIXME: test를 위해 idx 사용 - return msg get - private String sendNiceCiSocket(final String binTxt, final int idx) { + private String sendNiceCiSocket(final String binTxt) { String rtnMsg = ""; try (Socket socket = new Socket(HOST, PORT); // 서버에 연결 @@ -131,35 +139,30 @@ public class NiceCiApiService { //new OutputStreamWriter(socket.getOutputStream())); BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) { - try { - socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정 - - out.write(binTxt); - - // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 - out.write("\nEXIT"); - out.newLine(); - // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 - - out.flush(); - - //StringBuffer sb = new StringBuffer(); - //String rtnMsg = in.readLine(); - rtnMsg = getTestData(idx); - System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); - System.out.println(rtnMsg); - System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); - in.close(); - } catch (Exception e) { - throw new RuntimeException(e); - } + + socket.setSoTimeout(TIMEOUT); // 읽기 타임아웃 설정 + + out.write(binTxt); + + // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 + out.write("\nEXIT"); + out.newLine(); + // FIXME: 테스트 소켓서버 통신을 위해 임시로 추가 : 테스트 완료후 제거 + + out.flush(); + + rtnMsg = in.readLine(); + System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); + System.out.println(rtnMsg); + System.out.println("=============>>>서버 응답(EUC-KR로 읽어온 값)<<<===================================="); + } catch (SocketTimeoutException e) { // 타임아웃 발생 시 처리 log.error("NICE CI Socket 서버 응답 시간 초과: " + e.getMessage()); -// throw BizRuntimeException.create("NICE CI Socket 서버 응답 시간 초과로 인해 통신이 종료되었습니다."); + throw new EnsException(EnsErrCd.API_COMM_ERROR, "NICE CI Socket 서버 응답 시간 초과"); } catch (IOException e) { -// throw BizRuntimeException.create(e.getMessage()); + throw new EnsException(EnsErrCd.API_COMM_ERROR, e.getMessage()); } return rtnMsg; } diff --git a/src/main/resources/config/conf-contract.yml b/src/main/resources/config/conf-contract.yml index 8229821..0c240ae 100644 --- a/src/main/resources/config/conf-contract.yml +++ b/src/main/resources/config/conf-contract.yml @@ -145,3 +145,5 @@ contract: clientId: 0027370001 # 운영 #clientId: 0027370002 + # 상태조회중 에러 발생시 FAIL 처리 여부 + isStatusFail: false 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 c468d8d..bf4ea86 100644 --- a/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml +++ b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml @@ -159,10 +159,11 @@ WHERE lnk_input_id = #{lnkInputId} - - /** iup-niceci-mapper|updatePrcsCdOfInputXit-prcsCd update|julim */ + + /** 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} @@ -184,20 +185,23 @@ - - /** iup-niceci-mapper|insertNiceSmsSndngRequest-selest nice ci Send request 생성|julim */ + + /** iup-niceci-mapper|insertNiceSmsSndngRequest-nice ci Send request data 생성|julim */ INSERT INTO tb_nice_sms_sndng_requst ( - NIce_sms_sndng_requst_id, + nice_sms_sndng_requst_id, data_id, trnsc_id, spclty_groupcode, @@ -277,8 +281,8 @@ ) - - /** iup-niceci-mapper|insertNiceSmsSndngResponse-selest nice ci Send response 생성|julim */ + + /** iup-niceci-mapper|insertNiceSmsSndngResponse-nice ci Send response 생성|julim */ INSERT INTO tb_nice_sms_sndng_rspns ( nice_sms_sndng_requst_id, trnsc_id, @@ -299,7 +303,7 @@ sndng_mssage, dsptch_no, cttpc_inqire_se, - indvdlz_requst_blnk, + indvdlz_rspns_blnk, indvdl_bsnm_cpr_se, ihidnum, nm, @@ -351,4 +355,168 @@ 'ENS_SYS' ) + + + + + /** iup-niceci-mapper|insertNiceSmsSndngInquireRequest-nice ci Status request data 생성|julim */ + INSERT INTO tb_nice_sms_sndng_inqire_requs ( + nice_sms_sndng_inqire_id, + trnsc_id, + spclty_groupcode, + delng_asortcode, + delng_secode, + trsmrcv_at, + trmnl_se, + rspns_code, + partcpt_instt_id, + instt_spclty_manageno, + instt_spclty_trnsmistime, + nice_spclty_manageno, + nice_spclty_trnsmistime, + blnk, + search_pd_from, + search_pd_to, + indvdl_bsnm_cpr_se, + ihidnum, + result_se, + sms_sndng_requst_se, + requst_co, + accmlt_recptn_co, + indvdlz_requst_blnk, + creat_dt, + crtr + ) VALUES ( + #{niceSmsSndngInqireId}, + #{trnscId}, + #{niceCommon.spcltyGroupcode}, + #{niceCommon.delngAsortcode}, + #{niceCommon.delngSecode}, + #{niceCommon.trsmrcvAt}, + #{niceCommon.trmnlSe}, + #{niceCommon.rspnsCode}, + #{niceCommon.partcptInsttId}, + #{niceCommon.insttSpcltyManageno}, + #{niceCommon.insttSpcltyTrnsmistime}, + #{niceCommon.niceSpcltyManageno}, + #{niceCommon.niceSpcltyTrnsmistime}, + #{niceCommon.blnk}, + #{searchPdFrom}, + #{searchPdTo}, + #{indvdlBsnmCprSe}, + #{ihidnum}, + #{resultSe}, + #{smsSndngRequstSe}, + #{requstCo}, + #{accmltRecptnCo}, + #{indvdlzRequstBlnk}, + sysdate, + 'ENS_SYS' + ) + + + + /** iup-niceci-mapper|insertNiceSmsSndngInquireResponse-nice ci Send response 생성|julim */ + INSERT INTO tb_nice_sms_sndng_inqire_rspns ( + nice_sms_sndng_inqire_id, + trnsc_id, + spclty_groupcode, + delng_asortcode, + delng_secode, + trsmrcv_at, + trmnl_se, + rspns_code, + partcpt_instt_id, + instt_spclty_manageno, + instt_spclty_trnsmistime, + nice_spclty_manageno, + nice_spclty_trnsmistime, + blnk, + tot_co, + accmlt_co, + rspns_co, + creat_dt, + crtr + ) VALUES ( + #{niceSmsSndngInqireId}, + #{trnscId}, + #{niceCommon.spcltyGroupcode}, + #{niceCommon.delngAsortcode}, + #{niceCommon.delngSecode}, + #{niceCommon.trsmrcvAt}, + #{niceCommon.trmnlSe}, + #{niceCommon.rspnsCode}, + #{niceCommon.partcptInsttId}, + #{niceCommon.insttSpcltyManageno}, + #{niceCommon.insttSpcltyTrnsmistime}, + #{niceCommon.niceSpcltyManageno}, + #{niceCommon.niceSpcltyTrnsmistime}, + #{niceCommon.blnk}, + #{totCo}, + #{accmltCo}, + #{rspnsCo}, + sysdate, + 'ENS_SYS' + ) + + + + + /** iup-niceci-mapper|insertNiceSmsSndngInquireResponseRepeat-nice ci Send response 반복부 생성|julim */ + + + INTO tb_nice_sms_sndng_inqire_repti ( + nice_sms_sndng_inqire_id, + sn, + inqire_dt, + indvdl_bsnm_cpr_se, + ihidnum, + nm, + rank_cttpc_1, + rank_cttpc_2, + rank_cttpc_3, + result_se, + sms_sndng_requst_se, + sndng_mssage, + dsptch_no, + sms_sndng_cttpc_rank, + sms_sndng_cttpc_no, + sms_sndng_dt, + opetr_id, + cttpc_inqire_se, + mssage_sndng_result_se, + rspns_reptit_blnk, + creat_dt, + crtr + ) VALUES ( + #{item.niceSmsSndngInqireId}, + (#{index} + 1), + #{item.inqireDt}, + #{item.indvdlBsnmCprSe}, + #{item.ihidnum}, + #{item.nm}, + #{item.rankCttpc_1}, + #{item.rankCttpc_2}, + #{item.rankCttpc_3}, + #{item.resultSe}, + #{item.smsSndngRequstSe}, + #{item.sndngMssage}, + #{item.dsptchNo}, + #{item.smsSndngCttpcRank}, + #{item.smsSndngCttpcNo}, + #{item.smsSndngDt}, + #{item.opetrId}, + #{item.cttpcInqireSe}, + #{item.mssageSndngResultSe}, + #{item.rspnsReptitBlnk}, + sysdate, + 'ENS_SYS' + ) + + +