|
|
|
|
@ -229,6 +229,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
public void make(final EnsDTO.BatchEnsRequest reqDTO) {
|
|
|
|
|
final String sndngProcessSttus2 = ApiConstants.SndngProcessStatus.SENDING1.getCode();
|
|
|
|
|
final String sndngProcessSttus3 = ApiConstants.SndngProcessStatus.SENDING2.getCode();
|
|
|
|
|
|
|
|
|
|
final List<EnsDTO.SndngMssageParam> list = mapper.selectMakeTgts(reqDTO);
|
|
|
|
|
final List<EnsDTO.SndngMssageParam> list2 = mapper.selectMakeTgts(sndngProcessSttus2);
|
|
|
|
|
|
|
|
|
|
@ -316,7 +317,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
MDC.put("sndngMastrId", dto.getSndngMastrId());
|
|
|
|
|
MDC.put(SNDNG_PROCESS_STTUS, "send-fail" + dto.getTrySeq());
|
|
|
|
|
|
|
|
|
|
String[] tryVal = {
|
|
|
|
|
final String[] tryVal = {
|
|
|
|
|
Checks.checkVal(dto.getTry1(), ""),
|
|
|
|
|
Checks.checkVal(dto.getTry2(), ""),
|
|
|
|
|
Checks.checkVal(dto.getTry3(), "")
|
|
|
|
|
@ -354,9 +355,9 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
final String url = apiHost + apiKkoBulkStatus;
|
|
|
|
|
|
|
|
|
|
final List<String> docsBinderUuids = mapper.selectKakaoStatusTgts(reqDTO.getSndngProcessSttus());
|
|
|
|
|
final List<List<String>> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt);
|
|
|
|
|
|
|
|
|
|
List<List<String>> partitions = ListUtils.partition(docsBinderUuids, bulkKkoMaxCnt);
|
|
|
|
|
List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
final List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
.map(uuids -> apiWebClient.exchange(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
@ -369,12 +370,10 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
getHeadeMap())
|
|
|
|
|
).toList();
|
|
|
|
|
|
|
|
|
|
List<BulkStatusResponses> resList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
final List<BulkStatusResponses> resList = new ArrayList<>();
|
|
|
|
|
for(ApiResponseDTO apiResult : apiResults) {
|
|
|
|
|
if(apiResult.getData() != null) {
|
|
|
|
|
BulkStatusResponses data = JsonUtils.toObjByObj(apiResult.getData(), BulkStatusResponses.class);
|
|
|
|
|
resList.add(data);
|
|
|
|
|
resList.add(JsonUtils.toObjByObj(apiResult.getData(), BulkStatusResponses.class));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -402,11 +401,11 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
public void close(final EnsDTO.BatchEnsRequest reqDTO) {
|
|
|
|
|
final List<String> list = mapper.selectCloseTgts(reqDTO.getSndngProcessSttus());
|
|
|
|
|
final List<String> list = mapper.selectCloseTgts(reqDTO);
|
|
|
|
|
|
|
|
|
|
// 연계발송 마스터(tb_cntc_sndng_mastr) 상태 변경 : send-ok -> close
|
|
|
|
|
for (String id : list) {
|
|
|
|
|
EnsDTO.SndngMssageParam paramDTO = EnsDTO.SndngMssageParam.builder()
|
|
|
|
|
final EnsDTO.SndngMssageParam paramDTO = EnsDTO.SndngMssageParam.builder()
|
|
|
|
|
.unitySndngMastrId(id)
|
|
|
|
|
.sndngProcessSttus(reqDTO.getSndngProcessSttus())
|
|
|
|
|
.newSndngProcessSttus(ApiConstants.SndngProcessStatus.CLOSE.getCode())
|
|
|
|
|
@ -471,7 +470,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
* @return Map<String,String>
|
|
|
|
|
*/
|
|
|
|
|
private Map<String,String> getHeadeMap(){
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
final Map<String, String> map = new HashMap<>();
|
|
|
|
|
map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
|
|
|
|
//map.put(HttpHeaders.AUTHORIZATION, "");
|
|
|
|
|
return map;
|
|
|
|
|
@ -488,10 +487,10 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private void validatedAccept(List<EnsDTO.sndngVali> valiList) {
|
|
|
|
|
List<String> errors = new ArrayList<>();
|
|
|
|
|
final List<String> errors = new ArrayList<>();
|
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
|
|
List<List<EnsDTO.sndngVali>> arrList = ListUtils.partition(valiList, bulkKkoMaxCnt);
|
|
|
|
|
final List<List<EnsDTO.sndngVali>> arrList = ListUtils.partition(valiList, bulkKkoMaxCnt);
|
|
|
|
|
for (List<EnsDTO.sndngVali> list : arrList) {
|
|
|
|
|
for (EnsDTO.sndngVali dto : list) {
|
|
|
|
|
Set<ConstraintViolation<EnsDTO.sndngVali>> errList = validator.validate(dto);
|
|
|
|
|
@ -520,7 +519,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] tryVal = {
|
|
|
|
|
final String[] tryVal = {
|
|
|
|
|
Checks.checkVal(dto.getTry1(), ""),
|
|
|
|
|
Checks.checkVal(dto.getTry2(), ""),
|
|
|
|
|
Checks.checkVal(dto.getTry3(), "")
|
|
|
|
|
@ -598,7 +597,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
private void updateAcceptCntcSndngMstFailStatus(final List<String> mstIdList, final String stsErrMsg) {
|
|
|
|
|
|
|
|
|
|
for (String id : mstIdList) {
|
|
|
|
|
EnsDTO.SndngMssageParam paramDTO = EnsDTO.SndngMssageParam.builder()
|
|
|
|
|
final EnsDTO.SndngMssageParam paramDTO = EnsDTO.SndngMssageParam.builder()
|
|
|
|
|
.unitySndngMastrId(id)
|
|
|
|
|
.newSndngProcessSttus("accept-fail")
|
|
|
|
|
.errorMssage(stsErrMsg)
|
|
|
|
|
@ -727,13 +726,13 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
* - 카카오페이 연계 결과 반영 : tb_ens_kakao_my_doc
|
|
|
|
|
* - 모바일 페이지 생성 : tb_ens_mobile_page_manage
|
|
|
|
|
* - 연계발송결과 생성 : tb_cntc_sndng_result
|
|
|
|
|
* @param tgtDTO SndngMssageParam
|
|
|
|
|
* @param reqDTO SndngMssageParam
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private void sendBulkKakaoMyDocs(final EnsDTO.SndngMssageParam tgtDTO) {
|
|
|
|
|
private void sendBulkKakaoMyDocs(final EnsDTO.SndngMssageParam reqDTO) {
|
|
|
|
|
final String url = apiHost + apiKkoBulkSend;
|
|
|
|
|
|
|
|
|
|
final List<SendKakaoTgt> list = mapper.selectKakaoSendTgts(tgtDTO);
|
|
|
|
|
final List<SendKakaoTgt> list = mapper.selectKakaoSendTgts(reqDTO);
|
|
|
|
|
if(list.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
final String mstId = list.get(0).getSndngMastrId();
|
|
|
|
|
@ -747,15 +746,14 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<List<BulkSendReq>> partitions = ListUtils.partition(bulkList, bulkKkoMaxCnt);
|
|
|
|
|
|
|
|
|
|
List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
final List<List<BulkSendReq>> partitions = ListUtils.partition(bulkList, bulkKkoMaxCnt);
|
|
|
|
|
final List<ApiResponseDTO> apiResults = partitions.stream()
|
|
|
|
|
.map(bulkSendList -> apiWebClient.exchange(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
BulkSendRequests.builder()
|
|
|
|
|
.signguCode(tgtDTO.getSignguCode())
|
|
|
|
|
.ffnlgCode(tgtDTO.getFfnlgCode())
|
|
|
|
|
.signguCode(reqDTO.getSignguCode())
|
|
|
|
|
.ffnlgCode(reqDTO.getFfnlgCode())
|
|
|
|
|
.documents(bulkSendList)
|
|
|
|
|
.build(),
|
|
|
|
|
ApiResponseDTO.class,
|
|
|
|
|
@ -763,15 +761,12 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BulkSendResponses> resList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
final List<BulkSendResponses> resList = new ArrayList<>();
|
|
|
|
|
boolean isSuccess = false;
|
|
|
|
|
String errMsg = null;
|
|
|
|
|
for(ApiResponseDTO apiResult : apiResults) {
|
|
|
|
|
if(apiResult.getData() != null) {
|
|
|
|
|
BulkSendResponses data = JsonUtils.toObjByObj(apiResult.getData(), BulkSendResponses.class);
|
|
|
|
|
resList.add(data);
|
|
|
|
|
resList.add(JsonUtils.toObjByObj(apiResult.getData(), BulkSendResponses.class));
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
@ -779,7 +774,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
}
|
|
|
|
|
// 카카오 send 결과 반영
|
|
|
|
|
if(!isSuccess) requireNewService.updateSndngMstFailStatus(mstId, SndngSeCode.KAKAO, errMsg);
|
|
|
|
|
requireNewService.saveKkoMyDocResult(mstId, tgtDTO.getUnitySndngMastrId(), resList);
|
|
|
|
|
requireNewService.saveKkoMyDocResult(mstId, reqDTO.getUnitySndngMastrId(), resList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -789,7 +784,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
* @return List<KkopayDocBulkDTO.BulkSendReq>
|
|
|
|
|
*/
|
|
|
|
|
private static List<KkopayDocBulkDTO.BulkSendReq> setKkoMyDocSendBulks(List<EnsDTO.SendKakaoTgt> list) {
|
|
|
|
|
List<KkopayDocBulkDTO.BulkSendReq> bulkList = new ArrayList<>();
|
|
|
|
|
final List<KkopayDocBulkDTO.BulkSendReq> bulkList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (EnsDTO.SendKakaoTgt sendTgtDTO : list) {
|
|
|
|
|
/**
|
|
|
|
|
@ -822,7 +817,7 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
.external_document_uuid(sendTgtDTO.getUnitySndngDetailId())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
BulkSendReq bulkReqDTO = BulkSendReq.builder()
|
|
|
|
|
final BulkSendReq bulkReqDTO = BulkSendReq.builder()
|
|
|
|
|
.title(sendTgtDTO.getTitle())
|
|
|
|
|
.common_categories(Collections.singletonList(ApiConstants.Categories.NOTICE))
|
|
|
|
|
.read_expired_at(sendTgtDTO.getClosDt())
|
|
|
|
|
@ -847,46 +842,41 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
List<String> errors = new ArrayList<>();
|
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
|
|
List<List<BulkSendReq>> arrList = ListUtils.partition(bulkList, bulkKkoMaxCnt);
|
|
|
|
|
for (List<BulkSendReq> list : arrList) {
|
|
|
|
|
for (KkopayDocBulkDTO.BulkSendReq dto : list) {
|
|
|
|
|
Set<ConstraintViolation<KkopayDocBulkDTO.BulkSendReq>> errList = validator.validate(
|
|
|
|
|
dto);
|
|
|
|
|
for (BulkSendReq dto : bulkList) {
|
|
|
|
|
final Set<ConstraintViolation<BulkSendReq>> errList = validator.validate(dto);
|
|
|
|
|
|
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
|
if(!errList.isEmpty()) {
|
|
|
|
|
int finalIdx = idx;
|
|
|
|
|
errors.addAll(errList.stream()
|
|
|
|
|
.map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1,
|
|
|
|
|
row.getMessageTemplate()))
|
|
|
|
|
.toList()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int finalIdx = idx;
|
|
|
|
|
errors.addAll(errList.stream()
|
|
|
|
|
.map(row -> String.format("%s[%d]=%s", row.getPropertyPath(), finalIdx + 1,
|
|
|
|
|
row.getMessageTemplate()))
|
|
|
|
|
.toList()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (dto.getRead_expired_at() != null && dto.getRead_expired_sec() != null) {
|
|
|
|
|
errors.add("처리마감시간(절대시간 또는 상대시간)은 하나만 지정해야 합니다.");
|
|
|
|
|
}
|
|
|
|
|
if (dto.getRead_expired_at() == null && dto.getRead_expired_sec() == null) {
|
|
|
|
|
errors.add("처리마감시간(절대시간 또는 상대시간)을 지정해야 합니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dto.getRead_expired_at() != null && dto.getRead_expired_sec() != null) {
|
|
|
|
|
errors.add("처리마감시간(절대시간 또는 상대시간)은 하나만 지정해야 합니다.");
|
|
|
|
|
final Receiver receiver = dto.getReceiver();
|
|
|
|
|
if (Checks.isEmpty(receiver.getCi())) {
|
|
|
|
|
if (Checks.isEmpty(receiver.getName())) {
|
|
|
|
|
errors.add(
|
|
|
|
|
String.format("받는이 이름은 필수입니다(receiver.name[%d] 번째 오류)", idx + 1));
|
|
|
|
|
}
|
|
|
|
|
if (dto.getRead_expired_at() == null && dto.getRead_expired_sec() == null) {
|
|
|
|
|
errors.add("처리마감시간(절대시간 또는 상대시간)을 지정해야 합니다.");
|
|
|
|
|
if (Checks.isEmpty(receiver.getPhone_number())) {
|
|
|
|
|
errors.add(String.format("받는이 전화번호는 필수입니다(receiver.phone_number[%d] 번째 오류)",
|
|
|
|
|
idx + 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Receiver receiver = dto.getReceiver();
|
|
|
|
|
if (Checks.isEmpty(receiver.getCi())) {
|
|
|
|
|
if (Checks.isEmpty(receiver.getName())) {
|
|
|
|
|
errors.add(
|
|
|
|
|
String.format("받는이 이름은 필수입니다(receiver.name[%d] 번째 오류)", idx + 1));
|
|
|
|
|
}
|
|
|
|
|
if (Checks.isEmpty(receiver.getPhone_number())) {
|
|
|
|
|
errors.add(String.format("받는이 전화번호는 필수입니다(receiver.phone_number[%d] 번째 오류)",
|
|
|
|
|
idx + 1));
|
|
|
|
|
}
|
|
|
|
|
if (Checks.isEmpty(receiver.getBirthday())) {
|
|
|
|
|
errors.add(
|
|
|
|
|
String.format("받는이 생년월일은 필수입니다(receiver.birthday[%d] 번째 오류)", idx + 1));
|
|
|
|
|
}
|
|
|
|
|
if (Checks.isEmpty(receiver.getBirthday())) {
|
|
|
|
|
errors.add(
|
|
|
|
|
String.format("받는이 생년월일은 필수입니다(receiver.birthday[%d] 번째 오류)", idx + 1));
|
|
|
|
|
}
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
|
@ -907,26 +897,19 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
KtBcMst mstDTO = mapper.selectKtBcMstTgtInfo(reqDTO)
|
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("KT BC 본문자 수신 등록 대상이 존재 하지 않습니다 "));
|
|
|
|
|
|
|
|
|
|
List<KtMainSendReqData> sendReqs = mapper.selectKtBcSendTgts(reqDTO);
|
|
|
|
|
|
|
|
|
|
//TODO :: KKO 기준 작성 필요
|
|
|
|
|
final List<BulkSendReq> bulkList = new ArrayList<>();
|
|
|
|
|
final String mstId = mstDTO.getSndngMastrId();
|
|
|
|
|
final String unitySndMstId = mstDTO.getUnitySndngMastrId();
|
|
|
|
|
|
|
|
|
|
// setKtBcSendBulks(list, bulkList, mstIdList);
|
|
|
|
|
final List<KtMainSendReqData> sendReqs = mapper.selectKtBcSendTgts(reqDTO);
|
|
|
|
|
|
|
|
|
|
// validation check
|
|
|
|
|
// try {
|
|
|
|
|
// validatedKkoMyDocSendBulks(bulkList);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// updateKkoMyDocSndngMstFailStatus(mstIdList, "[send]카카오 문서 발송(bulks)요청 실패(파라메터 오류)");
|
|
|
|
|
// throw e;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
List<List<KtMainSendReqData>> partitions = ListUtils.partition(sendReqs, bulkKtMaxCnt);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
validatedKtBcSendBulks(sendReqs);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
requireNewService.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);
|
|
|
|
|
@ -966,7 +949,6 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 모두 실패한 경우
|
|
|
|
|
if(!isSuccess) {
|
|
|
|
|
reqDTO.setResultCd("01");
|
|
|
|
|
@ -986,6 +968,29 @@ public class EnsBatchService extends EgovAbstractServiceImpl implements IEnsBatc
|
|
|
|
|
mapper.updateKtBcMst(reqDTO);
|
|
|
|
|
requireNewService.updateSendSndngMstStatus(mstId, unitySndMstId, SndngSeCode.KAKAO, "KT-BC 실패(발송마스터 데이타 오류)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validatedKtBcSendBulks(List<KtMainSendReqData> sendReqs) {
|
|
|
|
|
List<String> errors = new ArrayList<>();
|
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
|
|
for (KtMainSendReqData dto : sendReqs) {
|
|
|
|
|
Set<ConstraintViolation<KtMainSendReqData>> 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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|