feat: 전자고지 대상 엑셀업로드 유효성 체크 추가

포스트플러스인 경우 CI변환 skip 적용
dev
gitea-관리자 1 year ago
parent fe3a584560
commit 386666116d

@ -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(StringUtils.isEmpty(String.join("", dto.getCi1(), dto.getCi2()))){
errCnt++;
if(Checks.isNotEmpty(ciRslts)) {
for(FmcInfExcelRslt dto : ciRslts) {
if(StringUtils.isEmpty(String.join("", dto.getCi1(), dto.getCi2()))) {
errCnt++;
}
mapper.insertCi(dto);
}
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 = "{"

@ -1,40 +0,0 @@
package kr.xit.core.biz.web;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcExcelUpload;
import kr.xit.core.model.IApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <pre>
* description :
*
* packageName : kr.xit.core.biz.web
* fileName : CmmFileMgtController
* author : limju
* date : 2023-09-04
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-04 limju
*
* </pre>
*/
@Slf4j
@Tag(name = "CmmFileMgtController", description = "파일 관리")
@RestController
@RequestMapping(value = "/api/cmm")
public class CmmFileMgtController {
@PostMapping(value = "/fileUpload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public IApiResponse saveFiles(@ModelAttribute FmcExcelUpload fileReq) {
//cmmFileMst, fileReq.getFiles()));
log.debug("{}", fileReq);
log.debug("{}", fileReq.getFiles()[0].getOriginalFilename());
return null;
}
}

@ -13,6 +13,8 @@ fail.api.token.invalid.expired={0} access token \uC720\uD6A8\uAE30\uAC04\uC774 \
fail.api.kt.token.request=KT \uD1A0\uD070 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.
fail.api.excel.upload.data={0} \uBC88\uC9F8 {1} \uC140(\uD544\uB4DC) \uAC12\uC774 \uBD80\uC815\uD655 \uD569\uB2C8\uB2E4[{2} - {3}]
err.api.nice.pubKey.0000=\uACF5\uAC1C\uD0A4\uBC1C\uAE09
err.api.nice.pubKey.0001=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958
err.api.nice.pubKey.0003=\uACF5\uAC1C\uD0A4 \uBC1C\uAE09 \uB300\uC0C1 \uD68C\uC6D0\uC0AC \uC544\uB2D8
@ -62,5 +64,5 @@ info.api.kt.msg.rslt.4V=MMS\uBC1C\uC1A1 \uC218\uC2E0\uB4F1\uB85D \uD734\uB300\uD
info.api.kt.msg.rslt.4W=MMS\uBC1C\uC1A1 \uAE30\uB3D9\uC758 \uC0AC\uC804\uBB38\uC790 \uC81C\uC678
info.api.kt.msg.rslt.50=\uC218\uC2E0\uD655\uC778 \uC218\uC2E0\uC131\uACF5
#(MMS\uBC1C\uC1A1\uACB0\uACFC\uC21C\uBC88=2, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)
info.api.kt.msg.rslt.60=\uC5F4\uB78C\uD655\uC778 \uC5F4\uB78C\uD655\uC778(MMS\uBC1C\uC1A1\uACB0\uACFC\uCF54\uB4DC=40, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)
info.api.kt.msg.rslt.60=\uC5F4\uB78C\uD655\uC778(MMS\uBC1C\uC1A1\uACB0\uACFC\uCF54\uB4DC=40, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)

@ -150,12 +150,6 @@ public class EnsBatchExtractService extends EgovAbstractServiceImpl implements
mapper.updateKtBcMst(dto);
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void sendPostPlus(SndngMssageParam dto) {
}
/**
* <pre>
* fail

@ -34,9 +34,6 @@ public interface IEnsBatchExtractService {
void saveKtBcResult(final SndngMssageParam dto, final List<KtMainSendReqData> sendReqs);
void sendPostPlus(final SndngMssageParam dto);
void updateSndngMstFailStatus(final String mstId, final SndngSeCode seCode, final String errCode, final String errMsg, final String stsErrMsg);
//-----------------------------------------------------------------------------------------------------------------

Loading…
Cancel
Save