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