|
|
@ -1,49 +1,38 @@
|
|
|
|
package cokr.xit.ens.modules.kkotalk.service.support;
|
|
|
|
package cokr.xit.ens.modules.kkotalk.service.support;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.stream.*;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import org.apache.commons.lang3.*;
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
import org.springframework.context.*;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.*;
|
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
|
import org.springframework.transaction.annotation.*;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.*;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.google.gson.*;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
import cokr.xit.ens.core.aop.*;
|
|
|
|
|
|
|
|
import cokr.xit.ens.core.exception.*;
|
|
|
|
import cokr.xit.ens.core.aop.EnsResponseVO;
|
|
|
|
import cokr.xit.ens.core.exception.code.*;
|
|
|
|
import cokr.xit.ens.core.exception.EnsException;
|
|
|
|
import cokr.xit.ens.core.monitor.slack.event.*;
|
|
|
|
import cokr.xit.ens.core.exception.code.EnsErrCd;
|
|
|
|
import cokr.xit.ens.core.utils.*;
|
|
|
|
import cokr.xit.ens.core.monitor.slack.event.MonitorEvent;
|
|
|
|
import cokr.xit.ens.modules.common.biztmplt.*;
|
|
|
|
import cokr.xit.ens.core.utils.CmmnUtil;
|
|
|
|
import cokr.xit.ens.modules.common.code.*;
|
|
|
|
import cokr.xit.ens.core.utils.MapDeserailizer;
|
|
|
|
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.*;
|
|
|
|
import cokr.xit.ens.modules.common.biztmplt.SendProcTemplate;
|
|
|
|
import cokr.xit.ens.modules.common.ctgy.sys.mng.service.*;
|
|
|
|
import cokr.xit.ens.modules.common.code.PostSeCd;
|
|
|
|
import cokr.xit.ens.modules.common.domain.*;
|
|
|
|
import cokr.xit.ens.modules.common.code.StatCd;
|
|
|
|
import cokr.xit.ens.modules.common.domain.repository.*;
|
|
|
|
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng;
|
|
|
|
import cokr.xit.ens.modules.common.domain.support.*;
|
|
|
|
import cokr.xit.ens.modules.common.ctgy.sys.mng.service.OrgMngService;
|
|
|
|
import cokr.xit.ens.modules.common.event.*;
|
|
|
|
import cokr.xit.ens.modules.common.domain.SendMast;
|
|
|
|
import cokr.xit.ens.modules.common.monitor.*;
|
|
|
|
import cokr.xit.ens.modules.common.domain.repository.SendMastRepository;
|
|
|
|
import cokr.xit.ens.modules.kkotalk.code.*;
|
|
|
|
import cokr.xit.ens.modules.common.domain.support.FieldError;
|
|
|
|
import cokr.xit.ens.modules.kkotalk.domain.*;
|
|
|
|
import cokr.xit.ens.modules.common.event.SendMastStatUpdateEvent;
|
|
|
|
import cokr.xit.ens.modules.kkotalk.domain.repository.*;
|
|
|
|
import cokr.xit.ens.modules.common.monitor.MessageByPhase;
|
|
|
|
import cokr.xit.ens.modules.kkotalk.mapper.*;
|
|
|
|
import cokr.xit.ens.modules.kkomydoc.code.KkoMydocStatusCd;
|
|
|
|
import cokr.xit.ens.modules.kkotalk.model.*;
|
|
|
|
import cokr.xit.ens.modules.kkomydoc.domain.SendDetailKkoMydoc;
|
|
|
|
import lombok.*;
|
|
|
|
import cokr.xit.ens.modules.kkomydoc.domain.SendDetailKkoMydocReqHist;
|
|
|
|
import lombok.extern.slf4j.*;
|
|
|
|
import cokr.xit.ens.modules.kkomydoc.domain.repository.SendDetailKkoMydocReqHistRepository;
|
|
|
|
|
|
|
|
import cokr.xit.ens.modules.kkomydoc.model.KkoMydocApiRespVO;
|
|
|
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.mapper.IKkoTalkMapper;
|
|
|
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.model.KkotalkApiDTO;
|
|
|
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO;
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: 카카오톡 신규 추가
|
|
|
|
// FIXME: 카카오톡 신규 추가
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -53,13 +42,12 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
|
|
|
|
|
|
|
|
private final ApplicationEventPublisher applicationEventPublisher;
|
|
|
|
private final ApplicationEventPublisher applicationEventPublisher;
|
|
|
|
private final SendMastRepository sendMastRepository;
|
|
|
|
private final SendMastRepository sendMastRepository;
|
|
|
|
//private final SendDetailKkoMydocRepository sendDetailKkoMydocRepository;
|
|
|
|
|
|
|
|
private final IKkoTalkMapper talkMapper;
|
|
|
|
private final IKkoTalkMapper talkMapper;
|
|
|
|
private final SendDetailKkoMydocReqHistRepository sendDetailKkoMydocReqHistRepository;
|
|
|
|
private final SendDetailKkoTalkReqHistRepository sendDetailKkoTalkReqHistRepository;
|
|
|
|
private final OrgMngService orgMngService;
|
|
|
|
private final OrgMngService orgMngService;
|
|
|
|
//private final KkoMydocApiSpec kkoMydocApi;
|
|
|
|
|
|
|
|
private final KkoTalkApiService kkoTalkApi;
|
|
|
|
private final KkoTalkApiService kkoTalkApi;
|
|
|
|
@Value("${contract.kakao.pay.mydoc.api.bulksend-batch-unit}")
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${contract.kakao.talk.bulksend-batch-unit}")
|
|
|
|
private int SEND_BATCH_UNIT;
|
|
|
|
private int SEND_BATCH_UNIT;
|
|
|
|
|
|
|
|
|
|
|
|
private Gson gson = new GsonBuilder().registerTypeAdapter(Map.class, new MapDeserailizer()).disableHtmlEscaping().create();
|
|
|
|
private Gson gson = new GsonBuilder().registerTypeAdapter(Map.class, new MapDeserailizer()).disableHtmlEscaping().create();
|
|
|
@ -84,12 +72,13 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
Lists.partition(sendDetails, SEND_BATCH_UNIT).stream()
|
|
|
|
Lists.partition(sendDetails, SEND_BATCH_UNIT).stream()
|
|
|
|
.forEach(list -> {
|
|
|
|
.forEach(list -> {
|
|
|
|
|
|
|
|
|
|
|
|
String sendRespBody = null;
|
|
|
|
String resp = null;
|
|
|
|
String jsonStr = null;
|
|
|
|
List<KkotalkApiDTO.Envelope> envelopes = null;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
List<KkotalkApiDTO.Envelope> envelopes = this.makeMessage(list);
|
|
|
|
envelopes = this.makeMessage(list);
|
|
|
|
KkotalkDTO.BulkSendResponse resp = kkoTalkApi.requestSendBulk(
|
|
|
|
resp = kkoTalkApi.requestSendBulk(
|
|
|
|
KkotalkDTO.BulkSendRequest.builder()
|
|
|
|
KkotalkDTO.BulkSendRequest.builder()
|
|
|
|
.envelopes(envelopes)
|
|
|
|
.envelopes(envelopes)
|
|
|
|
.signguCode(orgMng.getOrgCd())
|
|
|
|
.signguCode(orgMng.getOrgCd())
|
|
|
@ -98,69 +87,37 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
EnsResponseVO<?> mResponse = this.respMsgToMap(resp);
|
|
|
|
EnsResponseVO message = this.makeMessage(list);
|
|
|
|
|
|
|
|
if (!(EnsErrCd.OK.equals(message.getErrCode()) || null == message.getErrCode()))
|
|
|
|
|
|
|
|
throw new EnsException(message.getErrCode(), message.getErrMsg());
|
|
|
|
|
|
|
|
jsonStr = String.valueOf(message.getResultInfo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<String> resp = kkoMydocApi.bulkSend(orgMng.getKkoMdAccessToken(), orgMng.getKkoMdContractUuid(), jsonStr);
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
|
|
sb.append("\n==============================================================================")
|
|
|
|
|
|
|
|
.append("\n[ Kakao Mydoc - Sending ]")
|
|
|
|
|
|
|
|
.append("\n### Request Info...")
|
|
|
|
|
|
|
|
.append("\n" + jsonStr)
|
|
|
|
|
|
|
|
.append("\n### Response Info...")
|
|
|
|
|
|
|
|
.append("\n" + resp.getBody())
|
|
|
|
|
|
|
|
.append("\n==============================================================================");
|
|
|
|
|
|
|
|
log.debug(sb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendRespBody = resp.getBody();
|
|
|
|
|
|
|
|
if (resp.getStatusCode() != HttpStatus.OK)
|
|
|
|
|
|
|
|
throw new EnsException(EnsErrCd.SEND620, String.format("전송요청 중.. %s %s", resp.getStatusCode().toString(), resp.getBody()));
|
|
|
|
|
|
|
|
EnsResponseVO mResponse = this.respMsgToMap(resp.getBody());
|
|
|
|
|
|
|
|
if (!EnsErrCd.OK.equals(mResponse.getErrCode()))
|
|
|
|
if (!EnsErrCd.OK.equals(mResponse.getErrCode()))
|
|
|
|
throw new EnsException(mResponse.getErrCode(), mResponse.getErrMsg());
|
|
|
|
throw new EnsException(mResponse.getErrCode(), mResponse.getErrMsg());
|
|
|
|
List<Map<String, Object>> documents = (List<Map<String, Object>>) ((Map<String, Object>) mResponse.getResultInfo()).get("documents");
|
|
|
|
List<Map<String, Object>> documents = (List<Map<String, Object>>) ((Map<String, Object>) mResponse.getResultInfo()).get("envelopeIds");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, KkoTalkApiRespVO> mApiResp = documents.stream()
|
|
|
|
Map<String, KkoMydocApiRespVO> mApiRespVOByExtDocUuid = documents.stream()
|
|
|
|
.map(this::toApiRespVOMap)
|
|
|
|
.map(row -> this.toApiRespVOMap(row))
|
|
|
|
.collect(Collectors.toMap(m -> String.valueOf(m.get("key")), m -> (KkoTalkApiRespVO) m.get("value"), (k1, k2) -> k1));
|
|
|
|
.collect(Collectors.toMap(m -> String.valueOf(m.get("key")), m -> (KkoMydocApiRespVO) m.get("value"), (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.stream()
|
|
|
|
list.stream()
|
|
|
|
.forEach(row -> this.modifyDocSendRsltByExtDocUuid(row, mApiRespVOByExtDocUuid));
|
|
|
|
.forEach(row -> this.modifyTalkSendRsltByExtDocUuid(row, mApiResp));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (EnsException e) {
|
|
|
|
} catch (EnsException e) {
|
|
|
|
|
|
|
|
|
|
|
|
list.stream()
|
|
|
|
list.stream()
|
|
|
|
.forEach(row -> {
|
|
|
|
.forEach(row -> {
|
|
|
|
row.set(KkoMydocStatusCd.SENT_FAIL);
|
|
|
|
row.setStatus(KkoTalkStatusCd.SENT_FAIL);
|
|
|
|
row.setError(FieldError.initBuilder()
|
|
|
|
row.setErrorCode(e.getErrCd().getCode());
|
|
|
|
.errorCode(e.getErrCd().getCode())
|
|
|
|
row.setErrorMessage(e.getMessage());
|
|
|
|
.errorMessage(e.getMessage())
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
list.stream()
|
|
|
|
list.stream()
|
|
|
|
.forEach(row -> {
|
|
|
|
.forEach(row -> {
|
|
|
|
row.setKkoDocStat(KkoMydocStatusCd.SENT_FAIL);
|
|
|
|
row.setStatus(KkoTalkStatusCd.SENT_FAIL);
|
|
|
|
row.setError(FieldError.initBuilder()
|
|
|
|
row.setErrorCode(EnsErrCd.SEND500.getCode());
|
|
|
|
.errorCode(EnsErrCd.SEND500.getCode())
|
|
|
|
row.setErrorMessage(e.getMessage());
|
|
|
|
.errorMessage(e.getMessage())
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
// if (!CmmnUtil.isEmpty(jsonStr))
|
|
|
|
if (!CmmnUtil.isEmpty(envelopes))
|
|
|
|
// sendDetailKkoMydocReqHistRepository.saveAll(this.toSendDetailReqHist(list, jsonStr, sendRespBody));
|
|
|
|
sendDetailKkoTalkReqHistRepository.saveAll(this.toSendDetailReqHist(list, JsonUtils.toJson(envelopes), resp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -172,7 +129,7 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
if (cntSuccess.get() > 0)
|
|
|
|
if (cntSuccess.get() > 0)
|
|
|
|
respVO = EnsResponseVO.okBuilder()
|
|
|
|
respVO = EnsResponseVO.okBuilder()
|
|
|
|
.resultInfo(sendDetails.stream()
|
|
|
|
.resultInfo(sendDetails.stream()
|
|
|
|
// .map(row -> this.toResultInfo(row))
|
|
|
|
.map(row -> this.toResultInfo(row))
|
|
|
|
.collect(Collectors.toList()))
|
|
|
|
.collect(Collectors.toList()))
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -199,7 +156,7 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
applicationEventPublisher.publishEvent(MonitorEvent.builder()
|
|
|
|
applicationEventPublisher.publishEvent(MonitorEvent.builder()
|
|
|
|
.message(MessageByPhase.builder()
|
|
|
|
.message(MessageByPhase.builder()
|
|
|
|
.oClass(getClass().getSimpleName() + "." + new Throwable().getStackTrace()[0].getMethodName())
|
|
|
|
.oClass(getClass().getSimpleName() + "." + new Throwable().getStackTrace()[0].getMethodName())
|
|
|
|
.postSeCd(PostSeCd.kkoMydoc)
|
|
|
|
.postSeCd(PostSeCd.kkoTalk)
|
|
|
|
.statCd(StatCd.sendfail)
|
|
|
|
.statCd(StatCd.sendfail)
|
|
|
|
.errCd(respVO.getErrCode())
|
|
|
|
.errCd(respVO.getErrCode())
|
|
|
|
.message("-.SendMastId: " + sendMastId + "\n" + respVO.getErrMsg())
|
|
|
|
.message("-.SendMastId: " + sendMastId + "\n" + respVO.getErrMsg())
|
|
|
@ -268,14 +225,14 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Map<String, Object> toApiRespVOMap(Map<String, Object> row) {
|
|
|
|
private Map<String, Object> toApiRespVOMap(Map<String, Object> row) {
|
|
|
|
KkoMydocApiRespVO apiRespVO = KkoMydocApiRespVO.builder()
|
|
|
|
KkoTalkApiRespVO apiRespVO = KkoTalkApiRespVO.builder()
|
|
|
|
.error_code(row.containsKey("error_code") ? String.valueOf(row.get("error_code")) : null)
|
|
|
|
.errorCode(row.containsKey("errorCode") ? String.valueOf(row.get("errorCode")) : null)
|
|
|
|
.error_message(row.containsKey("error_message") ? String.valueOf(row.get("error_message")) : null)
|
|
|
|
.errorMessage(row.containsKey("errorMessage") ? String.valueOf(row.get("errorMessage")) : null)
|
|
|
|
.data(row.containsKey("document_binder_uuid") ? String.valueOf(row.get("document_binder_uuid")) : null)
|
|
|
|
.data(row.containsKey("envelopeId") ? String.valueOf(row.get("envelopeId")) : null)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
m.put("key", row.get("external_document_uuid"));
|
|
|
|
m.put("key", row.get("externalId"));
|
|
|
|
m.put("value", apiRespVO);
|
|
|
|
m.put("value", apiRespVO);
|
|
|
|
return m;
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -284,34 +241,31 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
* 전송요청결과 갱신(update)
|
|
|
|
* 전송요청결과 갱신(update)
|
|
|
|
* -. 성공/실패 여부에 따라 문서식별번호(document_binder_uuid) 및 Error 필드 갱신
|
|
|
|
* -. 성공/실패 여부에 따라 문서식별번호(document_binder_uuid) 및 Error 필드 갱신
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param row
|
|
|
|
* @param row SendDetailKkoTalkDTO
|
|
|
|
* @param mApiRespVOByExtDocUuid
|
|
|
|
* @param map Map<String, KkoTalkApiRespVO>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void modifyDocSendRsltByExtDocUuid(SendDetailKkoMydoc row, Map<String, KkoMydocApiRespVO> mApiRespVOByExtDocUuid) {
|
|
|
|
private void modifyTalkSendRsltByExtDocUuid(KkotalkDTO.SendDetailKkoTalkDTO row, Map<String, KkoTalkApiRespVO> map) {
|
|
|
|
KkoMydocApiRespVO apiRespVO = mApiRespVOByExtDocUuid.get(row.getPropExternalDocumentUuid());
|
|
|
|
KkoTalkApiRespVO apiRespVO = map.get(row.getExternalId());
|
|
|
|
if (CmmnUtil.isEmpty(apiRespVO.getError_code())) {
|
|
|
|
if (CmmnUtil.isEmpty(apiRespVO.getErrorCode())) {
|
|
|
|
row.setKkoDocStat(KkoMydocStatusCd.SENT);
|
|
|
|
row.setStatus(KkoTalkStatusCd.SENT);
|
|
|
|
row.setDocumentBinderUuid(String.valueOf(apiRespVO.getData()));
|
|
|
|
row.setEnvelopeId(String.valueOf(apiRespVO.getData()));
|
|
|
|
row.setError(FieldError.initBuilder().build());
|
|
|
|
//row.setErrorCode(FieldError.initBuilder().build());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
row.setKkoDocStat(KkoMydocStatusCd.valueOfEnum(apiRespVO.getError_code()));
|
|
|
|
row.setStatus(KkoTalkStatusCd.valueOfEnum(apiRespVO.getErrorCode()));
|
|
|
|
row.setError(FieldError.initBuilder()
|
|
|
|
row.setErrorCode(EnsErrCd.SEND630.getCode());
|
|
|
|
.errorCode(EnsErrCd.SEND630.getCode())
|
|
|
|
row.setErrorMessage(String.format("%s %s", apiRespVO.getErrorCode(), apiRespVO.getErrorMessage()));
|
|
|
|
.errorMessage(String.format("%s %s", apiRespVO.getError_code(), apiRespVO.getError_message()))
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String> toResultInfo(SendDetailKkoMydoc row) {
|
|
|
|
private Map<String, String> toResultInfo(KkotalkDTO.SendDetailKkoTalkDTO row) {
|
|
|
|
Map<String, String> m = new HashMap<>();
|
|
|
|
Map<String, String> m = new HashMap<>();
|
|
|
|
// m.put("msgIdx", row.getMsgIdx());
|
|
|
|
m.put("envelopeId", row.getEnvelopeId());
|
|
|
|
m.put("documentBinderUuid", row.getDocumentBinderUuid());
|
|
|
|
m.put("externalId", row.getExternalId());
|
|
|
|
m.put("externalDocumentUuid", row.getPropExternalDocumentUuid());
|
|
|
|
if (!CmmnUtil.isEmpty(row.getErrorCode())) {
|
|
|
|
if (!CmmnUtil.isEmpty(row.getError())) {
|
|
|
|
m.put("errCd", row.getErrorCode());
|
|
|
|
m.put("errCd", row.getError().getErrorCode());
|
|
|
|
m.put("errMsg", row.getErrorMessage());
|
|
|
|
m.put("errMsg", row.getError().getErrorMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m;
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -324,14 +278,14 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
* @param respMsg
|
|
|
|
* @param respMsg
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private List<SendDetailKkoMydocReqHist> toSendDetailReqHist(List<SendDetailKkoMydoc> list, String sendMsg, String respMsg) {
|
|
|
|
private List<SendDetailKkoTalkReqHist> toSendDetailReqHist(List<KkotalkDTO.SendDetailKkoTalkDTO> list, String sendMsg, String respMsg) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> sendMsgList = (List<Map<String, Object>>) gson.fromJson(sendMsg, Map.class).get("documents");
|
|
|
|
List<Map<String, Object>> sendMsgList = (List<Map<String, Object>>) gson.fromJson(sendMsg, Map.class).get("envelopes");
|
|
|
|
Map<String, Long> mSendDetailIds = list.stream()
|
|
|
|
Map<String, Long> mSendDetailIds = list.stream()
|
|
|
|
.map(row -> {
|
|
|
|
.map(row -> {
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
m.put("key", row.getPropExternalDocumentUuid());
|
|
|
|
m.put("key", row.getExternalId());
|
|
|
|
m.put("value", row.getSendDetailId());
|
|
|
|
m.put("value", row.getSendDetailId());
|
|
|
|
return m;
|
|
|
|
return m;
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -342,15 +296,15 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
|
|
|
|
|
|
|
|
if (EnsErrCd.OK.equals(respVO.getErrCode())) {
|
|
|
|
if (EnsErrCd.OK.equals(respVO.getErrCode())) {
|
|
|
|
Map<String, Object> mRespBody = (Map<String, Object>) respVO.getResultInfo();
|
|
|
|
Map<String, Object> mRespBody = (Map<String, Object>) respVO.getResultInfo();
|
|
|
|
List<Map<String, String>> documents = (List<Map<String, String>>) mRespBody.get("documents");
|
|
|
|
List<Map<String, String>> documents = (List<Map<String, String>>) mRespBody.get("envelopeIds");
|
|
|
|
Map<String, Map<String, String>> mRespMsg = documents.stream()
|
|
|
|
Map<String, Map<String, String>> mRespMsg = documents.stream()
|
|
|
|
.map(row -> {
|
|
|
|
.map(row -> {
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
Map<String, Object> m = new HashMap<>();
|
|
|
|
m.put("key", String.valueOf(row.get("external_document_uuid")));
|
|
|
|
m.put("key", String.valueOf(row.get("externalId")));
|
|
|
|
Map<String, String> mValue = new HashMap<>();
|
|
|
|
Map<String, String> mValue = new HashMap<>();
|
|
|
|
mValue.put("document_binder_uuid", row.get("document_binder_uuid"));
|
|
|
|
mValue.put("envelopeId", row.get("envelopeId"));
|
|
|
|
mValue.put("error_code", row.get("error_code"));
|
|
|
|
mValue.put("errorCode", row.get("errorCode"));
|
|
|
|
mValue.put("error_message", row.get("error_message"));
|
|
|
|
mValue.put("errorMessage", row.get("errorMessage"));
|
|
|
|
mValue.put("rawMsg", gson.toJson(row));
|
|
|
|
mValue.put("rawMsg", gson.toJson(row));
|
|
|
|
m.put("value", mValue);
|
|
|
|
m.put("value", mValue);
|
|
|
|
return m;
|
|
|
|
return m;
|
|
|
@ -359,21 +313,22 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
|
|
|
|
|
|
|
|
return sendMsgList.stream()
|
|
|
|
return sendMsgList.stream()
|
|
|
|
.map(row -> {
|
|
|
|
.map(row -> {
|
|
|
|
Map<String, String> property = (Map<String, String>) row.get("property");
|
|
|
|
//
|
|
|
|
String externalDocumentUuid = property.get("external_document_uuid");
|
|
|
|
//Map<String, String> property = (Map<String, String>) row.get("property");
|
|
|
|
boolean isSuccess = CmmnUtil.isEmpty(mRespMsg.get(externalDocumentUuid).get("error_code"));
|
|
|
|
String externalId = (String)row.get("externalId");
|
|
|
|
|
|
|
|
boolean isSuccess = CmmnUtil.isEmpty(mRespMsg.get(externalId).get("errorCode"));
|
|
|
|
|
|
|
|
|
|
|
|
return SendDetailKkoMydocReqHist.builder()
|
|
|
|
return SendDetailKkoTalkReqHist.builder()
|
|
|
|
.sendDetailId(mSendDetailIds.get(externalDocumentUuid))
|
|
|
|
.sendDetailId(mSendDetailIds.get(externalId))
|
|
|
|
.sendRawMsg(gson.toJson(row))
|
|
|
|
.sendRawMsg(gson.toJson(row))
|
|
|
|
.externalDocumentUuid(externalDocumentUuid)
|
|
|
|
.externalId(externalId)
|
|
|
|
.documentBinderUuid(mRespMsg.get(externalDocumentUuid).get("document_binder_uuid"))
|
|
|
|
.envelopeId(mRespMsg.get(externalId).get("envelopeId"))
|
|
|
|
.respRawMsg(mRespMsg.get(externalDocumentUuid).get("rawMsg"))
|
|
|
|
.respRawMsg(mRespMsg.get(externalId).get("rawMsg"))
|
|
|
|
.error(FieldError.initBuilder()
|
|
|
|
.error(FieldError.initBuilder()
|
|
|
|
.errorCode(isSuccess ? null : EnsErrCd.SEND620.getCode())
|
|
|
|
.errorCode(isSuccess ? null : EnsErrCd.SEND620.getCode())
|
|
|
|
.errorMessage(isSuccess ? null : String.format("%s %s"
|
|
|
|
.errorMessage(isSuccess ? null : String.format("%s %s"
|
|
|
|
, mRespMsg.get(externalDocumentUuid).get("error_code")
|
|
|
|
, mRespMsg.get(externalId).get("errorCode")
|
|
|
|
, mRespMsg.get(externalDocumentUuid).get("error_message")
|
|
|
|
, mRespMsg.get(externalId).get("errorMessage")
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.build())
|
|
|
|
.build())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
@ -383,12 +338,13 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return sendMsgList.stream()
|
|
|
|
return sendMsgList.stream()
|
|
|
|
.map(row -> {
|
|
|
|
.map(row -> {
|
|
|
|
Map<String, String> property = (Map<String, String>) row.get("property");
|
|
|
|
//Map<String, String> property = (Map<String, String>) row.get("property");
|
|
|
|
String externalDocumentUuid = property.get("external_document_uuid");
|
|
|
|
String externalId = (String)row.get("externalId");
|
|
|
|
return SendDetailKkoMydocReqHist.builder()
|
|
|
|
|
|
|
|
.sendDetailId(mSendDetailIds.get(externalDocumentUuid))
|
|
|
|
return SendDetailKkoTalkReqHist.builder()
|
|
|
|
|
|
|
|
.sendDetailId(mSendDetailIds.get(externalId))
|
|
|
|
.sendRawMsg(gson.toJson(row))
|
|
|
|
.sendRawMsg(gson.toJson(row))
|
|
|
|
.externalDocumentUuid(externalDocumentUuid)
|
|
|
|
.externalId(externalId)
|
|
|
|
.respRawMsg(respMsg)
|
|
|
|
.respRawMsg(respMsg)
|
|
|
|
.error(FieldError.initBuilder()
|
|
|
|
.error(FieldError.initBuilder()
|
|
|
|
.errorCode(respVO.getErrCode().getCode())
|
|
|
|
.errorCode(respVO.getErrCode().getCode())
|
|
|
@ -400,13 +356,13 @@ public class KkoTalkSender extends SendProcTemplate {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private EnsResponseVO respMsgToMap(String respMsg) {
|
|
|
|
private EnsResponseVO<?> respMsgToMap(String respMsg) {
|
|
|
|
EnsErrCd errCode = EnsErrCd.OK;
|
|
|
|
EnsErrCd errCode = EnsErrCd.OK;
|
|
|
|
String errMsg = EnsErrCd.OK.getCodeNm();
|
|
|
|
String errMsg = EnsErrCd.OK.getCodeNm();
|
|
|
|
Map<String, Object> mResp = null;
|
|
|
|
Map<String, Object> mResp = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
mResp = gson.fromJson(respMsg, Map.class);
|
|
|
|
mResp = gson.fromJson(respMsg, Map.class);
|
|
|
|
if (CmmnUtil.isEmpty(mResp.get("documents")))
|
|
|
|
if (CmmnUtil.isEmpty(mResp.get("envelopeIds")))
|
|
|
|
throw new EnsException(EnsErrCd.SEND620, String.format("전송요청API 오류. documents 키값이 없습니다. %s", respMsg));
|
|
|
|
throw new EnsException(EnsErrCd.SEND620, String.format("전송요청API 오류. documents 키값이 없습니다. %s", respMsg));
|
|
|
|
} catch (EnsException e) {
|
|
|
|
} catch (EnsException e) {
|
|
|
|
errCode = e.getErrCd();
|
|
|
|
errCode = e.getErrCd();
|
|
|
|