diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngSendBulksTasklet.java b/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngSendBulksTasklet.java index 5779ed3..4c78457 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngSendBulksTasklet.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngSendBulksTasklet.java @@ -1,8 +1,10 @@ package kr.xit.batch.ens.task; +import java.util.List; import java.util.UUID; import kr.xit.batch.ens.task.cmm.TaskCmmUtils; import kr.xit.biz.ens.model.EnsDTO; +import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.service.IEnsBatchSendService; import kr.xit.core.spring.util.error.ErrorParse; import lombok.RequiredArgsConstructor; @@ -38,39 +40,73 @@ public class SndngSendBulksTasklet implements Tasklet { @JobScope public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) { final String isSlackEnabled = contribution.getStepExecution().getJobParameters().getString("isSlackEnabled"); + boolean isSuccess = false; try { MDC.put("request_trace_batch_id", UUID.randomUUID().toString().replace("-", "")); //MDC.put("uri", "/v1/documents/bulk"); MDC.put("method", "POST"); - service.sendBulks( + List tgtList = service.findBulks( EnsDTO.BatchEnsRequest.builder() - .signguCode(contribution.getStepExecution().getJobParameters().getString("signguCode")) - .ffnlgCode(contribution.getStepExecution().getJobParameters().getString("ffnlgCode")) - .sndngProcessSttus(contribution.getStepExecution().getJobParameters().getString("sndngProcessSttus")) + .signguCode( + contribution.getStepExecution().getJobParameters().getString("signguCode")) + .ffnlgCode( + contribution.getStepExecution().getJobParameters().getString("ffnlgCode")) + .sndngProcessSttus(contribution.getStepExecution().getJobParameters() + .getString("sndngProcessSttus")) .build() ); - }catch(Exception e){ - String errMsg = ErrorParse.extractError(e).getMessage(); - log.error("SndngSendBulksTasklet error :: {}", e.getMessage()); - MDC.put("service_error_msg", errMsg); - TaskCmmUtils.taskBatchErrorLog( - contribution.getStepExecution().getJobExecution().getJobInstance().getJobName(), - errMsg, - isSlackEnabled - ); + for(SndngMssageParam dto : tgtList) { + try { + dto.setSndngProcessSttus(contribution.getStepExecution().getJobParameters() + .getString("sndngProcessSttus")); + service.sendBulks(dto); + isSuccess = true; + } catch (Exception e) { + String errMsg = ErrorParse.extractError(e).getMessage(); + log.error("SndngSendBulksTasklet error :: {}", e.getMessage()); + MDC.put("service_error_msg", errMsg); - TaskCmmUtils.taskEnsBatchServiceUpdateErrorLog( - contribution.getStepExecution().getJobExecution().getJobInstance().getJobName(), - errMsg, - isSlackEnabled - ); - contribution.setExitStatus(ExitStatus.FAILED); + TaskCmmUtils.taskBatchErrorLog( + contribution.getStepExecution().getJobExecution().getJobInstance() + .getJobName(), + errMsg, + isSlackEnabled + ); + + TaskCmmUtils.taskEnsBatchServiceUpdateErrorLog( + contribution.getStepExecution().getJobExecution().getJobInstance() + .getJobName(), + errMsg, + isSlackEnabled + ); + } + } +// } catch (Exception e) { +// String errMsg = ErrorParse.extractError(e).getMessage(); +// log.error("SndngSendBulksTasklet error :: {}", e.getMessage()); +// MDC.put("service_error_msg", errMsg); +// +// TaskCmmUtils.taskBatchErrorLog( +// contribution.getStepExecution().getJobExecution().getJobInstance() +// .getJobName(), +// errMsg, +// isSlackEnabled +// ); +// +// TaskCmmUtils.taskEnsBatchServiceUpdateErrorLog( +// contribution.getStepExecution().getJobExecution().getJobInstance() +// .getJobName(), +// errMsg, +// isSlackEnabled +// ); + + } finally { + if(!isSuccess) contribution.setExitStatus(ExitStatus.FAILED); + else contribution.setExitStatus(ExitStatus.COMPLETED); return RepeatStatus.FINISHED; } - contribution.setExitStatus(ExitStatus.COMPLETED); - return RepeatStatus.FINISHED; } } 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 0ea580f..c2a71d2 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 @@ -90,6 +90,49 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns private final ApiWebClientUtil apiWebClient; private final IEnsBatchMapper mapper; + @Override + @Transactional(readOnly = true) + public List findBulks(final EnsDTO.BatchEnsRequest reqDTO) { + + // 발송/통합발송 마스터에서 대상 조회 + reqDTO.setBatchPeriod(batchSendPeriod); + return mapper.selectSendBulkTgts(reqDTO); +// for (SndngMssageParam dto : tgtList) { +// dto.setSignguCode(reqDTO.getSignguCode()); +// dto.setFfnlgCode(reqDTO.getFfnlgCode()); +// dto.setProfile(ApiConstants.PROFILE); +// +// MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId()); +// MDC.put("sndngMastrId", dto.getSndngMastrId()); +// MDC.put(SNDNG_PROCESS_STTUS, "send-fail" + dto.getTrySeq()); +// +// final String[] tryVal = { +// Checks.checkVal(dto.getTry1(), ""), +// Checks.checkVal(dto.getTry2(), ""), +// Checks.checkVal(dto.getTry3(), "") +// }; +// +// // 마스터 상태 변경값을 파라메터에서 받은 상태값으로 set +// dto.setNewSndngProcessSttus(reqDTO.getSndngProcessSttus()); +// final String seCode = tryVal[dto.getTrySeq() - 1]; +// +// // 업무 문서 구분에 따른 분기 +// switch (SndngSeCode.compare(seCode)) { +// /* +// * 카카오페이 연계 결과 반영 : tb_ens_kakao_my_doc +// * 모바일 페이지 생성 : tb_ens_mobile_page_manage +// * 연계발송결과 생성 : tb_cntc_sndng_result +// */ +// case KAKAO -> sendBulkKakaoMyDocs(dto); +// case KT_BC -> sendBulkKtBc(dto); +// case PPLUS -> sendBulkPplus(dto); +// case E_GREEN -> extractService.sendEgreen(dto); +// case SMS -> extractService.sendSms(dto); +// default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", seCode)); +// } +// } + } + /** *
      * 전자고지(문서) send bulks - 문서 중개자별 send
@@ -110,14 +153,14 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
      */
     @Override
     @Transactional(propagation = Propagation.REQUIRES_NEW)
-    public void sendBulks(final EnsDTO.BatchEnsRequest reqDTO) {
+    public void sendBulks(final SndngMssageParam dto) {
 
         // 발송/통합발송 마스터에서 대상 조회
-        reqDTO.setBatchPeriod(batchSendPeriod);
-        final List tgtList = mapper.selectSendBulkTgts(reqDTO);
-        for (SndngMssageParam dto : tgtList) {
-            dto.setSignguCode(reqDTO.getSignguCode());
-            dto.setFfnlgCode(reqDTO.getFfnlgCode());
+        //reqDTO.setBatchPeriod(batchSendPeriod);
+        //final List tgtList = mapper.selectSendBulkTgts(reqDTO);
+        //for (SndngMssageParam dto : tgtList) {
+//            dto.setSignguCode(reqDTO.getSignguCode());
+//            dto.setFfnlgCode(reqDTO.getFfnlgCode());
             dto.setProfile(ApiConstants.PROFILE);
 
             MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId());
@@ -131,7 +174,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
             };
 
             // 마스터 상태 변경값을 파라메터에서 받은 상태값으로 set
-            dto.setNewSndngProcessSttus(reqDTO.getSndngProcessSttus());
+            dto.setNewSndngProcessSttus(dto.getSndngProcessSttus());
             final String seCode = tryVal[dto.getTrySeq() - 1];
 
             // 업무 문서 구분에 따른 분기
@@ -148,7 +191,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
                 case SMS -> extractService.sendSms(dto);
                 default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", seCode));
             }
-        }
+        //}
     }
 
     //-----------------------------------------------------------------------------------------------------------------
