|
|
|
@ -18,7 +18,8 @@ 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.kkomydoc.domain.*;
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.domain.*;
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.domain.repository.*;
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.model.*;
|
|
|
|
|
import cokr.xit.ens.modules.kkotalk.service.support.*;
|
|
|
|
|
import lombok.*;
|
|
|
|
@ -236,14 +237,14 @@ public class KkoTalkService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS)
|
|
|
|
|
public EnsResponseVO statBulk(Long sendMastId) {
|
|
|
|
|
public EnsResponseVO<?> statBulk(Long sendMastId) {
|
|
|
|
|
try {
|
|
|
|
|
SendMast sendMast = sendMastRepository.findById(sendMastId)
|
|
|
|
|
.orElseThrow(() -> new EnsException(EnsErrCd.RSLT404, "일치하는 자료가 없습니다."));
|
|
|
|
|
if (!PostSeCd.kkoTalk.equals(sendMast.getPostSe()))
|
|
|
|
|
throw new EnsException(EnsErrCd.RSLT404, String.format("%s 자료가 아닙니다.", PostSeCd.kkoTalk.getCodeNm()));
|
|
|
|
|
if (!Arrays.asList(StatCd.sendok, StatCd.sendcmplt, StatCd.open).stream()
|
|
|
|
|
.anyMatch(statCd -> statCd.equals(sendMast.getStatCd())))
|
|
|
|
|
if (Stream.of(StatCd.sendok, StatCd.sendcmplt, StatCd.open)
|
|
|
|
|
.noneMatch(statCd -> statCd.equals(sendMast.getStatCd())))
|
|
|
|
|
throw new EnsException(EnsErrCd.RSLT404, "전송성공/전송완료/열람중(sendok/sendcmplt/open) 단계가 아닙니다.");
|
|
|
|
|
} catch (EnsException e) {
|
|
|
|
|
return EnsResponseVO.errBuilder()
|
|
|
|
@ -264,9 +265,9 @@ public class KkoTalkService {
|
|
|
|
|
public EnsResponseVO<?> statBulkAll() {
|
|
|
|
|
List<Long> sendMastIds = sendMastRepository.findAllByPostSeAndStatCdIn(PostSeCd.kkoTalk, Arrays.asList(StatCd.sendok, StatCd.sendcmplt, StatCd.open))
|
|
|
|
|
.stream()
|
|
|
|
|
.map(row -> row.getSendMastId())
|
|
|
|
|
.map(SendMast::getSendMastId)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (sendMastIds.size() < 1)
|
|
|
|
|
if (sendMastIds.isEmpty())
|
|
|
|
|
return EnsResponseVO.errBuilder()
|
|
|
|
|
.errCode(EnsErrCd.RSLT404)
|
|
|
|
|
.errMsg("\"전송성공/전송완료/열람중(sendok/sendcmplt/open)\" 상태인 자료가 없습니다")
|
|
|
|
@ -276,8 +277,8 @@ public class KkoTalkService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EnsResponseVO<?> stat(List<Long> sendMastIds) {
|
|
|
|
|
List<EnsResponseVO> resultInfo = sendMastIds.stream()
|
|
|
|
|
.map(sendMastId -> kkoTalkRsltFetcher.execute(sendMastId))
|
|
|
|
|
List<?> resultInfo = sendMastIds.stream()
|
|
|
|
|
.map(kkoTalkRsltFetcher::execute)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
|
|
|
|
@ -293,7 +294,7 @@ public class KkoTalkService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
public EnsResponseVO<?> tokenVerify(String orgCd, String envelopId, String token, String externalDocumentUuid) {
|
|
|
|
|
public EnsResponseVO<?> tokenVerify(String orgCd, String envelopId, String token, String externalId) {
|
|
|
|
|
EnsResponseVO responseVO = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -303,6 +304,7 @@ public class KkoTalkService {
|
|
|
|
|
throw new EnsException(EnsErrCd.ERR401, "토큰(은)는 필수조건 입니다.");
|
|
|
|
|
OrgMng orgMng = orgMngService.find(orgCd).getResultInfo();
|
|
|
|
|
|
|
|
|
|
// FIXME: 카카오톡 토큰검증 API 처리
|
|
|
|
|
KkotalkApiDTO.ValidTokenResponse resp = kkoTalkApi.validToken(
|
|
|
|
|
KkotalkApiDTO.ValidTokenRequest.builder()
|
|
|
|
|
.signguCode(orgMng.getOrgCd())
|
|
|
|
@ -366,23 +368,23 @@ public class KkoTalkService {
|
|
|
|
|
} finally {
|
|
|
|
|
if (EnsErrCd.OK.equals(responseVO.getErrCode())) {
|
|
|
|
|
Map<String, Object> resultInfo = (Map<String, Object>) responseVO.getResultInfo();
|
|
|
|
|
sendDetailKkoTalkTokenHistRepository.save(SendDetailKkoMydocTokenHist.builder()
|
|
|
|
|
.externalDocumentUuid(externalDocumentUuid)
|
|
|
|
|
.documentBinderUuid(envelopId)
|
|
|
|
|
sendDetailKkoTalkTokenHistRepository.save(SendDetailKkoTalkTokenHist.builder()
|
|
|
|
|
.envelopeId(envelopId)
|
|
|
|
|
.envelopeId(externalId)
|
|
|
|
|
.token(token)
|
|
|
|
|
.tokenStatus((String) resultInfo.get("token_status"))
|
|
|
|
|
.tokenUsedAt((Long) resultInfo.get("token_used_at"))
|
|
|
|
|
.docBoxSentAt((Long) resultInfo.get("doc_box_sent_at"))
|
|
|
|
|
.docBoxReceivedAt((Long) resultInfo.get("doc_box_received_at"))
|
|
|
|
|
.authenticatedAt((Long) resultInfo.get("authenticated_at"))
|
|
|
|
|
.userNotifiedAt((Long) resultInfo.get("user_notified_at"))
|
|
|
|
|
.tokenUsedAt((String) resultInfo.get("used_at"))
|
|
|
|
|
.sentAt((String) resultInfo.get("sent_at"))
|
|
|
|
|
.receivedAt((String) resultInfo.get("received_at"))
|
|
|
|
|
.authenticatedAt((String) resultInfo.get("authenticated_at"))
|
|
|
|
|
.userNotifiedAt((String) resultInfo.get("user_notified_at"))
|
|
|
|
|
.payload((String) resultInfo.get("payload"))
|
|
|
|
|
.signedAt((String) resultInfo.get("signed_at"))
|
|
|
|
|
.build());
|
|
|
|
|
} else {
|
|
|
|
|
sendDetailKkoTalkTokenHistRepository.save(SendDetailKkoTalkTokenHist.builder()
|
|
|
|
|
.externalDocumentUuid(externalDocumentUuid)
|
|
|
|
|
.documentBinderUuid(envelopId)
|
|
|
|
|
.envelopeId(envelopId)
|
|
|
|
|
.externalId(externalId)
|
|
|
|
|
.token(token)
|
|
|
|
|
.error(FieldError.initBuilder()
|
|
|
|
|
.errorCode(responseVO.getErrCode().getCode())
|
|
|
|
@ -404,7 +406,7 @@ public class KkoTalkService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS)
|
|
|
|
|
public EnsResponseVO readCmplt(String orgCd, String envelopeId) {
|
|
|
|
|
public EnsResponseVO<?> readCmplt(String orgCd, String envelopeId) {
|
|
|
|
|
EnsResponseVO responseVO = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -414,6 +416,7 @@ public class KkoTalkService {
|
|
|
|
|
throw new EnsException(EnsErrCd.ERR401, "문서식별번호(은)는 필수조건 입니다.");
|
|
|
|
|
OrgMng orgMng = orgMngService.find(orgCd).getResultInfo();
|
|
|
|
|
|
|
|
|
|
// FIXME: 카카오툭 토큰 확인 API 호출 처리
|
|
|
|
|
KkotalkApiDTO.KkotalkErrorDTO resp = kkoTalkApi.modifyStatus(
|
|
|
|
|
KkotalkDTO.EnvelopeId.builder()
|
|
|
|
|
.envelopeId(envelopeId)
|
|
|
|
@ -475,7 +478,7 @@ public class KkoTalkService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS)
|
|
|
|
|
public EnsResponseVO sendResultProvide(Long sendMastId) {
|
|
|
|
|
public EnsResponseVO<?> sendResultProvide(Long sendMastId) {
|
|
|
|
|
|
|
|
|
|
return kkoTalkRsltProvider.execute(sendMastId);
|
|
|
|
|
}
|
|
|
|
|