diff --git a/src/main/java/kr/xit/fims/biz/ec/model/CtznSttemntDTO.java b/src/main/java/kr/xit/fims/biz/ec/model/CtznSttemntDTO.java index f59e26de..7321eedc 100644 --- a/src/main/java/kr/xit/fims/biz/ec/model/CtznSttemntDTO.java +++ b/src/main/java/kr/xit/fims/biz/ec/model/CtznSttemntDTO.java @@ -1,6 +1,7 @@ package kr.xit.fims.biz.ec.model; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; @@ -94,7 +95,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType private String updtDt; private String updusr; - private List dtlList; + private List dtlList = new ArrayList<>(); @Getter @Setter 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 1ef39393..b93f0ced 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 @@ -5,6 +5,8 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.ibatis.session.RowBounds; import org.springframework.beans.factory.annotation.Value; @@ -15,6 +17,8 @@ import org.springframework.web.multipart.MultipartFile; import kr.xit.fims.biz.cmm.FimsConst; import kr.xit.fims.biz.ec.mapper.IEcNatlNewspaperMapper; +import kr.xit.fims.biz.ec.model.CtznSttemntDTO; +import kr.xit.fims.biz.ec.model.CtznSttemntDetailDTO; import kr.xit.fims.biz.ec.model.EcNatlNewspaperRcvReqDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO; import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO; @@ -74,6 +78,11 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { xmlDto.setRegister(getUserUniqId()); mapper.insertEcEsbInterface(xmlDto); + //TODO: ~~~~~~~~~~~~~ + CtznSttemntDTO ctznSttemntDTO = new CtznSttemntDTO(); + ctznSttemntDTO.setDtlList(parseReason(xmlDto.getPetiReasonL())); + //List list = parseReason(xmlDto.getPetiReasonL()); + // 첨부 파일 생성 NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto = xmlDto.getAppendFileInfo(); int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount()); @@ -128,17 +137,222 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService { return mapper.selectEcEsbInterfaces(paraMap, rowBounds); } + private List parseReason(final String reasonStr){ + List list = new ArrayList<>(); + + //--------------------------------- + // 단속일시 / 차량번호 + //--------------------------------- + //* (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.*\\)\\sC:\\s"; + + Pattern pattern = Pattern.compile(regx+".*"); + Matcher matcher = pattern.matcher(reasonStr); + while(matcher.find()) { + String[] arrSrc = + matcher.group() + .replaceAll(regx, "") + .replaceAll("차량번호 : ", "") + .replaceAll(" \\(위·변조 없음\\)", "") + .split("\\s"); + + CtznSttemntDTO.CtznSttemntDetailDTO dto = new CtznSttemntDTO.CtznSttemntDetailDTO(); + //단속일시 + dto.setRegltDeTime(arrSrc[0].concat(arrSrc[1]).replaceAll("[\\/:]","")); + //차량번호 + dto.setVhcleNo(arrSrc[2]); + list.add(dto); + } + + //--------------------------------- + // GPS 위도 + //--------------------------------- + //* 발생지역 위도:37.37350845336914 경도:126.9384536743164 + regx = "\\*\\s발생지역\\s"; + + pattern = Pattern.compile(regx+".*"); + matcher = pattern.matcher(reasonStr); + while(matcher.find()){ + String[] arrGps = matcher.group() + .replaceAll(regx, "") + .replaceAll("[위도:경도:]", "") + .split("\\s"); + + list.forEach(dto -> { + dto.setGpsX(arrGps[0]); + dto.setGpsY(arrGps[1]); + }); + } + + //--------------------------------- + // 단속장소 / 위반내역명 + //--------------------------------- + //[사고발생지역]경기도 군포시 산본동 73-35 + //소화전 불법 주정차 신고입니다. + regx = "\\[사고발생지역\\].*\\n"; + + pattern = Pattern.compile(regx+".*"); + matcher = pattern.matcher(reasonStr); + while(matcher.find()){ + String[] arrSrc = matcher.group() + .replaceAll("[\\[사고발생지역\\]신고입니다.]", "") + .split("\\n"); + + list.forEach(dto -> { + dto.setRegltPlace(arrSrc[0]); + dto.setVioltDtlsNm(arrSrc[1].trim()); + }); + } + return list; + } + public static void main(String[] args) { - String data = "D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399.xml"; + String data = "/Users/minuk/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399.xml"; NatlNewspaperRcvXmlDTO xmlDto = XmlParseUtils.readXmlToObject(NatlNewspaperRcvXmlDTO.class, data); String reasonStr = xmlDto.getPetiReasonL(); log.debug(reasonStr); - // /\*\s\(.\/.*\)\sC:\s/g - // - // /\*\s\(.\/.*\)\sC:\s.*/g + List list = new ArrayList<>(); + + //--------------------------------- + // 단속일시 / 차량번호 + //--------------------------------- + //* (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.*\\)\\sC:\\s"; + + Pattern pattern = Pattern.compile(regx+".*"); + Matcher matcher = pattern.matcher(reasonStr); + while(matcher.find()) { + String[] arrSrc = + matcher.group() + .replaceAll(regx, "") + .replaceAll("차량번호 : ", "") + .replaceAll(" \\(위·변조 없음\\)", "") + .split("\\s"); + + CtznSttemntDetailDTO dto = new CtznSttemntDetailDTO(); + //단속일시 + dto.setRegltDeTime(arrSrc[0].concat(arrSrc[1]).replaceAll("[\\/:]","")); + //차량번호 + dto.setVhcleNo(arrSrc[2]); + list.add(dto); + } + //--------------------------------- + // GPS 위도 + //--------------------------------- + //* 발생지역 위도:37.37350845336914 경도:126.9384536743164 + regx = "\\*\\s발생지역\\s"; + pattern = Pattern.compile(regx+".*"); + matcher = pattern.matcher(reasonStr); + while(matcher.find()){ + String[] arrGps = matcher.group() + .replaceAll(regx, "") + .replaceAll("[위도:경도:]", "") + .split("\\s"); + + list.forEach(dto -> { + dto.setGpsX(arrGps[0]); + dto.setGpsY(arrGps[1]); + }); + } + + //--------------------------------- + // 단속장소 / 위반내역명 + //--------------------------------- + //[사고발생지역]경기도 군포시 산본동 73-35 + //소화전 불법 주정차 신고입니다. + regx = "\\[사고발생지역\\].*\\n"; + + pattern = Pattern.compile(regx+".*"); + matcher = pattern.matcher(reasonStr); + while(matcher.find()){ + String[] arrSrc = matcher.group() + .replaceAll("[\\[사고발생지역\\]신고입니다.]", "") + .split("\\n"); + + list.forEach(dto -> { + dto.setRegltPlace(arrSrc[0]); + dto.setVioltDtlsNm(arrSrc[1].trim()); + }); + } + + log.debug("{}", list); + + // //--------------------------------- + // // 단속일시 / 차량번호 + // //--------------------------------- + // //* (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.*\\)\\sC:\\s"; + // + // Pattern pattern = Pattern.compile(regx+".*"); + // Matcher matcher = pattern.matcher(reasonStr); + // while(matcher.find()) { + // String[] sss = + // matcher.group() + // .replaceAll(regx, "") + // .replaceAll("차량번호 : ", "") + // .replaceAll(" \\(위·변조 없음\\)", "") + // .split("\\s"); + // //log.debug("{}", sss.length); + // + // //단속일시 + // //CtznSttemntDetailDTO.regltDeTime + // log.debug(sss[0].concat(sss[1]).replaceAll("[\\/:]","")); + // + // //차량번호 + // //CtznSttemntDetailDTO.vhcleNo + // log.debug(sss[2]); + // } + // + // //--------------------------------- + // // GPS 위도 + // //--------------------------------- + // //* 발생지역 위도:37.37350845336914 경도:126.9384536743164 + // regx = "\\*\\s발생지역\\s"; + // + // pattern = Pattern.compile(regx+".*"); + // matcher = pattern.matcher(reasonStr); + // while(matcher.find()){ + // String[] arrGps = matcher.group() + // .replaceAll(regx, "") + // .replaceAll("[위도:경도:]", "") + // .split("\\s"); + // + // //CtznSttemntDetailDTO.gpsX + // log.debug("{}", arrGps[0]); + // //CtznSttemntDetailDTO.gpsY + // log.debug("{}", arrGps[1]); + // } + // + // //--------------------------------- + // // 단속장소 / 위반내역명 + // //--------------------------------- + // //[사고발생지역]경기도 군포시 산본동 73-35 + // //소화전 불법 주정차 신고입니다. + // regx = "\\[사고발생지역\\].*\\n"; + // + // pattern = Pattern.compile(regx+".*"); + // matcher = pattern.matcher(reasonStr); + // while(matcher.find()){ + // String[] sss = matcher.group() + // .replaceAll("[\\[사고발생지역\\]신고입니다.]", "") + // //.replaceAll("[위도:경도:]", "") + // .split("\\n"); + // + // //CtznSttemntDetailDTO.regltPlace + // log.debug("{}", sss[0].trim()); + // //CtznSttemntDetailDTO.violtDtlsNm + // log.debug("{}", sss[1].trim()); + // } } + }