From aa99ccffada745b8590bd07a72c3a2c3785ace39 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 29 Dec 2022 22:15:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=99=B8=EB=B6=80=EC=97=B0=EA=B3=84=20?= =?UTF-8?q?-=20=EC=9B=90=EB=B3=B8=EB=B0=B1=EC=97=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ec/service/EcCctvCrackdownService.java | 30 ++- .../ec/service/EcNatlNewspaperService.java | 206 ++---------------- .../resources/props/dev/globals.properties | 1 + .../resources/props/local/globals.properties | 7 +- 4 files changed, 48 insertions(+), 196 deletions(-) diff --git a/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java b/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java index f2388efd..fa36325c 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/EcCctvCrackdownService.java @@ -1,5 +1,6 @@ package kr.xit.fims.biz.ec.service; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -10,6 +11,7 @@ import java.util.Objects; import java.util.stream.Collectors; import org.apache.commons.collections4.ListUtils; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.ibatis.session.RowBounds; import org.springframework.beans.factory.annotation.Value; @@ -50,11 +52,8 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { @Value("#{prop['file.upload.busonly-cctv.path']}") private String uploadBusCctvPath; - // @Value("#{prop['file.rcv.root']}") - // private String rcvRoot; - // - // @Value("#{prop['file.rcv.natl-newspaper.path']}") - // private String rcvNewsPaperPath; + @Value("#{prop['file.rcv.backup.root']}") + private String rcvBackupRoot; private final IEcCctvCrackdownMapper mapper; private final IEcCtznSttemntMapper ctznSttemntMapper; @@ -143,6 +142,7 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { * 2) tb_ec_extrl_reglt_cntc insert * 3) tb_cmm_file_mastr insert * tb_cmm_file_detail insert + * 4) 완료 파일 backup * @param dto * */ @@ -151,9 +151,11 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { public void saveBusCctvCrackdownDatas(final FolderReqDTO dto) { String filePath = dto.getFilePath(); + //for(FolderReqDTO.FileInfo fi: dto.getFileInfoList()) { dto.getFileInfoList().forEach((fi) -> { 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() @@ -164,8 +166,8 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { //.어린이보호구역 .regltBeginTime(busOnlyDTO.getRegltTime()) .regltEndTime(busOnlyDTO.getRegltTime()) - .gpsX(busOnlyDTO.getGpsX().substring(0,20)) - .gpsY(busOnlyDTO.getGpsY().substring(0,20)) + .gpsX(busOnlyDTO.getGpsX().substring(0, 20)) + .gpsY(busOnlyDTO.getGpsY().substring(0, 20)) .regltDe(busOnlyDTO.getRegltDe()) //단속업체 @@ -186,7 +188,19 @@ public class EcCctvCrackdownService implements IEcCctvCrackdownService { .cmmFileDtls(new ArrayList<>()) .build(); 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(); + } }); + //} } diff --git a/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java b/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java index 001fdc7d..d7ffa689 100644 --- a/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java +++ b/src/main/java/kr/xit/fims/biz/ec/service/EcNatlNewspaperService.java @@ -1,5 +1,7 @@ package kr.xit.fims.biz.ec.service; +import java.io.File; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -13,6 +15,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.apache.commons.io.FileUtils; import org.apache.ibatis.session.RowBounds; import org.springframework.beans.factory.annotation.Value; 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.IEcNatlNewspaperMapper; 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.NatlNewspaperRcvDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO; import kr.xit.framework.biz.cmm.model.CmmFileDTO; import kr.xit.framework.biz.cmm.service.ICmmFileService; @@ -50,11 +53,8 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { @Value("#{prop['file.upload.natl-newspaper.path']}") private String uploadNewsPaperPath; - // @Value("#{prop['file.rcv.root']}") - // private String rcvRoot; - // - // @Value("#{prop['file.rcv.natl-newspaper.path']}") - // private String rcvNewsPaperPath; + @Value("#{prop['file.rcv.backup.root']}") + private String rcvBackupRoot; private final IEcNatlNewspaperMapper mapper; private final IEcCtznSttemntMapper ctznSttemntMapper; @@ -81,6 +81,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { * tb_ex_ctzn_sttemnt_detail insert * 3) tb_cmm_file_mastr insert * tb_cmm_file_detail insert + * 4) 완료 파일 backup * @param dto * */ @@ -125,6 +126,9 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { // 단속건수가 1건인 경우 파일 전체 저장 if(ctznStmtDTO.isSingle()) { saveAllAppendFiles(xmlDto, appendFileDto, dtl, fileCnt); + + // FIXME: src file backup + processOrgFileBackup(filePath, fi); return; } @@ -154,14 +158,14 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { }; } saveFstOverAppendFiles(appendFileDto, dtl, pngDtlDTO, index.get()); + // FIXME: src file backup + processOrgFileBackup(filePath, fi); } index.addAndGet(1); }; }); } - - /** * xml parsing * @@ -459,189 +463,21 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { return fileMstDTO; } - private static String makeUploadPath() { + private String makeUploadPath() { String dateStr = DateUtils.getToday(""); dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4); 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") - public static void main(String[] args) { - 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 dtlList = new ArrayList<>(); - // 중복데이타 목록 - List 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); - }); + } catch (IOException fee){ + fee.printStackTrace(); } - dto.setStmtDtlDTOs(dtlList); - - log.debug("{}", dto); - //return dto; - } - - - } diff --git a/src/main/resources/props/dev/globals.properties b/src/main/resources/props/dev/globals.properties index eef86420..05101e10 100644 --- a/src/main/resources/props/dev/globals.properties +++ b/src/main/resources/props/dev/globals.properties @@ -132,5 +132,6 @@ file.upload.cctv-fix.path=/cctv-fix file.upload.cctv-drv.path=/cctv-drv file.rcv.root=/data/fims/extnl/rcv +file.rcv.backup.root=/data/fims/extnl/backup file.rcv.natl-newspaper.path=/natl-newspaper file.rcv.busonly-cctv.path=/busonly diff --git a/src/main/resources/props/local/globals.properties b/src/main/resources/props/local/globals.properties index 84456273..a7d48b19 100644 --- a/src/main/resources/props/local/globals.properties +++ b/src/main/resources/props/local/globals.properties @@ -133,6 +133,7 @@ file.upload.cctv-fix.path=/cctv-fix 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=D:/project_data/fims/01. \uC5F0\uACC4 -file.rcv.natl-newspaper.path=/01. \uAD6D\uBBFC\uC2E0\uBB38\uACE0/rcv -file.rcv.busonly-cctv.path=/02. CCTV/CCTV \uC0D8\uD50C\uC790\uB8CC/\uBC84\uC2A4\uC804\uC6A9\uCC28\uB85C +file.rcv.root=D:/data/fims/extnl/rcv +file.rcv.backup.root=D:/data/fims/extnl/backup +file.rcv.natl-newspaper.path=/natl-newspaper +file.rcv.busonly-cctv.path=/busonly