@@ -186,6 +229,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
 
        // validation check
         try {
+            if(true)throw BizRuntimeException.create("$$$$$$$$$$$#########");
             validatedKkoMyDocSendBulks(bulkList);
         } catch (Exception e) {
             extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "", e.getMessage(), "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)");
@@ -193,6 +237,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
         }
 
         final List> partitions = ListUtils.partition(bulkList, bulkKkoMaxCnt);
+        //noinspection rawtypes
         final List apiResults = partitions.stream()
             .map(bulkSendList -> apiWebClient.exchange(
                 url,
@@ -210,6 +255,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
         final List resList = new ArrayList<>();
         boolean isSuccess = false;
         String errMsg = null;
+        //noinspection rawtypes
         for(ApiResponseDTO apiResult : apiResults) {
             if(apiResult.getData() != null) {
                 resList.add(toObjByObj(apiResult.getData(), BulkSendResponses.class));
diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchSendService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchSendService.java
index f645305..e4030bc 100644
--- a/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchSendService.java
+++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/IEnsBatchSendService.java
@@ -1,6 +1,8 @@
 package kr.xit.biz.ens.service;
 
+import java.util.List;
 import kr.xit.biz.ens.model.EnsDTO;
+import kr.xit.biz.ens.model.cmm.SndngMssageParam;
 
 /**
  * 
@@ -18,5 +20,6 @@ import kr.xit.biz.ens.model.EnsDTO;
  * 
*/ public interface IEnsBatchSendService { - void sendBulks(final EnsDTO.BatchEnsRequest reqDTO); + List findBulks(final EnsDTO.BatchEnsRequest reqDTO); + void sendBulks(final SndngMssageParam dto); } diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/web/EnsBatchController.java b/mens-batch/src/main/java/kr/xit/biz/ens/web/EnsBatchController.java index fec9374..a0a6e0b 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/web/EnsBatchController.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/web/EnsBatchController.java @@ -5,6 +5,7 @@ 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.EnsDTO; +import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.service.IEnsBatchAcceptService; import kr.xit.biz.ens.service.IEnsBatchCloseService; import kr.xit.biz.ens.service.IEnsBatchMakeService; @@ -117,7 +118,10 @@ public class EnsBatchController { }) @PostMapping(value = "/sendBulks", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse sendBulks(@RequestBody final EnsDTO.BatchEnsRequest reqDTO){ - sendService.sendBulks(reqDTO); + for(SndngMssageParam bulk : sendService.findBulks(reqDTO)) { + bulk.setSndngProcessSttus(reqDTO.getSndngProcessSttus()); + sendService.sendBulks(bulk); + } return ApiResponseDTO.success(); } 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 980882e..38a65b6 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 @@ -581,6 +581,8 @@ , tesm.sndng_co , tesm.try_seq , tesm.sndng_process_sttus + , tesm.signgu_code + , tesm.ffnlg_code , teusm.try1 , teusm.try2 , teusm.try3