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 64eedb3..f943c09 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 @@ -35,5 +35,5 @@ public interface INiceCiMapper { Optional selectKkoBpApiUrlFromEnsOrgMng(final String orgCd); Optional selectNiceCiRequestId(); - Optional selectTmpltMsg(final String tmpltId); + Optional selectTmpltMsg(final String tmpltId); } diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java index 26307c1..6888bab 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceCiApiDTO.java @@ -146,7 +146,7 @@ public class NiceCiApiDTO { * */ @Schema(title = "SMS 발신번호", example = " ") - @Pattern(regexp = "^\\s{12}$|[\\d]{3,12}", message = "SMS 발신번호는 3 ~ 12자리 입니다") + @Pattern(regexp = "^[\\s\\S]{3,12}$", message = "SMS 발신번호는 3 ~ 12자리 입니다") private String sndPhoneNo = StringUtils.rightPad("0442113377", 12, StringUtils.SPACE); public void setSndPhoneNo(String sndPhoneNo) { this.sndPhoneNo = StringUtils.rightPad(nvl(sndPhoneNo), 12, StringUtils.SPACE); @@ -196,8 +196,8 @@ public class NiceCiApiDTO { * */ @Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "버튼요청건수", example = " ") - @Pattern(regexp = "^ |[0-5]$", message = "버튼요청건수는 1자리로 최대 5 입니다.") - private String btnReqCnt = StringUtils.SPACE; + @Pattern(regexp = "^[0-5]$", message = "버튼요청건수는 1자리로 최대 5 입니다.") + private String btnReqCnt = "1"; public void setBtnReqCnt(Integer btnReqCnt) { this.btnReqCnt = StringUtils.rightPad(nvl(btnReqCnt == null ? "" : btnReqCnt.toString()), 1, StringUtils.SPACE); } @@ -583,7 +583,7 @@ public class NiceCiApiDTO { */ @Schema(title = "버튼이름", example = "1") @Size(min = 56, max = 56, message = "버튼이름은 56자리 입니다.") - private String btnName = StringUtils.rightPad(StringUtils.EMPTY, 56, StringUtils.SPACE); + private String btnName = StringUtils.rightPad("납부하기", 56, StringUtils.SPACE); public void setBtnName(String jumin) { this.btnName = StringUtils.rightPad(nvl(btnName), 56, StringUtils.SPACE); } @@ -596,7 +596,10 @@ public class NiceCiApiDTO { */ @Schema(title = "버튼URL웹링크1", example = " ") @Size(min = 1000, max = 1000, message = "버튼URL웹링크1 은 1000자리 입니다.") - private String btnUrlWebLink1 = StringUtils.rightPad(StringUtils.EMPTY, 1000, StringUtils.SPACE); + private String btnUrlWebLink1 = StringUtils.rightPad( + "https://billgates-web.kakao.com/r/platform/pages/paynow/search/1832/11/01819e09-8b4c-4287-9f0f-1c5c2df80bf0", + 1000, + StringUtils.SPACE); public void setBtnUrlWebLink1(String btnUrlWebLink1) { this.btnUrlWebLink1 = StringUtils.rightPad(nvl(btnUrlWebLink1), 1000, StringUtils.SPACE); } 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 64dbba2..ed37359 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 @@ -428,12 +428,12 @@ public class NiceCiDTO { private String errorMessage; } - @Schema(name = "TmpltMng DTO", description = "TmpltMng DTO") + @Schema(name = "TmpltMngDTO DTO", description = "TmpltMngDTO DTO") @Data @NoArgsConstructor @AllArgsConstructor @Builder - public static class TmpltMng { + public static class TmpltMngDTO { private String dtype; private String orgCd; 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 0b89caf..2cf6276 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 @@ -2,17 +2,17 @@ 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 com.google.gson.*; + 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.core.utils.*; import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*; -import cokr.xit.ens.modules.nice.cmm.*; import cokr.xit.ens.modules.nice.mapper.*; import cokr.xit.ens.modules.nice.model.*; import cokr.xit.ens.modules.nice.service.support.*; @@ -46,6 +46,7 @@ public class NiceCiSendBulkService { private final NiceCiApiService niceCiApiService; private final INiceCiMapper niceCiMapper; + private Gson gson = new GsonBuilder().disableHtmlEscaping().create(); final String msg = "민자도로 관리지원센터에서 김해찬님께 발송한 미납통행료 고지서가 도착했습니다.\n" + "\n" @@ -90,9 +91,9 @@ public class NiceCiSendBulkService { for(NiceCiDTO.InputXit xit : list) { final String tmpltId = xit.getJobCd(); - final NiceCiDTO.TmpltMng tmpltMng = niceCiMapper.selectTmpltMsg(tmpltId) + final NiceCiDTO.TmpltMngDTO tmpltMngDTO = niceCiMapper.selectTmpltMsg(tmpltId) .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); - final String sndMsg = tmpltMng.getMessage().replace("~~@@!!", "#{").replace("!!@@~~", "}"); + final String sndMsg = tmpltMngDTO.getMessage();//.replace("~~@@!!", "#{").replace("!!@@~~", "}"); final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(xit.getOrgCd()) .orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm())); @@ -109,33 +110,23 @@ public class NiceCiSendBulkService { NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request(); - NiceCiApiCommon nc = new NiceCiApiCommon(); + NiceCiApiCommon nCommon = new NiceCiApiCommon(); + NiceCiApiDTO.QueryRequest queryRequest = new NiceCiApiDTO.QueryRequest(); + NiceCiApiDTO.ButtonRequest btnRequest = new NiceCiApiDTO.ButtonRequest(); // 공통부 set - setNiceCiApiRequestCommon(nc, niceSmsReqId); + setNiceCiApiRequestCommon(nCommon, niceSmsReqId); // 개별부 set - setNiceCiApiPrivateReq(ciRequest, tmpltId, sndMsg); - - NiceCiApiDTO.QueryRequest qr = new NiceCiApiDTO.QueryRequest(); - NiceCiApiDTO.ButtonRequest br = new NiceCiApiDTO.ButtonRequest(); - - ciRequest.setNiceCommon(nc); - ciRequest.getQueryRequests().add(qr); - ciRequest.getButtonRequests().add(br); - - + setNiceCiApiPrivateReq(ciRequest, tmpltId, sndMsg, data); + // 조회요청반복부 set + setQueryRequest(queryRequest, data); + // 버튼요청반복부 set + setBtnRequest(btnRequest, data); + ciRequest.setNiceCommon(nCommon); + ciRequest.getQueryRequests().add(queryRequest); + ciRequest.getButtonRequests().add(btnRequest); - 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.requestSendBulk(ciRequest); log.info(responseVO.toString()); return responseVO; @@ -146,36 +137,48 @@ public class NiceCiSendBulkService { return null; } - private void setNiceCiApiRequestCommon(final NiceCiApiCommon nc, final String niceSmsReqId) { + /** + * 공통부 set + * @param nCommon NiceCiApiCommon + * @param niceSmsReqId 기관전문관리번호 - 업무 PK + */ + private void setNiceCiApiRequestCommon(final NiceCiApiCommon nCommon, final String niceSmsReqId) { //////////////////////////////////////////////////////////// // 공통부 START //////////////////////////////////////////////////////////// //--------------------------------------------------------- // 공통부 : default start //--------------------------------------------------------- - // nc.setGrpCode("NICEIF "); // 전문그룹코드 - // nc.setTrType("0200"); // 거래종별코드 - // nc.setTrClassification("31896"); // 거래구분코드 - // nc.setSndAndRcvFlag("B"); // 송수신플래그 - // nc.setDeviceClassification("503"); // 단말기구분 - // nc.setRsltCode(" "); // 응답코드 - // nc.setNiceMngNo(""); // NICE 전문관리번호 - // nc.setNiceSndDt(""); // NICE 전문 전송시간 - // ciRequest.setCommonEmptyField(""); // 공란 - 16자리 - // ciRequest.setQueryConsentReason("1"); // 조회동의사유 + // nCommon.setGrpCode("NICEIF "); // 전문그룹코드 + // nCommon.setTrType("0200"); // 거래종별코드 + // nCommon.setTrClassification("31896"); // 거래구분코드 + // nCommon.setSndAndRcvFlag("B"); // 송수신플래그 + // nCommon.setDeviceClassification("503"); // 단말기구분 + // nCommon.setRsltCode(" "); // 응답코드 + // nCommon.setNiceMngNo(""); // NICE 전문관리번호 + // nCommon.setNiceSndDt(""); // NICE 전문 전송시간 + // ciRequest.setCommonEmptyField(""); // 공란 - 16자리 + // ciRequest.setQueryConsentReason("1"); // 조회동의사유 //---------------------------------------------------------- // 공통부 : default end //---------------------------------------------------------- - nc.setOrgId(ORG_ID); // 참가기관ID - property 에서 - nc.setOrgMngNo(niceSmsReqId); // 기관전문관리번호 - LPAD(SEQ_NICE_SMS_SNDNG_REQUST_ID, 10, '0') - nc.setOrgSndDt(DateUtil.getTodayAndNowTime("yyyyMMdd")); // 기관전문전송시간 + nCommon.setOrgId(ORG_ID); // 참가기관ID - property 에서 + nCommon.setOrgMngNo(niceSmsReqId); // 기관전문관리번호 - LPAD(SEQ_NICE_SMS_SNDNG_REQUST_ID, 10, '0') + nCommon.setOrgSndDt(DateUtil.getTodayAndNowTime("yyyyMMdd")); // 기관전문전송시간 //////////////////////////////////////////////////////////// // 공통부 END //////////////////////////////////////////////////////////// } - private void setNiceCiApiPrivateReq(final NiceCiApiDTO.Request ciRequest, final String tmpltId, final String sndMsg){ + /** + * 개별요청부 set + * @param ciRequest NiceCiApiDTO.Request + * @param tmpltId template ID + * @param sndMsg 전송메세지 템플릿 + * @param data NiceCiDTO.InputDataXit data + */ + private void setNiceCiApiPrivateReq(final NiceCiApiDTO.Request ciRequest, final String tmpltId, String sndMsg, final NiceCiDTO.InputDataXit data){ //////////////////////////////////////////////////////////// // 개별요청부 START //////////////////////////////////////////////////////////// @@ -194,10 +197,50 @@ public class NiceCiSendBulkService { //--------------------------------------------------------- ciRequest.setQueryReqCnt(1); // 조회요청건수 + Map map = gson.fromJson(data.getMsgData(), Map.class); + for(Map.Entry entry : map.entrySet()){ + sndMsg = sndMsg.replace(entry.getKey(), entry.getValue()); + } ciRequest.setSndMessage(sndMsg); // 발송메세지 ciRequest.setAlimtalkTmpltCode(tmpltId); // 알림톡 템플릿 코드 //////////////////////////////////////////////////////////// // 개별요청부 END //////////////////////////////////////////////////////////// } + + /** + * 조회요청 반복부 set + * @param queryRequest NiceCiApiDTO.QueryRequest + * @param data NiceCiDTO.InputDataXit + */ + private void setQueryRequest(final NiceCiApiDTO.QueryRequest queryRequest, final NiceCiDTO.InputDataXit data) { + //--------------------------------------------------------- + // 조회요청 반복부 : default START + //--------------------------------------------------------- + // queryRequest.setIdDiv("1"); // 개인사업자법인구분 : "1" + // queryRequest.setEmptyField(""); // 공란 - 36 자리 + //--------------------------------------------------------- + // 조회요청 반복부 : default END + //--------------------------------------------------------- + queryRequest.setJumin(data.getSid()); // 주민번호 + } + + /** + * 버튼요청 반복부 set + * @param btnRequest NiceCiApiDTO.ButtonRequest + * @param data NiceCiDTO.InputDataXit + */ + private void setBtnRequest(final NiceCiApiDTO.ButtonRequest btnRequest, final NiceCiDTO.InputDataXit data) { + //--------------------------------------------------------- + // 버튼요청 반복부 : default START + //--------------------------------------------------------- + // btnRequest.setBtnType("WL"); // 버튼타입 + // btnRequest.setBtnName("납부하기"); // 버튼이름 + // btnRequest.setBtnUrlWebLink2(""); + // btnRequest.setEmptyField(""); // 공란 : 942 자리 + //--------------------------------------------------------- + // 버튼요청 반복부 : default END + //--------------------------------------------------------- + btnRequest.setBtnUrlWebLink1(data.getPayUrl()); // 공란 - 36 자리 + } } 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 0b27a11..1d0343c 100644 --- a/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml +++ b/src/main/resources/mybatis-mapper/modules/iup-niceci-mapper.xml @@ -182,7 +182,7 @@ FROM DUAL - /** iup-niceci-mapper|selectTmpltMsg-selest nice ci template message|julim */ SELECT dtype , org_cd