From 56e415581f933e3146ac1038811657a28e4c0723 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 13 Oct 2023 13:21:25 +0900 Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EC=8A=A4=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fims/crdn/parsing/AttachedTxtParser.java | 14 +++++- .../fims/crdn/parsing/LayoutDescriptor.java | 4 ++ .../fims/crdn/parsing/OnlyImageParser.java | 7 ++- .../fims/crdn/parsing/SingleFileParser.java | 15 +++++- .../crdn/service/bean/ImportServiceBean.java | 13 ++--- .../xit/fims/crdn/web/Crdn05Controller.java | 9 ++-- .../mapper/fims/crdn/global-stng-mapper.xml | 47 ++++++++++--------- 7 files changed, 74 insertions(+), 35 deletions(-) diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java index 03e19ac7..e1159eea 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java @@ -6,7 +6,9 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Path; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.stream.Collectors; @@ -39,9 +41,19 @@ public class AttachedTxtParser extends LayoutParser{ dataObject.put("FILE_PATH", filePath); String fileName = file.getName(); dataObject.put("FILE_NAME", fileName); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd / HH:mm:ss"); + dataObject.put("FILE_LAST_MODIFIED", sdf.format(new Date(file.lastModified()))); + dataObject.put("FILE_SIZE", file.length()+" byte"); + String fileExtension = FilenameUtils.getExtension(fileName); dataObject.put("FILE_EXTENSION", fileExtension); + boolean isUserUpload = file.compareTo(new File(descriptor.getLinkFileLocation()+File.separator+fileName)) == 0; + if(!isUserUpload) { + dataObject.put("LINK_ENT_NM", descriptor.getLinkEnterpriseName()); + } + boolean isMetaData = fileExtension.toUpperCase().equals("TXT"); String[] fileNameSplit = FilenameUtils.removeExtension(fileName).split(Matcher.quoteReplacement("_")); @@ -102,7 +114,7 @@ public class AttachedTxtParser extends LayoutParser{ } } dataObject.put("TEMP_GROUP_ID", tempGroupSeq); - dataObject.put("ENT_TYPE", "xit"); + dataObjectList.add(dataObject); before = dataObject; }); diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java index 872567d8..6a8cb57f 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java @@ -82,4 +82,8 @@ public class LayoutDescriptor { */ private String secondSeperatorStarterItems; + /** + * 연계 업체 명 + */ + private String linkEnterpriseName; } diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java index 15538671..668ac80a 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java @@ -46,6 +46,11 @@ public class OnlyImageParser extends LayoutParser { String extension = FilenameUtils.getExtension(fileName); dataObject.put("FILE_EXTENSION", extension); + boolean isUserUpload = file.compareTo(new File(descriptor.getLinkFileLocation()+File.separator+fileName)) == 0; + if(!isUserUpload) { + dataObject.put("LINK_ENT_NM", descriptor.getLinkEnterpriseName()); + } + String[] fileNameSplit = FilenameUtils.removeExtension(fileName).split(Matcher.quoteReplacement("_")); dataObject.put("DEVICE_ID", fileNameSplit[0]); @@ -96,7 +101,7 @@ public class OnlyImageParser extends LayoutParser { } dataObject.put("TEMP_GROUP_ID", tempGroupSeq); - dataObject.put("ENT_TYPE", "ino"); + dataObjectList.add(dataObject); before = dataObject; }); diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java index f4eae89a..7e0ae21b 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java @@ -7,10 +7,12 @@ import java.io.InputStream; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Base64; import java.util.Base64.Decoder; import java.util.Base64.Encoder; +import java.util.Date; import java.util.List; import cokr.xit.base.file.FileInfo; @@ -36,6 +38,17 @@ public class SingleFileParser extends LayoutParser { String fileName = file.getName(); dataObject.put("FILE_NAME", fileName); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd / HH:mm:ss"); + dataObject.put("FILE_LAST_MODIFIED", sdf.format(new Date(file.lastModified()))); + dataObject.put("FILE_SIZE", file.length()+" byte"); + + dataObject.put("FILE_EXTENSION",""); + + boolean isUserUpload = file.compareTo(new File(descriptor.getLinkFileLocation()+File.separator+fileName)) == 0; + if(!isUserUpload) { + dataObject.put("LINK_ENT_NM", descriptor.getLinkEnterpriseName()); + } + //파일내용 String fileCn0 = ""; try { @@ -78,7 +91,6 @@ public class SingleFileParser extends LayoutParser { dataObject.put("TRAFFIC_LIGHT_TYPE", CmmnUtil.substringByBytes(fileCn, 113, 113)); //신호등종류(미사용) dataObject.put("SOME", CmmnUtil.substringByBytes(fileCn, 113, 113)); //?(미사용) - String fileAreaText = fileCn0.substring(114); Encoder encoder = Base64.getEncoder(); @@ -127,7 +139,6 @@ public class SingleFileParser extends LayoutParser { dataObject.put("TEMP_GROUP_ID", tempGroupSeq); tempGroupSeq++; - dataObject.put("ENT_TYPE", "hitecom"); dataObjectList.add(dataObject); }); 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 77687f68..f1df383f 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 @@ -110,9 +110,9 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ DataObject linkFileInfo = endData; - String entType = linkFileInfo.string("ENT_TYPE"); + String entType = linkFileInfo.string("LINK_ENT_NM"); if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); - if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); else crdn.setCrdnInptSeCd("15"); crdn.setCrdnInptSeCd("11"); @@ -155,9 +155,9 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } } - String entType = metaFileInfo.string("ENT_TYPE"); + String entType = metaFileInfo.string("LINK_ENT_NM"); if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); - if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); else crdn.setCrdnInptSeCd("15"); crdn.setVltnCd("01"); @@ -207,11 +207,12 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } DataObject linkFileInfo = linkFileInfoList.get(0); - String entType = linkFileInfo.string("ENT_TYPE"); + String entType = linkFileInfo.string("LINK_ENT_NM"); if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); - if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); else crdn.setCrdnInptSeCd("15"); + crdn.setVltnCd("01"); crdn.setCrdnSeCd("07"); diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java index b6170673..5e30ac08 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -233,7 +233,7 @@ public class Crdn05Controller extends ApplicationController { */ public ModelAndView getEquipmentFileInfoList(HttpServletRequest hReq) { ModelAndView mav = new ModelAndView("jsonView"); - List parsedDataList = new ArrayList(); + List allParsedDataList = new ArrayList(); String taskSeCd = hReq.getParameter("taskSeCd"); String institute = currentUser().getInstitute(); @@ -264,12 +264,15 @@ public class Crdn05Controller extends ApplicationController { case "BIN": parser = new SingleFileParser(); break; } + parser.setDescriptor(layoutDescriptors.get(i)); + if(!fileList.isEmpty()) { - parsedDataList.addAll(parser.parsing(fileList)); + List parsedDataList = parser.parsing(fileList); + allParsedDataList.addAll(parsedDataList); } } - mav = setCollectionInfo(mav, parsedDataList, ""); + mav = setCollectionInfo(mav, allParsedDataList, ""); return mav; } diff --git a/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml index 8ae0b750..6cdf6d15 100644 --- a/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml @@ -18,6 +18,7 @@ + /* 연계파일 레이아웃 정보 조회(globalStngMapper.selectLinkFileLayoutMetadata) */ -SELECT FILE_LAYOUT_ID - , SGG_CD - , TASK_SE_CD - , INST_CD - , DEPT_CD - , DATA_FILE_SE - , FILE_NM_SZ - , FILE_SE_TYPE - , FILE_NM_LAYOUT - , DATA_SE_TYPE1 - , DATA_LAYOUT1 - , DATA_SE_TYPE2 - , DATA_LAYOUT2 - , FILE_TNOCS - , LINK_FILE_PATH - FROM TB_CRDN_FILE_LAYOUT - WHERE USE_YN = 'Y' +SELECT A.FILE_LAYOUT_ID + , A.SGG_CD + , A.TASK_SE_CD + , A.INST_CD + , A.DEPT_CD + , A.DATA_FILE_SE + , A.FILE_NM_SZ + , A.FILE_SE_TYPE + , A.FILE_NM_LAYOUT + , A.DATA_SE_TYPE1 + , A.DATA_LAYOUT1 + , A.DATA_SE_TYPE2 + , A.DATA_LAYOUT2 + , A.FILE_TNOCS + , A.LINK_FILE_PATH + , B.LINK_ENT_NM + FROM TB_CRDN_FILE_LAYOUT A + LEFT OUTER JOIN TB_FTP_INFO B ON (A.FILE_LAYOUT_ID = B.FILE_LAYOUT_ID) + WHERE A.USE_YN = 'Y' - AND FILE_LAYOUT_ID = #{fileLayoutId} + AND A.FILE_LAYOUT_ID = #{fileLayoutId} - AND SGG_CD = #{sggCd} - AND TASK_SE_CD = #{taskSeCd} - AND INST_CD = #{instCd} - AND DEPT_CD = #{deptCd} + AND A.SGG_CD = #{sggCd} + AND A.TASK_SE_CD = #{taskSeCd} + AND A.INST_CD = #{instCd} + AND A.DEPT_CD = #{deptCd}