|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
|
|
|
import javax.validation.Validation;
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
@ -81,6 +82,7 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public String fmcExcelUpload(FmcExcelUpload fileReq) {
|
|
|
|
|
String rtnMsg = "";
|
|
|
|
|
final Set<ConstraintViolation<FmcExcelUpload>> errors = validator.validate(fileReq);
|
|
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
|
throw BizRuntimeException.create(errors.stream()
|
|
|
|
@ -92,27 +94,64 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
|
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
|
|
|
|
|
checkValidated(fmcExcels);
|
|
|
|
|
|
|
|
|
|
final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(
|
|
|
|
|
fmcExcels.get(0).getTmplatId())
|
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
|
List<String> unitySndngMastrIds = fmcExcels.stream().map(FmcInfExcel::getUnitySndngMastrId).collect(Collectors.toList());
|
|
|
|
|
for (String unitySndngMastrId : unitySndngMastrIds){
|
|
|
|
|
String tmplatId = "";
|
|
|
|
|
int excelCnt = 0;
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels){
|
|
|
|
|
if(unitySndngMastrId.equals(dto.getUnitySndngMastrId())){
|
|
|
|
|
excelCnt++;
|
|
|
|
|
if("".equals(tmplatId)) tmplatId = dto.getTmplatId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ci 변환
|
|
|
|
|
fileReq.setSignguCode(tmpDTO.getSignguCode());
|
|
|
|
|
fileReq.setFfnlgCode(tmpDTO.getFfnlgCode());
|
|
|
|
|
fileReq.setTry1(tmpDTO.getTry1());
|
|
|
|
|
fileReq.setPostDlvrSe(tmpDTO.getPostDlvrSe());
|
|
|
|
|
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
|
final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(tmplatId)
|
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
|
|
|
|
|
|
List<FmcInfExcelRslt> ciRslts = null;
|
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", fmcExcels.get(0).getTmplatId())) {
|
|
|
|
|
ciRslts = getConvertCis(fileReq, fmcExcels);
|
|
|
|
|
}
|
|
|
|
|
// Ci 변환
|
|
|
|
|
fileReq.setSignguCode(tmpDTO.getSignguCode());
|
|
|
|
|
fileReq.setFfnlgCode(tmpDTO.getFfnlgCode());
|
|
|
|
|
fileReq.setTry1(tmpDTO.getTry1());
|
|
|
|
|
fileReq.setPostDlvrSe(tmpDTO.getPostDlvrSe());
|
|
|
|
|
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
|
|
|
|
|
|
// CNTC 테이블 insert
|
|
|
|
|
final String rtnMsg = makeCntc(ciRslts, fmcExcels, fileReq);
|
|
|
|
|
fileReq.setPostDlvrSe(null);
|
|
|
|
|
fileReq.setSignguCode(null);
|
|
|
|
|
fileReq.setFfnlgCode(null);
|
|
|
|
|
List<FmcInfExcelRslt> ciRslts = null;
|
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", tmplatId)) {
|
|
|
|
|
ciRslts = getConvertCis(fileReq, fmcExcels, unitySndngMastrId, excelCnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CNTC 테이블 insert
|
|
|
|
|
final String rtnMsgSub = makeCntc(ciRslts, fmcExcels, fileReq, unitySndngMastrId, excelCnt);
|
|
|
|
|
fileReq.setSignguCode(null);
|
|
|
|
|
fileReq.setFfnlgCode(null);
|
|
|
|
|
fileReq.setTry1(null);
|
|
|
|
|
fileReq.setPostDlvrSe(null);
|
|
|
|
|
fileReq.setPostTmplatCode(null);
|
|
|
|
|
if("".equals(rtnMsg)) rtnMsg = unitySndngMastrId + ":" + rtnMsgSub;
|
|
|
|
|
if(!"".equals(rtnMsg)) rtnMsg = rtnMsg + ", " + unitySndngMastrId + ":" + rtnMsgSub;
|
|
|
|
|
}
|
|
|
|
|
// final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(
|
|
|
|
|
// fmcExcels.get(0).getTmplatId())
|
|
|
|
|
// .orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
|
//
|
|
|
|
|
// // Ci 변환
|
|
|
|
|
// fileReq.setSignguCode(tmpDTO.getSignguCode());
|
|
|
|
|
// fileReq.setFfnlgCode(tmpDTO.getFfnlgCode());
|
|
|
|
|
// fileReq.setTry1(tmpDTO.getTry1());
|
|
|
|
|
// fileReq.setPostDlvrSe(tmpDTO.getPostDlvrSe());
|
|
|
|
|
// fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
|
//
|
|
|
|
|
// 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(ciRslts, fmcExcels, fileReq);
|
|
|
|
|
// fileReq.setPostDlvrSe(null);
|
|
|
|
|
// fileReq.setSignguCode(null);
|
|
|
|
|
// fileReq.setFfnlgCode(null);
|
|
|
|
|
return rtnMsg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -265,47 +304,49 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
|
* @return List<FmcInfExcelRslt>
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private List<FmcInfExcelRslt> getConvertCis(final FmcExcelUpload fileReq, final List<FmcInfExcel> fmcExcels){
|
|
|
|
|
private List<FmcInfExcelRslt> getConvertCis(final FmcExcelUpload fileReq, final List<FmcInfExcel> fmcExcels, final String unitySndngMastrId, final int excelCnt){
|
|
|
|
|
List<FmcInfExcelRslt> rslts = new ArrayList<>();
|
|
|
|
|
int errCnt = 0;
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
IpinCiResDataBody dataBody = niceCiService.requestCi(
|
|
|
|
|
NiceCiRequest.builder()
|
|
|
|
|
.signguCode(fileReq.getSignguCode())
|
|
|
|
|
.ffnlgCode(fileReq.getFfnlgCode())
|
|
|
|
|
.juminId(dto.getRecveJuminno())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
IpinCiResEncData resEncData = dataBody.toEncData();
|
|
|
|
|
rslts.add(
|
|
|
|
|
FmcInfExcelRslt.builder()
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.ci1(resEncData.getCi1())
|
|
|
|
|
.ci2(resEncData.getCi2())
|
|
|
|
|
.resultCd(dataBody.getResultCd())
|
|
|
|
|
.message(CmmNiceCiUtils.getFromResultCd(NiceCiWrkDiv.CI, dataBody.getResultCd()))
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
} catch (BizRuntimeException e){
|
|
|
|
|
errCnt++;
|
|
|
|
|
rslts.add(
|
|
|
|
|
FmcInfExcelRslt.builder()
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.resultCd(e.getCode())
|
|
|
|
|
.message(e.getMessage())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
|
if(unitySndngMastrId.equals(dto.getUnitySndngMastrId())){
|
|
|
|
|
try {
|
|
|
|
|
IpinCiResDataBody dataBody = niceCiService.requestCi(
|
|
|
|
|
NiceCiRequest.builder()
|
|
|
|
|
.signguCode(fileReq.getSignguCode())
|
|
|
|
|
.ffnlgCode(fileReq.getFfnlgCode())
|
|
|
|
|
.juminId(dto.getRecveJuminno())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
IpinCiResEncData resEncData = dataBody.toEncData();
|
|
|
|
|
rslts.add(
|
|
|
|
|
FmcInfExcelRslt.builder()
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.ci1(resEncData.getCi1())
|
|
|
|
|
.ci2(resEncData.getCi2())
|
|
|
|
|
.resultCd(dataBody.getResultCd())
|
|
|
|
|
.message(CmmNiceCiUtils.getFromResultCd(NiceCiWrkDiv.CI, dataBody.getResultCd()))
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
} catch (BizRuntimeException e){
|
|
|
|
|
errCnt++;
|
|
|
|
|
rslts.add(
|
|
|
|
|
FmcInfExcelRslt.builder()
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.resultCd(e.getCode())
|
|
|
|
|
.message(e.getMessage())
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fileReq.setSndngCo(fmcExcels.size());
|
|
|
|
|
fileReq.setSndngCo(excelCnt);
|
|
|
|
|
|
|
|
|
|
if(fmcExcels.size() != rslts.size()) throw BizRuntimeException.create(
|
|
|
|
|
if(excelCnt != rslts.size()) throw BizRuntimeException.create(
|
|
|
|
|
String.format(
|
|
|
|
|
"CI 전환 오류[변환대상-%d건, 변환완료-%d건, 변환오류-%d건]",
|
|
|
|
|
fmcExcels.size(),
|
|
|
|
|
excelCnt,
|
|
|
|
|
rslts.size()-errCnt,
|
|
|
|
|
errCnt)
|
|
|
|
|
);
|
|
|
|
@ -320,79 +361,81 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
|
* @return String
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private String makeCntc(final List<FmcInfExcelRslt> ciRslts, final List<FmcInfExcel> fmcExcels, FmcExcelUpload fileReq){
|
|
|
|
|
private String makeCntc(final List<FmcInfExcelRslt> ciRslts, final List<FmcInfExcel> fmcExcels, FmcExcelUpload fileReq, final String unitySndngMastrId, final int excelCnt){
|
|
|
|
|
int mst = 0;
|
|
|
|
|
int errCnt = 0;
|
|
|
|
|
String mpc = null;
|
|
|
|
|
final int excelCnt = fmcExcels.size();
|
|
|
|
|
final String register = StringUtils.defaultString(fileReq.getRegister(),"");
|
|
|
|
|
String unitySndngMastrId = "";
|
|
|
|
|
// String unitySndngMastrId = "";
|
|
|
|
|
String[] ppMasterJson = new String[2];
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels){
|
|
|
|
|
//최초 1회 CNTC master 생성
|
|
|
|
|
if(StringUtils.isNotEmpty(dto.getUnitySndngMastrId()) && mst == 0){
|
|
|
|
|
unitySndngMastrId = dto.getUnitySndngMastrId();
|
|
|
|
|
fileReq.setUnitySndngMastrId(unitySndngMastrId);
|
|
|
|
|
mapper.insertCntcSndngMst(
|
|
|
|
|
CntcDTO.SndngMst.builder()
|
|
|
|
|
.unitySndngMastrId(dto.getUnitySndngMastrId())
|
|
|
|
|
.tmplatId(dto.getTmplatId())
|
|
|
|
|
.sndngDt(dto.getSndngDt())
|
|
|
|
|
.closDt(dto.getNapPd() + "235959")
|
|
|
|
|
.sndngCo(excelCnt)
|
|
|
|
|
.sndngProcessSttus(ApiConstants.SndngProcessStatus.ACCEPT.getCode())
|
|
|
|
|
.register(register)
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
mst++;
|
|
|
|
|
|
|
|
|
|
// POST-PLUS(전자우편) 일 경우 tb_ens_post_plus_json 테이블 insert
|
|
|
|
|
if("POST-PLUS".equals(fileReq.getTry1())){
|
|
|
|
|
//최초 1회 POST-PLUS master json 생성
|
|
|
|
|
if(mst == 1){
|
|
|
|
|
ppMasterJson = PPMasterJson(dto, fileReq, excelCnt);
|
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
|
if(unitySndngMastrId.equals(dto.getUnitySndngMastrId())){
|
|
|
|
|
//최초 1회 CNTC master 생성
|
|
|
|
|
// if(StringUtils.isNotEmpty(dto.getUnitySndngMastrId()) && mst == 0){
|
|
|
|
|
// unitySndngMastrId = dto.getUnitySndngMastrId();
|
|
|
|
|
if(mst == 0){
|
|
|
|
|
fileReq.setUnitySndngMastrId(unitySndngMastrId);
|
|
|
|
|
mapper.insertCntcSndngMst(
|
|
|
|
|
CntcDTO.SndngMst.builder()
|
|
|
|
|
.unitySndngMastrId(dto.getUnitySndngMastrId())
|
|
|
|
|
.tmplatId(dto.getTmplatId())
|
|
|
|
|
.sndngDt(dto.getSndngDt())
|
|
|
|
|
.closDt(dto.getNapPd() + "235959")
|
|
|
|
|
.sndngCo(excelCnt)
|
|
|
|
|
.sndngProcessSttus(ApiConstants.SndngProcessStatus.ACCEPT.getCode())
|
|
|
|
|
.register(register)
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
mst++;
|
|
|
|
|
|
|
|
|
|
// POST-PLUS(전자우편) 일 경우 tb_ens_post_plus_json 테이블 insert
|
|
|
|
|
if("POST-PLUS".equals(fileReq.getTry1())){
|
|
|
|
|
//최초 1회 POST-PLUS master json 생성
|
|
|
|
|
if(mst == 1){
|
|
|
|
|
ppMasterJson = PPMasterJson(dto, fileReq, excelCnt);
|
|
|
|
|
}
|
|
|
|
|
String ppDetailJson[] = PPDetailJson(Integer.toString(mst),dto, fileReq.getSignguCode());
|
|
|
|
|
mapper.insertPostPlusJson(
|
|
|
|
|
CntcDTO.PostPlusJson.builder()
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.serviceCd("PST")
|
|
|
|
|
.conKey(unitySndngMastrId)
|
|
|
|
|
.sn(Integer.toString(mst))
|
|
|
|
|
.masterCols(ppMasterJson[0])
|
|
|
|
|
.masterRows(ppMasterJson[1])
|
|
|
|
|
.detailCols(ppDetailJson[0])
|
|
|
|
|
.detailRows(jasyptStringEncryptor.encrypt(ppDetailJson[1]))
|
|
|
|
|
.register(register)
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}else {
|
|
|
|
|
switch (fileReq.getSignguCode()) {
|
|
|
|
|
case "88328": //교통시설운영처
|
|
|
|
|
mpc = jsonCn1(dto);
|
|
|
|
|
break;
|
|
|
|
|
case "88316": //추모시설운영처
|
|
|
|
|
mpc = jsonCn2(dto);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String ppDetailJson[] = PPDetailJson(Integer.toString(mst),dto, fileReq.getSignguCode());
|
|
|
|
|
mapper.insertPostPlusJson(
|
|
|
|
|
CntcDTO.PostPlusJson.builder()
|
|
|
|
|
//CNTC detail 생성
|
|
|
|
|
mapper.insertCntcSndngDtl(
|
|
|
|
|
CntcDTO.SndngDtl.builder()
|
|
|
|
|
.unitySndngMastrId(unitySndngMastrId)
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.serviceCd("PST")
|
|
|
|
|
.conKey(unitySndngMastrId)
|
|
|
|
|
.sn(Integer.toString(mst))
|
|
|
|
|
.masterCols(ppMasterJson[0])
|
|
|
|
|
.masterRows(ppMasterJson[1])
|
|
|
|
|
.detailCols(ppDetailJson[0])
|
|
|
|
|
.detailRows(jasyptStringEncryptor.encrypt(ppDetailJson[1]))
|
|
|
|
|
.tmplatId(dto.getTmplatId())
|
|
|
|
|
.mainCode(dto.getTaxNum1()+dto.getTaxNum2()+dto.getTaxNum3()+dto.getTaxNum4()) // 납세번호로 자료 찾기
|
|
|
|
|
.tmpltMsgData(dto.getNapAmountTotal()) // 고객사 요청 사항 납부금액 표기
|
|
|
|
|
.useInsttIdntfcId(dto.getGojiDetailNm()) // 교통시설운영처 제목 가변 항목
|
|
|
|
|
.mobilePageCn(mpc)
|
|
|
|
|
.register(register)
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}else {
|
|
|
|
|
switch (fileReq.getSignguCode()) {
|
|
|
|
|
case "88328": //교통시설운영처
|
|
|
|
|
mpc = jsonCn1(dto);
|
|
|
|
|
break;
|
|
|
|
|
case "88316": //추모시설운영처
|
|
|
|
|
mpc = jsonCn2(dto);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//CNTC detail 생성
|
|
|
|
|
mapper.insertCntcSndngDtl(
|
|
|
|
|
CntcDTO.SndngDtl.builder()
|
|
|
|
|
.unitySndngMastrId(unitySndngMastrId)
|
|
|
|
|
.unitySndngDetailId(dto.getUnitySndngDetailId())
|
|
|
|
|
.tmplatId(dto.getTmplatId())
|
|
|
|
|
.mainCode(dto.getTaxNum1()+dto.getTaxNum2()+dto.getTaxNum3()+dto.getTaxNum4()) // 납세번호로 자료 찾기
|
|
|
|
|
.tmpltMsgData(dto.getNapAmountTotal()) // 고객사 요청 사항 납부금액 표기
|
|
|
|
|
.useInsttIdntfcId(dto.getGojiDetailNm()) // 교통시설운영처 제목 가변 항목
|
|
|
|
|
.mobilePageCn(mpc)
|
|
|
|
|
.register(register)
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Checks.isNotEmpty(ciRslts)) {
|
|
|
|
@ -404,10 +447,11 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return String.format(
|
|
|
|
|
"전자고지 대상 %d건 Upload[완료-%d건, 오류-%d건]",
|
|
|
|
|
fmcExcels.size(),
|
|
|
|
|
fmcExcels.size()-errCnt,
|
|
|
|
|
excelCnt,
|
|
|
|
|
excelCnt-errCnt,
|
|
|
|
|
errCnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|