ftp 다운로드 처리 수정

main
이범준 1 year ago
parent 57cfe2355a
commit a865704685

@ -14,6 +14,9 @@ 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) {
File f = new File(downloadRoot + remoteWorkPath);
f.mkdirs();
FTPClient client = null; FTPClient client = null;
try { try {
@ -100,6 +103,7 @@ public class FTPUtil {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("오류 발생"); throw new RuntimeException("오류 발생");
} finally { } finally {
// ftp 커넥션이 연결되어 있으면 종료한다. // ftp 커넥션이 연결되어 있으면 종료한다.
@ -108,7 +112,7 @@ public class FTPUtil {
client.disconnect(); client.disconnect();
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); throw new RuntimeException("오류 발생");
} }
} }
@ -147,6 +151,7 @@ public class FTPUtil {
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(); throw new RuntimeException();
} }

@ -124,7 +124,7 @@ public class HiteCom implements EquipmentEnterprise {
tempGroupSeq++; tempGroupSeq++;
dataObject.put("TEMP_GROUP_ID", tempGroupSeq); dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
dataObject.put("ENT_TYPE", "HITECOM"); dataObject.put("ENT_TYPE", "hitecom");
dataObjectList.add(dataObject); dataObjectList.add(dataObject);
}); });

@ -91,7 +91,7 @@ public class Ino implements EquipmentEnterprise {
} }
dataObject.put("TEMP_GROUP_ID", tempGroupSeq); dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
dataObject.put("ENT_TYPE", "INO"); dataObject.put("ENT_TYPE", "ino");
dataObjectList.add(dataObject); dataObjectList.add(dataObject);
before = dataObject; before = dataObject;
}); });

