feat: 시민신고 테이블 등록 진행

main
minuk926 2 years ago
parent 04aeb88eb5
commit d7e582848f

@ -46,12 +46,29 @@ public class FimsConst {
private final String desc; private final String desc;
} }
/**
* : FIM001
*/
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum FimsCmmCode { public enum FfnlgCode {
YEAR("FfnlgCode", "88") PVS("PVS", "주정차위반과태료")
,MONTH("MONTH", "월") ,BPV("BPV", "전용차로위반과태료")
,DAY("DAY", "일") ,DPV("DPV", "장애인전용주차구역")
,ECA("ECA", "전기차주차구역")
;
private final String code;
private final String desc;
}
/**
*
*/
@Getter
@AllArgsConstructor
public enum CtznSttemntStatusCode {
UNTREATED("01", "미처리")
; ;
private final String code; private final String code;

@ -2,7 +2,9 @@ package kr.xit.fims.biz.ec.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -28,7 +30,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
/** /**
* :88-sys_gubun_c * :88-sys_gubun_c
*/ */
private String ffnlgCode; private String sysCode;
/** /**
* :140/180/140-peti_gubun_c * :140/180/140-peti_gubun_c
*/ */
@ -82,7 +84,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
*/ */
private String cvplRceptDt; private String cvplRceptDt;
/** /**
*-peti_proc_dur_n *-peti_end_d
*/ */
private String cvplProcessPd; private String cvplProcessPd;
/** /**
@ -99,6 +101,25 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
private List<CtznSttemntDetailDTO> sttemntDetailDTOs = new ArrayList<>(); private List<CtznSttemntDetailDTO> sttemntDetailDTOs = new ArrayList<>();
private boolean isSingle = true;
/**
* <pre>
*
* vhcleNo:( ""), idx: , lastIdx: ( )
* </pre>
*/
private List<DupDataDTO> dupDataList = new ArrayList<>();
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public static class DupDataDTO implements Serializable {
private CtznSttemntDetailDTO sttemntDetailDTO;
private Set<Integer> indexs = new HashSet<>();
}
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@ -175,7 +196,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
/** /**
* *
*/ */
private String ffnlgCode; private String sysCode;
/** /**
* *
*/ */
@ -184,5 +205,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
private String register; private String register;
private String updtDt; private String updtDt;
private String updusr; private String updusr;
private Set<Integer> indexs = new HashSet<>();
} }
} }

@ -1,36 +0,0 @@
// package kr.xit.fims.biz.ec.model;
//
// import java.io.Serializable;
//
// import lombok.AllArgsConstructor;
// import lombok.Getter;
// import lombok.NoArgsConstructor;
// import lombok.Setter;
// import lombok.ToString;
//
// @Getter
// @Setter
// @NoArgsConstructor
// @AllArgsConstructor
// @ToString
// public class CtznSttemntDetailDTO implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private String interfaceSeqN;
// private String vhcleNo;
// private String ctznSttemntDetailSn;
// private String regltId;
// private String regltDeTime;
// private String regltPlace;
// private String violtDtlsNm;
// private String gpsX;
// private String gpsY;
// private String insttCode;
// private String ffnlgCode;
// private String ctznSttemntDetailProcessSttus;
// private String registDt;
// private String register;
// private String updtDt;
// private String updusr;
//
// }

