From 657c5dabc0f2e5095b4bd7685d6b12e92833f883 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Tue, 20 Aug 2024 12:58:29 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20KT-GIBIS=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/mens_traffic.sql | 4 + .../xit/biz/ktgbs/mapper/IBizKtGbsMapper.java | 28 ++ .../biz/ktgbs/service/BizKtGbsService.java | 137 ++++++ .../biz/ktgbs/service/IBizKtGbsService.java | 26 ++ .../xit/ens/ktgbs/service/IKtGbsService.java | 31 ++ .../xit/ens/ktgbs/service/KtGbsService.java | 70 +++ .../kr/xit/ens/ktgbs/web/KtGbsController.java | 46 ++ .../ens/ktgbs/web/KtGbsInboundController.java | 79 ++++ .../main/resources/config/application-ens.yml | 7 + .../xit/biz/ens/mapper/IEnsBatchMapper.java | 17 + .../kr/xit/biz/ens/model/EnsKtGbsDTO.java | 64 +++ .../ens/service/EnsBatchAcceptService.java | 2 +- .../ens/service/EnsBatchExtractService.java | 11 + .../biz/ens/service/EnsBatchMakeService.java | 16 + .../biz/ens/service/EnsBatchSendService.java | 118 ++++- .../ens/service/EnsBatchStatusService.java | 2 +- .../ens/service/IEnsBatchExtractService.java | 2 + .../main/resources/config/application-ens.yml | 14 +- .../mapper/biz/ens-mysql-mapper.xml | 18 +- .../mapper/biz/ens-oracle-mapper.xml | 139 +++++- .../java/kr/xit/biz/common/ApiConstants.java | 1 + .../xit/biz/ens/model/ktgbs/KtGbsApiDTO.java | 426 ++++++++++++++++++ .../kr/xit/biz/ens/model/ktgbs/KtGbsDTO.java | 18 + .../core/spring/util/ApiWebClientUtil.java | 19 + 24 files changed, 1267 insertions(+), 28 deletions(-) create mode 100644 mens-api/src/main/java/kr/xit/biz/ktgbs/mapper/IBizKtGbsMapper.java create mode 100644 mens-api/src/main/java/kr/xit/biz/ktgbs/service/BizKtGbsService.java create mode 100644 mens-api/src/main/java/kr/xit/biz/ktgbs/service/IBizKtGbsService.java create mode 100644 mens-api/src/main/java/kr/xit/ens/ktgbs/service/IKtGbsService.java create mode 100644 mens-api/src/main/java/kr/xit/ens/ktgbs/service/KtGbsService.java create mode 100644 mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsController.java create mode 100644 mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java create mode 100644 mens-batch/src/main/java/kr/xit/biz/ens/model/EnsKtGbsDTO.java create mode 100644 mens-core/src/main/java/kr/xit/biz/ens/model/ktgbs/KtGbsApiDTO.java create mode 100644 mens-core/src/main/java/kr/xit/biz/ens/model/ktgbs/KtGbsDTO.java diff --git a/db/mens_traffic.sql b/db/mens_traffic.sql index ea574d9..2eaa1fa 100644 --- a/db/mens_traffic.sql +++ b/db/mens_traffic.sql @@ -92,3 +92,7 @@ where teim.ihidnum = 'RUNCNjEwM0JERENGMEMzNjRBOTAyMERERjg5MDFEODc='; AND IFNULL(tekmd.document_binder_uuid, '') != '' AND tesm.signgu_code = '51110' AND tesm.ffnlg_code = '11'; + + +select * from ens_snd_mast; +select * from ENS_SND_DTL_KT_GBS; diff --git a/mens-api/src/main/java/kr/xit/biz/ktgbs/mapper/IBizKtGbsMapper.java b/mens-api/src/main/java/kr/xit/biz/ktgbs/mapper/IBizKtGbsMapper.java new file mode 100644 index 0000000..4633ffe --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/ktgbs/mapper/IBizKtGbsMapper.java @@ -0,0 +1,28 @@ +package kr.xit.biz.ktgbs.mapper; + +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; +import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMsgRsltReqData; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.ktgbs.mapper
+ * fileName    : IBizKtGbsMapper
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19    limju       최초 생성
+ *
+ * 
+ */ +@Mapper +public interface IBizKtGbsMapper { + int updateRlaybsnmKtInfo(final CmmEnsRlaybsnmDTO dto); + int updateKtBcDtl(final KtMsgRsltReqData dto); + int saveKtCntcSndngResult(final KtMsgRsltReqData dto); +} diff --git a/mens-api/src/main/java/kr/xit/biz/ktgbs/service/BizKtGbsService.java b/mens-api/src/main/java/kr/xit/biz/ktgbs/service/BizKtGbsService.java new file mode 100644 index 0000000..4e768b3 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/ktgbs/service/BizKtGbsService.java @@ -0,0 +1,137 @@ +package kr.xit.biz.ktgbs.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import kr.xit.biz.cmm.service.ICmmEnsCacheService; +import kr.xit.biz.common.ApiConstants; +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.kt.KtCommonDTO.ErrorMsg; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; +import kr.xit.biz.ktgbs.mapper.IBizKtGbsMapper; +import kr.xit.core.service.AbstractService; +import kr.xit.core.spring.annotation.TraceLogging; +import kr.xit.core.support.utils.Checks; +import kr.xit.core.support.utils.DateUtils; +import kr.xit.ens.cmm.CmmEnsUtils; +import kr.xit.ens.kt.web.KtBcInboundController; +import kr.xit.ens.ktgbs.service.IKtGbsService; +import lombok.RequiredArgsConstructor; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.ktgbs.service
+ * fileName    : BizKtGbsService
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19    limju       최초 생성
+ *
+ * 
+ */ +@RequiredArgsConstructor +@Service +public class BizKtGbsService extends AbstractService implements IBizKtGbsService { + private final IKtGbsService ktGbsService; + private final ICmmEnsCacheService cacheService; + private final IBizKtGbsMapper mapper; + + /** + *
+     * kt Access token 획득
+     * 1. kt Access token 요청
+     * 2. 요청결과 DB 반영
+     * 3. 정보중계자 정보 캐시 삭제
+     * @param paramDTO KtMnsRequest
+     * @return KtTokenResponse
+     * 
+ */ + /* + @Override + public KtTokenResponse requestToken(final KtMnsRequest paramDTO) { + KtTokenResponse resDTO = ktMmsService.requestToken(paramDTO); + + if(StringUtils.isEmpty(resDTO.getAccessToken())){ + throw BizRuntimeException.create("fail.api.kt.token.request"); + } + mapper.updateRlaybsnmKtInfo( + CmmEnsRlaybsnmDTO.builder() + .signguCode(paramDTO.getSignguCode()) + .ffnlgCode(paramDTO.getFfnlgCode()) + .profile(ApiConstants.PROFILE) + .ktAccessToken(resDTO.getAccessToken()) + .ktTokenExpiresIn(resDTO.getExpiresIn()) + .ktScope(resDTO.getScope()) + .ktTokenJti(resDTO.getJti()) + .build() + ); + cacheService.removeRlaybsnmInfoCache( + CmmEnsRequestDTO.builder() + .signguCode(paramDTO.getSignguCode()) + .ffnlgCode(paramDTO.getFfnlgCode()) + .profile(paramDTO.getProfile()) + .build() + ); + return resDTO; + } +*/ + /** + *
+     * 사전/본 문자 발송/수신 결과 전송
+     * - KT 에서 호출 되는 서비스
+     * - http://{각대행사(IP:Port)}/api/ag/message/result
+     * {@link KtBcInboundController#messageResult messageResult}
+     *
+     * 본문자 수신 등록 요청시 보낸 묶음 단위로 처리
+     * -> 처리중 1건이라도 실패시, 전체 건 재 전송
+     * -> 업무단에서는 건별 처리하도록 구현
+     *
+     * @param reqDTO KtMsgRsltRequest
+     * @return KtCommonResponse
+     * 
+ */ + @Override + @TraceLogging + @Transactional + public KtCommonDTO.KtCommonResponse messageResult(final KtGbsApiDTO.MsgRsltRequest reqDTO) { + List errors = CmmEnsUtils.getValidateErrors(reqDTO); + + if(!errors.isEmpty()) return throwError(errors); + + for(KtGbsApiDTO.MsgRsltReqsData dto : reqDTO.getReqs()){ + + // 결과코드가 '40' 이고 열람타임스탬프가 있는 경우 -> 결과코드 '열람확인:60'으로 reset + if("40".equals(dto.getMmsRsltDvcd()) && Checks.isNotEmpty(dto.getMmsRdgTmst())){ + dto.setMmsRsltDvcd("60"); + } + dto.setMmsRsltDvcdMsg(messageUtil.getMessage("info.api.kt.msg.rslt."+dto.getMmsRsltDvcd())); + // FIXME: KT GIBIS 적용 안됨 + //if(mapper.updateKtBcDtl(dto) != 1) { + // errors.add(new ErrorMsg( + // String.format("존재 하지 않는 발송 대상(src_key[%s], mms_rslt_sqno[%s]) 입니다", + // dto.getSrcKey(), dto.getMmsSndgRsltSqno()))); + //} + // FIXME: KT GIBIS 적용 안됨 + //mapper.saveKtCntcSndngResult(dto); + } + + return KtCommonDTO.KtCommonResponse.builder() + .resultCd("00") + .resultDt(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT)) + .build(); + } + + private static KtCommonDTO.KtCommonResponse throwError(List errors) { + return KtCommonDTO.KtCommonResponse.builder() + .resultCd("01") + .resultDt(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT)) + .errors(errors) + .build(); + } +} diff --git a/mens-api/src/main/java/kr/xit/biz/ktgbs/service/IBizKtGbsService.java b/mens-api/src/main/java/kr/xit/biz/ktgbs/service/IBizKtGbsService.java new file mode 100644 index 0000000..a130ef0 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/ktgbs/service/IBizKtGbsService.java @@ -0,0 +1,26 @@ +package kr.xit.biz.ktgbs.service; + + +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.ktgbs.service
+ * fileName    : IBizKtGbsService
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19    limju       최초 생성
+ *
+ * 
+ */ +public interface IBizKtGbsService { + + //KtTokenResponse requestToken(final KtMnsRequest paramDTO); + KtCommonDTO.KtCommonResponse messageResult(final KtGbsApiDTO.MsgRsltRequest reqDTO); +} diff --git a/mens-api/src/main/java/kr/xit/ens/ktgbs/service/IKtGbsService.java b/mens-api/src/main/java/kr/xit/ens/ktgbs/service/IKtGbsService.java new file mode 100644 index 0000000..802d485 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/ens/ktgbs/service/IKtGbsService.java @@ -0,0 +1,31 @@ +package kr.xit.ens.ktgbs.service; + +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; + +/** + *
+ * description : 
+ * packageName : kr.xit.ens.ktgbs.service
+ * fileName    : IKtGbsService
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19   limju       최초 생성
+ *
+ * 
+ */ +public interface IKtGbsService { + // FIXME : KT GIBIS 적용 안됨 + //------------------------------------------------------------------------------ + // mens 사용 API + //------------------------------------------------------------------------------ + // KtTokenDTO.KtTokenResponse requestToken(final KtCommonDTO.KtMnsRequest paramDTO); + KtCommonDTO.KtCommonResponse mainSend(final KtGbsApiDTO.MsgSendRequest reqDTO); + // KtTokenDTO.KtTokenConfirmResponse cfmToken(final KtTokenDTO.KtTokenConfirmRequest reqDTO); + // KtCommonDTO.KtCommonResponse readToken(final KtTokenDTO.KtTokenReadRequest reqDTO); + //------------------------------------------------------------------------------ + +} diff --git a/mens-api/src/main/java/kr/xit/ens/ktgbs/service/KtGbsService.java b/mens-api/src/main/java/kr/xit/ens/ktgbs/service/KtGbsService.java new file mode 100644 index 0000000..d73b0d9 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/ens/ktgbs/service/KtGbsService.java @@ -0,0 +1,70 @@ +package kr.xit.ens.ktgbs.service; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; + +import kr.xit.biz.common.ApiConstants; +import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; +import kr.xit.core.service.AbstractService; +import kr.xit.core.spring.annotation.TraceLogging; +import kr.xit.core.spring.util.ApiWebClientUtil; +import kr.xit.core.support.utils.JsonUtils; +import kr.xit.ens.cmm.CmmEnsUtils; +import lombok.RequiredArgsConstructor; + +/** + *
+ * description : 
+ * packageName : kr.xit.ens.ktgbs.service
+ * fileName    : KtGbsService
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19   limju       최초 생성
+ *
+ * 
+ */ +@RequiredArgsConstructor +@Service +public class KtGbsService extends AbstractService implements IKtGbsService { + @Value("${app.contract.ktgbs.host}") + private String HOST; + + /** + * 본문자수신등록 : BC-AG-SN-002 + */ + @Value("${app.contract.ktgbs.api.main-send}") + private String API_MAIN_SEND; + + private final ApiWebClientUtil webClient; + + // FIXME : KT GIBIS 적용 안됨 + @Override + @TraceLogging + public KtCommonDTO.KtCommonResponse mainSend(final KtGbsApiDTO.MsgSendRequest reqDTO) { + final CmmEnsRlaybsnmDTO ktMnsInfo = getRlaybsnmInfo(reqDTO); + reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode()); + reqDTO.setServiceCd(ktMnsInfo.getKtSvcCerfKey()); + reqDTO.setSignguCode(null); + reqDTO.setFfnlgCode(null); + reqDTO.setProfile(null); + CmmEnsUtils.validate(reqDTO); + + return webClient.exchangeKtGbs( + HOST + API_MAIN_SEND, + HttpMethod.POST, + JsonUtils.toJson(reqDTO), + KtCommonDTO.KtCommonResponse.class, + ktMnsInfo + ); + } + + private CmmEnsRlaybsnmDTO getRlaybsnmInfo(final KtCommonDTO.KtMnsRequest request){ + return CmmEnsUtils.getRlaybsnmInfo(request.getSignguCode(), request.getFfnlgCode(), ApiConstants.SndngSeCode.KT_BC); + } +} diff --git a/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsController.java b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsController.java new file mode 100644 index 0000000..f9f8e0f --- /dev/null +++ b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsController.java @@ -0,0 +1,46 @@ +package kr.xit.ens.ktgbs.web; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; +import kr.xit.core.model.ApiResponseDTO; +import kr.xit.core.model.IApiResponse; +import kr.xit.ens.ktgbs.service.IKtGbsService; +import lombok.RequiredArgsConstructor; + +/** + *
+ * description : 
+ * packageName : kr.xit.ens.ktgbs.web
+ * fileName    : KtGbsController
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19   limju       최초 생성
+ *
+ * 
+ */ +@Tag(name = "KtGbsController", description = "KT GIBIS API controller") +@RequiredArgsConstructor +@RestController +@RequestMapping(value = "/api/ens/ktgbs/v1") +public class KtGbsController { + private final IKtGbsService service; + + // FIXME : KT GIBIS 적용 안됨 + @Operation(summary = "본문자 수신 등록 요청", description = "본문자 수신 등록 요청") + @PostMapping(value = "/mainSend", produces = MediaType.APPLICATION_JSON_VALUE) + public IApiResponse mainSend(@RequestBody final KtGbsApiDTO.MsgSendRequest reqDTO) { + KtCommonDTO.KtCommonResponse dto = service.mainSend(reqDTO); + return ApiResponseDTO.success(dto); + } +} diff --git a/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java new file mode 100644 index 0000000..37ec74a --- /dev/null +++ b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java @@ -0,0 +1,79 @@ +package kr.xit.ens.ktgbs.web; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.tags.Tag; +import kr.xit.biz.ens.model.kt.KtCommonDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; +import lombok.RequiredArgsConstructor; + +/** + *
+ * description : KT GBIS 에서 사용 되는 API
+ * packageName : kr.xit.ens.ktgbs.web
+ * fileName    : KtGbsMmsInboundController
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-19   limju       최초 생성
+ *
+ * 
+ */ +@Tag(name = "KtGbsInboundController", description = "KT GIBIS Inbound API") +@RequiredArgsConstructor +@RestController +public class KtGbsInboundController { + /** + *
+     * 메세지 발송/수신 결과 전송 -> KT GIBIS에서 호출
+     * - KT GBIS 에서 호출 되는 서비스
+     * - url 고정 : http://{각대행사(IP:Port)}/api/msg/result
+     * @param reqDTO KtMsgRsltRequest
+     * @return KtCommonResponse
+     * 
+ */ + // FIXME : KT GIBIS 적용 안됨 + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content( + mediaType = "application/json", + examples = { + @ExampleObject( + value = """ + { + "service_cd" : "CD001", + "reqs" : [ + { + "src_key" : "OvSsuljd1K-67c1fc38-1a59-4fbe-930e-802db6609140", + "mms_sndg_rslt_sqno" : 2, + "prcs_dt" : "20240819", + "mms_bsns_dvcd" : "01001", + "mbl_bzowr_dvcd" : "02", + "rl_mms_sndg_telno" : "4230", + "mms_rslt_dvcd" : "40", + "mms_sndg_tmst" : "20240819090237", + "mms_rcv_tmst" : "20240819090239", + "mms_rdg_tmst" : "20240819114405", + "prev_approve_yn" : "Y", + "msg_type" : "2" + } + ] + } + """ + ), + }) + }) + @Operation(summary = "메세지 발송/수신 결과 전송 -> KT GIBIS에서 호출", description = "메세지 발송/수신 결과 전송 -> KT GIBIS에서 호출") + //@PostMapping(value = "/goji/kt/gibis/stat/bulk", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/api/msg/result", produces = MediaType.APPLICATION_JSON_VALUE) + public KtCommonDTO.KtCommonResponse messageResult(@RequestBody final KtGbsApiDTO.MsgRsltRequest reqDTO) { + return null; //bizService.messageResult(reqDTO); + } +} diff --git a/mens-api/src/main/resources/config/application-ens.yml b/mens-api/src/main/resources/config/application-ens.yml index 6ccc6dc..cf5adeb 100644 --- a/mens-api/src/main/resources/config/application-ens.yml +++ b/mens-api/src/main/resources/config/application-ens.yml @@ -82,3 +82,10 @@ app: info-acmd: /api/acmdinfo # 전자문서유통정보수치확인서 발급처리 : BC-AG-HS-002 cfm-acmd: /api/acmdinfocfm + ktgbs: + host: http://172.16.0.13:10210/ONLWeb + api: + # 본문자수신등록 : BC-AG-SN-002 + main-send: /api/msg/send + # 사전/본 문자 발송/수신 결과 전송 : BC-AG-SN-010 + result-message: /api/msg/result diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java b/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java index e347bd0..d87abf4 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/mapper/IEnsBatchMapper.java @@ -8,6 +8,7 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import kr.xit.biz.ens.model.EnsDTO; import kr.xit.biz.ens.model.EnsKtBcDTO; +import kr.xit.biz.ens.model.EnsKtGbsDTO; import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.cmm.TmplatManage; import kr.xit.biz.ens.model.cntc.CntcDTO; @@ -15,6 +16,7 @@ import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; /** *
@@ -182,6 +184,7 @@ public interface IEnsBatchMapper {
     /**
      * 
      * Kt 공인알림문자 마스타 데이터 생성
+     * KT GIBIS 사용시는 skip
      * - tb_ens_kt_bc
      * @param t T
      * @return int
@@ -199,6 +202,16 @@ public interface IEnsBatchMapper {
      */
      int insertKtBcDetail(final T t);
 
+    /**
+     * 
+     * Kt Gibis 디테일 데이터 생성
+     * - ens_snd_dtl_kt_gbs
+     * @param t T
+     * @return int
+     * 
+ */ + int insertKtGbsDetail(final T t); + /** *
      * 통합발송마스터 상태 변경
@@ -316,6 +329,10 @@ public interface IEnsBatchMapper {
     Optional selectKtBcMstTgtInfo(final SndngMssageParam dto);
     List selectKtBcSendTgts(final SndngMssageParam dto);
     int updateKtBcMst(final SndngMssageParam dto);
+
+    Optional selectKtGbsMstTgtInfo(final SndngMssageParam dto);
+    List selectKtGbsSendTgts(final SndngMssageParam dto);
+
     //----------------------------------------------------------------------
     // send
     //----------------------------------------------------------------------
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/model/EnsKtGbsDTO.java b/mens-batch/src/main/java/kr/xit/biz/ens/model/EnsKtGbsDTO.java
new file mode 100644
index 0000000..be4db88
--- /dev/null
+++ b/mens-batch/src/main/java/kr/xit/biz/ens/model/EnsKtGbsDTO.java
@@ -0,0 +1,64 @@
+package kr.xit.biz.ens.model;
+
+import kr.xit.biz.common.ApiConstants;
+import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.SuperBuilder;
+
+/**
+ * 
+ * description : tb_ens_ Entity DTO
+ *
+ * packageName : kr.xit.biz.ens.model
+ * fileName    : EnsKtGbsDTO
+ * author      : limju
+ * date        : 2024-08-19
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-29    limju       최초 생성
+ *
+ * 
+ */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +@EqualsAndHashCode(callSuper = true) +public class EnsKtGbsDTO extends KtGbsApiDTO.MsgSendRequest { + + @Builder.Default + private String sndngTyCode = "ENS"; + /** + * 템플릿 ID + */ + private String tmplatId; + /** + * 사전알림 데이타 생성 대상 여부 + */ + private String tgtYn; + + /** + * 통합발송 마스터ID + */ + private String unitySndngMastrId; + /** + * 통합발송 상세ID + */ + private String unitySndngDetailId; + + /** + * 발송 마스터 ID + */ + private String sndngMastrId; + + /** + * 발송처리상태 + */ + @Builder.Default + private String sndngProcessSttus = ApiConstants.SndngProcessStatus.ACCEPT.getCode(); +} diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchAcceptService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchAcceptService.java index 14d7c19..eb0118e 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchAcceptService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchAcceptService.java @@ -271,7 +271,7 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA } //FIXME : KT 데이타 적합성 체크 - case KT_BC -> { + case KT_BC, KT_GIBIS -> { isCiCreate = true; } diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchExtractService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchExtractService.java index 919d179..5925553 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchExtractService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchExtractService.java @@ -23,6 +23,7 @@ import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.service.AbstractService; import kr.xit.core.support.utils.Checks; @@ -150,6 +151,16 @@ public class EnsBatchExtractService extends AbstractService implements mapper.updateKtBcMst(dto); } + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void saveKtGbsResult(final SndngMssageParam dto, final List sendReqs) { + // 성공처리 + // mobile page create + // FIXME : KT GIBIS 적용 안됨 + if(Checks.isNotEmpty(sendReqs)) sendReqs.forEach(d -> mapper.insertKtMobilePageManage(d.getSrcKey())); + mapper.updateKtBcMst(dto); + } + /** *
      * 발송 관련 마스터 테이블 fail 처리
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchMakeService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchMakeService.java
index 3c53240..c6225f0 100644
--- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchMakeService.java
+++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchMakeService.java
@@ -218,6 +218,22 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak
                     mapper.insertKtBcMastr(dto);
                     yield mapper.insertKtBcDetail(dto);
                 }
+                // FIXME : KT GIBIS 적용 안됨
+                case KT_GIBIS -> {
+                    // FIXME: KT callback url 확인 적용
+                    // ENS_SND_DTL_KT_GBS
+                    if(SignguCode.CHUNCHEON.getCode().equals(dto.getSignguCode())){
+                        dto.setUrl(CHUNCHEON_CALLBACK_URL);
+                    }
+                    // FIXME: KT callback url 확인 적용
+                    if(SignguCode.FUNERAL.getCode().equals(dto.getSignguCode())){
+                        dto.setUrl(ME_CALLBACK_URL);
+                    }
+                    //mapper.insertKtBcMastr(dto);
+                    //tb_ens_sndng_mastr
+                    //ENS_SND_DTL_KT_GBS
+                    yield mapper.insertKtGbsDetail(dto);
+                }
                 //default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", sndngSeCode.getCode()));
         };
     }
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchSendService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchSendService.java
index b826b77..6dc21a8 100644
--- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchSendService.java
+++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchSendService.java
@@ -32,6 +32,7 @@ import kr.xit.biz.ens.mapper.IEnsBatchMapper;
 import kr.xit.biz.ens.model.EnsDTO;
 import kr.xit.biz.ens.model.EnsDTO.SendKakaoTgt;
 import kr.xit.biz.ens.model.EnsKtBcDTO;
+import kr.xit.biz.ens.model.EnsKtGbsDTO;
 import kr.xit.biz.ens.model.cmm.SndngMssageParam;
 import kr.xit.biz.ens.model.kakao.v1.KkopayDocAttrDTO;
 import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO;
@@ -40,6 +41,7 @@ import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.ErrorMsg;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.KtCommonResponse;
 import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData;
+import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO;
 import kr.xit.core.exception.BizRuntimeException;
 import kr.xit.core.model.ApiResponseDTO;
 import kr.xit.core.service.AbstractService;
@@ -78,9 +80,12 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
     @Value("${app.contract.kakao.api.talk.bulksend}")
     private String apiKkotalkBulkSend;
 
-    @Value("${app.contract.kt.api.bulksend}")
+    @Value("${app.contract.kt.bc.api.bulksend}")
     private String apiKtBcBulkSend;
 
+    @Value("${app.contract.kt.gibis.api.bulksend}")
+    private String apiKtGbsBulkSend;
+
     @Value("${app.contract.kakao.bulk-max-cnt}")
     private int bulkKkoMaxCnt;
 
@@ -153,6 +158,7 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
             case KAKAO -> sendBulkKakaopay(dto);
             case KAKAO_NEW -> sendBulkKakaotalk(dto);
             case KT_BC -> sendBulkKtBc(dto);
+            case KT_GIBIS -> sendBulkKtGibis(dto);
             default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", sndngSeCode.getCode()));
         }
     }
@@ -593,6 +599,93 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen
         extractService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KT_BC, "KT-BC 실패(발송마스터 데이타 오류)");
     }
 
+    /**
+     * 
+     * KT BC 문서 send
+     * @param dto SndngMssageParam
+     * 
+ */ + // FIXME : KT GIBIS 적용 안됨 + private void sendBulkKtGibis(final SndngMssageParam dto) { + final String url = apiHost + apiKtGbsBulkSend; + + EnsKtGbsDTO mstDTO = mapper.selectKtGbsMstTgtInfo(dto) + .orElseThrow(() -> BizRuntimeException.create("KT GBIS 본문자 수신 등록 대상이 존재 하지 않습니다 ")); + + final String mstId = dto.getSndngMastrId(); + final String unitySndMstId = dto.getUnitySndngMastrId(); + final List sendReqs = mapper.selectKtGbsSendTgts(dto); + + // validation check + try { + validatedKtGbsSendBulks(sendReqs); + } catch (Exception e) { + extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_GIBIS, "", e.getMessage(), "[send]KT-GIBIS 발송(bulks)요청 실패(파라메터 오류)"); + throw e; + } + + final List> partitions = ListUtils.partition(sendReqs, bulkKtMaxCnt); + @SuppressWarnings("rawtypes") + List apiResults = partitions.stream() + .map(bulkSendList -> { + mstDTO.setReqs(bulkSendList); + return apiWebClient.exchange( + url, + HttpMethod.POST, + mstDTO, + ApiResponseDTO.class, + CmmEnsBizUtils.getHeadeMap()); + } + ) + .toList(); + + boolean isSuccess = false; + List errList = new ArrayList<>(); + //noinspection rawtypes + for(ApiResponseDTO apiResult : apiResults) { + // KT-BC API 정상 호출 + if(ObjectUtils.isNotEmpty(apiResult.getData())) { + KtCommonResponse resDTO = toObjByObj(apiResult.getData(), KtCommonResponse.class); + assert resDTO != null; + dto.setResultDt(resDTO.getResultDt()); + + if(ObjectUtils.isNotEmpty(resDTO) && "00".equals(resDTO.getResultCd())){ + isSuccess = true; + dto.setErrorMssage("정상"); + }else{ + //TODO:: 모바일 콘텐츠 삭제?? + errList.addAll(resDTO.getErrors()); + } + + }else{ + // KT-BC API 호출전 에러 발생 + if(ObjectUtils.isEmpty(dto.getResultDt())) { + dto.setResultDt(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT)); + } + dto.setErrorMssage(apiResult.getMessage()); + errList.add(new ErrorMsg(apiResult.getMessage())); + } + } + + // 모두 실패한 경우 + if(!isSuccess) { + dto.setResultCd("01"); + dto.setErrorMssage( + errList.stream() + .map(ErrorMsg::getErrorMsg) + .collect(Collectors.joining(",")) + ); + extractService.saveKtBcResult(dto, null); + extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, dto.getErrorCode(), dto.getErrorMssage(), "[send] KT-BC 발송(bulks)요청 실패"); + return; + } + // 성공 건수 존재시 성공 처리 + dto.setResultCd("00"); + dto.setErrorMssage("정상"); + extractService.saveKtGbsResult(dto, sendReqs); + extractService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KT_BC, "KT-BC 실패(발송마스터 데이타 오류)"); + } + private void validatedKtBcSendBulks(List sendReqs) { List errors = new ArrayList<>(); int idx = 0; @@ -615,5 +708,28 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen throw BizRuntimeException.create(errors.toString()); } } + + private void validatedKtGbsSendBulks(List sendReqs) { + List errors = new ArrayList<>(); + int idx = 0; + + for (KtGbsApiDTO.MsgSendReqsData dto : sendReqs) { + Set> errList = validator.validate(dto); + + if (!errList.isEmpty()) { + int finalIdx = idx; + errors.addAll(errList.stream() + .map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1, + row.getMessageTemplate())) + .toList() + ); + } + idx++; + } + + if (!errors.isEmpty()) { + throw BizRuntimeException.create(errors.toString()); + } + } //----------------------------------------------------------------------------------------------------------------- } diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java index 0717945..84de349 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchStatusService.java @@ -107,7 +107,7 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS case KAKAO_NEW -> statusKakaotalk(dto); //break; - case KT_BC -> {} + case KT_BC, KT_GIBIS -> {} default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", sndngSeCode.getCode())); diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchExtractService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchExtractService.java index ed5da9b..6eca080 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchExtractService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchExtractService.java @@ -7,6 +7,7 @@ import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.kakao.v1.KkopayDocBulkDTO; import kr.xit.biz.ens.model.kakao.v2.KkotalkDTO; import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendReqData; +import kr.xit.biz.ens.model.ktgbs.KtGbsApiDTO; /** *
@@ -34,6 +35,7 @@ public interface IEnsBatchExtractService {
     void saveKkotalkSendResult(final String mstId, String unitySndMstId, final List resList);
 
     void saveKtBcResult(final SndngMssageParam dto, final List sendReqs);
+    void saveKtGbsResult(final SndngMssageParam dto, final List sendReqs);
 
 
     void updateSndngMstFailStatus(final String mstId, final SndngSeCode seCode, final String errCode, final String errMsg, final String stsErrMsg);
diff --git a/mens-batch/src/main/resources/config/application-ens.yml b/mens-batch/src/main/resources/config/application-ens.yml
index 5bb9158..abd733b 100644
--- a/mens-batch/src/main/resources/config/application-ens.yml
+++ b/mens-batch/src/main/resources/config/application-ens.yml
@@ -32,12 +32,14 @@ app:
           bulkstatus: /api/ens/kakao/v2/envelopes/bulk/status
     kt:
       bulk-max-cnt: 10
-      api:
-        bulksend: /api/ens/kt/v1/mainSend
-        bulkstatus: /api/ens/kt/v1/messageResult
-    other:
-      api:
-        merge: /api/other/v1/merge
+      bc:
+        api:
+          bulksend: /api/ens/kt/v1/mainSend
+          bulkstatus: /api/ens/kt/v1/messageResult
+      gibis:
+        api:
+          bulksend: /api/ens/ktgbs/v1/mainSend
+          bulkstatus: /api/ens/ktgbs/v1/messageResult
 
   # 배치 설정
   batch:
diff --git a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
index 33cf000..ef5b5ab 100644
--- a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
+++ b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-mysql-mapper.xml
@@ -310,9 +310,9 @@
 			 , now()
 			 , 'batch'
 		FROM tb_ens_unity_sndng_mastr teusm
-	    LEFT JOIN tb_ens_tmplat_manage tetm
+	    JOIN tb_ens_tmplat_manage tetm
 		  ON teusm.tmplat_id = tetm.tmplat_id
-		LEFT JOIN tb_ens_unity_sndng_detail teusd
+		JOIN tb_ens_unity_sndng_detail teusd
 		  ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
 	   WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
 		 AND teusm.sndng_process_sttus = #{sndngProcessSttus}
@@ -361,9 +361,9 @@
 			 , now()
 			 , 'batch'
 		FROM tb_ens_unity_sndng_mastr teusm
-		LEFT JOIN tb_ens_tmplat_manage tetm
+		JOIN tb_ens_tmplat_manage tetm
 		  ON teusm.tmplat_id = tetm.tmplat_id
-		LEFT JOIN tb_ens_unity_sndng_detail teusd
+		JOIN tb_ens_unity_sndng_detail teusd
 		  ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
 	   WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
 		 AND teusm.sndng_process_sttus = #{sndngProcessSttus}
@@ -417,9 +417,9 @@
 				 , now()
 				 , 'batch'
 			FROM tb_ens_unity_sndng_mastr teusm
-			LEFT JOIN tb_ens_tmplat_manage tetm
+			JOIN tb_ens_tmplat_manage tetm
 			  ON teusm.tmplat_id = tetm.tmplat_id
-			LEFT JOIN tb_ens_rlaybsnm_manage term
+			JOIN tb_ens_rlaybsnm_manage term
 			  ON teusm.signgu_code = term.signgu_code AND teusm.ffnlg_code = term.ffnlg_code
 		   WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
 			 AND teusm.sndng_process_sttus = #{sndngProcessSttus}
@@ -466,11 +466,11 @@
 			 , now()
 			 , 'batch'
 		  FROM tb_ens_unity_sndng_mastr teusm
-		  LEFT JOIN tb_ens_tmplat_manage tetm
+		  JOIN tb_ens_tmplat_manage tetm
 			ON teusm.tmplat_id = tetm.tmplat_id
-		  LEFT JOIN tb_ens_unity_sndng_detail teusd
+		  JOIN tb_ens_unity_sndng_detail teusd
 			ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
-		  LEFT JOIN tb_ens_rlaybsnm_manage term
+		  JOIN tb_ens_rlaybsnm_manage term
 			ON teusm.signgu_code = term.signgu_code AND teusm.ffnlg_code = term.ffnlg_code
 		  LEFT JOIN tb_ens_ci tec
 			ON teusd.unity_sndng_detail_id = tec.unity_sndng_detail_id
diff --git a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-oracle-mapper.xml b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-oracle-mapper.xml
index 28f9746..8b6abce 100644
--- a/mens-batch/src/main/resources/egovframework/mapper/biz/ens-oracle-mapper.xml
+++ b/mens-batch/src/main/resources/egovframework/mapper/biz/ens-oracle-mapper.xml
@@ -436,8 +436,7 @@
 
 	
 		/** ens-oracle-mapper|insertKtBcDetail 공인 알림문자 디테일 데이터 생성|julim  */
-		INSERT
-		INTO tb_ens_kt_bc_detail (
+		INSERT INTO tb_ens_kt_bc_detail (
 			sndng_mastr_id,				/* 발송 마스터 id */
 			sndng_detail_id,			/* 발송 상세 id */
 			unity_sndng_detail_id,		/* 통합 발송 상세 id */
@@ -474,16 +473,63 @@
 			 , sysdate
 			 , 'batch'
 		FROM tb_ens_unity_sndng_mastr teusm
-		LEFT JOIN tb_ens_tmplat_manage tetm
+		JOIN tb_ens_tmplat_manage tetm
 		  ON teusm.tmplat_id = tetm.tmplat_id
-		LEFT JOIN tb_ens_unity_sndng_detail teusd
+		JOIN tb_ens_unity_sndng_detail teusd
 		  ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
-		LEFT JOIN tb_ens_rlaybsnm_manage term
+		JOIN tb_ens_rlaybsnm_manage term
 		  ON teusm.signgu_code = term.signgu_code AND teusm.ffnlg_code = term.ffnlg_code
 		LEFT JOIN tb_ens_ci tec
 		  ON teusd.unity_sndng_detail_id = tec.unity_sndng_detail_id
-		WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
-		  AND teusm.sndng_process_sttus = #{sndngProcessSttus}
+	   WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
+		 AND teusm.sndng_process_sttus = #{sndngProcessSttus}
+	
+
+	
+		/** ens-oracle-mapper|insertKtGbsDetail KT GIBIS 디테일 데이터 생성|julim  */
+		INSERT INTO ens_snd_dtl_kt_gbs (
+			send_mast_id,				/* 발송 마스터 id */
+			send_detail_id,			/* 발송 상세 id */
+			-- unity_sndng_detail_id,		/* 통합 발송 상세 id */
+			src_key,					/* 관리키 */
+			src_seq,			        /* 리스트 순번 */
+			ci,							/* ci */
+			mms_dtl_cnts,				/* MMS 상세 내용 */
+			mms_title,					/* MMS 제목 */
+			rcs_dtl_cnts,               /* RCS 메시지 생세내용 */
+			url,						/* 연결 URL */
+			hash,				    /* 문서 해시 */
+			mdn,						/* 개인 휴대 전화 번호 */
+			mk_tmplt_msg_json_data,
+		    doc_stat
+		)
+		SELECT #{sndngMastrId}
+			 , LPAD(sndng_detail_id_seq.nextval, 20, '0')
+			 -- , teusd.unity_sndng_detail_id
+			 , teusd.unity_sndng_detail_id
+			 , row_number() over (order by teusd.unity_sndng_detail_id)
+			 , tec.ci
+			 , tetm.tmplat_cn || CHR(13) || CHR(10) || '- 열람기간 : ' || substr(teusm.clos_dt, 1, 4) || '년 ' || substr(teusm.clos_dt, 5, 2) || '월 ' || substr(teusm.clos_dt, 7, 2) || '일까지'|| CHR(13) || CHR(10) || '- 문의처 : ' || tetm.cstmr_cnter_tlphon_no || CHR(13) || CHR(10) || CHR(13) || CHR(10) ||'{#INFO_CFRM_STR}'|| CHR(13) || CHR(10) ||'{#RCVE_RF_STR}'
+			 , tetm.tmplat_sj
+			 , tetm.tmplat_cn || CHR(13) || CHR(10) || '- 열람기간 : ' || substr(teusm.clos_dt, 1, 4) || '년 ' || substr(teusm.clos_dt, 5, 2) || '월 ' || substr(teusm.clos_dt, 7, 2) || '일까지'|| CHR(13) || CHR(10) || '- 문의처 : ' || tetm.cstmr_cnter_tlphon_no || CHR(13) || CHR(10)
+			 , #{url}
+			 , sha256.encrypt(teusd.unity_sndng_detail_id)
+			 , ''
+		     , tensd.tmplt_msg_data
+		     , ''
+		FROM tb_ens_unity_sndng_mastr teusm
+		JOIN tb_ens_tmplat_manage tetm
+		  ON teusm.tmplat_id = tetm.tmplat_id
+		JOIN tb_ens_unity_sndng_detail teusd
+		  ON teusm.unity_sndng_mastr_id = teusd.unity_sndng_mastr_id
+		JOIN tb_ens_rlaybsnm_manage term
+		  ON teusm.signgu_code = term.signgu_code AND teusm.ffnlg_code = term.ffnlg_code
+		JOIN tb_elctrn_ntic_sndng_detail tensd
+			 ON teusd.unity_sndng_detail_id = tensd.elctrn_ntic_sndng_detail_id
+		LEFT JOIN tb_ens_ci tec
+		  ON teusd.unity_sndng_detail_id = tec.unity_sndng_detail_id
+	   WHERE teusm.unity_sndng_mastr_id = #{unitySndngMastrId}
+		 AND teusm.sndng_process_sttus = #{sndngProcessSttus}
 	
 
 	
@@ -653,9 +699,9 @@
 			 , tekbm.test_sndn_yn
 			 , tekbm.rcv_rfrl_yn
 			 , tekbm.reopen_day                           /* ci */
-		FROM tb_ens_sndng_mastr tesm
-		JOIN tb_ens_kt_bc_mastr tekbm
-		  ON tesm.sndng_mastr_id = tekbm.sndng_mastr_id
+		 FROM tb_ens_sndng_mastr tesm
+		 JOIN tb_ens_kt_bc_mastr tekbm
+		   ON tesm.sndng_mastr_id = tekbm.sndng_mastr_id
 		WHERE tesm.sndng_mastr_id = #{sndngMastrId}
 		  AND tesm.signgu_code = #{signguCode}
 		  AND tesm.ffnlg_code = #{ffnlgCode}
@@ -700,6 +746,79 @@
 		ORDER BY tekbd.sndng_detail_id
 	
 
+	
+
+	
+