|
|
|
@ -46,13 +46,30 @@ public class NiceCiStatBulkService {
|
|
|
|
|
|
|
|
|
|
private final INiceCiMapper niceCiMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* -- 1. 대상 조회
|
|
|
|
|
* SELECT *
|
|
|
|
|
* FROM tb_input_xit tix
|
|
|
|
|
* WHERE tix.send_type='NI'
|
|
|
|
|
* AND tix.prcs_cd='IPCP';
|
|
|
|
|
*
|
|
|
|
|
* -- 2.결과 INSERT OR UPDATE tb_send_result
|
|
|
|
|
* SELECT * FROM tb_send_result;
|
|
|
|
|
* send_sttus_cd 발송 처리 코드
|
|
|
|
|
* TALK_SEND 카카오 알림톡 발송 성공
|
|
|
|
|
* SMS_SEND KT 문자 발송 성공
|
|
|
|
|
* FAIL 발송 실패
|
|
|
|
|
* @return EnsResponseVO
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
public EnsResponseVO<?> findBulkStatus() {
|
|
|
|
|
final NiceCiDTO.NiceCiParam niceCiParam = NiceCiDTO.NiceCiParam.builder()
|
|
|
|
|
.sendType(IupSendTypeCd.NI.getCode())
|
|
|
|
|
.prcsCd(IupPrcsCd.IPCP.getCode())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectNiceCiTgts(niceCiParam);
|
|
|
|
|
final List<NiceCiDTO.InputXit> list = niceCiMapper.selectInputXits(niceCiParam);
|
|
|
|
|
if(list.isEmpty()){
|
|
|
|
|
return EnsResponseVO.errBuilder()
|
|
|
|
|
.errCode(EnsErrCd.ERR404)
|
|
|
|
@ -62,7 +79,7 @@ public class NiceCiStatBulkService {
|
|
|
|
|
|
|
|
|
|
list.forEach(d -> {
|
|
|
|
|
niceCiParam.setLnkInputId(d.getLnkInputId());
|
|
|
|
|
d.setInputDataXits(niceCiMapper.selectNiceCiAcceptDatas(niceCiParam));
|
|
|
|
|
d.setInputDataXits(niceCiMapper.selectInputDataXits(niceCiParam));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for(NiceCiDTO.InputXit xit : list) {
|
|
|
|
@ -70,6 +87,8 @@ public class NiceCiStatBulkService {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
List<NiceCiDTO.InputDataXit> inputDataXits = xit.getInputDataXits();
|
|
|
|
|
NiceCiDTO.SendResult sendResult = null;
|
|
|
|
|
|
|
|
|
|
for (NiceCiDTO.InputDataXit data : inputDataXits) {
|
|
|
|
|
|
|
|
|
|
// 기관전문관리번호, TB_NICE_SMS_SNDNG_REQUEST - NICE_SMS_SNDNG_REQUST_ID
|
|
|
|
@ -77,7 +96,9 @@ public class NiceCiStatBulkService {
|
|
|
|
|
() -> new EnsException(EnsErrCd.MAKE521, EnsErrCd.MAKE521.getCodeNm())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
NiceCiApiStatusDTO.Request ciRequest = new NiceCiApiStatusDTO.Request();
|
|
|
|
|
// 검색기간 (from ~ to) 조회 및 SET
|
|
|
|
|
NiceCiApiStatusDTO.Request ciRequest = niceCiMapper.selectFromAndToOfStatusParam(niceCiParam)
|
|
|
|
|
.orElseThrow(() -> new EnsException(EnsErrCd.MAKE521, "검색기간 설정 조회 실패"));
|
|
|
|
|
NiceCiApiCommon nCommon = new NiceCiApiCommon();
|
|
|
|
|
|
|
|
|
|
// 공통부 set
|
|
|
|
@ -87,27 +108,21 @@ public class NiceCiStatBulkService {
|
|
|
|
|
// 개별요청부 set
|
|
|
|
|
setNiceCiApiPrivateReq(ciRequest);
|
|
|
|
|
|
|
|
|
|
// API request 저장
|
|
|
|
|
ciRequest.setNiceSmsSndngInqireId(niceSmsInqId);
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireRequest(ciRequest);
|
|
|
|
|
|
|
|
|
|
EnsResponseVO<?> responseVO = niceCiApiService.findBulkStatus(ciRequest);
|
|
|
|
|
if (!EnsErrCd.OK.equals(responseVO.getErrCode()))
|
|
|
|
|
throw new EnsException(responseVO.getErrCode(), responseVO.getErrMsg());
|
|
|
|
|
|
|
|
|
|
NiceCiApiStatusDTO.Response resDTO = (NiceCiApiStatusDTO.Response)responseVO.getResultInfo();
|
|
|
|
|
resDTO.setNiceSmsSndngInqireId(niceSmsInqId);
|
|
|
|
|
|
|
|
|
|
// API response 저장
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireResponse(resDTO);
|
|
|
|
|
int totCo = 0;
|
|
|
|
|
int repeat = 0;
|
|
|
|
|
do {
|
|
|
|
|
ciRequest.setAccmltRecptnCo(Integer.toString(repeat));
|
|
|
|
|
NiceCiApiStatusDTO.Response resDTO = repeatStatusBulk(
|
|
|
|
|
ciRequest,
|
|
|
|
|
xit,
|
|
|
|
|
data
|
|
|
|
|
//sendResult
|
|
|
|
|
);
|
|
|
|
|
if(totCo == 0) totCo = Integer.parseInt(resDTO.getTotCo());
|
|
|
|
|
repeat += 100;
|
|
|
|
|
} while(totCo > 100 && totCo > repeat);
|
|
|
|
|
|
|
|
|
|
// API response 반복부 저장
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireResponseRepeat(
|
|
|
|
|
resDTO.getNiceCiResults()
|
|
|
|
|
.stream().peek(d -> d.setNiceSmsSndngInqireId(niceSmsInqId))
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
log.info(responseVO.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (EnsException e) {
|
|
|
|
|
// FIXME : API 통신에러 인경우 skip - 재시도 되어야
|
|
|
|
@ -205,12 +220,82 @@ public class NiceCiStatBulkService {
|
|
|
|
|
// 개별요청부 : default end
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ciRequest.setSearchPdFrom(DateUtil.getNowTimeMicrosecond()); // 검색기간 - from
|
|
|
|
|
ciRequest.setSearchPdTo(DateUtil.getNowTimeMicrosecond()); // 검색기간 - to
|
|
|
|
|
ciRequest.setRequstCo("?"); // 요청건수
|
|
|
|
|
//ciRequest.setAccmltRecptnCo(); // 누적수신건수
|
|
|
|
|
// selectFromAndToOfStatusParam 에서 SET
|
|
|
|
|
// ciRequest.setSearchPdFrom(DateUtil.getNowTimeMicrosecond()); // 검색기간 - from
|
|
|
|
|
// ciRequest.setSearchPdTo(DateUtil.getNowTimeMicrosecond()); // 검색기간 - to
|
|
|
|
|
ciRequest.setRequstCo("100"); // 요청건수
|
|
|
|
|
ciRequest.setAccmltRecptnCo("0000000000"); // 누적수신건수
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
// 개별요청부 END
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private NiceCiApiStatusDTO.Response repeatStatusBulk(
|
|
|
|
|
NiceCiApiStatusDTO.Request ciRequest,
|
|
|
|
|
NiceCiDTO.InputXit xit,
|
|
|
|
|
NiceCiDTO.InputDataXit data){
|
|
|
|
|
// 기관전문관리번호, TB_NICE_SMS_SNDNG_REQUEST - NICE_SMS_SNDNG_REQUST_ID
|
|
|
|
|
final String niceSmsInqId = niceCiMapper.selectNiceCiInqireId().orElseThrow(
|
|
|
|
|
() -> new EnsException(EnsErrCd.MAKE521, EnsErrCd.MAKE521.getCodeNm())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// API Call 전처리 START - request & 결과테이블 저장
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
ciRequest.setNiceSmsSndngInqireId(niceSmsInqId);
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireRequest(ciRequest);
|
|
|
|
|
|
|
|
|
|
NiceCiDTO.SendResult sendResult = NiceCiDTO.SendResult.builder()
|
|
|
|
|
.lnkInputId(xit.getLnkInputId())
|
|
|
|
|
.dataId(data.getDataId())
|
|
|
|
|
.prcsOdr("1")
|
|
|
|
|
.sendType(xit.getSendType())
|
|
|
|
|
.runDt(xit.getRunDt())
|
|
|
|
|
.expiresDt(xit.getExpiresDt())
|
|
|
|
|
.prcsYn("N")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
// 결과 테이블 데이타 생성 or update
|
|
|
|
|
niceCiMapper.mergeSendResult(sendResult);
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// API Call 전처리 END - request & 결과테이블 저장
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// Status API call & Get Result START
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
EnsResponseVO<?> responseVO = niceCiApiService.findBulkStatus(ciRequest);
|
|
|
|
|
if (!EnsErrCd.OK.equals(responseVO.getErrCode()))
|
|
|
|
|
throw new EnsException(responseVO.getErrCode(), responseVO.getErrMsg());
|
|
|
|
|
|
|
|
|
|
NiceCiApiStatusDTO.Response resDTO = (NiceCiApiStatusDTO.Response)responseVO.getResultInfo();
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// Status API call & Get Result END
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// API Call 후처리 START - response & 결과테이블 저장
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// API response 저장
|
|
|
|
|
resDTO.setNiceSmsSndngInqireId(niceSmsInqId);
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireResponse(resDTO);
|
|
|
|
|
|
|
|
|
|
// API response 반복부 저장
|
|
|
|
|
niceCiMapper.insertNiceSmsSndngInquireResponseRepeat(
|
|
|
|
|
resDTO.getNiceCiResults()
|
|
|
|
|
.stream().peek(d -> d.setNiceSmsSndngInqireId(niceSmsInqId))
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: 아래 값으로 set
|
|
|
|
|
//mssageSndngResultSe 1 -> TALK_SEND, 2 -> SMS_SEND, FAIL
|
|
|
|
|
// 결과 테이블 데이타 update
|
|
|
|
|
sendResult.setSendSttusCd("");
|
|
|
|
|
niceCiMapper.mergeSendResult(sendResult);
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
// API Call 후처리 END - response & 결과테이블 저장
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
return resDTO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|