소스 정리

main
이범준 1 year ago
parent dd6aa937a8
commit 6cd14ea8ce

@ -12,7 +12,7 @@ import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply; import org.apache.commons.net.ftp.FTPReply;
public class FTPUtil { 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; FTPClient client = null;
try { try {

@ -5,7 +5,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class remoteSystemInfo { public class RemoteSystemInfo {
String ip; String ip;
String id; String id;
String pw; String pw;

@ -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<DataObject> parsing(Stream<Path> fileList);
}

@ -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<DataObject> parsing(Stream<Path> fileList) {
List<DataObject> 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;
}
}

@ -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<DataObject> parsing(Stream<Path> fileList) {
return null;
}
}

@ -3,19 +3,17 @@ package cokr.xit.fims.crdn.web;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.stream.Stream;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; 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.CrdnQuery;
import cokr.xit.fims.crdn.dao.CrdnInstMapper; import cokr.xit.fims.crdn.dao.CrdnInstMapper;
import cokr.xit.fims.crdn.dao.GlobalStngMapper; 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.CrdnService;
import cokr.xit.fims.crdn.service.CrdnStngService; import cokr.xit.fims.crdn.service.CrdnStngService;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
@ -103,87 +104,65 @@ public class Crdn05Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
String entType = hReq.getParameter("entType"); 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<Path> fileList = null;
List<DataObject> dataObjectList = new ArrayList<>(); List<DataObject> dataObjectList = new ArrayList<>();
String downloadRoot = ""; String downloadRoot = ""; //ftp나 usb에서 다운받는 파일 경로
if(entType.equals("이노")) { if(entType.equals("이노") || entType.equals("knl")) {
//ftp G클라우드
try { 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) { } catch (Exception e) {
e.printStackTrace(); 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; return mav;
} }

@ -8,7 +8,7 @@
<div class="row g-1"> <div class="row g-1">
<div class="col-md-4"> <div class="col-md-4">
<label for="taskSeCd--${pageName}" <label for="taskSeCd--${pageName}"
class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">과태료업무</label> class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">과태료업무</label>
<select id="taskSeCd--${pageName}" name="taskSeCd" class="form-select" disabled> <select id="taskSeCd--${pageName}" name="taskSeCd" class="form-select" disabled>
<c:forEach items="${FIM054List}" var="item"> <c:forEach items="${FIM054List}" var="item">
<option value="${item.code}" <option value="${item.code}"
@ -19,7 +19,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label for="entType--${pageName}" <label for="entType--${pageName}"
class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">장비업체</label> class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">장비업체</label>
<select id="entType--${pageName}" name="entType" class="form-select"> <select id="entType--${pageName}" name="entType" class="form-select">
<option value="">선택하세요</option> <option value="">선택하세요</option>
<option value="KNL">KNL</option> <option value="KNL">KNL</option>
@ -29,40 +29,35 @@
<option value="하이테콤">하이테콤</option> <option value="하이테콤">하이테콤</option>
</select> </select>
</div> </div>
<div class="col-md-4"> <c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}">
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}"> <div class="col-md-4">
<label for="cctvType--${pageName}" <label for="cctvType--${pageName}"
class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">cctv 구분</label> class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">cctv 구분</label>
<select id="cctvType--${pageName}" name="cctvType" class="form-select"> <select id="cctvType--${pageName}" name="cctvType" class="form-select">
<option value="">선택</option> <option value="">선택</option>
<option value="고정형">고정형</option> <option value="고정형">고정형</option>
<option value="주행형">주행형</option> <option value="주행형">주행형</option>
<option value="버스장착형">버스장착형</option> <option value="버스장착형">버스장착형</option>
</select> </select>
</c:if>
</div>
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}">
<div class="col-md-4">
<label for="localFile--${pageName}"
class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">파일</label>
<input type="file" id="localFile--${pageName}" name="localFile" />
</div> </div>
</c:if> </c:if>
</div>
<div class="col-md-12">
<div class="row mt-4 justify-content-end mb-3"> <c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}">
<div class="col-md-6"> <label for="localFile--${pageName}"
<div class="row justify-content-end"> class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">파일</label>
<div class="col-sm-3"> <input type="file" id="localFile--${pageName}" name="localFile" />
<c:if test="${taskSeCd == 'ECA' or taskSeCd == 'DPV'}"> </c:if>
<button type="button" id="btnSearch--${pageName}" class="btn btn-primary">조회</button> <span class="justify-content-end float-end me-4">
</c:if> <c:if test="${taskSeCd == 'ECA' or taskSeCd == 'DPV'}">
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}"> <button type="button" id="btnSearch--${pageName}" class="btn btn-primary">조회</button>
<button type="button" id="btnFileUpload--${pageName}" class="btn btn-primary">등록</button> </c:if>
</c:if> <c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV' or taskSeCd == '미세먼지'}">
</div> <button type="button" id="btnFileUpload--${pageName}" class="btn btn-primary">등록</button>
</div> </c:if>
</span>
</div> </div>
</div> </div>
</form> </form>
</div> </div>

Loading…
Cancel
Save