feat: 외부연계 - 원본백업 추가

main
minuk926 2 years ago
parent 92980114e2
commit aa99ccffad

@ -1,5 +1,6 @@
package kr.xit.fims.biz.ec.service; package kr.xit.fims.biz.ec.service;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,6 +11,7 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -50,11 +52,8 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService {
@Value("#{prop['file.upload.busonly-cctv.path']}") @Value("#{prop['file.upload.busonly-cctv.path']}")
private String uploadBusCctvPath; private String uploadBusCctvPath;
// @Value("#{prop['file.rcv.root']}") @Value("#{prop['file.rcv.backup.root']}")
// private String rcvRoot; private String rcvBackupRoot;
//
// @Value("#{prop['file.rcv.natl-newspaper.path']}")
// private String rcvNewsPaperPath;
private final IEcCctvCrackdownMapper mapper; private final IEcCctvCrackdownMapper mapper;
private final IEcCtznSttemntMapper ctznSttemntMapper; private final IEcCtznSttemntMapper ctznSttemntMapper;
@ -143,6 +142,7 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService {
* 2) tb_ec_extrl_reglt_cntc insert * 2) tb_ec_extrl_reglt_cntc insert
* 3) tb_cmm_file_mastr insert * 3) tb_cmm_file_mastr insert
* tb_cmm_file_detail insert * tb_cmm_file_detail insert
* 4) backup
* @param dto * @param dto
* </pre> * </pre>
*/ */
@ -151,9 +151,11 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService {
public void saveBusCctvCrackdownDatas(final FolderReqDTO dto) { public void saveBusCctvCrackdownDatas(final FolderReqDTO dto) {
String filePath = dto.getFilePath(); String filePath = dto.getFilePath();
//for(FolderReqDTO.FileInfo fi: dto.getFileInfoList()) {
dto.getFileInfoList().forEach((fi) -> { dto.getFileInfoList().forEach((fi) -> {
CctvCrackdownDTO.BusOnly busOnlyDTO = new CctvCrackdownDTO.BusOnly(); CctvCrackdownDTO.BusOnly busOnlyDTO = new CctvCrackdownDTO.BusOnly();
ExtlFileParseUtils.parseFileBusonlyToObject(busOnlyDTO, filePath+"/"+fi.getFileNm(), uploadRoot+uploadTempPath); ExtlFileParseUtils.parseFileBusonlyToObject(busOnlyDTO, filePath + "/" + fi.getFileNm(),
uploadRoot + uploadTempPath);
// 외부연계 테이블 생성 // 외부연계 테이블 생성
CctvCrackdownDTO.ExtrlRegltCntc extrDTO = CctvCrackdownDTO.ExtrlRegltCntc.builder() CctvCrackdownDTO.ExtrlRegltCntc extrDTO = CctvCrackdownDTO.ExtrlRegltCntc.builder()
@ -164,8 +166,8 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService {
//.어린이보호구역 //.어린이보호구역
.regltBeginTime(busOnlyDTO.getRegltTime()) .regltBeginTime(busOnlyDTO.getRegltTime())
.regltEndTime(busOnlyDTO.getRegltTime()) .regltEndTime(busOnlyDTO.getRegltTime())
.gpsX(busOnlyDTO.getGpsX().substring(0,20)) .gpsX(busOnlyDTO.getGpsX().substring(0, 20))
.gpsY(busOnlyDTO.getGpsY().substring(0,20)) .gpsY(busOnlyDTO.getGpsY().substring(0, 20))
.regltDe(busOnlyDTO.getRegltDe()) .regltDe(busOnlyDTO.getRegltDe())
//단속업체 //단속업체
@ -186,7 +188,19 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService {
.cmmFileDtls(new ArrayList<>()) .cmmFileDtls(new ArrayList<>())
.build(); .build();
cmmFileService.saveFiles(fileMstDTO, busOnlyDTO.getBusonlyImgList()); cmmFileService.saveFiles(fileMstDTO, busOnlyDTO.getBusonlyImgList());
// FIXME: src file backup
try {
FileUtils.moveFile(
new File(filePath + "/" + fi.getFileNm())
, new File(rcvBackupRoot + uploadBusCctvPath + "/" + fi.getFileNm())
);
} catch (IOException ie) {
ie.printStackTrace();
}
}); });
//}
} }

@ -1,5 +1,7 @@
package kr.xit.fims.biz.ec.service; package kr.xit.fims.biz.ec.service;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@ -13,6 +15,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.codec.Base64; import org.springframework.security.crypto.codec.Base64;
@ -24,8 +27,8 @@ import kr.xit.fims.biz.FimsConst;
import kr.xit.fims.biz.ec.mapper.IEcCtznSttemntMapper; import kr.xit.fims.biz.ec.mapper.IEcCtznSttemntMapper;
import kr.xit.fims.biz.ec.mapper.IEcNatlNewspaperMapper; import kr.xit.fims.biz.ec.mapper.IEcNatlNewspaperMapper;
import kr.xit.fims.biz.ec.model.CtznStmtDTO; import kr.xit.fims.biz.ec.model.CtznStmtDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO;
import kr.xit.fims.biz.ec.model.FolderReqDTO; import kr.xit.fims.biz.ec.model.FolderReqDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO;
import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.biz.cmm.model.CmmFileDTO;
import kr.xit.framework.biz.cmm.service.ICmmFileService; import kr.xit.framework.biz.cmm.service.ICmmFileService;
@ -50,11 +53,8 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
@Value("#{prop['file.upload.natl-newspaper.path']}") @Value("#{prop['file.upload.natl-newspaper.path']}")
private String uploadNewsPaperPath; private String uploadNewsPaperPath;
// @Value("#{prop['file.rcv.root']}") @Value("#{prop['file.rcv.backup.root']}")
// private String rcvRoot; private String rcvBackupRoot;
//
// @Value("#{prop['file.rcv.natl-newspaper.path']}")
// private String rcvNewsPaperPath;
private final IEcNatlNewspaperMapper mapper; private final IEcNatlNewspaperMapper mapper;
private final IEcCtznSttemntMapper ctznSttemntMapper; private final IEcCtznSttemntMapper ctznSttemntMapper;
@ -81,6 +81,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
* tb_ex_ctzn_sttemnt_detail insert * tb_ex_ctzn_sttemnt_detail insert
* 3) tb_cmm_file_mastr insert * 3) tb_cmm_file_mastr insert
* tb_cmm_file_detail insert * tb_cmm_file_detail insert
* 4) backup
* @param dto * @param dto
* </pre> * </pre>
*/ */
@ -125,6 +126,9 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
// 단속건수가 1건인 경우 파일 전체 저장 // 단속건수가 1건인 경우 파일 전체 저장
if(ctznStmtDTO.isSingle()) { if(ctznStmtDTO.isSingle()) {
saveAllAppendFiles(xmlDto, appendFileDto, dtl, fileCnt); saveAllAppendFiles(xmlDto, appendFileDto, dtl, fileCnt);
// FIXME: src file backup
processOrgFileBackup(filePath, fi);
return; return;
} }
@ -154,14 +158,14 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}; };
} }
saveFstOverAppendFiles(appendFileDto, dtl, pngDtlDTO, index.get()); saveFstOverAppendFiles(appendFileDto, dtl, pngDtlDTO, index.get());
// FIXME: src file backup
processOrgFileBackup(filePath, fi);
} }
index.addAndGet(1); index.addAndGet(1);
}; };
}); });
} }
/** /**
* xml parsing * xml parsing
* *
@ -459,189 +463,21 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
return fileMstDTO; return fileMstDTO;
} }
private static String makeUploadPath() { private String makeUploadPath() {
String dateStr = DateUtils.getToday(""); String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4); dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
return "/" + dateStr; return "/" + dateStr;
} }
private void processOrgFileBackup(String filePath, FolderReqDTO.FileInfo fi) {
try {
FileUtils.moveFile(
new File(filePath + "/" + fi.getFileNm())
, new File(rcvBackupRoot + uploadNewsPaperPath + "/" + fi.getFileNm())
);
@SuppressWarnings("DuplicatedCode") } catch (IOException fee){
public static void main(String[] args) { fee.printStackTrace();
String xdata = "D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399_backup.xml";
NatlNewspaperRcvXmlDTO xmlDto = XmlParseUtils.readXmlToObject(NatlNewspaperRcvXmlDTO.class, xdata);
String reasonStr = xmlDto.getPetiReasonL();
log.debug(reasonStr);
// 단일데이타 : 차량번호가 동일(차량번호가 없는 경우 포함)
CtznStmtDTO dto = new CtznStmtDTO();
List<CtznStmtDTO.CtznStmtDtl> dtlList = new ArrayList<>();
// 중복데이타 목록
List<CtznStmtDTO.DupData> dupDataList = dto.getDupDataList();
dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dto.setInsttCode(xmlDto.getAncCodeV());
dto.setSysCode(FimsConst.SysCode.PVS.getCode());
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.UNPROCESSED.getCode());
//dto.setCtznSttemntProcessSttus();
dto.setRegister("");
//---------------------------------
// 단속일시 / 차량번호
//---------------------------------
//* (1/2) C: 2022/09/15 21:38:10 차량번호 : 11서0194 (위·변조 없음)
//* (2/2) C: 2022/09/15 21:40:02 차량번호 : 11서0194 (위·변조 없음)
// "(1/2) C: " 문자열 패턴
String regx = "(\\*\\s\\(\\d.*\\/\\d.*\\)\\s[GCS]:\\s)(.*)(\\s차량번호\\s:\\s)(.*)";
Pattern pattern = Pattern.compile(regx);
Matcher matcher = pattern.matcher(reasonStr);
boolean isFirst = true;
String carNo = null;
while(matcher.find()) {
String[] arrSrc =
matcher.group()
.replaceAll(regx, "$2,$4")
.replaceAll("\\(위·변조 없음\\)", "")
.replaceAll("[: /]", "")
.split(",");
CtznStmtDTO.CtznStmtDtl dtlDto = new CtznStmtDTO.CtznStmtDtl();
//단속일시
dtlDto.setRegltDeTime(arrSrc[0]);
//차량번호
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.setRegister("");
dtlDto.setCtznSttemntDetailProcessSttus(FimsConst.CtznSttemntStatusCode.UNPROCESSED.getCode());
dtlList.add(dtlDto);
isFirst = false;
}
if(!dto.isSingle()) {
CtznStmtDTO.DupData dupDto = new CtznStmtDTO.DupData();
dupDto.setSttemntDetailDTO(dtlList.get(0));
dupDto.getIndexs().add(0);
dto.getDupDataList().add(dupDto);
for (int idx = 1; idx < dtlList.size(); idx++) {
CtznStmtDTO.CtznStmtDtl 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()) {
CtznStmtDTO.DupData ddto = new CtznStmtDTO.DupData();
ddto.setSttemntDetailDTO(tgt);
ddto.getIndexs().add(idx);
dto.getDupDataList().add(ddto);
}
}
}
// 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해)
dtlList = dtlList.stream()
.sorted(Comparator.comparing(CtznStmtDTO.CtznStmtDtl::getRegltDeTime).reversed()).collect(
Collectors.toList());
// 중복제거(동일 차량 번호중 단속일시가 가장 늦은것 pick)
// 차량번호가 없는 경우가 존재하여 체크로직 추가
dtlList = FunctionUtils.removeDuplication(dtlList, dtl -> {
if(Checks.isNotEmpty(dtl.getVhcleNo())) return dtl.getVhcleNo();
return dtl;
});
//---------------------------------
// GPS 위도
//---------------------------------
//* 발생지역 위도:37.37350845336914 경도:126.9384536743164
regx = "(\\*\\s발생지역\\s위도:)(.*)(\\s경도:)(.*)\\n";
pattern = Pattern.compile(regx);
matcher = pattern.matcher(reasonStr);
while(matcher.find()){
String[] arrGps = matcher.group()
.replaceAll(regx, "$2,$4")
.split(",");
dtlList.forEach(dtlDto -> {
dtlDto.setGpsX(arrGps[0]);
dtlDto.setGpsY(arrGps[1]);
});
}
//---------------------------------
// 단속장소
//---------------------------------
//[사고발생지역]경기도 군포시 산본동 73-35
regx = "(\\[사고발생지역\\])(.*)(\\n)";
pattern = Pattern.compile(regx);
matcher = pattern.matcher(reasonStr);
while(matcher.find()){
String str = matcher.group()
.replaceAll(regx, "$2");
dtlList.forEach(dtlDto -> {
dtlDto.setRegltPlace(str);
});
}
//---------------------------------
// 위반내역명
//---------------------------------
//(SPP-2209-1517326)소화전 불법 주정차 신고입니다.* 안전신문고 신고파]
String petiTitleStr = xmlDto.getPetiTitleV();
regx = "(\\(.*\\))(.*)(\\s신고입니다.*)";
pattern = Pattern.compile(regx);
matcher = pattern.matcher(petiTitleStr);
while(matcher.find()){
String str = matcher.group()
.replaceAll(regx, "$2");
dtlList.forEach(dtlDto -> {
dtlDto.setVioltDtlsNm(str);
});
} }
dto.setStmtDtlDTOs(dtlList);
log.debug("{}", dto);
//return dto;
} }
} }

@ -132,5 +132,6 @@ file.upload.cctv-fix.path=/cctv-fix
file.upload.cctv-drv.path=/cctv-drv file.upload.cctv-drv.path=/cctv-drv
file.rcv.root=/data/fims/extnl/rcv file.rcv.root=/data/fims/extnl/rcv
file.rcv.backup.root=/data/fims/extnl/backup
file.rcv.natl-newspaper.path=/natl-newspaper file.rcv.natl-newspaper.path=/natl-newspaper
file.rcv.busonly-cctv.path=/busonly file.rcv.busonly-cctv.path=/busonly

@ -133,6 +133,7 @@ file.upload.cctv-fix.path=/cctv-fix
file.upload.cctv-drv.path=/cctv-drv file.upload.cctv-drv.path=/cctv-drv
#file.rcv.root=/Users/minuk/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0 #file.rcv.root=/Users/minuk/project_data/fims/01. \uC5F0\uACC4/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0
file.rcv.root=D:/project_data/fims/01. \uC5F0\uACC4 file.rcv.root=D:/data/fims/extnl/rcv
file.rcv.natl-newspaper.path=/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0/rcv file.rcv.backup.root=D:/data/fims/extnl/backup
file.rcv.busonly-cctv.path=/02. CCTV/CCTV \uC0D8\uD50C\uC790\uB8CC/\uBC84\uC2A4\uC804\uC6A9\uCC28\uB85C file.rcv.natl-newspaper.path=/natl-newspaper
file.rcv.busonly-cctv.path=/busonly

Loading…
Cancel
Save