|
|
|
@ -9,6 +9,8 @@ import java.util.Arrays;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
|
|
|
import javax.validation.Validation;
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
@ -88,6 +90,8 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
|
|
|
|
|
// 템플릿 정보 조회
|
|
|
|
|
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
|
|
|
|
|
checkValidated(fmcExcels);
|
|
|
|
|
|
|
|
|
|
final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(
|
|
|
|
|
fmcExcels.get(0).getTmplatId())
|
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
@ -99,10 +103,13 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
fileReq.setPostDlvrSe(tmpDTO.getPostDlvrSe());
|
|
|
|
|
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
|
|
|
|
|
|
List<FmcInfExcelRslt> rslts = getConvertCis(fileReq, fmcExcels);
|
|
|
|
|
List<FmcInfExcelRslt> ciRslts = null;
|
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", fmcExcels.get(0).getTmplatId())) {
|
|
|
|
|
ciRslts = getConvertCis(fileReq, fmcExcels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CNTC 테이블 insert
|
|
|
|
|
final String rtnMsg = makeCntc(rslts, fmcExcels, fileReq);
|
|
|
|
|
final String rtnMsg = makeCntc(ciRslts, fmcExcels, fileReq);
|
|
|
|
|
fileReq.setPostDlvrSe(null);
|
|
|
|
|
fileReq.setSignguCode(null);
|
|
|
|
|
fileReq.setFfnlgCode(null);
|
|
|
|
@ -126,6 +133,9 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
return mapper.selectSndngResultDetails(reqDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// private method
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
private List<FmcInfExcel> parsingFmcExcel(MultipartFile mf) {
|
|
|
|
|
final List<FmcInfExcel> fmcExcels = new ArrayList<>();
|
|
|
|
|
|
|
|
|
@ -213,7 +223,7 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}catch (IOException ie){
|
|
|
|
|
|
|
|
|
|
throw BizRuntimeException.create(ie.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return fmcExcels;
|
|
|
|
|
}
|
|
|
|
@ -247,7 +257,8 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* 전자고지 대상 CI 변환
|
|
|
|
|
* 전자고지 대상 CI 변환 : 카카오, KT-BC인 경우만 필요
|
|
|
|
|
* -> tmplatId(우편물발송구분)의 마지막 자리가 1 또는 2인 경우만
|
|
|
|
|
* -> 실패시 code, message에 에러 set
|
|
|
|
|
* @param fileReq FmcExcelUpload
|
|
|
|
|
* @param fmcExcels List<FmcInfExcel>
|
|
|
|
@ -259,6 +270,7 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
int errCnt = 0;
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
IpinCiResDataBody dataBody = niceCiService.requestCi(
|
|
|
|
|
NiceCiRequest.builder()
|
|
|
|
@ -292,7 +304,7 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
|
|
|
|
|
if(fmcExcels.size() != rslts.size()) throw BizRuntimeException.create(
|
|
|
|
|
String.format(
|
|
|
|
|
"CI 전환 오류 %s[변환대상-%d건, 변환완료-%d건, 변환오류-%d건]",
|
|
|
|
|
"CI 전환 오류[변환대상-%d건, 변환완료-%d건, 변환오류-%d건]",
|
|
|
|
|
fmcExcels.size(),
|
|
|
|
|
rslts.size()-errCnt,
|
|
|
|
|
errCnt)
|
|
|
|
@ -304,11 +316,11 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
* <pre>
|
|
|
|
|
* 전자고지 대상(CNTC) 생성
|
|
|
|
|
* -> 실패시 code, message에 에러 set
|
|
|
|
|
* @param rslts List<FmcInfExcelRslt>
|
|
|
|
|
* @param ciRslts List<FmcInfExcelRslt>
|
|
|
|
|
* @return String
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private String makeCntc(final List<FmcInfExcelRslt> rslts, final List<FmcInfExcel> fmcExcels, FmcExcelUpload fileReq){
|
|
|
|
|
private String makeCntc(final List<FmcInfExcelRslt> ciRslts, final List<FmcInfExcel> fmcExcels, FmcExcelUpload fileReq){
|
|
|
|
|
int mst = 0;
|
|
|
|
|
int errCnt = 0;
|
|
|
|
|
String mpc = null;
|
|
|
|
@ -383,20 +395,56 @@ public class BizSisulService extends EgovAbstractServiceImpl implements IBizSisu
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcelRslt dto : rslts){
|
|
|
|
|
if(Checks.isNotEmpty(ciRslts)) {
|
|
|
|
|
for(FmcInfExcelRslt dto : ciRslts) {
|
|
|
|
|
if(StringUtils.isEmpty(String.join("", dto.getCi1(), dto.getCi2()))) {
|
|
|
|
|
errCnt++;
|
|
|
|
|
}
|
|
|
|
|
mapper.insertCi(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return String.format(
|
|
|
|
|
"전자고지 대상 %d건 Upload[완료-%d건, 오류-%d건]",
|
|
|
|
|
rslts.size(),
|
|
|
|
|
rslts.size()-errCnt,
|
|
|
|
|
fmcExcels.size(),
|
|
|
|
|
fmcExcels.size()-errCnt,
|
|
|
|
|
errCnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void checkValidated(List<FmcInfExcel> fmcExcels){
|
|
|
|
|
AtomicInteger idx = new AtomicInteger(1);
|
|
|
|
|
fmcExcels.forEach(d -> {
|
|
|
|
|
if(Checks.isEmpty(d.getUnitySndngMastrId()) || d.getUnitySndngMastrId().length() > 20){
|
|
|
|
|
throw BizRuntimeException.create("fail.api.excel.upload.data", new String[]{
|
|
|
|
|
String.valueOf(idx.get()), "unitySndngMastrId(파일유일키)", "필수(최대 20자)", d.getUnitySndngMastrId()});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Checks.isEmpty(d.getUnitySndngDetailId()) || d.getUnitySndngDetailId().length() > 20){
|
|
|
|
|
throw BizRuntimeException.create("fail.api.excel.upload.data", new String[]{
|
|
|
|
|
String.valueOf(idx.get()), "unitySndngDetailId(파일유일키)", "필수(최대 20자)", d.getUnitySndngDetailId()});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Checks.isEmpty(d.getSndngDt()) || d.getSndngDt().length() != 14 || !Pattern.matches("20([2-9][0-9][0-1][1-9][0-2][0-9][0-2][0-9][0-5][0-9][0-5][0-9])", d.getSndngDt())){
|
|
|
|
|
throw BizRuntimeException.create("fail.api.excel.upload.data", new String[]{
|
|
|
|
|
String.valueOf(idx.get()), "sndngDt(우편물요청일시)", "필수(14자)", d.getSndngDt()});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Checks.isEmpty(d.getTmplatId()) || d.getTmplatId().length() != 5){
|
|
|
|
|
throw BizRuntimeException.create("fail.api.excel.upload.data", new String[]{
|
|
|
|
|
String.valueOf(idx.get()), "tmplatId(우편물발송구분)", "필수(5자)", d.getTmplatId()});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// KAKAO or KT-BC의 경우에만 주민번호 필요
|
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", d.getTmplatId())){
|
|
|
|
|
if(Checks.isEmpty(d.getRecveJuminno()) || d.getRecveJuminno().length() != 13){
|
|
|
|
|
throw BizRuntimeException.create("fail.api.excel.upload.data", new String[]{
|
|
|
|
|
String.valueOf(idx.get()), "recveJuminno(수취인주민번호)", "필수(13자리)", d.getRecveJuminno()});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
idx.getAndIncrement();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String jsonCn1(FmcInfExcel dto){
|
|
|
|
|
String jsonCn = "{"
|
|
|
|
|