feat: NICE CI 인증톡 진행 - sendBulk API 파라메터 set

dev
Jonguk. Lim 1 month ago
parent a4ab009b83
commit 3ad2b1e1ac

@ -182,4 +182,7 @@ Values
select nvl(max(id), 0) + 1
from IUP.ENS_BILL_HIS
where id = 99999999999999999999
where id = 99999999999999999999;;
SELECT * FROM ens_tmplt_mng
where tmplt_cd='A0001';

@ -23,7 +23,7 @@ import cokr.xit.ens.modules.nice.model.*;
*/
@Mapper
public interface INiceCiMapper {
List<NiceCiDTO.InputXit> selectNiceCiAcceptTgts(final NiceCiDTO.NiceCiParam niceCiParam);
List<NiceCiDTO.InputXit> selectNiceCiTgts(final NiceCiDTO.NiceCiParam niceCiParam);
List<NiceCiDTO.InputDataXit> selectNiceCiAcceptDatas(final NiceCiDTO.NiceCiParam niceCiParam);
int insertBill(final NiceCiDTO.BillDTO billDTO);
@ -32,5 +32,8 @@ public interface INiceCiMapper {
int saveBillKko(final NiceCiDTO.BillKkoDTO billKkoDTO);
int updatePayUrlOfDataInput(final NiceCiDTO.InputDataXit inputDataXit);
int updatePrcsCdOfInputXit(final NiceCiDTO.InputXit inputXit);
Optional<OrgMng> selectKkoBpApiUrlFromEnsOrgMng(String orgCd);
Optional<OrgMng> selectKkoBpApiUrlFromEnsOrgMng(final String orgCd);
Optional<String> selectNiceCiRequestId();
Optional<NiceCiDTO.TmpltMng> selectTmpltMsg(final String tmpltId);
}

@ -60,12 +60,12 @@ public class NiceCiApiCommon {
/**
* <pre>
* - 5
* "31895" set
* "31896" set
* </pre>
*/
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "거래구분코드(5자리)", example = "31895")
@Size(min = 5, max = 5, message = "거래 구분 코드는 5자리 입니다.")
private String trClassification = "31895";
private String trClassification = "31896";
public void setTrClassification(String trClassification) {
this.trClassification = StringUtils.rightPad(nvl(trClassification), 5, StringUtils.SPACE);
}
@ -124,7 +124,7 @@ public class NiceCiApiCommon {
* </pre>
*/
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "참가기관ID(9자리)", example = "503")
@Size(min = 9, max = 9, message = "참가기관ID는 3자리 입니다.")
@Size(min = 9, max = 9, message = "참가기관ID는 9자리 입니다.")
private String orgId = StringUtils.rightPad(StringUtils.EMPTY, 9, StringUtils.SPACE);
public void setOrgId(String orgId) {
this.orgId = StringUtils.rightPad(nvl(orgId), 9, StringUtils.SPACE);

@ -94,8 +94,7 @@ public class NiceCiApiDTO {
*/
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "조회사유", example = " ")
@Size(min = 2, max = 2, message = "조회사유는 2자리 입니다")
//@Pattern(regexp = "^\\s{2}$|s{1,2}", message = "조회사유는 2자리 입니다")
private String queryReason = StringUtils.rightPad(StringUtils.EMPTY, 2, StringUtils.SPACE);
private String queryReason = "17";
public void setQueryReason(String queryReason) {
this.queryReason = StringUtils.rightPad(nvl(queryReason), 2, StringUtils.SPACE);
}
@ -108,9 +107,9 @@ public class NiceCiApiDTO {
*/
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "조회요청건수", example = " ")
@Pattern(regexp = "^\\s{2}$|\\d{1,2}", message = "조회요청 최대건수는 48입니다(2자리)")
private String queryReqCnt = StringUtils.rightPad(StringUtils.EMPTY, 2, StringUtils.SPACE);
private String queryReqCnt = "01";
public void setQueryReqCnt(Integer queryReqCnt) {
this.queryReqCnt = StringUtils.rightPad(nvl(queryReqCnt == null? "": queryReqCnt.toString()), 2, StringUtils.SPACE);
this.queryReqCnt = StringUtils.leftPad(nvl(queryReqCnt == null? "": queryReqCnt.toString()), 2, "0");
}
/**
@ -125,7 +124,7 @@ public class NiceCiApiDTO {
*/
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "SMS발송요청구분코드", example = " ", allowableValues = {"0", "1", "2", "3"})
@Pattern(regexp = "[0-3]", message = "SMS발송요청구분코드 0 ~ 3 입니다(1자리)")
private String smsSndReqCode = "1";
private String smsSndReqCode = "3";
/**
* <pre>
@ -148,7 +147,7 @@ public class NiceCiApiDTO {
*/
@Schema(title = "SMS 발신번호", example = " ")
@Pattern(regexp = "^\\s{12}$|[\\d]{3,12}", message = "SMS 발신번호는 3 ~ 12자리 입니다")
private String sndPhoneNo = StringUtils.rightPad(StringUtils.EMPTY, 12, StringUtils.SPACE);
private String sndPhoneNo = StringUtils.rightPad("0442113377", 12, StringUtils.SPACE);
public void setSndPhoneNo(String sndPhoneNo) {
this.sndPhoneNo = StringUtils.rightPad(nvl(sndPhoneNo), 12, StringUtils.SPACE);
}

@ -426,6 +426,33 @@ public class NiceCiDTO {
private String errorCode;
private String errorMessage;
}
@Schema(name = "TmpltMng DTO", description = "TmpltMng DTO")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class TmpltMng {
private String dtype;
private String orgCd;
private String tmpltCd;
private String title;
private String message;
private String useYn;
private String registId;
private LocalDateTime registDt;
private String updId;
private LocalDateTime lastUpdtDt;
}
}

