refactor: Profile, IS_CCN(춘천시스템여부) 공통 처리

main
Jonguk. Lim 3 months ago
parent 310f89ba19
commit 64e505a29f

@ -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);

@ -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()

@ -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,

@ -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;
/**
* <pre>
@ -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이 실행될 수 있는 경우???

@ -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));
}
}

@ -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 List<SndngMssageParam> list = 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<String> 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]연계 발송 마스터 상태변경 실패");
}

@ -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]연계 발송 마스터 상태변경 실패");

@ -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()));
}

@ -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]데이타 생성(발송마스터 상태변경) 실패");
}

@ -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());

@ -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());

@ -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;
/**
* <pre>
* 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();

@ -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";
/**

Loading…
Cancel
Save