@ -7,6 +7,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -109,6 +110,27 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
CmmFileDtlDTO pngDtlDTO = null; CmmFileDtlDTO pngDtlDTO = null;
for(CtznSttemntDTO.CtznSttemntDetailDTO dtl : ctznSttemntDTO.getSttemntDetailDTOs()){ for(CtznSttemntDTO.CtznSttemntDetailDTO dtl : ctznSttemntDTO.getSttemntDetailDTOs()){
ctznSttemntMapper.insertEcCtznSttemntDetail(dtl); ctznSttemntMapper.insertEcCtznSttemntDetail(dtl);
// 단속건수가 1건인 경우 파일 전체 저장
if(ctznSttemntDTO.isSingle()) {
saveAllAppendFiles(xmlDto, appendFileDto, dtl, fileCnt);
return;
}
CtznSttemntDTO.DupDataDTO dupDataDTO = ctznSttemntDTO.getDupDataList().stream()
.filter(d -> Objects.equals(d.getSttemntDetailDTO().getVhcleNo(), dtl.getVhcleNo()))
.findFirst()
.get();
dtl.getIndexs().addAll(dupDataDTO.getIndexs());
//------------------------------------------------------------- //-------------------------------------------------------------
// 첨부파일 저장 // 첨부파일 저장
//------------------------------------------------------------- //-------------------------------------------------------------
@ -116,7 +138,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
// if(fileCnt >= 2 && fileCnt - 1 >= index.get()) { // if(fileCnt >= 2 && fileCnt - 1 >= index.get()) {
if(index.get() == 0) { if(index.get() == 0) {
fstMstDTO = saveAppendFiles(xmlDto, appendFileDto, dtl, index.get(), fileCnt); fstMstDTO = saveAppendFiles(appendFileDto, dtl, index.get(), fileCnt);
}else { }else {
if(Checks.isEmpty(pngDtlDTO)) { if(Checks.isEmpty(pngDtlDTO)) {
if (fstMstDTO == null || fstMstDTO.getCmmFileDtls().size() == 0) if (fstMstDTO == null || fstMstDTO.getCmmFileDtls().size() == 0)
@ -129,7 +151,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
} }
}; };
} }
saveFstOverAppendFiles(xmlDto, appendFileDto, dtl, pngDtlDTO, index.get()); saveFstOverAppendFiles(appendFileDto, dtl, pngDtlDTO, index.get());
} }
index.addAndGet(1); index.addAndGet(1);
// } // }
@ -161,11 +183,13 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN()); dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dto.setInsttCode(xmlDto.getAncCodeV()); dto.setInsttCode(xmlDto.getAncCodeV());
//TODO: 재정의 후 적용 //TODO: 재정의 후 적용
dto.setFfnlgCode("88"); dto.setSysCode("88");
dto.setCvplSe(xmlDto.getPetiGubunC()); dto.setCvplSe(xmlDto.getPetiGubunC());
dto.setCvplReqstNo(xmlDto.getPetiNoC()); dto.setCvplReqstNo(xmlDto.getPetiNoC());
dto.setCvplRceptNo(xmlDto.getCivilNoC()); dto.setCvplRceptNo(xmlDto.getCivilNoC());
dto.setCvplApplcntAdres(xmlDto.getPeterNameV()); dto.setCvplRceptDt(xmlDto.getAncRegD());
dto.setCvplApplcntNm(xmlDto.getPeterNameV());
dto.setCvplApplcntAdres(xmlDto.getAddressV());
dto.setCvplApplcntZip(xmlDto.getZipCodeC()); dto.setCvplApplcntZip(xmlDto.getZipCodeC());
dto.setCvplApplcntAdres(xmlDto.getAddressV()); dto.setCvplApplcntAdres(xmlDto.getAddressV());
dto.setCvplApplcntEmailAdres(xmlDto.getEmailV()); dto.setCvplApplcntEmailAdres(xmlDto.getEmailV());
@ -174,10 +198,9 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
dto.setCvplReqstSj(xmlDto.getPetiTitleV()); dto.setCvplReqstSj(xmlDto.getPetiTitleV());
dto.setCvplReqstCn(reasonStr); dto.setCvplReqstCn(reasonStr);
dto.setCvplReqstDt(xmlDto.getPetiRegD()); dto.setCvplReqstDt(xmlDto.getPetiRegD());
dto.setCvplProcessPd(xmlDto.getPetiProcDurN()); dto.setCvplProcessPd(xmlDto.getPetiEndD());
//TODO: ???
dto.setCvplRegistDt(xmlDto.getRegD()); dto.setCvplRegistDt(xmlDto.getRegD());
//dto.setCtznSttemntProcessSttus(); dto.setCtznSttemntProcessSttus(FimsConst.CtznSttemntStatusCode.UNTREATED.getCode());
dto.setRegister(getUserUniqId()); dto.setRegister(getUserUniqId());
//--------------------------------- //---------------------------------
@ -186,10 +209,12 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//* (1/2) C: 2022/09/15 21:38:10 차량번호 : 11서0194 (위·변조 없음) //* (1/2) C: 2022/09/15 21:38:10 차량번호 : 11서0194 (위·변조 없음)
//* (2/2) C: 2022/09/15 21:40:02 차량번호 : 11서0194 (위·변조 없음) //* (2/2) C: 2022/09/15 21:40:02 차량번호 : 11서0194 (위·변조 없음)
// "(1/2) C: " 문자열 패턴 // "(1/2) C: " 문자열 패턴
String regx = "(\\*\\s\\(\\d.*\\/\\d.*\\)\\sC:\\s)(.*)(\\s차량번호\\s:\\s)(.*)"; String regx = "(\\*\\s\\(\\d.*\\/\\d.*\\)\\s[GCS]:\\s)(.*)(\\s차량번호\\s:\\s)(.*)";
Pattern pattern = Pattern.compile(regx); Pattern pattern = Pattern.compile(regx);
Matcher matcher = pattern.matcher(reasonStr); Matcher matcher = pattern.matcher(reasonStr);
boolean isFirst = true;
String carNo = null;
while(matcher.find()) { while(matcher.find()) {
String[] arrSrc = String[] arrSrc =
matcher.group() matcher.group()
@ -201,13 +226,47 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
CtznSttemntDTO.CtznSttemntDetailDTO dtlDto = new CtznSttemntDTO.CtznSttemntDetailDTO(); CtznSttemntDTO.CtznSttemntDetailDTO dtlDto = new CtznSttemntDTO.CtznSttemntDetailDTO();
//단속일시 //단속일시
dtlDto.setRegltDeTime(arrSrc[0]); dtlDto.setRegltDeTime(arrSrc[0]);
//차량번호 //차량번호
if(arrSrc.length > 1) dtlDto.setVhcleNo(arrSrc[1]); if(isFirst) carNo = (arrSrc.length > 1)? arrSrc[1]: "";
dtlDto.setVhcleNo((arrSrc.length > 1)? arrSrc[1]: "");
if(!isFirst && !Objects.equals(carNo, dtlDto.getVhcleNo())) dto.setSingle(false);
//공통 추가 항목 //공통 추가 항목
dtlDto.setInterfaceSeqN(xmlDto.getInterfaceSeqN()); dtlDto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dtlDto.setRegister(getUserUniqId()); dtlDto.setRegister("");
dtlDto.setCtznSttemntDetailProcessSttus(FimsConst.CtznSttemntStatusCode.UNTREATED.getCode());
dtlList.add(dtlDto); dtlList.add(dtlDto);
isFirst = false;
}
if(!dto.isSingle()) {
CtznSttemntDTO.DupDataDTO dupDto = new CtznSttemntDTO.DupDataDTO();
dupDto.setSttemntDetailDTO(dtlList.get(0));
dupDto.getIndexs().add(0);
dto.getDupDataList().add(dupDto);
for (int idx = 1; idx < dtlList.size(); idx++) {
CtznSttemntDTO.CtznSttemntDetailDTO tgt = dtlList.get(idx);
int finalIdx = idx;
AtomicBoolean isDup = new AtomicBoolean(false);
dto.getDupDataList().forEach(dupData -> {
if(Objects.equals(dupData.getSttemntDetailDTO().getVhcleNo(), tgt.getVhcleNo())){
dupData.getIndexs().add(finalIdx);
isDup.set(true);
}
});
if(!isDup.get()) {
CtznSttemntDTO.DupDataDTO ddto = new CtznSttemntDTO.DupDataDTO();
ddto.setSttemntDetailDTO(tgt);
ddto.getIndexs().add(idx);
dto.getDupDataList().add(ddto);
}
}
} }
// 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해) // 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해)
dtlList = dtlList.stream() dtlList = dtlList.stream()
@ -270,7 +329,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
.replaceAll(regx, "$2"); .replaceAll(regx, "$2");
dtlList.forEach(dtlDto -> { dtlList.forEach(dtlDto -> {
dtlDto.setRegltPlace(str); dtlDto.setVioltDtlsNm(str);
}); });
} }
dto.setSttemntDetailDTOs(dtlList); dto.setSttemntDetailDTOs(dtlList);
@ -278,15 +337,12 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
return dto; return dto;
} }
//TODO: 단속정보별 파일 저장 하도록 적용 필요 - 2건 단속자료면 1번은 1번 파일만, 2번은 2번 파일만
//TODO: 단속정보를 보여줄 때는 모든 이미지 정보 보여준다(insterfaceSeqN 별로 - 어느 DTL항목 파일인지는 당근 표시해야지!!!) private CmmFileMstDTO saveAllAppendFiles(
//TODO: .png는 각각 set - 파일 업로드는 1번만
private CmmFileMstDTO saveAppendFiles(
NatlNewspaperRcvXmlDTO xmlDto, NatlNewspaperRcvXmlDTO xmlDto,
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto, NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto,
CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO, CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO,
int index, int fileCnt) {
int pngFileIndex) {
// 첨부 파일 생성 // 첨부 파일 생성
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount()); //int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
@ -297,39 +353,104 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
String makeDir = "/" + dateStr; String makeDir = "/" + dateStr;
String makePath = uploadRoot + uploadNewsPaperPath + makeDir; String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
try { for (int idx = 0; idx < fileCnt; idx++) {
Method method = clz.getMethod("getPetiFilePath" + (index + 1) + "V", null); try {
String petiFileNm = (String)method.invoke(appendFileDto, null);
method = clz.getMethod("getApndfilcont" + (index + 1), null);
String petiFileStr = (String)method.invoke(appendFileDto, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장 Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
//String saveFileName = CommUtils.getStringFromUUID(); String petiFileNm = (String)method.invoke(appendFileDto, null);
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes())); method = clz.getMethod("getApndfilcont" + (idx + 1), null);
// 실제 저장된 파일명 set String petiFileStr = (String)method.invoke(appendFileDto, null);
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드 //TODO: 실제 저장할 파일명 생성후 파일 내용 저장
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes()))); //String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
// 최초 파일 업로드인 경우, png 파일 같이 업로드 //TODO: 원본 파일명으로 파일 생성후 파일 업로드
if(index == 0) {
method = clz.getMethod("getPetiFilePath" + pngFileIndex + "V", null);
petiFileNm = (String)method.invoke(appendFileDto, null);
method = clz.getMethod("getApndfilcont" + pngFileIndex, null);
petiFileStr = (String)method.invoke(appendFileDto, null);
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes()))); mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
} }
}
CmmFileMstDTO fileMstDTO = new CmmFileMstDTO();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); return cmmFileService.saveFiles(fileMstDTO, mfList);
}
//TODO: 단속정보별 파일 저장 하도록 적용 필요 - 2건 단속자료면 1번은 1번 파일만, 2번은 2번 파일만
//TODO: 단속정보를 보여줄 때는 모든 이미지 정보 보여준다(insterfaceSeqN 별로 - 어느 DTL항목 파일인지는 당근 표시해야지!!!)
//TODO: .png는 각각 set - 파일 업로드는 1번만
private CmmFileMstDTO saveAppendFiles(
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO,
CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO,
int index,
int fileCnt) {
// 첨부 파일 생성
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>();
Class<?> clz = apndFileDTO.getClass();
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
for(int idx : stmtDtlDTO.getIndexs()){
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
}
try{
if(index == 0) {
for(int idx = fileCnt; idx>=1; idx--) {
Method method = clz.getMethod("getPetiFilePath" + idx + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
if(petiFileNm.contains(".png")) {
method = clz.getMethod("getApndfilcont" + idx, null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
break;
}
}
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace(); e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage()); throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
} }
CmmFileMstDTO fileMstDTO = new CmmFileMstDTO(); CmmFileMstDTO fileMstDTO = new CmmFileMstDTO();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()); fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn()); fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath); fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode()); fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
@ -337,26 +458,50 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
} }
private CmmFileMstDTO saveFstOverAppendFiles( private CmmFileMstDTO saveFstOverAppendFiles(
final NatlNewspaperRcvXmlDTO xmlDto, final NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO,
final NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto, final CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO,
final CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO,
final CmmFileDtlDTO pngFileDtlDto, final CmmFileDtlDTO pngFileDtlDto,
int index) { int index) {
// 첨부 파일 생성 // 첨부 파일 생성
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount()); //int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>(); List<MultipartFile> mfList = new ArrayList<>();
Class<?> clz = appendFileDto.getClass(); Class<?> clz = apndFileDTO.getClass();
String dateStr = DateUtils.getToday(""); String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4); dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr; String makeDir = "/" + dateStr;
String makePath = uploadRoot + uploadNewsPaperPath + makeDir; String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
for(int idx : stmtDtlDTO.getIndexs()){
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
}
/*
try { try {
Method method = clz.getMethod("getPetiFilePath" + (index + 1) + "V", null); Method method = clz.getMethod("getPetiFilePath" + (index + 1) + "V", null);
String petiFileNm = (String)method.invoke(appendFileDto, null); String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (index + 1), null); method = clz.getMethod("getApndfilcont" + (index + 1), null);
String petiFileStr = (String)method.invoke(appendFileDto, null); String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장 //TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID(); //String saveFileName = CommUtils.getStringFromUUID();
@ -374,9 +519,11 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
e.getStackTrace(); e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage()); throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
} }
*/
CmmFileMstDTO fileMstDTO = new CmmFileMstDTO(); CmmFileMstDTO fileMstDTO = new CmmFileMstDTO();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode()); fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn()); fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath); fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode()); fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
@ -433,16 +580,45 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
} }
*/ */
/*
@SuppressWarnings("DuplicatedCode") @SuppressWarnings("DuplicatedCode")
public static void main(String[] args) { public static void main(String[] args) {
String data = "D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399.xml"; String xdata = "D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399_backup.xml";
NatlNewspaperRcvXmlDTO xmlDto = XmlParseUtils.readXmlToObject(NatlNewspaperRcvXmlDTO.class, data); NatlNewspaperRcvXmlDTO xmlDto = XmlParseUtils.readXmlToObject(NatlNewspaperRcvXmlDTO.class, xdata);
String reasonStr = xmlDto.getPetiReasonL(); String reasonStr = xmlDto.getPetiReasonL();
log.debug(reasonStr); log.debug(reasonStr);
// 단일데이타 : 차량번호가 동일(차량번호가 없는 경우 포함)
CtznSttemntDTO dto = new CtznSttemntDTO();
List<CtznSttemntDTO.CtznSttemntDetailDTO> dtlList = new ArrayList<>(); List<CtznSttemntDTO.CtznSttemntDetailDTO> dtlList = new ArrayList<>();
// 중복데이타 목록
List<CtznSttemntDTO.DupDataDTO> dupDataList = dto.getDupDataList();
dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dto.setInsttCode(xmlDto.getAncCodeV());
//TODO: 재정의 후 적용
dto.setSysCode("88");
dto.setCvplSe(xmlDto.getPetiGubunC());
dto.setCvplReqstNo(xmlDto.getPetiNoC());
dto.setCvplRceptNo(xmlDto.getCivilNoC());
dto.setCvplRceptDt(xmlDto.getAncRegD());
dto.setCvplApplcntNm(xmlDto.getPeterNameV());
dto.setCvplApplcntAdres(xmlDto.getAddressV());
dto.setCvplApplcntZip(xmlDto.getZipCodeC());
dto.setCvplApplcntAdres(xmlDto.getAddressV());
dto.setCvplApplcntEmailAdres(xmlDto.getEmailV());
dto.setCvplApplcntMoblphonNo(xmlDto.getCelNoV());
dto.setCvplApplcntTlphonNo(xmlDto.getTelNoV());
dto.setCvplReqstSj(xmlDto.getPetiTitleV());
dto.setCvplReqstCn(reasonStr);
dto.setCvplReqstDt(xmlDto.getPetiRegD());
dto.setCvplProcessPd(xmlDto.getPetiEndD());
//TODO: ???
dto.setCvplRegistDt(xmlDto.getRegD());
dto.setCtznSttemntProcessSttus(FimsConst.CtznSttemntStatusCode.UNTREATED.getCode());
//dto.setCtznSttemntProcessSttus();
dto.setRegister("");
//--------------------------------- //---------------------------------
// 단속일시 / 차량번호 // 단속일시 / 차량번호
@ -450,10 +626,12 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//* (1/2) C: 2022/09/15 21:38:10 차량번호 : 11서0194 (위·변조 없음) //* (1/2) C: 2022/09/15 21:38:10 차량번호 : 11서0194 (위·변조 없음)
//* (2/2) C: 2022/09/15 21:40:02 차량번호 : 11서0194 (위·변조 없음) //* (2/2) C: 2022/09/15 21:40:02 차량번호 : 11서0194 (위·변조 없음)
// "(1/2) C: " 문자열 패턴 // "(1/2) C: " 문자열 패턴
String regx = "(\\*\\s\\(\\d.*\\/\\d.*\\)\\sC:\\s)(.*)(\\s차량번호\\s:\\s)(.*)"; String regx = "(\\*\\s\\(\\d.*\\/\\d.*\\)\\s[GCS]:\\s)(.*)(\\s차량번호\\s:\\s)(.*)";
Pattern pattern = Pattern.compile(regx); Pattern pattern = Pattern.compile(regx);
Matcher matcher = pattern.matcher(reasonStr); Matcher matcher = pattern.matcher(reasonStr);
boolean isFirst = true;
String carNo = null;
while(matcher.find()) { while(matcher.find()) {
String[] arrSrc = String[] arrSrc =
matcher.group() matcher.group()
@ -462,17 +640,63 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
.replaceAll("[: /]", "") .replaceAll("[: /]", "")
.split(","); .split(",");
CtznSttemntDTO.CtznSttemntDetailDTO dto = new CtznSttemntDTO.CtznSttemntDetailDTO(); CtznSttemntDTO.CtznSttemntDetailDTO dtlDto = new CtznSttemntDTO.CtznSttemntDetailDTO();
//단속일시 //단속일시
dto.setRegltDeTime(arrSrc[0]); dtlDto.setRegltDeTime(arrSrc[0]);
//차량번호 //차량번호
dto.setVhcleNo(arrSrc[1]); if(isFirst) carNo = (arrSrc.length > 1)? arrSrc[1]: "";
dtlList.add(dto); dtlDto.setVhcleNo((arrSrc.length > 1)? arrSrc[1]: "");
if(!isFirst && !Objects.equals(carNo, dtlDto.getVhcleNo())) dto.setSingle(false);
//공통 추가 항목
dtlDto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dtlDto.setRegister("");
dtlDto.setCtznSttemntDetailProcessSttus(FimsConst.CtznSttemntStatusCode.UNTREATED.getCode());
dtlList.add(dtlDto);
isFirst = false;
} }
if(!dto.isSingle()) {
CtznSttemntDTO.DupDataDTO dupDto = new CtznSttemntDTO.DupDataDTO();
dupDto.setSttemntDetailDTO(dtlList.get(0));
dupDto.getIndexs().add(0);
dto.getDupDataList().add(dupDto);
for (int idx = 1; idx < dtlList.size(); idx++) {
CtznSttemntDTO.CtznSttemntDetailDTO tgt = dtlList.get(idx);
int finalIdx = idx;
AtomicBoolean isDup = new AtomicBoolean(false);
dto.getDupDataList().forEach(dupData -> {
if(Objects.equals(dupData.getSttemntDetailDTO().getVhcleNo(), tgt.getVhcleNo())){
dupData.getIndexs().add(finalIdx);
isDup.set(true);
}
});
if(!isDup.get()) {
CtznSttemntDTO.DupDataDTO ddto = new CtznSttemntDTO.DupDataDTO();
ddto.setSttemntDetailDTO(tgt);
ddto.getIndexs().add(idx);
dto.getDupDataList().add(ddto);
}
}
}
// 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해)
dtlList = dtlList.stream() dtlList = dtlList.stream()
.sorted(Comparator.comparing(CtznSttemntDTO.CtznSttemntDetailDTO::getRegltDeTime).reversed()).collect( .sorted(Comparator.comparing(CtznSttemntDTO.CtznSttemntDetailDTO::getRegltDeTime).reversed()).collect(
Collectors.toList()); Collectors.toList());
dtlList = FunctionUtils.removeDuplication(dtlList, CtznSttemntDTO.CtznSttemntDetailDTO::getVhcleNo); // 중복제거(동일 차량 번호중 단속일시가 가장 늦은것 pick)
// 차량번호가 없는 경우가 존재하여 체크로직 추가
dtlList = FunctionUtils.removeDuplication(dtlList, dtl -> {
if(Checks.isNotEmpty(dtl.getVhcleNo())) return dtl.getVhcleNo();
return dtl;
});
//--------------------------------- //---------------------------------
// GPS 위도 // GPS 위도
@ -485,12 +709,11 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
while(matcher.find()){ while(matcher.find()){
String[] arrGps = matcher.group() String[] arrGps = matcher.group()
.replaceAll(regx, "$2,$4") .replaceAll(regx, "$2,$4")
//.replaceAll("[위도:경도:]", "")
.split(","); .split(",");
dtlList.forEach(dto -> { dtlList.forEach(dtlDto -> {
dto.setGpsX(arrGps[0]); dtlDto.setGpsX(arrGps[0]);
dto.setGpsY(arrGps[1]); dtlDto.setGpsY(arrGps[1]);
}); });
} }
@ -506,8 +729,8 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
String str = matcher.group() String str = matcher.group()
.replaceAll(regx, "$2"); .replaceAll(regx, "$2");
dtlList.forEach(dto -> { dtlList.forEach(dtlDto -> {
dto.setRegltPlace(str); dtlDto.setRegltPlace(str);
}); });
} }
@ -524,15 +747,17 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
String str = matcher.group() String str = matcher.group()
.replaceAll(regx, "$2"); .replaceAll(regx, "$2");
dtlList.forEach(dto -> { dtlList.forEach(dtlDto -> {
dto.setRegltPlace(str); dtlDto.setVioltDtlsNm(str);
}); });
} }
dto.setSttemntDetailDTOs(dtlList);
log.debug("{}", dtlList); log.debug("{}", dto);
//return dto;
} }
*/
} }

