|
|
@ -11,6 +11,7 @@ import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
|
|
import javax.validation.Validation;
|
|
|
|
import javax.validation.Validation;
|
|
|
|
import javax.validation.Validator;
|
|
|
|
import javax.validation.Validator;
|
|
|
@ -81,6 +82,7 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String fmcExcelUpload(FmcExcelUpload fileReq) {
|
|
|
|
public String fmcExcelUpload(FmcExcelUpload fileReq) {
|
|
|
|
|
|
|
|
String rtnMsg = "";
|
|
|
|
final Set<ConstraintViolation<FmcExcelUpload>> errors = validator.validate(fileReq);
|
|
|
|
final Set<ConstraintViolation<FmcExcelUpload>> errors = validator.validate(fileReq);
|
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
throw BizRuntimeException.create(errors.stream()
|
|
|
|
throw BizRuntimeException.create(errors.stream()
|
|
|
@ -92,8 +94,19 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
|
|
|
|
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
|
|
|
|
checkValidated(fmcExcels);
|
|
|
|
checkValidated(fmcExcels);
|
|
|
|
|
|
|
|
|
|
|
|
final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
fmcExcels.get(0).getTmplatId())
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final TmplatManage tmpDTO = mapper.selectDeptInfoByTmplId(tmplatId)
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
|
|
|
|
|
|
|
|
|
|
|
|
// Ci 변환
|
|
|
|
// Ci 변환
|
|
|
@ -104,15 +117,41 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
|
|
|
|
|
|
|
|
|
|
|
|
List<FmcInfExcelRslt> ciRslts = null;
|
|
|
|
List<FmcInfExcelRslt> ciRslts = null;
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", fmcExcels.get(0).getTmplatId())) {
|
|
|
|
if(Pattern.matches("([\\w]{4}[1-2])", tmplatId)) {
|
|
|
|
ciRslts = getConvertCis(fileReq, fmcExcels);
|
|
|
|
ciRslts = getConvertCis(fileReq, fmcExcels, unitySndngMastrId, excelCnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CNTC 테이블 insert
|
|
|
|
// CNTC 테이블 insert
|
|
|
|
final String rtnMsg = makeCntc(ciRslts, fmcExcels, fileReq);
|
|
|
|
final String rtnMsgSub = makeCntc(ciRslts, fmcExcels, fileReq, unitySndngMastrId, excelCnt);
|
|
|
|
fileReq.setPostDlvrSe(null);
|
|
|
|
|
|
|
|
fileReq.setSignguCode(null);
|
|
|
|
fileReq.setSignguCode(null);
|
|
|
|
fileReq.setFfnlgCode(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;
|
|
|
|
return rtnMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -265,12 +304,13 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
* @return List<FmcInfExcelRslt>
|
|
|
|
* @return List<FmcInfExcelRslt>
|
|
|
|
* </pre>
|
|
|
|
* </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<>();
|
|
|
|
List<FmcInfExcelRslt> rslts = new ArrayList<>();
|
|
|
|
int errCnt = 0;
|
|
|
|
int errCnt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels) {
|
|
|
|
for(FmcInfExcel dto : fmcExcels) {
|
|
|
|
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
|
|
|
|
if(unitySndngMastrId.equals(dto.getUnitySndngMastrId())){
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
IpinCiResDataBody dataBody = niceCiService.requestCi(
|
|
|
|
IpinCiResDataBody dataBody = niceCiService.requestCi(
|
|
|
|
NiceCiRequest.builder()
|
|
|
|
NiceCiRequest.builder()
|
|
|
@ -300,12 +340,13 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fileReq.setSndngCo(fmcExcels.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
fileReq.setSndngCo(excelCnt);
|
|
|
|
|
|
|
|
|
|
|
|
if(fmcExcels.size() != rslts.size()) throw BizRuntimeException.create(
|
|
|
|
if(excelCnt != rslts.size()) throw BizRuntimeException.create(
|
|
|
|
String.format(
|
|
|
|
String.format(
|
|
|
|
"CI 전환 오류[변환대상-%d건, 변환완료-%d건, 변환오류-%d건]",
|
|
|
|
"CI 전환 오류[변환대상-%d건, 변환완료-%d건, 변환오류-%d건]",
|
|
|
|
fmcExcels.size(),
|
|
|
|
excelCnt,
|
|
|
|
rslts.size()-errCnt,
|
|
|
|
rslts.size()-errCnt,
|
|
|
|
errCnt)
|
|
|
|
errCnt)
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -320,19 +361,20 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
* @return String
|
|
|
|
* @return String
|
|
|
|
* </pre>
|
|
|
|
* </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 mst = 0;
|
|
|
|
int errCnt = 0;
|
|
|
|
int errCnt = 0;
|
|
|
|
String mpc = null;
|
|
|
|
String mpc = null;
|
|
|
|
final int excelCnt = fmcExcels.size();
|
|
|
|
|
|
|
|
final String register = StringUtils.defaultString(fileReq.getRegister(),"");
|
|
|
|
final String register = StringUtils.defaultString(fileReq.getRegister(),"");
|
|
|
|
String unitySndngMastrId = "";
|
|
|
|
// String unitySndngMastrId = "";
|
|
|
|
String[] ppMasterJson = new String[2];
|
|
|
|
String[] ppMasterJson = new String[2];
|
|
|
|
|
|
|
|
|
|
|
|
for(FmcInfExcel dto : fmcExcels){
|
|
|
|
for(FmcInfExcel dto : fmcExcels){
|
|
|
|
|
|
|
|
//23.11.22 jhseo: 하나의 엑셀에 unitySndngMastrId 여러개일 경우 동일한 unitySndngMastrId Row만 처리
|
|
|
|
|
|
|
|
if(unitySndngMastrId.equals(dto.getUnitySndngMastrId())){
|
|
|
|
//최초 1회 CNTC master 생성
|
|
|
|
//최초 1회 CNTC master 생성
|
|
|
|
if(StringUtils.isNotEmpty(dto.getUnitySndngMastrId()) && mst == 0){
|
|
|
|
// if(StringUtils.isNotEmpty(dto.getUnitySndngMastrId()) && mst == 0){
|
|
|
|
unitySndngMastrId = dto.getUnitySndngMastrId();
|
|
|
|
// unitySndngMastrId = dto.getUnitySndngMastrId();
|
|
|
|
|
|
|
|
if(mst == 0){
|
|
|
|
fileReq.setUnitySndngMastrId(unitySndngMastrId);
|
|
|
|
fileReq.setUnitySndngMastrId(unitySndngMastrId);
|
|
|
|
mapper.insertCntcSndngMst(
|
|
|
|
mapper.insertCntcSndngMst(
|
|
|
|
CntcDTO.SndngMst.builder()
|
|
|
|
CntcDTO.SndngMst.builder()
|
|
|
@ -394,6 +436,7 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(Checks.isNotEmpty(ciRslts)) {
|
|
|
|
if(Checks.isNotEmpty(ciRslts)) {
|
|
|
|
for(FmcInfExcelRslt dto : ciRslts) {
|
|
|
|
for(FmcInfExcelRslt dto : ciRslts) {
|
|
|
@ -404,10 +447,11 @@ public class BizSisulService extends AbstractService implements IBizSisulService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return String.format(
|
|
|
|
return String.format(
|
|
|
|
"전자고지 대상 %d건 Upload[완료-%d건, 오류-%d건]",
|
|
|
|
"전자고지 대상 %d건 Upload[완료-%d건, 오류-%d건]",
|
|
|
|
fmcExcels.size(),
|
|
|
|
excelCnt,
|
|
|
|
fmcExcels.size()-errCnt,
|
|
|
|
excelCnt-errCnt,
|
|
|
|
errCnt);
|
|
|
|
errCnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|