@ -1,47 +1,35 @@
package cokr.xit.ens.modules.kkotalk.service.support ;
package cokr.xit.ens.modules.kkotalk.service.support ;
import java.util.HashMap ;
import java.util.* ;
import java.util.List ;
import java.util.stream.* ;
import java.util.Map ;
import java.util.Optional ;
import org.springframework.context.* ;
import java.util.stream.Collectors ;
import org.springframework.stereotype.* ;
import org.springframework.transaction.annotation.* ;
import org.springframework.context.ApplicationEventPublisher ;
import org.springframework.stereotype.Component ;
import com.google.gson.* ;
import org.springframework.transaction.annotation.Propagation ;
import org.springframework.transaction.annotation.Transactional ;
import cokr.xit.ens.core.aop.* ;
import cokr.xit.ens.core.exception.* ;
import com.google.gson.Gson ;
import cokr.xit.ens.core.exception.code.* ;
import com.google.gson.GsonBuilder ;
import cokr.xit.ens.core.monitor.slack.event.* ;
import cokr.xit.ens.core.utils.* ;
import cokr.xit.ens.core.aop.EnsResponseVO ;
import cokr.xit.ens.core.utils.crypto.* ;
import cokr.xit.ens.core.exception.EnsException ;
import cokr.xit.ens.modules.common.biztmplt.* ;
import cokr.xit.ens.core.exception.code.EnsErrCd ;
import cokr.xit.ens.modules.common.code.* ;
import cokr.xit.ens.core.monitor.slack.event.MonitorEvent ;
import cokr.xit.ens.modules.common.ctgy.nicedici.service.* ;
import cokr.xit.ens.core.utils.CmmnUtil ;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.* ;
import cokr.xit.ens.core.utils.IdGenerator ;
import cokr.xit.ens.modules.common.ctgy.sys.mng.service.* ;
import cokr.xit.ens.core.utils.MapDeserailizer ;
import cokr.xit.ens.modules.common.domain.* ;
import cokr.xit.ens.core.utils.crypto.AES256 ;
import cokr.xit.ens.modules.common.domain.repository.* ;
import cokr.xit.ens.core.utils.crypto.Crypto ;
import cokr.xit.ens.modules.common.domain.support.* ;
import cokr.xit.ens.core.utils.crypto.SHA256 ;
import cokr.xit.ens.modules.common.event.* ;
import cokr.xit.ens.modules.common.biztmplt.MakeProcTemplate ;
import cokr.xit.ens.modules.common.monitor.* ;
import cokr.xit.ens.modules.common.code.PostSeCd ;
import cokr.xit.ens.modules.kkotalk.mapper.* ;
import cokr.xit.ens.modules.common.code.StatCd ;
import cokr.xit.ens.modules.kkotalk.model.* ;
import cokr.xit.ens.modules.common.ctgy.nicedici.service.NiceDiCiService ;
import cokr.xit.ens.modules.kkotalk.service.strategy.* ;
import cokr.xit.ens.modules.common.ctgy.sys.mng.domain.OrgMng ;
import lombok.* ;
import cokr.xit.ens.modules.common.ctgy.sys.mng.service.OrgMngService ;
import lombok.extern.slf4j.* ;
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.kkotalk.mapper.IKkoTalkMapper ;
import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO ;
import cokr.xit.ens.modules.kkotalk.model.TmpltMngKkoTalkDTO ;
import cokr.xit.ens.modules.kkotalk.service.strategy.TmpltMngStrategyKkoTalk ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import lombok.val ;
// FIXME: 카카오톡 신규 추가
// FIXME: 카카오톡 신규 추가
@Slf4j
@Slf4j
@ -74,8 +62,7 @@ public class KkoTalkMaker extends MakeProcTemplate {
sendDetails = kkoTalkMapper . findAllBySendMastId ( sendMastId ) ;
sendDetails = kkoTalkMapper . findAllBySendMastId ( sendMastId ) ;
SendMast finalSendMast = sendMast ;
SendMast finalSendMast = sendMast ;
OrgMng orgMng = orgMngService . find ( sendMast . getOrgCd ( ) ) . getResultInfo ( ) ;
OrgMng orgMng = orgMngService . find ( sendMast . getOrgCd ( ) ) . getResultInfo ( ) ;
// TmpltMngKkoMydoc tmpltMngDTO = tmpltMngRepository.findFetchByOrgCdAndTmpltCdAndUseYn(sendMast.getOrgCd(), sendMast.getTmpltCd(), "Y")
// .orElseThrow(() -> new EnsException(EnsErrCd.MAKE404, String.format("일치하는 템플릿 자료가 없거나 미사용 상태의 템플릿 입니다. [ sendMastId %s orgCd %s TmpltCd %s ]", sendMastId, finalSendMast.getOrgCd(), finalSendMast.getTmpltCd())));
TmpltMngKkoTalkDTO tmpltMngDTO = tmpltMngService . find ( sendMast . getOrgCd ( ) , sendMast . getTmpltCd ( ) )
TmpltMngKkoTalkDTO tmpltMngDTO = tmpltMngService . find ( sendMast . getOrgCd ( ) , sendMast . getTmpltCd ( ) )
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE404 , String . format ( "일치하는 템플릿 자료가 없습니다. [ sendMastId %s orgCd %s TmpltCd %s ]" , sendMastId , finalSendMast . getOrgCd ( ) , finalSendMast . getTmpltCd ( ) ) ) ) ;
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE404 , String . format ( "일치하는 템플릿 자료가 없습니다. [ sendMastId %s orgCd %s TmpltCd %s ]" , sendMastId , finalSendMast . getOrgCd ( ) , finalSendMast . getTmpltCd ( ) ) ) ) ;
if ( ! "Y" . equals ( tmpltMngDTO . getUseYn ( ) ) )
if ( ! "Y" . equals ( tmpltMngDTO . getUseYn ( ) ) )
@ -87,7 +74,6 @@ public class KkoTalkMaker extends MakeProcTemplate {
List < String > jids = sendDetails . stream ( )
List < String > jids = sendDetails . stream ( )
// .filter(row -> "Y".equals(row.getMkCiTransUseYn()))
// .filter(row -> "Y".equals(row.getMkCiTransUseYn()))
. filter ( row - > ! CmmnUtil . isEmpty ( row . getMkJid ( ) ) )
. filter ( row - > ! CmmnUtil . isEmpty ( row . getMkJid ( ) ) )
// .map(row -> row.getMkJid())
. map ( row - > aes256 . decrypt ( row . getMkJid ( ) ) )
. map ( row - > aes256 . decrypt ( row . getMkJid ( ) ) )
. collect ( Collectors . toList ( ) ) ;
. collect ( Collectors . toList ( ) ) ;
if ( ! CmmnUtil . isEmpty ( jids ) ) {
if ( ! CmmnUtil . isEmpty ( jids ) ) {
@ -128,11 +114,11 @@ public class KkoTalkMaker extends MakeProcTemplate {
String . format ( "name 생성에 실패 했습니다. [ orgCd %s tmpltCd %s]" ,
String . format ( "name 생성에 실패 했습니다. [ orgCd %s tmpltCd %s]" ,
tmpltMngDTO . getOrgCd ( ) , tmpltMngDTO . getTmpltCd ( ) ) ) ) ) ;
tmpltMngDTO . getOrgCd ( ) , tmpltMngDTO . getTmpltCd ( ) ) ) ) ) ;
}
}
//if ("Y".equals(tmpltMngDTO.getTmpltMsgUseYn())) {
if ( "Y" . equals ( tmpltMngDTO . getTmpltMsgUseYn ( ) ) ) {
// boolean usePryMsg = CmmnUtil.isEmpty(tmpltMngDTO.getPryMessage()) ? false : true;
boolean usePryMsg = CmmnUtil . isEmpty ( tmpltMngDTO . getPryMessage ( ) ) ? false : true ;
// row.setPropMessage(Optional.ofNullable(this.msgTmplateToMessage(usePryMsg, tmpltMngDTO, row.getMkTmpltMsgJsonData()))
row . setGuide ( Optional . ofNullable ( this . msgTmplateToMessage ( usePryMsg , tmpltMngDTO , row . getMkTmpltMsgJsonData ( ) ) )
// .orElseThrow(() -> new EnsException(EnsErrCd.MAKE521, String.format("propMessage 생성에 실패 했습니다. [ orgCd %s tmpltCd %s tmpltMsgJsonData %s ]", tmpltMngDTO.getOrgCd(), tmpltMngDTO.getTmpltCd(), row.getMkTmpltMsgJsonData()))));
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE521 , String . format ( "propMessage 생성에 실패 했습니다. [ orgCd %s tmpltCd %s tmpltMsgJsonData %s ]" , tmpltMngDTO . getOrgCd ( ) , tmpltMngDTO . getTmpltCd ( ) , row . getMkTmpltMsgJsonData ( ) ) ) ) ) ;
//}
}
if ( CmmnUtil . isEmpty ( row . getExternalId ( ) ) )
if ( CmmnUtil . isEmpty ( row . getExternalId ( ) ) )
row . setExternalId ( Optional . ofNullable ( IdGenerator . getUUID ( ) )
row . setExternalId ( Optional . ofNullable ( IdGenerator . getUUID ( ) )
@ -145,10 +131,10 @@ public class KkoTalkMaker extends MakeProcTemplate {
row . setHash ( Optional . ofNullable ( this . createHash ( row ) )
row . setHash ( Optional . ofNullable ( this . createHash ( row ) )
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE521 , String . format ( "hash 생성에 실패 했습니다." ) ) ) ) ;
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE521 , String . format ( "hash 생성에 실패 했습니다." ) ) ) ) ;
//if ("Y".equals(tmpltMngDTO.getCiTransUseYn()) && !CmmnUtil.isEmpty(row.getMkJid()))
if ( "Y" . equals ( tmpltMngDTO . getCiTransUseYn ( ) ) & & ! CmmnUtil . isEmpty ( row . getMkJid ( ) ) )
// row.setRecvCi(Optional.ofNullable(finalMCi.get(aes256.decrypt(row.getMkJid()).replaceAll("[^0-9]", "")))
row . setCi ( Optional . ofNullable ( finalMCi . get ( aes256 . decrypt ( row . getMkJid ( ) ) . replaceAll ( "[^0-9]" , "" ) ) )
// .map(ci -> CmmnUtil.isEmpty(ci) ? null : ci)
. map ( ci - > CmmnUtil . isEmpty ( ci ) ? null : ci )
// .orElseThrow(() -> new EnsException(EnsErrCd.MAKE610, String.format("recvCi 생성에 실패 했습니다. 주민번호에 대한 CI 값이 없습니다. [ jid %s ]", aes256.decrypt(row.getMkJid())))));
. orElseThrow ( ( ) - > new EnsException ( EnsErrCd . MAKE610 , String . format ( "recvCi 생성에 실패 했습니다. 주민번호에 대한 CI 값이 없습니다. [ jid %s ]" , aes256 . decrypt ( row . getMkJid ( ) ) ) ) ) ) ;
//row.setError(FieldError.initBuilder().build());
//row.setError(FieldError.initBuilder().build());
return 1 ;
return 1 ;
@ -191,7 +177,7 @@ public class KkoTalkMaker extends MakeProcTemplate {
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 . kko Mydoc )
. postSeCd ( PostSeCd . kko Talk )
. statCd ( StatCd . makefail )
. statCd ( StatCd . makefail )
. errCd ( respVO . getErrCode ( ) )
. errCd ( respVO . getErrCode ( ) )
. message ( "-.SendMastId: " + sendMastId + "\n" + respVO . getErrMsg ( ) )
. message ( "-.SendMastId: " + sendMastId + "\n" + respVO . getErrMsg ( ) )