diff --git a/mens-api/src/main/java/kr/xit/ens/cmm/CmmEnsUtils.java b/mens-api/src/main/java/kr/xit/ens/cmm/CmmEnsUtils.java index 83e639e..dc9839e 100644 --- a/mens-api/src/main/java/kr/xit/ens/cmm/CmmEnsUtils.java +++ b/mens-api/src/main/java/kr/xit/ens/cmm/CmmEnsUtils.java @@ -82,7 +82,7 @@ public class CmmEnsUtils { CmmEnsRequestDTO ensDTO = CmmEnsRequestDTO.builder() .signguCode(signguCode) .ffnlgCode(ffnlgCode) - .profile(ApiConstants.PROFILE) + .profile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod") .build(); final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ensDTO); @@ -101,7 +101,7 @@ public class CmmEnsUtils { KtMnsRequest.builder() .signguCode(signguCode) .ffnlgCode(ffnlgCode) - .profile(ApiConstants.PROFILE) + .profile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod") .build() ); return cacheService.getRlaybsnmInfoCache(ensDTO); diff --git a/mens-api/src/main/java/kr/xit/ens/kt/service/KtBcService.java b/mens-api/src/main/java/kr/xit/ens/kt/service/KtBcService.java index 412004a..09070d3 100644 --- a/mens-api/src/main/java/kr/xit/ens/kt/service/KtBcService.java +++ b/mens-api/src/main/java/kr/xit/ens/kt/service/KtBcService.java @@ -3,6 +3,7 @@ package kr.xit.ens.kt.service; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -171,10 +172,12 @@ public class KtBcService extends AbstractService implements IKtBcService { @Override @TraceLogging public KtTokenResponse requestToken(final KtMnsRequest paramDTO) { + String profile = StringUtils.isEmpty(paramDTO.getProfile()) ? (ApiConstants.IS_PROFILE_LOCAL? "local" : "prod") : paramDTO.getProfile(); + paramDTO.setProfile(profile); final CmmEnsRlaybsnmDTO ktMnsInfo = cacheService.getRlaybsnmInfoCache(CmmEnsRequestDTO.builder() .signguCode(paramDTO.getSignguCode()) .ffnlgCode(paramDTO.getFfnlgCode()) - .profile(ApiConstants.PROFILE) + .profile(paramDTO.getProfile()) .build()); final KtTokenRequest reqDTO = KtTokenRequest.builder() 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 index 34c9b4b..7d52bcd 100644 --- 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 @@ -3,6 +3,7 @@ package kr.xit.ens.ktgbs.service; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -70,10 +71,12 @@ public class KtGbsService extends AbstractService implements IKtGbsService { @Override @TraceLogging public KtGbsDTO.TokenResponse requestToken(final KtCommonDTO.KtMnsRequest paramDTO) { + String profile = StringUtils.isEmpty(paramDTO.getProfile()) ? (ApiConstants.IS_PROFILE_LOCAL? "local" : "prod") : paramDTO.getProfile(); + paramDTO.setProfile(profile); final CmmEnsRlaybsnmDTO ktMnsInfo = cacheService.getRlaybsnmInfoCache(CmmEnsRequestDTO.builder() .signguCode(paramDTO.getSignguCode()) .ffnlgCode(paramDTO.getFfnlgCode()) - .profile(ApiConstants.PROFILE) + .profile(paramDTO.getProfile()) .build()); final KtGbsDTO.TokenRequest reqDTO = KtGbsDTO.TokenRequest.builder() @@ -86,7 +89,6 @@ public class KtGbsService extends AbstractService implements IKtGbsService { headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); headerMap.put(HttpHeaders.AUTHORIZATION, String.format("Bearer %s", ktMnsInfo.getKtAccessToken())); - return webClient.exchangeFormData( HOST + API_ACCESS_TOKEN, HttpMethod.POST, diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngMakeTasklet.java b/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngMakeTasklet.java index 6af310f..d1a07aa 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngMakeTasklet.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/task/SndngMakeTasklet.java @@ -2,6 +2,15 @@ package kr.xit.batch.ens.task; import java.util.List; import java.util.Map; + +import org.slf4j.MDC; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.StepContribution; +import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.core.scope.context.ChunkContext; +import org.springframework.batch.core.step.tasklet.Tasklet; +import org.springframework.batch.repeat.RepeatStatus; + import kr.xit.batch.ens.task.cmm.TaskCmmUtils; import kr.xit.biz.common.ApiConstants; import kr.xit.biz.ens.model.EnsDTO; @@ -10,13 +19,6 @@ import kr.xit.biz.ens.service.IEnsBatchMakeService; import kr.xit.core.exception.ErrorParse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.slf4j.MDC; -import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.StepContribution; -import org.springframework.batch.core.configuration.annotation.JobScope; -import org.springframework.batch.core.scope.context.ChunkContext; -import org.springframework.batch.core.step.tasklet.Tasklet; -import org.springframework.batch.repeat.RepeatStatus; /** *
@@ -63,12 +65,12 @@ public class SndngMakeTasklet implements Tasklet { for(SndngMssageParam dto : tgtList) { try{ - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); if("tty1".equals(key)) { MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId()); MDC.put(SNDNG_PROCESS_STTUS, "make-fail1"); - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); dto.setSndngProcessSttus(contribution.getStepExecution().getJobParameters().getString("sndngProcessSttus")); dto.setNewSndngProcessSttus(ApiConstants.SndngProcessStatus.MAKE_OK.getCode()); //FIXME: try1,try2,tr3이 있는 경우 try1 이전에 try2,3이 실행될 수 있는 경우??? diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/cmm/CmmEnsBizUtils.java b/mens-batch/src/main/java/kr/xit/biz/ens/cmm/CmmEnsBizUtils.java index 3165044..53865fe 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/cmm/CmmEnsBizUtils.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/cmm/CmmEnsBizUtils.java @@ -62,8 +62,8 @@ public class CmmEnsBizUtils { * @param dto SndngMssageParam * @param processStatus 발송처리상태 */ - public static void setMappingProcessStatus(boolean isChuncheon, final SndngMssageParam dto, final String processStatus) { - if(isChuncheon) dto.setNewSndngProcessSttus(ApiConstants.MappingCcnSndngProcessStatus.fromEns(processStatus)); - else dto.setNewSndngProcessSttus(ApiConstants.MappingCanSndngProcessStatus.fromEns(processStatus)); + public static void setMappingProcessStatus(final SndngMssageParam dto, final String processStatus) { + if(ApiConstants.IS_CCN) dto.setNewSndngProcessSttus(ApiConstants.MappingCcnSndngProcessStatus.fromEns(processStatus)); + else dto.setNewSndngProcessSttus(ApiConstants.MappingCanSndngProcessStatus.fromEns(processStatus)); } } 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 145d61c..fb5639c 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 @@ -84,8 +84,6 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA /** * 춘천 시스템 여부 */ - private static final boolean IS_CCN = ApiConstants.PROFILE.matches(".*-ccn"); - private final ApiWebClientUtil apiWebClient; /** @@ -124,8 +122,8 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void accept(final EnsDTO.BatchEnsRequest reqDTO) { - if(IS_CCN) reqDTO.setSndngProcessSttus(MappingCcnSndngProcessStatus.fromEns(SndngProcessStatus.ACCEPT.getCode())); - else reqDTO.setSndngProcessSttus(MappingCanSndngProcessStatus.fromEns(SndngProcessStatus.ACCEPT.getCode())); + if(ApiConstants.IS_CCN) reqDTO.setSndngProcessSttus(MappingCcnSndngProcessStatus.fromEns(SndngProcessStatus.ACCEPT.getCode())); + else reqDTO.setSndngProcessSttus(MappingCanSndngProcessStatus.fromEns(SndngProcessStatus.ACCEPT.getCode())); final Listlist = mapper.selectAcceptTgts(reqDTO); String sndngDt = null; @@ -133,7 +131,7 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA //try { dto.setSignguCode(reqDTO.getSignguCode()); dto.setFfnlgCode(reqDTO.getFfnlgCode()); - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); final List mstIdList = new ArrayList<>(); String mstId = ""; if (!Objects.equals(mstId, dto.getUnitySndngMastrId())) { @@ -183,7 +181,7 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA insCnt)); } - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, SndngProcessStatus.ACCEPT_OK.getCode()); + CmmEnsBizUtils.setMappingProcessStatus(dto, SndngProcessStatus.ACCEPT_OK.getCode()); if (mapper.updateProcessSttusCntcSndngMst(dto) != 1) { throw BizRuntimeException.create("접수 데이타 생성(통합발송마스터 상태변경) 실패"); } @@ -323,7 +321,7 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA } // 춘천인 경우 DICI를 통한 CI 획득 - if(IS_CCN) { + if(ApiConstants.IS_CCN) { boolean isScc = requestNiceDici(dto, ihidnumManageId); if(isScc) isSuccess = true; }else{ @@ -482,7 +480,7 @@ public class EnsBatchAcceptService extends AbstractService implements IEnsBatchA .errorMssage(stsErrMsg) .build(); - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, SndngProcessStatus.ACCEPT_FAIL.getCode()); + CmmEnsBizUtils.setMappingProcessStatus(dto, SndngProcessStatus.ACCEPT_FAIL.getCode()); if (mapper.updateProcessSttusCntcSndngMst(dto) != 1) { throw BizRuntimeException.create("[accept]연계 발송 마스터 상태변경 실패"); } diff --git a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchCloseService.java b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchCloseService.java index 17ad44c..ac8f032 100644 --- a/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchCloseService.java +++ b/mens-batch/src/main/java/kr/xit/biz/ens/service/EnsBatchCloseService.java @@ -36,11 +36,6 @@ import lombok.RequiredArgsConstructor; public class EnsBatchCloseService extends AbstractService implements IEnsBatchCloseService { private final IEnsBatchMapper mapper; - /** - * 춘천 시스템 여부 - */ - private static final boolean IS_CCN = ApiConstants.PROFILE.matches(".*-ccn"); - /** * send-ok 값에 따라 close * @@ -58,7 +53,7 @@ public class EnsBatchCloseService extends AbstractService implements IEnsBatchCl .sndngProcessSttus(reqDTO.getSndngProcessSttus()) .build(); - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, paramDTO, ApiConstants.SndngProcessStatus.CLOSE.getCode()); + CmmEnsBizUtils.setMappingProcessStatus(paramDTO, ApiConstants.SndngProcessStatus.CLOSE.getCode()); if (mapper.updateProcessSttusCntcSndngMst(paramDTO) != 1) { throw BizRuntimeException.create("[close]연계 발송 마스터 상태변경 실패"); 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 cd4d212..0de8d30 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 @@ -56,11 +56,6 @@ public class EnsBatchExtractService extends AbstractService implements private final IEnsBatchMapper mapper; - /** - * 춘천 시스템 여부 - */ - private static final boolean IS_CCN = ApiConstants.PROFILE.matches(".*-ccn"); - //----------------------------------------------------------------------------------------------------------------- // REQUIRES_NEW service method //----------------------------------------------------------------------------------------------------------------- @@ -234,17 +229,17 @@ public class EnsBatchExtractService extends AbstractService implements final String status = dto.getNewSndngProcessSttus(); if ("SndngAcceptJob".equals(dto.getErrorCode())) { - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, status); + CmmEnsBizUtils.setMappingProcessStatus(dto, status); mapper.updateProcessSttusCntcSndngMst(dto); } else if ("SndngMakeJob".equals(dto.getErrorCode())) { - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, status); + CmmEnsBizUtils.setMappingProcessStatus(dto, status); mapper.updateProcessSttusCntcSndngMst(dto); dto.setNewSndngProcessSttus(status); mapper.updateProcessSttusUnitySndngMst(dto); } else if ("SndngSendBulksJob".equals(dto.getErrorCode())) { - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, status); + CmmEnsBizUtils.setMappingProcessStatus(dto, status); mapper.updateProcessSttusCntcSndngMst(dto); dto.setNewSndngProcessSttus(status); mapper.updateProcessSttusUnitySndngMst(dto); @@ -278,7 +273,7 @@ public class EnsBatchExtractService extends AbstractService implements private void updateMstTable(SndngMssageParam paramDTO, SndngSeCode seCode) { final String status = paramDTO.getNewSndngProcessSttus(); - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, paramDTO, status); + CmmEnsBizUtils.setMappingProcessStatus(paramDTO, status); if(mapper.updateProcessSttusCntcSndngMst(paramDTO) != 1) { throw BizRuntimeException.create(String.format("[send-%s]연계 발송 마스터 상태변경 실패", seCode.getCode())); } 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 0bc33f0..4a2bd9b 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 @@ -50,11 +50,6 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak private static final String SNDNG_PROCESS_STTUS = "sndngProcessSttus"; private static final String UNITY_SNDNG_MST_ID = "unitySndngMastrId"; - /** - * 춘천 시스템 여부 - */ - private static final boolean IS_CCN = ApiConstants.PROFILE.matches(".*-ccn"); - private final IEnsBatchMapper mapper; /** @@ -101,7 +96,7 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak public boolean makeIsNext(final SndngMssageParam dto) { MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId()); MDC.put(SNDNG_PROCESS_STTUS, "make-fail2"); - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); final SndngSeCode sndngSeCode = CmmEnsBizUtils.getSndngSeCodFromTrySeq(dto); @@ -114,7 +109,7 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak } //없으면 연계 발송 마스터, 통합 발송 마스터 send-ok if (sendCnt == 0) { - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, dto.getNewSndngProcessSttus()); + CmmEnsBizUtils.setMappingProcessStatus(dto, dto.getNewSndngProcessSttus()); if (mapper.updateProcessSttusCntcSndngMst(dto) != 1) { throw BizRuntimeException.create("[make]연계 발송 마스터 상태변경 실패"); } @@ -168,7 +163,7 @@ public class EnsBatchMakeService extends AbstractService implements IEnsBatchMak } // 3. status - CmmEnsBizUtils.setMappingProcessStatus(IS_CCN, dto, dto.getNewSndngProcessSttus()); + CmmEnsBizUtils.setMappingProcessStatus(dto, dto.getNewSndngProcessSttus()); if (mapper.updateProcessSttusCntcSndngMst(dto) != 1) { throw BizRuntimeException.create("[make]데이타 생성(발송마스터 상태변경) 실패"); } 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 427ec39..2e839f5 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 @@ -137,7 +137,7 @@ public class EnsBatchSendService extends AbstractService implements IEnsBatchSen @Transactional(propagation = Propagation.REQUIRES_NEW) // FIXME: kakao v1 or v2 public void sendBulks(final SndngMssageParam dto) { - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId()); MDC.put("sndngMastrId", dto.getSndngMastrId()); 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 a66e04c..dabd493 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 @@ -84,7 +84,7 @@ public class EnsBatchStatusService extends AbstractService implements IEnsBatchS for (SndngMssageParam dto : tgtList) { dto.setSignguCode(reqDTO.getSignguCode()); dto.setFfnlgCode(reqDTO.getFfnlgCode()); - dto.setProfile(ApiConstants.PROFILE); + dto.setProfile(ApiConstants.IS_PROFILE_LOCAL? "local" : "prod"); MDC.put(UNITY_SNDNG_MST_ID, dto.getUnitySndngMastrId()); MDC.put("sndngMastrId", dto.getSndngMastrId()); diff --git a/mens-batch/src/main/java/kr/xit/core/biz/batch/service/BatchCmmService.java b/mens-batch/src/main/java/kr/xit/core/biz/batch/service/BatchCmmService.java index ed3d95a..1f35ec3 100644 --- a/mens-batch/src/main/java/kr/xit/core/biz/batch/service/BatchCmmService.java +++ b/mens-batch/src/main/java/kr/xit/core/biz/batch/service/BatchCmmService.java @@ -2,16 +2,17 @@ package kr.xit.core.biz.batch.service; import java.util.List; import java.util.Optional; -import kr.xit.biz.common.ApiConstants; -import kr.xit.core.biz.batch.mapper.IBatchCmmMapper; -import kr.xit.core.biz.batch.model.BatchCmmDTO.BatchCmmRequest; -import kr.xit.core.biz.batch.model.BatchCmmDTO.BatchLock; -import kr.xit.core.exception.BizRuntimeException; + import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import kr.xit.core.biz.batch.mapper.IBatchCmmMapper; +import kr.xit.core.biz.batch.model.BatchCmmDTO.BatchCmmRequest; +import kr.xit.core.biz.batch.model.BatchCmmDTO.BatchLock; +import kr.xit.core.exception.BizRuntimeException; + /** * * description : @@ -78,7 +79,7 @@ public class BatchCmmService extends EgovAbstractServiceImpl implements IBatchCm @Transactional(readOnly = true) public String execBatch(final BatchCmmRequest reqDTO){ BatchLock rtnDTO = mapper.selectBatchLock(reqDTO.getInstanceId()).orElseThrow(() -> BizRuntimeException.create("배치 인스턴스를 찾을 수 없습니다.")); - reqDTO.setProfile(ApiConstants.PROFILE); + reqDTO.setProfile(reqDTO.getProfile()); String uri = rtnDTO.getInstanceUrl(); diff --git a/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java b/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java index d50278d..1b4495e 100644 --- a/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java +++ b/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java @@ -22,7 +22,19 @@ import lombok.Getter; */ public class ApiConstants { + /** + * profile + */ public static final String PROFILE = System.getProperty("spring.profiles.active"); + /** + * profile : local 여부 + */ + public static final boolean IS_PROFILE_LOCAL = PROFILE.matches("local-.*"); + + /** + * profile : 춘천 시스템 여부 + */ + public static final boolean IS_CCN = PROFILE.matches(".*-ccn"); public static final String FFNLN_CODE = "11"; /**