@ -241,7 +241,7 @@ public class CmmFileService implements ICmmFileService {
pngFileDtlDto.setFileMastrId(fileMstDTO.getFileMastrId()); pngFileDtlDto.setFileMastrId(fileMstDTO.getFileMastrId());
pngFileDtlDto.setFileId(CommUtils.getStringFromUUID()); //pngFileDtlDto.setFileId(CommUtils.getStringFromUUID());
mapper.insertCmmFileDetail(pngFileDtlDto); mapper.insertCmmFileDetail(pngFileDtlDto);
cmmFileDtls.add(pngFileDtlDto); cmmFileDtls.add(pngFileDtlDto);

@ -9,7 +9,7 @@
<sql id="sqlEcCtznSttemnt"> <sql id="sqlEcCtznSttemnt">
SELECT interface_seq_n SELECT interface_seq_n
, instt_code , instt_code
, ffnlg_code , sys_code
, cvpl_se , cvpl_se
, cvpl_reqst_no , cvpl_reqst_no
, cvpl_rcept_no , cvpl_rcept_no
@ -43,7 +43,7 @@
INTO tb_ec_ctzn_sttemnt ( INTO tb_ec_ctzn_sttemnt (
interface_seq_n interface_seq_n
, instt_code , instt_code
, ffnlg_code , sys_code
, cvpl_se , cvpl_se
, cvpl_reqst_no , cvpl_reqst_no
, cvpl_rcept_no , cvpl_rcept_no
@ -65,7 +65,7 @@
) VALUES ( ) VALUES (
#{interfaceSeqN} #{interfaceSeqN}
, #{insttCode} , #{insttCode}
, #{ffnlgCode} , #{sysCode}
, #{cvplSe} , #{cvplSe}
, #{cvplReqstNo} , #{cvplReqstNo}
, #{cvplRceptNo} , #{cvplRceptNo}
@ -108,7 +108,7 @@
, vhcle_no , vhcle_no
, reglt_id , reglt_id
, instt_code , instt_code
, ffnlg_code , sys_code
, reglt_de_time , reglt_de_time
, reglt_place , reglt_place
, violt_dtls_nm , violt_dtls_nm
@ -123,7 +123,7 @@
, #{vhcleNo} , #{vhcleNo}
, #{regltId} , #{regltId}
, #{insttCode} , #{insttCode}
, #{ffnlgCode} , #{sysCode}
, #{regltDeTime} , #{regltDeTime}
, #{regltPlace} , #{regltPlace}
, #{violtDtlsNm} , #{violtDtlsNm}

Loading…
Cancel
Save