ftp 다운로드 처리 수정

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

@ -14,6 +14,9 @@ import org.apache.commons.net.ftp.FTPReply;
public class FTPUtil {
public static boolean fileDown(RemoteSystemInfo rs, String remoteWorkPath, String downloadRoot) {
File f = new File(downloadRoot + remoteWorkPath);
f.mkdirs();
FTPClient client = null;
try {
@ -100,6 +103,7 @@ public class FTPUtil {
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("오류 발생");
} finally {
// ftp 커넥션이 연결되어 있으면 종료한다.
@ -108,7 +112,7 @@ public class FTPUtil {
client.disconnect();
}
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("오류 발생");
}
}
@ -127,7 +131,7 @@ public class FTPUtil {
if (!file.isFile()) {
// 디렉토리리면 함수의 재귀적 방식으로 하위 탐색을 시작한다.
if (!getFileList(client, fileSeparator, work + file.getName() + fileSeparator, files, directories)) {
if(!getFileList(client, fileSeparator, work + file.getName() + fileSeparator, files, directories)) {
return false;
}
@ -147,6 +151,7 @@ public class FTPUtil {
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException();
}

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

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

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

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

@ -1,5 +1,6 @@
package cokr.xit.fims.crdn.web;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
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.web.FileInfoFactory;
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.CrdnQuery;
import cokr.xit.fims.crdn.dao.CrdnInstMapper;
@ -129,10 +132,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null;
switch(entType){
case "INO": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break;
case "ino": enterprise = new Ino(); break;
case "knl": enterprise = new Knl(); break;
case "hitecom": enterprise = new HiteCom(); break;
case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break;
}
@ -141,24 +144,31 @@ public class Crdn05Controller extends ApplicationController {
String equipmentType = hReq.getParameter("equipmentType");
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
//ftp G클라우드
//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;
File workDir = new File(workPath);
workDir.mkdirs();
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 + entType
+ File.separator;
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) {
e.printStackTrace();
saved = false;
mav.addObject("saved", saved);
return mav;
}
saved = true;
@ -177,10 +187,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null;
switch(entType){
case "INO": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break;
case "ino": enterprise = new Ino(); break;
case "knl": enterprise = new Knl(); break;
case "hitecom": enterprise = new HiteCom(); break;
case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break;
}
@ -189,8 +199,19 @@ public class Crdn05Controller extends ApplicationController {
String equipmentType = hReq.getParameter("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);
return mav;
}
@ -205,10 +226,10 @@ public class Crdn05Controller extends ApplicationController {
String entType = hReq.getParameter("entType");
EquipmentEnterprise enterprise = null;
switch(entType){
case "INO": enterprise = new Ino(); break;
case "KNL": enterprise = new Knl(); break;
case "HITECOM": enterprise = new HiteCom(); break;
case "XIT": enterprise = new XitRecommend(); break;
case "ino": enterprise = new Ino(); break;
case "knl": enterprise = new Knl(); break;
case "hitecom": enterprise = new HiteCom(); break;
case "xit": enterprise = new XitRecommend(); break;
//case "": enterprise = new (); break;
}

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

Loading…
Cancel
Save