@ -11,13 +11,13 @@ public class ParsingUtil {
public static String getWorkDirectoryPath(String institute, String taskSeCd, String entType, String equipmentType) { public static String getWorkDirectoryPath(String institute, String taskSeCd, String entType, String equipmentType) {
String workPath = ""; String workPath = "";
if(entType.equals("INO")) { if(entType.equals("ino")) {
workPath = "files"+File.separator+"tempForIno"; workPath = "files"+File.separator+"tempForIno";
} }
if(entType.equals("KNL")) { if(entType.equals("knl")) {
workPath = "files"+File.separator+"tempForKnl"; workPath = "files"+File.separator+"tempForKnl";
} }
if(entType.equals("HITECOM")) { if(entType.equals("hitecom")) {
workPath = "files"+File.separator+"tempForHitecom"; workPath = "files"+File.separator+"tempForHitecom";
} }

@ -91,7 +91,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
List<FileInfo> fileInfoList = new ArrayList<FileInfo>(); List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
if(entType.equals("INO")) { if(entType.equals("ino")) {
crdn.setCrdnInptSeCd("11"); crdn.setCrdnInptSeCd("11");
crdn.setVltnCd("01"); crdn.setVltnCd("01");
@ -133,7 +133,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
} }
if(entType.equals("KNL")) { if(entType.equals("knl")) {
crdn.setCrdnInptSeCd("12"); crdn.setCrdnInptSeCd("12");
crdn.setVltnCd("01"); crdn.setVltnCd("01");

@ -1,5 +1,6 @@
package cokr.xit.fims.crdn.web; package cokr.xit.fims.crdn.web;
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.Path;
@ -20,6 +21,8 @@ import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.FileInfo;
import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.base.file.web.FileInfoFactory;
import cokr.xit.base.web.ApplicationController; import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.ftp.FTPUtil;
import cokr.xit.fims.cmmn.ftp.RemoteSystemInfo;
import cokr.xit.fims.crdn.Crdn; 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;
@ -129,10 +132,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType"); String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null; EquipmentEnterprise enterprise = null;
switch(entType){ switch(entType){
case "INO": enterprise = new Ino(); break; case "ino": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break; case "knl": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break; case "hitecom": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break; case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break; //case "": enterprise = new (); break;
} }
@ -141,24 +144,31 @@ public class Crdn05Controller extends ApplicationController {
String equipmentType = hReq.getParameter("equipmentType"); String equipmentType = hReq.getParameter("equipmentType");
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
File workDir = new File(workPath);
//ftp G클라우드 workDir.mkdirs();
RemoteSystemInfo rs = new RemoteSystemInfo();
//RemoteSystemInfo rs = new RemoteSystemInfo(); rs.setIp("211.119.124.9");
//rs.setIp("211.119.124.9"); rs.setId("xituser");
//rs.setId("xituser"); rs.setPw("xituser!@");
//rs.setPw("xituser!@"); rs.setOsType("linux");
//rs.setOsType("linux");
String remoteWorkPath = File.separator + "applications"
//String remoteWorkPath = File.separator + "applications" + File.separator + "tempForFTPTest"
// + File.separator + "tempForFTPTest" + File.separator + entType
// + File.separator + "ino" + File.separator;
// + File.separator;
try { try {
//boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath); boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath);
if(!result) {
saved = false;
mav.addObject("saved", saved);
return mav;
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
saved = false;
mav.addObject("saved", saved);
return mav;
} }
saved = true; saved = true;
@ -177,10 +187,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType"); String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null; EquipmentEnterprise enterprise = null;
switch(entType){ switch(entType){
case "INO": enterprise = new Ino(); break; case "ino": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break; case "knl": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break; case "hitecom": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break; case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break; //case "": enterprise = new (); break;
} }
@ -189,8 +199,19 @@ public class Crdn05Controller extends ApplicationController {
String equipmentType = hReq.getParameter("equipmentType"); String equipmentType = hReq.getParameter("equipmentType");
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
//TODO : File workDir = new File(workPath);
workDir.mkdirs();
try {
for(int i=0; i < uploadFiles.length; i++) {
File newFile = new File(workPath+File.separator+uploadFiles[i].getOriginalFilename());
uploadFiles[i].transferTo(newFile);
}
} catch (Exception e) {
saved = false;
mav.addObject("saved", saved);
return mav;
}
saved = true;
mav.addObject("saved", saved); mav.addObject("saved", saved);
return mav; return mav;
} }
@ -205,10 +226,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType"); String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null; EquipmentEnterprise enterprise = null;
switch(entType){ switch(entType){
case "INO": enterprise = new Ino(); break; case "ino": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break; case "knl": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break; case "hitecom": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break; case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break; //case "": enterprise = new (); break;
} }

@ -4,7 +4,7 @@
<div class="d-flex" style="flex-flow:column"> <div class="d-flex" style="flex-flow:column">
<div class="d-flex flex-row justify-content-evenly"> <div class="d-flex flex-row justify-content-evenly">
<div class="card" style="min-width:1400px;width:1400px;height:100px;"> <div class="card" style="min-width:1400px;width:1400px;height:100px;">
<form id="frmFirst--${pageName}"> <form id="frmFirst--${pageName}" method="post" enctype="multipart/form-data">
<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}"
@ -23,14 +23,14 @@
<select id="entType--${pageName}" name="entType" class="form-select"> <select id="entType--${pageName}" name="entType" class="form-select">
<option value="">선택하세요</option> <option value="">선택하세요</option>
<c:if test="${taskSeCd == 'DPV' or taskSeCd == 'ECA'}"> <c:if test="${taskSeCd == 'DPV' or taskSeCd == 'ECA'}">
<option value="KNL">KNL</option> <option value="knl">KNL</option>
<option value="INO">이노</option> <option value="ino">이노</option>
</c:if> </c:if>
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}"> <c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}">
<option value="GASAN">가산정보통신</option> <option value="gasan">가산정보통신</option>
<option value="ELISOFT">엘리소프트</option> <option value="elisoft">엘리소프트</option>
<option value="XIT">XIT권장포맷</option> <option value="xit">XIT권장포맷</option>
<option value="HITECOM">하이테콤</option> <option value="hitecom">하이테콤</option>
</c:if> </c:if>
<c:if test="${taskSeCd == '미세먼지'}"> <c:if test="${taskSeCd == '미세먼지'}">
<option value="unknown">unknown</option> <option value="unknown">unknown</option>
@ -54,9 +54,9 @@
</span> </span>
</div> </div>
<div class="col-md-12 d-flex align-items-center flex-nowrap"> <div class="col-md-12 d-flex align-items-center flex-nowrap">
<label for="localFile--${pageName}" <label for="uploadFiles--${pageName}"
class="w-px-120 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>
<input type="file" id="localFile--${pageName}" name="localFile" multiple="multiple" class="form-control"/> <input type="file" id="uploadFiles--${pageName}" name="uploadFiles" multiple="multiple" class="form-control"/>
<span class="d-flex justify-content-end float-end ms-auto me-4"> <span class="d-flex justify-content-end float-end ms-auto me-4">
<button type="button" id="btnFileUpload--${pageName}" class="btn btn-primary">업로드</button> <button type="button" id="btnFileUpload--${pageName}" class="btn btn-primary">업로드</button>
</span> </span>
@ -263,10 +263,10 @@ $(document).ready(function(){
$("#table-responsive--${pageName}").find("."+$P.entType).find("tbody").setCurrentRow(dataKey); $("#table-responsive--${pageName}").find("."+$P.entType).find("tbody").setCurrentRow(dataKey);
} }
if(item.data.ENT_TYPE == "INO"){ if(item.data.ENT_TYPE == "ino"){
var src = item.data.FILE_PATH; var src = item.data.FILE_PATH;
$P.renderImage(src); $P.renderImage(src);
} else if(item.data.ENT_TYPE == "HITECOM"){ } else if(item.data.ENT_TYPE == "hitecom"){
var srcArr = [ var srcArr = [
"data:image/jpg;base64,"+item.data.CAR_IMAGE, "data:image/jpg;base64,"+item.data.CAR_IMAGE,
"data:image/jpg;base64,"+item.data.PLATE_IMAGE "data:image/jpg;base64,"+item.data.PLATE_IMAGE
@ -292,10 +292,10 @@ $(document).ready(function(){
} }
if($("#entType--${pageName}").val() == "unkown" if($("#entType--${pageName}").val() == "unkown"
|| $("#entType--${pageName}").val() == "KNL" || $("#entType--${pageName}").val() == "knl"
|| $("#entType--${pageName}").val() == "GASAN" || $("#entType--${pageName}").val() == "gasan"
|| $("#entType--${pageName}").val() == "ELISOFT" || $("#entType--${pageName}").val() == "elisoft"
|| $("#entType--${pageName}").val() == "XIT" || $("#entType--${pageName}").val() == "xit"
){ ){
dialog.alert("해당 업체 연계는 현재 준비중입니다."); dialog.alert("해당 업체 연계는 현재 준비중입니다.");
return false; return false;
@ -339,13 +339,13 @@ $(document).ready(function(){
return; return;
} }
var formData = new FormData(document.getElementById("frmFirst--${pageName}"));
ajax.post({ ajax.post({
url : wctx.url("/${taskSeCd}/crdn/crdn05/020/importFileFromClient.do"), url : wctx.url("/${taskSeCd}/crdn/crdn05/020/importFileFromClient.do"),
data : { contentType : false, processData : false,
taskSeCd : $("#taskSeCd--${pageName}").val(), data : formData,
entType : $("#entType--${pageName}").val(),
equipmentType : $("#equipmentType--${pageName}").val()
},
success : (resp) => { success : (resp) => {
if(resp.saved){ if(resp.saved){
$P.searchFileList(); $P.searchFileList();
@ -363,9 +363,9 @@ $(document).ready(function(){
$P.parsedInfoControl.setData([]); $P.parsedInfoControl.setData([]);
if($("#entType--${pageName}").val() == "INO"){ if($("#entType--${pageName}").val() == "ino"){
$P.entType = "ino"; $P.entType = "ino";
} else if($("#entType--${pageName}").val() == "HITECOM"){ } else if($("#entType--${pageName}").val() == "hitecom"){
$P.entType = "hitecom"; $P.entType = "hitecom";
} else { } else {
$P.entType = ""; $P.entType = "";

Loading…
Cancel
Save