diff --git a/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java b/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java index 79190c7a..f7757125 100644 --- a/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java @@ -12,7 +12,7 @@ import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPReply; public class FTPUtil { - public static boolean fileDown(remoteSystemInfo rs, String remoteWorkPath, String downloadRoot) { + public static boolean fileDown(RemoteSystemInfo rs, String remoteWorkPath, String downloadRoot) { FTPClient client = null; try { diff --git a/src/main/java/cokr/xit/fims/cmmn/ftp/remoteSystemInfo.java b/src/main/java/cokr/xit/fims/cmmn/ftp/RemoteSystemInfo.java similarity index 82% rename from src/main/java/cokr/xit/fims/cmmn/ftp/remoteSystemInfo.java rename to src/main/java/cokr/xit/fims/cmmn/ftp/RemoteSystemInfo.java index e02622b8..16c5fef2 100644 --- a/src/main/java/cokr/xit/fims/cmmn/ftp/remoteSystemInfo.java +++ b/src/main/java/cokr/xit/fims/cmmn/ftp/RemoteSystemInfo.java @@ -5,7 +5,7 @@ import lombok.Setter; @Getter @Setter -public class remoteSystemInfo { +public class RemoteSystemInfo { String ip; String id; String pw; diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/EquipmentEnterprise.java b/src/main/java/cokr/xit/fims/crdn/parsing/EquipmentEnterprise.java new file mode 100644 index 00000000..c80dccc2 --- /dev/null +++ b/src/main/java/cokr/xit/fims/crdn/parsing/EquipmentEnterprise.java @@ -0,0 +1,13 @@ +package cokr.xit.fims.crdn.parsing; + +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Stream; + +import cokr.xit.foundation.data.DataObject; + +public interface EquipmentEnterprise { + + public List parsing(Stream fileList); + +} diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/Ino.java b/src/main/java/cokr/xit/fims/crdn/parsing/Ino.java new file mode 100644 index 00000000..da408447 --- /dev/null +++ b/src/main/java/cokr/xit/fims/crdn/parsing/Ino.java @@ -0,0 +1,79 @@ +package cokr.xit.fims.crdn.parsing; + +import java.io.File; +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.Stream; + +import org.apache.commons.io.FilenameUtils; + +import cokr.xit.foundation.data.DataObject; + +public class Ino implements EquipmentEnterprise { + + @Override + public List parsing(Stream fileList) { + + List dataObjectList = new ArrayList<>(); + + fileList.forEach(item -> { + DataObject dataObject = new DataObject(); + File file = item.toFile(); + String filePath = file.getPath(); + 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("TIMESTAMP", sdf.format(new Date(file.lastModified()))); + dataObject.put("FILE_SIZE", file.length()+" byte"); + + String extension = FilenameUtils.getExtension(fileName); + dataObject.put("EXTENSION", extension); + + String[] fileNameSplit = FilenameUtils.removeExtension(fileName).split(Matcher.quoteReplacement("_")); + + dataObject.put("DEVICE_ID", fileNameSplit[0]); + dataObject.put("CRDN_YMD_TM", fileNameSplit[1]); + dataObject.put("VHRNO", fileNameSplit[2]); + dataObject.put("PHOTO_CNT", fileNameSplit[3]); + + String photoSeq = fileNameSplit[4]; + if(photoSeq.equals("1")) photoSeq = "입차사진"; + else if(photoSeq.equals("2")) photoSeq = "주차사진"; + else if(photoSeq.equals("3")) photoSeq = "위반사진"; + else if(photoSeq.equals("4")) photoSeq = "출차사진"; + + dataObject.put("PHOTO_SEQ", photoSeq); + + dataObject.put("LOCATION_X", fileNameSplit[5]); + dataObject.put("LOCATION_Y", fileNameSplit[6]); + + String inputSe = fileNameSplit[7]; + if(inputSe.equals("S")) inputSe = "정상등록자료"; + else if(inputSe.equals("E")) inputSe = "삭제자료"; + + dataObject.put("INPUT_SE", inputSe); + dataObject.put("CRDN_PLC", fileNameSplit[8]); + dataObject.put("CRDN_ADDRESS", fileNameSplit[9]); + dataObject.put("CRDN_STDG_NM", fileNameSplit[10]); + + if(fileNameSplit.length >= 12) { + String crdnCn = fileNameSplit[11]; + if(crdnCn.equals("00")) crdnCn = "사용안함"; + else if(crdnCn.equals("01")) crdnCn = "일반차량(전기차)"; + else if(crdnCn.equals("02")) crdnCn = "장기주차(전기차)"; + dataObject.put("CRDN_CN", crdnCn); + } + + dataObjectList.add(dataObject); + }); + + return dataObjectList; + } + +} diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/Knl.java b/src/main/java/cokr/xit/fims/crdn/parsing/Knl.java new file mode 100644 index 00000000..69f3729e --- /dev/null +++ b/src/main/java/cokr/xit/fims/crdn/parsing/Knl.java @@ -0,0 +1,16 @@ +package cokr.xit.fims.crdn.parsing; + +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Stream; + +import cokr.xit.foundation.data.DataObject; + +public class Knl implements EquipmentEnterprise { + + @Override + public List parsing(Stream fileList) { + return null; + } + +} 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 92ef6eac..f0319199 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -3,19 +3,17 @@ package cokr.xit.fims.crdn.web; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; +import java.util.stream.Stream; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import org.apache.commons.io.FilenameUtils; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; @@ -27,6 +25,9 @@ import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnInstMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.fims.crdn.parsing.EquipmentEnterprise; +import cokr.xit.fims.crdn.parsing.Ino; +import cokr.xit.fims.crdn.parsing.Knl; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.CrdnStngService; import cokr.xit.foundation.data.DataObject; @@ -103,87 +104,65 @@ public class Crdn05Controller extends ApplicationController { ModelAndView mav = new ModelAndView("jsonView"); String entType = hReq.getParameter("entType"); + EquipmentEnterprise enterprise = null; + switch(entType){ + case "이노": enterprise = new Ino(); break; + case "knl": enterprise = new Knl(); break; + //case "": enterprise = new (); break; + //case "": enterprise = new (); break; + //case "": enterprise = new (); break; + } + + Stream fileList = null; List dataObjectList = new ArrayList<>(); - String downloadRoot = ""; + String downloadRoot = ""; //ftp나 usb에서 다운받는 파일 경로 - if(entType.equals("이노")) { + if(entType.equals("이노") || entType.equals("knl")) { + //ftp G클라우드 try { - //TODO : FTP접속정보 설정 + if(entType.equals("이노")) { + + //RemoteSystemInfo rs = new RemoteSystemInfo(); + //rs.setIp("211.119.124.9"); + //rs.setId("xituser"); + //rs.setPw("xituser!@"); + //rs.setOsType("linux"); + + //String remoteWorkPath = File.separator + "applications" + // + File.separator + "tempForFTPTest" + // + File.separator + "ino" + // + File.separator; + + downloadRoot = "files"+File.separator+"tempForIno"; + } + if(entType.equals("knl")) { - downloadRoot = "files"+File.separator+"tempForIno"; - //TODO : FTP접속 및 다운로드 + + downloadRoot = "files"+File.separator+"tempForKnl"; + } + + //boolean result = FTPUtil.fileDown(rs, remoteWorkPath, downloadRoot); } catch (Exception e) { e.printStackTrace(); } - try { - Files.walk(Paths.get(downloadRoot)) - .filter(Files::isRegularFile) - .forEach(item -> { - DataObject dataObject = new DataObject(); - File file = item.toFile(); - String filePath = file.getPath(); - 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("TIMESTAMP", sdf.format(new Date(file.lastModified()))); - dataObject.put("FILE_SIZE", file.length()+" byte"); - - String extension = FilenameUtils.getExtension(fileName); - dataObject.put("EXTENSION", extension); - - String[] fileNameSplit = FilenameUtils.removeExtension(fileName).split(Matcher.quoteReplacement("_")); - - dataObject.put("DEVICE_ID", fileNameSplit[0]); - dataObject.put("CRDN_YMD_TM", fileNameSplit[1]); - dataObject.put("VHRNO", fileNameSplit[2]); - dataObject.put("PHOTO_CNT", fileNameSplit[3]); - - String photoSeq = fileNameSplit[4]; - if(photoSeq.equals("1")) photoSeq = "입차사진"; - else if(photoSeq.equals("2")) photoSeq = "주차사진"; - else if(photoSeq.equals("3")) photoSeq = "위반사진"; - else if(photoSeq.equals("4")) photoSeq = "출차사진"; - - dataObject.put("PHOTO_SEQ", photoSeq); - - dataObject.put("LOCATION_X", fileNameSplit[5]); - dataObject.put("LOCATION_Y", fileNameSplit[6]); - - String inputSe = fileNameSplit[7]; - if(inputSe.equals("S")) inputSe = "정상등록자료"; - else if(inputSe.equals("E")) inputSe = "삭제자료"; - - dataObject.put("INPUT_SE", inputSe); - dataObject.put("CRDN_PLC", fileNameSplit[8]); - dataObject.put("CRDN_ADDRESS", fileNameSplit[9]); - dataObject.put("CRDN_STDG_NM", fileNameSplit[10]); - - if(fileNameSplit.length >= 12) { - String crdnCn = fileNameSplit[11]; - if(crdnCn.equals("00")) crdnCn = "사용안함"; - else if(crdnCn.equals("01")) crdnCn = "일반차량(전기차)"; - else if(crdnCn.equals("02")) crdnCn = "장기주차(전기차)"; - dataObject.put("CRDN_CN", crdnCn); - } - - dataObjectList.add(dataObject); - }); - } catch (IOException e) { - e.printStackTrace(); - } - - mav = setCollectionInfo(mav, dataObjectList, ""); } + try { + //폴더는 제외하고 파일만 필터링 + fileList = Files.walk(Paths.get(downloadRoot)).filter(Files::isRegularFile); + } catch (IOException e) { + e.printStackTrace(); + } + + dataObjectList = enterprise.parsing(fileList); + mav = setCollectionInfo(mav, dataObjectList, ""); return mav; } 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 40f76e3c..ca579141 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 @@ -8,7 +8,7 @@
+ class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">과태료업무 @@ -29,40 +29,35 @@
-
- + +
+ class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">cctv 구분 - -
- -
- -
-
- -
-
-
-
- - - - - - -
-
+ +
+ + + + + + + + + + + +
+