파일에이전트 버그 수정
- 같은 서버일경우 복사 프로시저 인덱스 수정
This commit is contained in:
parent
6082912a54
commit
4389ebaeb5
|
@ -288,7 +288,7 @@ public static void copyFileCommonsIO(String source, String dest) throws IOExcept
|
||||||
*/
|
*/
|
||||||
|
|
||||||
logger.info("[DEBUG] [procMSTINFOCRT] Begin");
|
logger.info("[DEBUG] [procMSTINFOCRT] Begin");
|
||||||
proc.put("SP_WAT_DEPLOYDATA_CRT_VER2", 8);
|
proc.put("SP_WAT_DEPLOYDATA_CRT_VER2", 9);
|
||||||
//proc.put("SP_WAT_DEPLOYDATA_CRT", 8);
|
//proc.put("SP_WAT_DEPLOYDATA_CRT", 8);
|
||||||
//IN_SALES_ORG_CD 추가해라
|
//IN_SALES_ORG_CD 추가해라
|
||||||
proc.setString(++i, (String)map.get("SALE_DT")); // tran_ymd
|
proc.setString(++i, (String)map.get("SALE_DT")); // tran_ymd
|
||||||
|
@ -305,8 +305,8 @@ public static void copyFileCommonsIO(String source, String dest) throws IOExcept
|
||||||
|
|
||||||
logger.info("[DEBUG] [procMSTINFOCRT] sql :" + proc.debug());
|
logger.info("[DEBUG] [procMSTINFOCRT] sql :" + proc.debug());
|
||||||
|
|
||||||
ret = prs.getInt(7);
|
ret = prs.getInt(8);
|
||||||
String retMsg = prs.getString(8);
|
String retMsg = prs.getString(9);
|
||||||
logger.info("[DEBUG] [procMSTINFOCRT] ResultMsg:" + retMsg);
|
logger.info("[DEBUG] [procMSTINFOCRT] ResultMsg:" + retMsg);
|
||||||
logger.info("[DEBUG] [procMSTINFOCRT] End");
|
logger.info("[DEBUG] [procMSTINFOCRT] End");
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ package biz.cms_FileAgent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
|
@ -117,31 +118,53 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
hm.put("FTP_USER_HOME", "/ftp_home/stationftp/dev/CMBO") ;
|
hm.put("FTP_USER_HOME", "/ftp_home/stationftp/dev/CMBO") ;
|
||||||
hm.put("DAY_CNT", "/ftp_home/stationftp/dev/CMBO") ;*/
|
hm.put("DAY_CNT", "/ftp_home/stationftp/dev/CMBO") ;*/
|
||||||
|
|
||||||
// hm.put("FTP_SERVER", "211.108.6.162");
|
// hm.put("FTP_SERVER", "211.108.6.162");
|
||||||
// hm.put("FTP_ID", "Nftp_nhs");
|
// hm.put("FTP_ID", "Nftp_nhs");
|
||||||
// hm.put("FTP_PWD", "L6y7V>gxU\\");
|
// hm.put("FTP_PWD", "L6y7V>gxU\\");
|
||||||
// hm.put("FTP_PORT","22");
|
// hm.put("FTP_PORT","22");
|
||||||
// hm.put("FTP_POS_PORT","21");
|
// hm.put("FTP_POS_PORT","21");
|
||||||
// hm.put("USER_HOME","/home/hs_dev");
|
// hm.put("USER_HOME","/home/hs_dev");
|
||||||
// hm.put("FTP_USER_HOME", "/data/Nftp_nhs/dev/CMBO") ;
|
// hm.put("FTP_USER_HOME", "/data/Nftp_nhs/dev/CMBO") ;
|
||||||
// hm.put("DAY_CNT", "/data/Nftp_nhs/dev/CMBO") ;
|
// hm.put("DAY_CNT", "/data/Nftp_nhs/dev/CMBO") ;
|
||||||
|
|
||||||
hm.put("FTP_SERVER", "10.0.40.148");
|
// hm.put("FTP_SERVER", "10.0.40.148");
|
||||||
hm.put("FTP_SERVER2", "10.0.40.149"); // 2019.07.10 148 접속 불가시 149 로 접속하라고 전달받음
|
// //hm.put("FTP_SERVER2", "10.0.40.149"); // 2019.07.10 148 접속 불가시 149 로 접속하라고 전달받음
|
||||||
hm.put("FTP_ID", "nhsftp");
|
// hm.put("FTP_ID", "nhsftp");
|
||||||
hm.put("FTP_PWD", "aj9upe%DPv");
|
// hm.put("FTP_PWD", "aj9upe%DPv");
|
||||||
hm.put("FTP_PORT","15638");
|
// hm.put("FTP_PORT","15638");
|
||||||
hm.put("FTP_POS_PORT","15638");
|
// hm.put("FTP_POS_PORT","15638");
|
||||||
hm.put("USER_HOME","/dev");
|
// hm.put("USER_HOME","/dev");
|
||||||
hm.put("FTP_USER_HOME", "/dev/CMBO") ;
|
// hm.put("FTP_USER_HOME", "/dev/CMBO") ;
|
||||||
hm.put("DAY_CNT", "/dev/CMBO") ;
|
// hm.put("DAY_CNT", "/dev/CMBO") ;
|
||||||
|
|
||||||
|
hm.put("FTP_SERVER", pu.findProperty("stsys-property", "FTP_SERVER_FA"));
|
||||||
|
hm.put("FTP_SERVER2", pu.findProperty("stsys-property", "FTP_SERVER2_FA"));
|
||||||
|
hm.put("FTP_ID", pu.findProperty("stsys-property", "FTP_ID_FA"));
|
||||||
|
hm.put("FTP_PWD", pu.findProperty("stsys-property", "FTP_PWD_FA"));
|
||||||
|
hm.put("FTP_PORT",Integer.parseInt(pu.findProperty("stsys-property", "FTP_PORT_FA")));
|
||||||
|
hm.put("FTP_POS_PORT",Integer.parseInt(pu.findProperty("stsys-property", "FTP_POS_PORT_FA")));
|
||||||
|
hm.put("USER_HOME",pu.findProperty("stsys-property", "USER_HOME_FA"));
|
||||||
|
hm.put("FTP_USER_HOME", pu.findProperty("stsys-property", "FTP_USER_HOME_FA")) ;
|
||||||
|
hm.put("DAY_CNT", pu.findProperty("stsys-property", "DAY_CNT_FA"));
|
||||||
|
hm.put("USER_HOME_NAS",pu.findProperty("stsys-property", "USER_HOME_NAS_FA"));
|
||||||
|
|
||||||
|
// logger.debug("[INIT] svr - " + hm.get("FTP_SERVER"));
|
||||||
|
// logger.debug("[INIT] id - " + hm.get("FTP_ID"));
|
||||||
|
// logger.debug("[INIT] pw - " + hm.get("FTP_PWD"));
|
||||||
|
// logger.debug("[INIT] port - " + hm.get("FTP_PORT"));
|
||||||
|
// logger.debug("[INIT] pport - " + hm.get("FTP_POS_PORT"));
|
||||||
|
// logger.debug("[INIT] home - " + hm.get("USER_HOME"));
|
||||||
|
// logger.debug("[INIT] fhome - " + hm.get("FTP_USER_HOME"));
|
||||||
|
// logger.debug("[INIT] NasHome - " + hm.get("USER_HOME_NAS"));
|
||||||
|
|
||||||
//법인 회사별 영업일 조회
|
//법인 회사별 영업일 조회
|
||||||
String deploy_dt = dao.getSysDate("BRKR" ,0);
|
String deploy_dt = dao.getSysDate("BRKR" ,0);
|
||||||
|
|
||||||
|
logger.debug("[INIT] deploy_dt - " + deploy_dt);
|
||||||
|
|
||||||
//백업기간 일자는 각 파일별로 다를 수 있음 3일치?
|
//백업기간 일자는 각 파일별로 다를 수 있음 3일치?
|
||||||
String deploy_dt2 =dao.getSysDate("BRKR" ,4);
|
String deploy_dt2 =dao.getSysDate("BRKR" ,4);
|
||||||
|
logger.debug("[INIT] deploy_dt2 - " + deploy_dt2);
|
||||||
|
|
||||||
|
|
||||||
//영업일 4일전부터 오늘까지
|
//영업일 4일전부터 오늘까지
|
||||||
|
@ -170,6 +193,8 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
// makeItemImageCreate("PCKR","002",deploy_dt,"TAG","TAG",ls,hm,"17");
|
// makeItemImageCreate("PCKR","002",deploy_dt,"TAG","TAG",ls,hm,"17");
|
||||||
// makeItemImageCreate("PCKR","002",deploy_dt,"LOGO","LOGO",ls,hm,"18");
|
// makeItemImageCreate("PCKR","002",deploy_dt,"LOGO","LOGO",ls,hm,"18");
|
||||||
|
|
||||||
|
logger.debug("[PROCESS] START ");
|
||||||
|
|
||||||
makeItemImageCreate("BRKR","5000",deploy_dt,"ITEM","ITEM",ls,hm,"11");
|
makeItemImageCreate("BRKR","5000",deploy_dt,"ITEM","ITEM",ls,hm,"11");
|
||||||
makeItemImageCreate("BRKR","5000",deploy_dt,"OPTN","OPTN",ls,hm,"12");
|
makeItemImageCreate("BRKR","5000",deploy_dt,"OPTN","OPTN",ls,hm,"12");
|
||||||
makeItemImageCreate("BRKR","5000",deploy_dt,"CAMPN","CAMPN",ls,hm,"13");
|
makeItemImageCreate("BRKR","5000",deploy_dt,"CAMPN","CAMPN",ls,hm,"13");
|
||||||
|
@ -179,12 +204,13 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
makeItemImageCreate("BRKR","5000",deploy_dt,"TAG","TAG",ls,hm,"17");
|
makeItemImageCreate("BRKR","5000",deploy_dt,"TAG","TAG",ls,hm,"17");
|
||||||
makeItemImageCreate("BRKR","5000",deploy_dt,"LOGO","LOGO",ls,hm,"18");
|
makeItemImageCreate("BRKR","5000",deploy_dt,"LOGO","LOGO",ls,hm,"18");
|
||||||
|
|
||||||
|
logger.debug("[PROCESS] END ");
|
||||||
|
|
||||||
//makeOptnImageCreate("PCKR","OPTN",hm); //부가옵션이미지
|
//makeOptnImageCreate("PCKR","OPTN",hm); //부가옵션이미지
|
||||||
//makeCampnImageCreate("PCKR","CAMPN",hm); //캠페인배너이미지
|
//makeCampnImageCreate("PCKR","CAMPN",hm); //캠페인배너이미지
|
||||||
//makeCateImageCreate("PCKR","CATE",hm); //제품카테고리이미지
|
//makeCateImageCreate("PCKR","CATE",hm); //제품카테고리이미지
|
||||||
//makeScreenImageCreate("PCKR","SCREEN",hm);//대기화면 이미지/동영상
|
//makeScreenImageCreate("PCKR","SCREEN",hm);//대기화면 이미지/동영상
|
||||||
//makePresentImageCreate("PCKR","PRESENT",hm);//사은품이미지
|
//makePresentImageCreate("PCKR","PRESENT",hm);//사은품이미지
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,34 +232,34 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
|
|
||||||
//1.WEB에서 업로드된 파일 폴더 --> /home/hs_dev/upload/PCKR/002/ITEM
|
//1.WEB에서 업로드된 파일 폴더 --> /home/hs_dev/upload/PCKR/002/ITEM
|
||||||
String webitem_imgdir = (String)hm.get("USER_HOME") + File.separator +
|
String webitem_imgdir = (String)hm.get("USER_HOME") + File.separator +
|
||||||
"upload" + File.separator +
|
"upload" + File.separator +
|
||||||
cmp_cd + File.separator +
|
cmp_cd + File.separator +
|
||||||
sales_org_cd + File.separator +
|
sales_org_cd + File.separator +
|
||||||
imageKindWeb;
|
imageKindWeb;
|
||||||
|
|
||||||
//2.POS 압축하기 위한 파일 폴더 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP/ITEM/
|
//2.POS 압축하기 위한 파일 폴더 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP/ITEM/
|
||||||
String positem_zipMakedir =(String)hm.get("USER_HOME") + File.separator +
|
String positem_zipMakedir =(String)hm.get("USER_HOME") + File.separator +
|
||||||
"CMBO/temp" + File.separator+
|
"CMBO/temp" + File.separator+
|
||||||
cmp_cd + File.separator +
|
cmp_cd + File.separator +
|
||||||
sales_org_cd + File.separator +
|
sales_org_cd + File.separator +
|
||||||
"CDP" + File.separator+
|
"CDP" + File.separator+
|
||||||
imageKindPos;
|
imageKindPos;
|
||||||
//3. POS 압축하기 위한 파일 폴더 전체 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP
|
//3. POS 압축하기 위한 파일 폴더 전체 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP
|
||||||
String positem_zipdir =(String)hm.get("USER_HOME")+ File.separator +
|
String positem_zipdir =(String)hm.get("USER_HOME")+ File.separator +
|
||||||
"CMBO/temp" + File.separator +
|
"CMBO/temp" + File.separator +
|
||||||
cmp_cd + File.separator +
|
cmp_cd + File.separator +
|
||||||
sales_org_cd + File.separator +
|
sales_org_cd + File.separator +
|
||||||
"CDP";
|
"CDP";
|
||||||
//4. POS 전체폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/ITEM
|
//4. POS 전체폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/ITEM
|
||||||
String positem_backupimgdir = (String)hm.get("USER_HOME") + File.separator +
|
String positem_backupimgdir = (String)hm.get("USER_HOME") + File.separator +
|
||||||
"CMBO" + File.separator +
|
"CMBO" + File.separator +
|
||||||
"TOTAL/CDP" + File.separator+
|
"TOTAL/CDP" + File.separator+
|
||||||
imageKindPos;// 전체 백업 저장 폴더
|
imageKindPos;// 전체 백업 저장 폴더
|
||||||
//5. POS total 압축폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/
|
//5. POS total 압축폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/
|
||||||
String positem_totzipdir =(String)hm.get("USER_HOME") + File.separator +
|
String positem_totzipdir =(String)hm.get("USER_HOME") + File.separator +
|
||||||
"CMBO" + File.separator +
|
"CMBO" + File.separator +
|
||||||
"TOTAL" + File.separator +
|
"TOTAL" + File.separator +
|
||||||
"CDP";
|
"CDP";
|
||||||
// 전체 img 압축 명--> PCKR_POS_ITEM_TOTALIMG.ZIP
|
// 전체 img 압축 명--> PCKR_POS_ITEM_TOTALIMG.ZIP
|
||||||
String positem_totzipNm = cmp_cd + "_"+ sales_org_cd + "_"+ "POS_"+ imageKindPos +"_TOTALIMG.ZIP";
|
String positem_totzipNm = cmp_cd + "_"+ sales_org_cd + "_"+ "POS_"+ imageKindPos +"_TOTALIMG.ZIP";
|
||||||
|
|
||||||
|
@ -253,18 +279,18 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
|
|
||||||
if (dirList.size()> 0 ) { // 웹경로에 파일이 존재하는 경우
|
if (dirList.size()> 0 ) { // 웹경로에 파일이 존재하는 경우
|
||||||
logger.debug("action file copy start " + dirList.size());
|
logger.debug("action file copy start " + dirList.size());
|
||||||
// 4.신규 이미지 카피
|
// 4.신규 이미지 카피
|
||||||
for(int k = 0;k < dirList.size();k++) {
|
for(int k = 0;k < dirList.size();k++) {
|
||||||
try {
|
try {
|
||||||
dao.fileCopy(webitem_imgdir
|
dao.fileCopy(webitem_imgdir
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8) + File.separator + dirList.get(k)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8) + File.separator + dirList.get(k)
|
||||||
,positem_zipMakedir+File.separator + dirList.get(k));
|
,positem_zipMakedir+File.separator + dirList.get(k));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug(" file backup copy err " + e.toString());
|
logger.debug(" file backup copy err " + e.toString());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,23 +304,23 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
|
|
||||||
|
|
||||||
List dirList = dao.getDirFileList(webitem_imgdir + File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
List dirList = dao.getDirFileList(webitem_imgdir + File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8));
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8));
|
||||||
|
|
||||||
if (dirList.size()> 0 ) { // 파일이 존재하는 경우
|
if (dirList.size()> 0 ) { // 파일이 존재하는 경우
|
||||||
logger.debug("action file copy start " + dirList.size());
|
logger.debug("action file copy start " + dirList.size());
|
||||||
// 4.신규 이미지 카피
|
// 4.신규 이미지 카피
|
||||||
for(int k = 0;k < dirList.size();k++) {
|
for(int k = 0;k < dirList.size();k++) {
|
||||||
try {
|
try {
|
||||||
dao.fileCopy(webitem_imgdir
|
dao.fileCopy(webitem_imgdir
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(0,4)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(4,6)
|
||||||
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8) + File.separator + dirList.get(k)
|
+ File.separator + ((String)map.get("SYS_DATE")).substring(6,8) + File.separator + dirList.get(k)
|
||||||
,positem_zipMakedir+File.separator + dirList.get(k));
|
,positem_zipMakedir+File.separator + dirList.get(k));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug(" file backup copy err " + e.toString());
|
logger.debug(" file backup copy err " + e.toString());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,12 +328,15 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String basePath = (String)hm.get("USER_HOME") + File.separator +
|
String basePath = (String)hm.get("USER_HOME") + File.separator +
|
||||||
"CMBO" +"/POS/UPLOAD"; // 파일 생성 루트
|
"CMBO" +"/POS/UPLOAD"; // 파일 생성 루트
|
||||||
|
|
||||||
|
logger.debug("[INFO] basePath - " + basePath);
|
||||||
|
|
||||||
//String fileName =cmp_cd+ "_"+sales_org_cd +"_"+ imageKindPos+"_" + "0000T" + ".zip";
|
//String fileName =cmp_cd+ "_"+sales_org_cd +"_"+ imageKindPos+"_" + "0000T" + ".zip";
|
||||||
String fileName =cmp_cd+ "_"+sales_org_cd +"_"+ imageKindPos+"_" + dao.getFileNm(cmp_cd, deploy_dt, fileDiv) + ".zip";
|
String fileName =cmp_cd+ "_"+sales_org_cd +"_"+ imageKindPos+"_" + dao.getFileNm(cmp_cd, deploy_dt, fileDiv) + ".zip";
|
||||||
|
|
||||||
|
logger.debug("[INFO] fileName - " + fileName);
|
||||||
|
|
||||||
File[] filelist = new File(positem_zipMakedir).listFiles();
|
File[] filelist = new File(positem_zipMakedir).listFiles();
|
||||||
if (filelist.length >0) {
|
if (filelist.length >0) {
|
||||||
cu.zip(new File(positem_zipMakedir) , new File(basePath) , "UTF-8", true ,fileName.toString());
|
cu.zip(new File(positem_zipMakedir) , new File(basePath) , "UTF-8", true ,fileName.toString());
|
||||||
|
@ -322,10 +351,66 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
|
|
||||||
String uploadPath=(String)hm.get("FTP_USER_HOME") + "/CDP/"+imageKindPos+"/";
|
String uploadPath=(String)hm.get("FTP_USER_HOME") + "/CDP/"+imageKindPos+"/";
|
||||||
|
|
||||||
|
logger.debug("[INFO] uploadPath - " + uploadPath);
|
||||||
|
|
||||||
ArrayList<String> ftplist = new ArrayList<String>();
|
ArrayList<String> ftplist = new ArrayList<String>();
|
||||||
ftplist.add(fileName.toString());
|
ftplist.add(fileName.toString());
|
||||||
|
|
||||||
|
String localIp = this.getLocalServerIp();
|
||||||
|
|
||||||
|
logger.debug("[INFO] getLocalServerIp - " + localIp);
|
||||||
|
|
||||||
|
String server1 = (String) hm.get("FTP_SERVER");
|
||||||
|
String server2 = (String) hm.get("FTP_SERVER2");
|
||||||
|
|
||||||
|
if(localIp.equals(server1) || localIp.equals(server2)) {
|
||||||
|
|
||||||
|
logger.debug("[INFO] local file copy start");
|
||||||
|
|
||||||
|
String target = (String) hm.get("USER_HOME_NAS");
|
||||||
|
String targetUploadPath = target + "/CDP/"+imageKindPos+"/";
|
||||||
|
|
||||||
|
String downPath = targetUploadPath + File.separator + sftpfile.getName();
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream(basePath +File.separator + fileName.toString());
|
||||||
|
FileOutputStream fos = new FileOutputStream(downPath);
|
||||||
|
|
||||||
|
int data = 0;
|
||||||
|
while((data=fis.read())!=-1) {
|
||||||
|
fos.write(data);
|
||||||
|
}
|
||||||
|
fis.close();
|
||||||
|
fos.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
logger.debug("[ERROR] local file copy fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("[INFO] local file copy end");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String port = String.valueOf(hm.get("FTP_PORT"));
|
||||||
|
JSCHFTPManager jsFtpMgr =null ;
|
||||||
|
jsFtpMgr = new JSCHFTPManager(
|
||||||
|
(String)hm.get("FTP_SERVER"),
|
||||||
|
Integer.parseInt(port) ,
|
||||||
|
(String)hm.get("FTP_ID"),
|
||||||
|
(String)hm.get("FTP_PWD")
|
||||||
|
);
|
||||||
|
|
||||||
|
//10.당일분 upload
|
||||||
|
String downPath = uploadPath
|
||||||
|
+ File.separator + sftpfile.getName();
|
||||||
|
|
||||||
|
logger.debug("[PROCESS] downPath - " + downPath);
|
||||||
|
|
||||||
|
File uploadFile = new File(basePath +File.separator + fileName);
|
||||||
|
|
||||||
|
// jsFtpMgr.upload(basePath +File.separator + fileName, remoteFile);
|
||||||
|
jsFtpMgr.upload(uploadPath, uploadFile);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
boolean re = sendFtpServer((String)hm.get("FTP_SERVER"),
|
boolean re = sendFtpServer((String)hm.get("FTP_SERVER"),
|
||||||
|
@ -335,26 +420,32 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
uploadPath,
|
uploadPath,
|
||||||
basePath +File.separator ,
|
basePath +File.separator ,
|
||||||
ftplist);
|
ftplist);
|
||||||
*/
|
*/
|
||||||
String port = String.valueOf(hm.get("FTP_PORT"));
|
// String port = String.valueOf(hm.get("FTP_PORT"));
|
||||||
JSCHFTPManager jsFtpMgr =null ;
|
// JSCHFTPManager jsFtpMgr =null ;
|
||||||
jsFtpMgr = new JSCHFTPManager(
|
// jsFtpMgr = new JSCHFTPManager(
|
||||||
(String)hm.get("FTP_SERVER"),
|
// (String)hm.get("FTP_SERVER"),
|
||||||
Integer.parseInt(port) ,
|
// Integer.parseInt(port) ,
|
||||||
(String)hm.get("FTP_ID"),
|
// (String)hm.get("FTP_ID"),
|
||||||
(String)hm.get("FTP_PWD")
|
// (String)hm.get("FTP_PWD")
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
//10.당일분 upload
|
// //10.당일분 upload
|
||||||
String downPath = uploadPath
|
// String downPath = uploadPath
|
||||||
+ File.separator + sftpfile.getName();
|
// + File.separator + sftpfile.getName();
|
||||||
|
//
|
||||||
File uploadFile = new File(basePath +File.separator + fileName);
|
// logger.debug("[PROCESS] downPath - " + downPath);
|
||||||
|
//
|
||||||
//jsFtpMgr.upload(basePath +File.separator + fileName, remoteFile);
|
// File uploadFile = new File(basePath +File.separator + fileName);
|
||||||
jsFtpMgr.upload(uploadPath, uploadFile);
|
//
|
||||||
|
//// jsFtpMgr.upload(basePath +File.separator + fileName, remoteFile);
|
||||||
|
// jsFtpMgr.upload(uploadPath, uploadFile);
|
||||||
|
|
||||||
|
//logger.debug("[PROCESS] jsFtpMgr.upload");
|
||||||
|
|
||||||
|
// String port = String.valueOf(hm.get("FTP_PORT"));
|
||||||
|
// (new StringBuilder(String.valueOf(uploadPath))).append(File.separator).append(sftpfile.getName()).toString();
|
||||||
|
// new File(basePath + File.separator + fileName);
|
||||||
|
|
||||||
if (!sftpfile.getName().equals("")){
|
if (!sftpfile.getName().equals("")){
|
||||||
//** 배치성으로 프로그램 실행시에는 stsys-property.xml 에 브랜드 회사코드 정보 저장
|
//** 배치성으로 프로그램 실행시에는 stsys-property.xml 에 브랜드 회사코드 정보 저장
|
||||||
|
@ -367,10 +458,10 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
mapFile.put("FILE_NM", fileName);
|
mapFile.put("FILE_NM", fileName);
|
||||||
mapFile.put("STOR_CD", "");
|
mapFile.put("STOR_CD", "");
|
||||||
mapFile.put("FILE_PATH",uploadPath);
|
mapFile.put("FILE_PATH",uploadPath);
|
||||||
//"/data/nhs_ftp/CMBO"+ "/CDP/" + imageKindPos + File.separator);
|
//"/data/nhs_ftp/CMBO"+ "/CDP/" + imageKindPos + File.separator);
|
||||||
mapFile.put("DEPLOY_DIV", fileDiv);
|
mapFile.put("DEPLOY_DIV", fileDiv);
|
||||||
//2.배신 테이블에 데이터 생성
|
//2.배신 테이블에 데이터 생성
|
||||||
int ret = dao.procMSTINFOCRT(mapFile);
|
int ret = dao.procMSTINFOCRT(mapFile);
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
logger.debug("[ERROR] " + e.toString());
|
logger.debug("[ERROR] " + e.toString());
|
||||||
}
|
}
|
||||||
|
@ -380,10 +471,10 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
logger.debug("[file not found]");
|
logger.debug("[file not found]");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.debug("[ERROR] " + e.toString());
|
logger.debug("[ERROR] " + e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
// 작업 완료 후 폴더 삭제
|
// 작업 완료 후 폴더 삭제
|
||||||
dao.deleteDirectory(new File(positem_zipMakedir));
|
dao.deleteDirectory(new File(positem_zipMakedir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,26 +485,26 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
|
||||||
{
|
{
|
||||||
NetworkInterface intf = en.nextElement();
|
NetworkInterface intf = en.nextElement();
|
||||||
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
|
||||||
{
|
{
|
||||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||||
if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress())
|
if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress())
|
||||||
{
|
{
|
||||||
return inetAddress.getHostAddress().toString();
|
return inetAddress.getHostAddress().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SocketException ex) {}
|
catch (SocketException ex) {}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean sendFtpServer(String ip, String port, String id, String password,
|
public boolean sendFtpServer(String ip, String port, String id, String password,
|
||||||
String folder,String localPath, ArrayList<String> files) {
|
String folder,String localPath, ArrayList<String> files) {
|
||||||
|
|
||||||
boolean isSuccess = false;
|
boolean isSuccess = false;
|
||||||
FTPClient ftp = null;
|
FTPClient ftp = null;
|
||||||
|
@ -429,15 +520,15 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
// success.
|
// success.
|
||||||
reply = ftp.getReplyCode();
|
reply = ftp.getReplyCode();
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||||
ftp.disconnect();
|
ftp.disconnect();
|
||||||
logger.info("FTP server refused connection.");
|
logger.info("FTP server refused connection.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ftp.login(id, password)) {
|
if(!ftp.login(id, password)) {
|
||||||
ftp.logout();
|
ftp.logout();
|
||||||
logger.info("ftp 서버에 로그인하지 못했습니e");
|
logger.info("ftp 서버에 로그인하지 못했습니e");
|
||||||
//throw new Exception("ftp 서버에 로그인하지 못했습니다.");
|
//throw new Exception("ftp 서버에 로그인하지 못했습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ftp.setFileType(FTP.BINARY_FILE_TYPE);
|
ftp.setFileType(FTP.BINARY_FILE_TYPE);
|
||||||
|
@ -445,49 +536,49 @@ public class FileAgentPollingAction extends PollingAction {
|
||||||
|
|
||||||
logger.info(ftp.printWorkingDirectory());
|
logger.info(ftp.printWorkingDirectory());
|
||||||
try{
|
try{
|
||||||
ftp.makeDirectory(folder);
|
ftp.makeDirectory(folder);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error(e.toString());
|
logger.error(e.toString());
|
||||||
}
|
}
|
||||||
ftp.changeWorkingDirectory(folder);
|
ftp.changeWorkingDirectory(folder);
|
||||||
logger.info(ftp.printWorkingDirectory());
|
logger.info(ftp.printWorkingDirectory());
|
||||||
|
|
||||||
for(int i = 0; i < files.size(); i++) {
|
for(int i = 0; i < files.size(); i++) {
|
||||||
String sourceFile = localPath + files.get(i);
|
String sourceFile = localPath + files.get(i);
|
||||||
File uploadFile = new File(sourceFile);
|
File uploadFile = new File(sourceFile);
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
fis = new FileInputStream(uploadFile);
|
fis = new FileInputStream(uploadFile);
|
||||||
logger.info(sourceFile + " : 전송시작 = >");
|
logger.info(sourceFile + " : 전송시작 = >");
|
||||||
//logger.info
|
//logger.info
|
||||||
isSuccess = ftp.storeFile(files.get(i), fis);
|
isSuccess = ftp.storeFile(files.get(i), fis);
|
||||||
logger.info(sourceFile + " : 전송결과 = >" + isSuccess);
|
logger.info(sourceFile + " : 전송결과 = >" + isSuccess);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
logger.error( "send err" + e.toString());
|
logger.error( "send err" + e.toString());
|
||||||
isSuccess = false;
|
isSuccess = false;
|
||||||
} finally {
|
} finally {
|
||||||
if (fis != null) {
|
if (fis != null) {
|
||||||
try {
|
try {
|
||||||
fis.close();
|
fis.close();
|
||||||
logger.info( "send final ok" );
|
logger.info( "send final ok" );
|
||||||
|
|
||||||
} catch(IOException e)
|
} catch(IOException e)
|
||||||
{
|
{
|
||||||
logger.error( "send final err" + e.toString());
|
logger.error( "send final err" + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end try
|
}//end try
|
||||||
}//end for
|
}//end for
|
||||||
|
|
||||||
ftp.logout();
|
ftp.logout();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (ftp != null && ftp.isConnected()) {
|
if (ftp != null && ftp.isConnected()) {
|
||||||
try { ftp.disconnect(); } catch (IOException e) {}
|
try { ftp.disconnect(); } catch (IOException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isSuccess;
|
return isSuccess;
|
||||||
|
|
|
@ -182,4 +182,40 @@
|
||||||
<property name="PGM_DELAY">
|
<property name="PGM_DELAY">
|
||||||
<![CDATA[100]]>
|
<![CDATA[100]]>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<!-- BRKR 5000 FileAgent start -->
|
||||||
|
|
||||||
|
<property name="FTP_SERVER_FA">
|
||||||
|
<![CDATA[10.0.40.148]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_SERVER2_FA">
|
||||||
|
<![CDATA[10.0.40.149]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_ID_FA">
|
||||||
|
<![CDATA[nhsftp]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_PWD_FA">
|
||||||
|
<![CDATA[aj9upe%DPv]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_PORT_FA">
|
||||||
|
<![CDATA[15638]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_POS_PORT_FA">
|
||||||
|
<![CDATA[500095]]>
|
||||||
|
</property>
|
||||||
|
<property name="USER_HOME_FA">
|
||||||
|
<![CDATA[/home/hs_dev]]>
|
||||||
|
</property>
|
||||||
|
<property name="USER_HOME_NAS_FA">
|
||||||
|
<![CDATA[/nas/nhs/dev/CMBO]]>
|
||||||
|
</property>
|
||||||
|
<property name="FTP_USER_HOME_FA">
|
||||||
|
<![CDATA[/dev/CMBO]]>
|
||||||
|
</property>
|
||||||
|
<property name="DAY_CNT_FA">
|
||||||
|
<![CDATA[/dev/CMBO]]>
|
||||||
|
</property>
|
||||||
|
|
||||||
|
<!-- BRKR 5000 FileAgent end -->
|
||||||
|
|
||||||
</property-resource>
|
</property-resource>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user