|
|
|
|
@ -17,7 +17,8 @@ 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.EnsDTO.SndngMssageParam;
|
|
|
|
|
import kr.xit.biz.ens.model.EnsKtBcDTO.KtBcMst;
|
|
|
|
|
import kr.xit.biz.ens.model.EnsKtBcDTO;
|
|
|
|
|
import kr.xit.biz.ens.model.EnsPostPlusDTO;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendReq;
|
|
|
|
|
import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendRequests;
|
|
|
|
|
@ -68,6 +69,8 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
private String apiKkoBulkSend;
|
|
|
|
|
@Value("${contract.kt.api.bulksend}")
|
|
|
|
|
private String apiKtBcBulkSend;
|
|
|
|
|
@Value("${contract.pplus.api.bulksend}")
|
|
|
|
|
private String apiPplusBulkSend;
|
|
|
|
|
|
|
|
|
|
@Value("${contract.kakao.bulk-max-cnt}")
|
|
|
|
|
private int bulkKkoMaxCnt;
|
|
|
|
|
@ -78,7 +81,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
private static final String SNDNG_PROCESS_STTUS = "sndngProcessSttus";
|
|
|
|
|
private static final String UNITY_SNDNG_MST_ID = "unitySndngMastrId";
|
|
|
|
|
private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
|
|
|
|
private final EnsBatchExtractService requireNewService;
|
|
|
|
|
private final EnsBatchExtractService extractService;
|
|
|
|
|
private final ApiWebClientUtil apiWebClient;
|
|
|
|
|
private final IEnsBatchMapper mapper;
|
|
|
|
|
|
|
|
|
|
@ -134,8 +137,8 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
case KAKAO -> sendBulkKakaoMyDocs(dto);
|
|
|
|
|
case KT_BC -> sendBulkKtBc(dto);
|
|
|
|
|
case PPLUS -> sendBulkPplus(dto);
|
|
|
|
|
case E_GREEN -> requireNewService.sendEgreen(dto);
|
|
|
|
|
case SMS -> requireNewService.sendSms(dto);
|
|
|
|
|
case E_GREEN -> extractService.sendEgreen(dto);
|
|
|
|
|
case SMS -> extractService.sendSms(dto);
|
|
|
|
|
default -> throw BizRuntimeException.create(String.format("정의 되지 않은 문서 중개자[%s] 입니다", seCode));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -162,13 +165,13 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
* - 카카오페이 연계 결과 반영 : tb_ens_kakao_my_doc
|
|
|
|
|
* - 모바일 페이지 생성 : tb_ens_mobile_page_manage
|
|
|
|
|
* - 연계발송결과 생성 : tb_cntc_sndng_result
|
|
|
|
|
* @param reqDTO SndngMssageParam
|
|
|
|
|
* @param dto SndngMssageParam
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private void sendBulkKakaoMyDocs(final SndngMssageParam reqDTO) {
|
|
|
|
|
private void sendBulkKakaoMyDocs(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiKkoBulkSend;
|
|
|
|
|
|
|
|
|
|
final List<SendKakaoTgt> list = mapper.selectKakaoSendTgts(reqDTO);
|
|
|
|
|
final List<SendKakaoTgt> list = mapper.selectKakaoSendTgts(dto);
|
|
|
|
|
if(list.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
final String mstId = list.get(0).getSndngMastrId();
|
|
|
|
|
@ -178,7 +181,7 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
try {
|
|
|
|
|
validatedKkoMyDocSendBulks(bulkList);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
requireNewService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -188,8 +191,8 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
BulkSendRequests.builder()
|
|
|
|
|
.signguCode(reqDTO.getSignguCode())
|
|
|
|
|
.ffnlgCode(reqDTO.getFfnlgCode())
|
|
|
|
|
.signguCode(dto.getSignguCode())
|
|
|
|
|
.ffnlgCode(dto.getFfnlgCode())
|
|
|
|
|
.documents(bulkSendList)
|
|
|
|
|
.build(),
|
|
|
|
|
ApiResponseDTO.class,
|
|
|
|
|
@ -209,8 +212,8 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
errMsg = apiResult.getMessage();
|
|
|
|
|
}
|
|
|
|
|
// 카카오 send 결과 반영
|
|
|
|
|
if(!isSuccess) requireNewService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, errMsg);
|
|
|
|
|
requireNewService.saveKkoMyDocResult(mstId, reqDTO.getUnitySndngMastrId(), resList);
|
|
|
|
|
if(!isSuccess) extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, errMsg);
|
|
|
|
|
extractService.saveKkoMyDocResult(mstId, dto.getUnitySndngMastrId(), resList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -323,25 +326,24 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* KT BC 문서 send
|
|
|
|
|
* @param reqDTO SndngMssageParam
|
|
|
|
|
* @param dto SndngMssageParam
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
// TODO :: 구현 필요
|
|
|
|
|
private void sendBulkKtBc(final SndngMssageParam reqDTO) {
|
|
|
|
|
private void sendBulkKtBc(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiKtBcBulkSend;
|
|
|
|
|
|
|
|
|
|
KtBcMst mstDTO = mapper.selectKtBcMstTgtInfo(reqDTO)
|
|
|
|
|
EnsKtBcDTO mstDTO = mapper.selectKtBcMstTgtInfo(dto)
|
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("KT BC 본문자 수신 등록 대상이 존재 하지 않습니다 "));
|
|
|
|
|
|
|
|
|
|
final String mstId = mstDTO.getSndngMastrId();
|
|
|
|
|
final String unitySndMstId = mstDTO.getUnitySndngMastrId();
|
|
|
|
|
final List<KtMainSendReqData> sendReqs = mapper.selectKtBcSendTgts(reqDTO);
|
|
|
|
|
final List<KtMainSendReqData> sendReqs = mapper.selectKtBcSendTgts(dto);
|
|
|
|
|
|
|
|
|
|
// validation check
|
|
|
|
|
try {
|
|
|
|
|
validatedKtBcSendBulks(sendReqs);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
requireNewService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send]KT-BC 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send]KT-BC 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -366,43 +368,43 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
if(ObjectUtils.isNotEmpty(apiResult.getData())) {
|
|
|
|
|
KtCommonResponse resDTO = toObjByObj(apiResult.getData(), KtCommonResponse.class);
|
|
|
|
|
assert resDTO != null;
|
|
|
|
|
reqDTO.setResultDt(resDTO.getResultDt());
|
|
|
|
|
dto.setResultDt(resDTO.getResultDt());
|
|
|
|
|
|
|
|
|
|
if(ObjectUtils.isNotEmpty(resDTO) && "00".equals(resDTO.getResultCd())){
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
reqDTO.setErrorMssage("정상");
|
|
|
|
|
dto.setErrorMssage("정상");
|
|
|
|
|
}else{
|
|
|
|
|
errList.addAll(resDTO.getErrors());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
// KT-BC API 호출전 에러 발생
|
|
|
|
|
if(ObjectUtils.isEmpty(reqDTO.getResultDt())) {
|
|
|
|
|
reqDTO.setResultDt(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT));
|
|
|
|
|
if(ObjectUtils.isEmpty(dto.getResultDt())) {
|
|
|
|
|
dto.setResultDt(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT));
|
|
|
|
|
}
|
|
|
|
|
reqDTO.setErrorMssage(apiResult.getMessage());
|
|
|
|
|
dto.setErrorMssage(apiResult.getMessage());
|
|
|
|
|
errList.add(new ErrorMsg(apiResult.getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 모두 실패한 경우
|
|
|
|
|
if(!isSuccess) {
|
|
|
|
|
reqDTO.setResultCd("01");
|
|
|
|
|
reqDTO.setErrorMssage(
|
|
|
|
|
dto.setResultCd("01");
|
|
|
|
|
dto.setErrorMssage(
|
|
|
|
|
errList.stream()
|
|
|
|
|
.map(ErrorMsg::getErrorMsg)
|
|
|
|
|
.collect(Collectors.joining(","))
|
|
|
|
|
);
|
|
|
|
|
mapper.updateKtBcMst(reqDTO);
|
|
|
|
|
requireNewService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send] KT-BC 발송(bulks)요청 실패");
|
|
|
|
|
mapper.updateKtBcMst(dto);
|
|
|
|
|
extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send] KT-BC 발송(bulks)요청 실패");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 성공 건수 존재시 성공 처리
|
|
|
|
|
reqDTO.setResultCd("00");
|
|
|
|
|
reqDTO.setErrorMssage("정상");
|
|
|
|
|
mapper.updateKtBcMst(reqDTO);
|
|
|
|
|
requireNewService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO, "KT-BC 실패(발송마스터 데이타 오류)");
|
|
|
|
|
dto.setResultCd("00");
|
|
|
|
|
dto.setErrorMssage("정상");
|
|
|
|
|
mapper.updateKtBcMst(dto);
|
|
|
|
|
extractService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KT_BC, "KT-BC 실패(발송마스터 데이타 오류)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validatedKtBcSendBulks(List<KtMainSendReqData> sendReqs) {
|
|
|
|
|
@ -433,12 +435,99 @@ public class EnsBatchSendService extends EgovAbstractServiceImpl implements IEns
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* Post plus 문서 send
|
|
|
|
|
* @param tgtDTO SndngMssageParam
|
|
|
|
|
* @param dto SndngMssageParam
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
// TODO:: 구현 필요
|
|
|
|
|
private void sendBulkPplus(final SndngMssageParam tgtDTO) {
|
|
|
|
|
requireNewService.sendPostPlus(tgtDTO);
|
|
|
|
|
private void sendBulkPplus(final SndngMssageParam dto) {
|
|
|
|
|
final String url = apiHost + apiPplusBulkSend;
|
|
|
|
|
|
|
|
|
|
final List<EnsPostPlusDTO> tgtList = mapper.selectPostPlusSendTgts(dto);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// PpAcceptRequestStruct reqDataDTO = PpAcceptRequestStruct.builder()
|
|
|
|
|
// .master(PpAcceptReqDataStruct.builder()
|
|
|
|
|
// .cols(JsonUtils.toJson(mstJson.get("cols")))
|
|
|
|
|
// .rows(JsonUtils.toJson(mstJson.get("rows")))
|
|
|
|
|
// .build())
|
|
|
|
|
// .detail(PpAcceptReqDataStruct.builder()
|
|
|
|
|
// .cols(JsonUtils.toJson(dtlJson.get("cols")))
|
|
|
|
|
// .rows(JsonUtils.toJson(dtlJson.get("rows")))
|
|
|
|
|
// .build())
|
|
|
|
|
// .build();
|
|
|
|
|
//
|
|
|
|
|
// String reqDataJsonStr = JsonUtils.toJson(reqDataDTO);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// // validation check
|
|
|
|
|
// try {
|
|
|
|
|
// validatedKtBcSendBulks(sendReqs);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send]KT-BC 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
// throw e;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// final List<List<KtMainSendReqData>> partitions = ListUtils.partition(sendReqs, bulkKtMaxCnt);
|
|
|
|
|
// List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
// .map(bulkSendList -> {
|
|
|
|
|
// mstDTO.setReqs(bulkSendList);
|
|
|
|
|
// return apiWebClient.exchange(
|
|
|
|
|
// url,
|
|
|
|
|
// HttpMethod.POST,
|
|
|
|
|
// mstDTO,
|
|
|
|
|
// ApiResponseDTO.class,
|
|
|
|
|
// CmmEnsBizUtils.getHeadeMap());
|
|
|
|
|
// }
|
|
|
|
|
// )
|
|
|
|
|
// .toList();
|
|
|
|
|
//
|
|
|
|
|
// boolean isSuccess = false;
|
|
|
|
|
// List<ErrorMsg> errList = new ArrayList<>();
|
|
|
|
|
// 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{
|
|
|
|
|
// 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(","))
|
|
|
|
|
// );
|
|
|
|
|
// mapper.updateKtBcMst(dto);
|
|
|
|
|
// extractService.updateSndngMstFailStatus(mstId, SndngSeCode.KT_BC, "[send] KT-BC 발송(bulks)요청 실패");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 성공 건수 존재시 성공 처리
|
|
|
|
|
// dto.setResultCd("00");
|
|
|
|
|
// dto.setErrorMssage("정상");
|
|
|
|
|
// mapper.updateKtBcMst(dto);
|
|
|
|
|
// extractService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO, "KT-BC 실패(발송마스터 데이타 오류)");
|
|
|
|
|
//
|
|
|
|
|
// extractService.sendPostPlus(tgtDTO);
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
}
|
|
|
|
|
|