From 0e2fff8283ea6b6a9b0ce5bd9ca3efc7042f27bf Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Wed, 4 Oct 2023 13:08:18 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=A5=EB=B9=84=EC=97=B0=EA=B3=84=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC(xit=EA=B6=8C=EC=9E=A5=ED=8F=AC=EB=A7=B7)=20=EB=8B=A8?= =?UTF-8?q?=EC=86=8D=EB=8C=80=EC=9E=A5=20=EB=93=B1=EB=A1=9D=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/fims/crdn/parsing/ParsingUtil.java | 4 +- .../xit/fims/crdn/parsing/XitRecommend.java | 68 ++++++++++++--- .../crdn/service/bean/ImportServiceBean.java | 53 +++++++++++ .../WEB-INF/jsp/fims/crdn/crdn05020-info.jsp | 87 +++++++++++++++---- 4 files changed, 183 insertions(+), 29 deletions(-) diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java b/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java index d2d4620e..d5285ac0 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java @@ -20,7 +20,9 @@ public class ParsingUtil { if(entType.equals("hitecom")) { workPath = "files"+File.separator+"tempForHitecom"; } - + if(entType.equals("xit")) { + workPath = "files"+File.separator+"tempForXit"; + } return workPath; } } diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/XitRecommend.java b/src/main/java/cokr/xit/fims/crdn/parsing/XitRecommend.java index 771dfa83..bdc6c0b1 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/XitRecommend.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/XitRecommend.java @@ -3,7 +3,6 @@ package cokr.xit.fims.crdn.parsing; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Path; @@ -19,6 +18,9 @@ import cokr.xit.foundation.data.DataObject; public class XitRecommend implements EquipmentEnterprise{ + private DataObject before = new DataObject(); + private int tempGroupSeq = 1; + @Override public List parsing(Stream fileList) { @@ -36,9 +38,10 @@ public class XitRecommend implements EquipmentEnterprise{ dataObject.put("FILE_PATH", filePath); String fileName = file.getName(); dataObject.put("FILE_NAME", fileName); + String fileExtension = FilenameUtils.getExtension(fileName); + dataObject.put("EXTENSION", fileExtension); - //TODO: - boolean isMetaData = FilenameUtils.getExtension(fileName).toUpperCase().equals("TXT"); + boolean isMetaData = fileExtension.toUpperCase().equals("TXT"); String[] fileNameSplit = FilenameUtils.removeExtension(fileName).split(Matcher.quoteReplacement("_")); String crdnTiemstamp = fileNameSplit[0]; @@ -54,18 +57,53 @@ public class XitRecommend implements EquipmentEnterprise{ BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file),Charset.forName("EUC-KR"))); - - } catch (FileNotFoundException e) { - + String line1 = br.readLine(); + String[] lineSplit = line1.split(Matcher.quoteReplacement(",")); + + dataObject.put("VHRNO", lineSplit[0]); + dataObject.put("CRDN_DONG_NM", lineSplit[1]); + dataObject.put("CRDN_PLC", lineSplit[2]); + dataObject.put("LAW", lineSplit[3]); + dataObject.put("SPECIAL_AREA", lineSplit[4]); + dataObject.put("CRDN_BGNG_TM", lineSplit[5]); + dataObject.put("CRDN_END_TM", lineSplit[6]); + + String line2 = br.readLine(); + if(line2 != null && !line2.equals("")) { + dataObject.put("CRDN_SE_CD", "02"); + + dataObject.put("GPS_X", line2); + String line3 = br.readLine(); + dataObject.put("GPS_Y", line3); + } else { + dataObject.put("CRDN_SE_CD", "01"); + } + + } catch (Exception e) { + throw new RuntimeException(e); } - - //파일내용.split(Matcher.quoteReplacement(",")); - } else { - + dataObject.put("VHRNO", ""); + dataObject.put("CRDN_DONG_NM", ""); + dataObject.put("CRDN_PLC", ""); + dataObject.put("LAW", ""); + dataObject.put("SPECIAL_AREA", ""); + dataObject.put("CRDN_BGNG_TM", ""); + dataObject.put("CRDN_END_TM", ""); + dataObject.put("GPS_X", ""); + dataObject.put("GPS_Y", ""); } + if(!before.isEmpty()) { + boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before); + if(isChangeTempGroup) { + tempGroupSeq++; + } + } + dataObject.put("TEMP_GROUP_ID", tempGroupSeq); + dataObject.put("ENT_TYPE", "xit"); dataObjectList.add(dataObject); + before = dataObject; }); return dataObjectList; @@ -115,9 +153,15 @@ public class XitRecommend implements EquipmentEnterprise{ @Override public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem) { - //TODO: - return false; + String currentFileNamePrefix = currentItem.string("FILE_NAME").substring(0,25); + String beforeFileNamePrefix = beforeItem.string("FILE_NAME").substring(0,25); + + if(currentFileNamePrefix.equals(beforeFileNamePrefix)) { + return false; + } else { + return true; + } } } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java index 9215b869..e901bbad 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java @@ -142,8 +142,61 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ crdn.setVltnCd("01"); } + //XIT권장포맷 + if(entType.equals("xit")) { + + crdn.setCrdnInptSeCd("15"); + + crdn.setVltnCd("01"); + + //1. 연계파일정보를 단속 엔티티로 변환 + crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); + + DataObject metaFileInfo = null; + for (DataObject linkFileInfo0 : linkFileInfoList) { + if(linkFileInfo0.string("EXTENSION").toUpperCase().equals("TXT")) { + metaFileInfo = linkFileInfo0; + } + } + + crdn.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD")); + crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD")); + crdn.setCrdnTm(metaFileInfo.string("CRDN_TM")); + crdn.setVhrno(metaFileInfo.string("VHRNO")); + crdn.setGpsX(metaFileInfo.string("GPS_X")); + crdn.setGpsY(metaFileInfo.string("GPS_Y")); + crdn.setCrdnBgngTm(metaFileInfo.string("CRDN_BGNG_TM")); + crdn.setCrdnEndTm(metaFileInfo.string("CRDN_END_TM")); + crdn.setCrdnPlc(metaFileInfo.string("CRDN_PLC")); + + if(metaFileInfo.string("SPECIAL_AREA").equals("어린이보호구역")) { + crdn.setCrdnSpareaCd("01"); + } else { + crdn.setCrdnSpareaCd("00"); + } + + //metaFileInfo.string("LAW"); + //metaFileInfo.string("EQM_CD"); + //metaFileInfo.string("CRDN_DONG_NM"); + + List files = new ArrayList<>(); + for (DataObject linkFileInfo0 : linkFileInfoList) { + if(!linkFileInfo0.string("EXTENSION").toUpperCase().equals("TXT")) { + files.add(new File(linkFileInfo0.string("FILE_PATH"))); + } + } + + fileInfoList = new FileInfoFactory().createFileInfos(null, files); + for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) { + fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName())); + } + + } + // if(entType.equals("hitecom")) { + crdn.setCrdnSeCd("07"); + crdn.setCrdnInptSeCd("15"); crdn.setVltnCd("01"); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp index 4266853e..e74ba94b 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp @@ -87,7 +87,7 @@ - + + + + +