@ -27,8 +27,9 @@ import lombok.*;
@RequiredArgsConstructor
@RequestMapping(value = "/nice/talk")
public class NiceCiController {
private final NiceCiService niceCiService;
private final NiceCiAcceptService niceCiAcceptService;
private final NiceCiSendBulkService niceCiSendService;
private final NiceCiStatBulkService niceCiStatBulkService;
@Operation(summary = "접수")
@PostMapping(value = "/accept/all", produces = MediaType.APPLICATION_JSON_VALUE)
@ -39,12 +40,12 @@ public class NiceCiController {
@Operation(summary = "(대량)전송요청")
@PostMapping(value = "/send/bulk/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> sendBulk() {
return new ResponseEntity<>(niceCiService.requestSendBulk(), HttpStatus.OK);
return new ResponseEntity<>(niceCiSendService.requestSendBulk(), HttpStatus.OK);
}
@Operation(summary = "(대량)상태조회")
@PostMapping(value = "/stat/bulk/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> findBulkStatus() {
return new ResponseEntity<>(niceCiService.findBulkStatus(), HttpStatus.OK);
return new ResponseEntity<>(niceCiStatBulkService.findBulkStatus(), HttpStatus.OK);
}
}

@ -88,7 +88,7 @@ public class NiceCiAcceptService {
.prcsCd(IupPrcsCd.TGRG.getCode())
.build();
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiAcceptTgts(niceCiParam);
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiTgts(niceCiParam);
if(list.isEmpty()){
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.ERR404)
@ -112,10 +112,10 @@ public class NiceCiAcceptService {
.expireAt(DateUtil.getStringFromLocalDate(list.get(0).getExpiresDt(), "yyyyMMddHHmmss"))
.build();
final OrgMng orgMng = niceCiMapper.selectKkoBpApiUrlFromEnsOrgMng(list.get(0).getOrgCd())
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm()));
for(NiceCiDTO.InputXit xit : list){
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<NiceCiDTO.InputDataXit> inputDataXits = xit.getInputDataXits();

@ -0,0 +1,203 @@
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.*;
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.*;
import lombok.*;
import lombok.extern.slf4j.*;
/**
* <pre>
* description :
* packageName : cokr.xit.ens.modules.nice.service
* fileName : NiceCiSendBulkService
* author : limju
* date : 2024 9 27
* ======================================================================
*
* ----------------------------------------------------------------------
* 2024 9 27 limju
*
* </pre>
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class NiceCiSendBulkService {
@Value("${contract.niceCi.orgId}")
private String ORG_ID;
@Value("${contract.niceCi.clientId}")
private String CLIENT_ID;
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<?> requestSendBulk() {
final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder()
.sendType(IupSendTypeCd.NI.getCode())
.prcsCd(IupPrcsCd.GRUC.getCode())
.build();
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiTgts(niceCiParam);
if(list.isEmpty()){
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.ERR404)
.errMsg(EnsErrCd.ERR404.getCodeNm())
.build();
}
list.forEach(d -> {
niceCiParam.setLnkInputId(d.getLnkInputId());
d.setInputDataXits(niceCiMapper.selectNiceCiAcceptDatas(niceCiParam));
});
for(NiceCiDTO.InputXit xit : list) {
final String tmpltId = xit.getJobCd();
final NiceCiDTO.TmpltMng tmpltMng = niceCiMapper.selectTmpltMsg(tmpltId)
.orElseThrow(() -> new EnsException(EnsErrCd.NO_DATA_FOUND, EnsErrCd.NO_DATA_FOUND.getCodeNm()));
final String sndMsg = tmpltMng.getMessage().replace("~~@@!!", "#{").replace("!!@@~~", "}");
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<NiceCiDTO.InputDataXit> inputDataXits = xit.getInputDataXits();
for (NiceCiDTO.InputDataXit data : inputDataXits) {
// 기관전문관리번호, TB_NICE_SMS_SNDNG_REQUEST
final String niceSmsReqId = niceCiMapper.selectNiceCiRequestId().orElseThrow(
() -> new EnsException(EnsErrCd.MAKE521, EnsErrCd.MAKE521.getCodeNm())
);
NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request();
NiceCiApiCommon nc = new NiceCiApiCommon();
// 공통부 set
setNiceCiApiRequestCommon(nc, 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);
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;
}
} catch (Exception e) {
}
}
return null;
}
private void setNiceCiApiRequestCommon(final NiceCiApiCommon nc, 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"); // 조회동의사유
//----------------------------------------------------------
// 공통부 : 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")); // 기관전문전송시간
////////////////////////////////////////////////////////////
// 공통부 END
////////////////////////////////////////////////////////////
}
private void setNiceCiApiPrivateReq(final NiceCiApiDTO.Request ciRequest, final String tmpltId, final String sndMsg){
////////////////////////////////////////////////////////////
// 개별요청부 START
////////////////////////////////////////////////////////////
//----------------------------------------------------------
// 개별요청부 : default start
//----------------------------------------------------------
// ciRequest.setQueryReason("17"); // 조회사유
// ciRequest.setSmsSndReqCode("3"); // SMS발송요청구분코드
// ciRequest.setSndPhoneNo("0442113377"); // 발신번호
// ciRequest.setContactSearchCode("3"); // 연락처 조회 구분
// ciRequest.setAlimtalkSndReqDiv("1"); // 알림톡발송요청구분코드
// ciRequest.setBtnReqCnt(1); // 버튼요청건수
// ciRequest.setPrivateEmptyField(""); // 공란 - 880자리
//---------------------------------------------------------
// 개별요청부 : default end
//---------------------------------------------------------
ciRequest.setQueryReqCnt(1); // 조회요청건수
ciRequest.setSndMessage(sndMsg); // 발송메세지
ciRequest.setAlimtalkTmpltCode(tmpltId); // 알림톡 템플릿 코드
////////////////////////////////////////////////////////////
// 개별요청부 END
////////////////////////////////////////////////////////////
}
}

@ -1,10 +1,14 @@
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.cmm.*;
import cokr.xit.ens.modules.nice.mapper.*;
import cokr.xit.ens.modules.nice.model.*;
@ -16,7 +20,7 @@ import lombok.extern.slf4j.*;
* <pre>
* description :
* packageName : cokr.xit.ens.modules.nice.service
* fileName : NiceCiService
* fileName : NiceCiStatBulkService
* author : limju
* date : 2024 9 27
* ======================================================================
@ -29,7 +33,7 @@ import lombok.extern.slf4j.*;
@Slf4j
@Service
@RequiredArgsConstructor
public class NiceCiService {
public class NiceCiStatBulkService {
@Value("${contract.niceCi.orgId}")
private String ORG_ID;
@ -61,54 +65,20 @@ public class NiceCiService {
+ "\n"
+ "문의처 : 044-211-3377";
public EnsResponseVO<?> requestSendBulk() {
NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.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()));
ciRequest.setSndMessage(msg);
// 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);
ciRequest.getQueryRequests().add(qr);
ciRequest.getButtonRequests().add(br);
// 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.requestSendBulk(ciRequest);
log.info(responseVO.toString());
return responseVO;
}
public EnsResponseVO<?> findBulkStatus() {
final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder()
.sendType(IupSendTypeCd.NI.getCode())
.prcsCd(IupPrcsCd.IPCP.getCode())
.build();
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiTgts(niceCiParam);
if(list.isEmpty()){
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.ERR404)
.errMsg(EnsErrCd.ERR404.getCodeNm())
.build();
}
NiceCiApiHistoryDTO.Request ciRequest = new NiceCiApiHistoryDTO.Request();
//ciRequest.setTrCode("0000006150");
// // 공통부

@ -6,8 +6,8 @@
<!-- ================================ accept =========================================== -->
<!-- =================================================================================== -->
<select id="selectNiceCiAcceptTgts" parameterType="cokr.xit.ens.modules.nice.model.NiceCiDTO$NiceCiParam" resultType="cokr.xit.ens.modules.nice.model.NiceCiDTO$InputXit">
/** iup-niceci-mapper|selectNiceCiAcceptTgts-NICE CI 발송 대상 조회|julim */
<select id="selectNiceCiTgts" parameterType="cokr.xit.ens.modules.nice.model.NiceCiDTO$NiceCiParam" resultType="cokr.xit.ens.modules.nice.model.NiceCiDTO$InputXit">
/** iup-niceci-mapper|selectNiceCiTgts-NICE CI 대상 조회|julim */
SELECT lnk_input_id
, err_msg
, expires_dt
@ -26,6 +26,9 @@
FROM tb_input_xit
WHERE send_type = #{sendType}
AND prcs_cd = #{prcsCd}
<if test="sendType eq 'GRUC'">
AND run_dt &lt; sysdate
</if>
</select>
<select id="selectNiceCiAcceptDatas" parameterType="cokr.xit.ens.modules.nice.model.NiceCiDTO$NiceCiParam" resultType="cokr.xit.ens.modules.nice.model.NiceCiDTO$InputDataXit">
@ -173,4 +176,20 @@
WHERE org_cd = #{orgCd}
</select>
<select id="selectNiceCiRequestId" resultType="string">
/** iup-niceci-mapper|selectNiceCiRequestId-select nice ci request Id|julim */
SELECT LPAD(SEQ_NICE_SMS_SNDNG_REQUST_ID.nextval, 10, '0')
FROM DUAL
</select>
<select id="selectTmpltMsg" parameterType="string " resultType="cokr.xit.ens.modules.nice.model.NiceCiDTO$TmpltMng">
/** iup-niceci-mapper|selectTmpltMsg-selest nice ci template message|julim */
SELECT dtype
, org_cd
, tmplt_cd
, message
, title
FROM ens_tmplt_mng
WHERE tmplt_cd = #{tmpltCd}
</select>
</mapper>

Loading…
Cancel
Save