diff --git a/src/biz/cms_FileAgent/FileAgentDAO.java b/src/biz/cms_FileAgent/FileAgentDAO.java index 5e18e7f..a9e26ca 100644 --- a/src/biz/cms_FileAgent/FileAgentDAO.java +++ b/src/biz/cms_FileAgent/FileAgentDAO.java @@ -288,7 +288,7 @@ public static void copyFileCommonsIO(String source, String dest) throws IOExcept */ 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); //IN_SALES_ORG_CD 추가해라 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()); - ret = prs.getInt(7); - String retMsg = prs.getString(8); + ret = prs.getInt(8); + String retMsg = prs.getString(9); logger.info("[DEBUG] [procMSTINFOCRT] ResultMsg:" + retMsg); logger.info("[DEBUG] [procMSTINFOCRT] End"); diff --git a/src/biz/cms_FileAgent/FileAgentPollingAction.java b/src/biz/cms_FileAgent/FileAgentPollingAction.java index 4ac3040..681f5bf 100644 --- a/src/biz/cms_FileAgent/FileAgentPollingAction.java +++ b/src/biz/cms_FileAgent/FileAgentPollingAction.java @@ -9,6 +9,7 @@ package biz.cms_FileAgent; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.NetworkInterface; @@ -33,7 +34,7 @@ import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; import org.apache.log4j.Logger; - + import biz.comm.CompressionUtil; import biz.comm.JSCHFTPManager; @@ -53,12 +54,12 @@ import biz.comm.SFTPManager; public class FileAgentPollingAction extends PollingAction { private static Logger logger = Logger.getLogger(FileAgentPollingAction.class); - + //private final int MAX_TARGET_NUM = 30; public static void main(String args[]) throws Exception { FileAgentPollingAction action = new FileAgentPollingAction(); - + logger.debug("▶ " + " FileAgent main args null"); try { @@ -66,39 +67,39 @@ public class FileAgentPollingAction extends PollingAction { logger.debug("▶ " + " master main args null"); } String path = nvl(args[0].replaceFirst("-path:" ,"")); - + DaemonConfigLocator locator = DaemonConfigLocator.getInstance("xml",path); action.execute("1"); - + }catch(Exception e) { logger.debug("[ERROR]" + e.getMessage()); } } - + private static String nvl(String param) { return param != null ? param: ""; } - + public void execute(String actionMode ) { - + try { PropertyUtil pu = new PropertyUtil(); //String server_no = pu.findProperty("stsys-property", "SERVER_NO"); String server_no = "1"; - + if (actionMode.equals("1") && server_no.equals("1")) { - + FileAgentDAO dao = new FileAgentDAO(); Calendar calendar = new GregorianCalendar(Locale.KOREA); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); calendar.setTime(new Date()); String today = sdf.format(calendar.getTime()); - + //calendar.add(Calendar.DATE, 1); //String sale_dt = sdf.format(calendar.getTime()); - + HashMap hm = new HashMap(); - + /*hm.put("FTP_SERVER", pu.findProperty("stsys-property", "FTP_SERVER_IP")); hm.put("FTP_ID", pu.findProperty("stsys-property", "FTP_SERVER_ID")); hm.put("FTP_PWD", pu.findProperty("stsys-property", "FTP_SERVER_PWD")); @@ -107,7 +108,7 @@ public class FileAgentPollingAction extends PollingAction { hm.put("USER_HOME","/home/hs_dev"); hm.put("FTP_USER_HOME", pu.findProperty("stsys-property", "FTP_USER_HOME")) ; hm.put("DAY_CNT", pu.findProperty("stsys-property", "FTP_USER_HOME")) ;*/ - + /*hm.put("FTP_SERVER", "10.0.40.148"); hm.put("FTP_ID", "stationftp"); hm.put("FTP_PWD", "R+n0Ef}?%]"); @@ -116,51 +117,73 @@ public class FileAgentPollingAction extends PollingAction { hm.put("USER_HOME","/home/hs_dev"); hm.put("FTP_USER_HOME", "/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_ID", "Nftp_nhs"); -// hm.put("FTP_PWD", "L6y7V>gxU\\"); -// hm.put("FTP_PORT","22"); -// hm.put("FTP_POS_PORT","21"); -// hm.put("USER_HOME","/home/hs_dev"); -// hm.put("FTP_USER_HOME", "/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_SERVER2", "10.0.40.149"); // 2019.07.10 148 접속 불가시 149 로 접속하라고 전달받음 - hm.put("FTP_ID", "nhsftp"); - hm.put("FTP_PWD", "aj9upe%DPv"); - hm.put("FTP_PORT","15638"); - hm.put("FTP_POS_PORT","15638"); - hm.put("USER_HOME","/dev"); - hm.put("FTP_USER_HOME", "/dev/CMBO") ; - hm.put("DAY_CNT", "/dev/CMBO") ; - - + + // hm.put("FTP_SERVER", "211.108.6.162"); + // hm.put("FTP_ID", "Nftp_nhs"); + // hm.put("FTP_PWD", "L6y7V>gxU\\"); + // hm.put("FTP_PORT","22"); + // hm.put("FTP_POS_PORT","21"); + // hm.put("USER_HOME","/home/hs_dev"); + // hm.put("FTP_USER_HOME", "/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_SERVER2", "10.0.40.149"); // 2019.07.10 148 접속 불가시 149 로 접속하라고 전달받음 + // hm.put("FTP_ID", "nhsftp"); + // hm.put("FTP_PWD", "aj9upe%DPv"); + // hm.put("FTP_PORT","15638"); + // hm.put("FTP_POS_PORT","15638"); + // hm.put("USER_HOME","/dev"); + // hm.put("FTP_USER_HOME", "/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); - + + logger.debug("[INIT] deploy_dt - " + deploy_dt); + //백업기간 일자는 각 파일별로 다를 수 있음 3일치? - String deploy_dt2 =dao.getSysDate("BRKR" ,4); - - + String deploy_dt2 =dao.getSysDate("BRKR" ,4); + logger.debug("[INIT] deploy_dt2 - " + deploy_dt2); + + //영업일 4일전부터 오늘까지 //List ls = new ArrayList(); - - - + + + //ls.add("20190307"); - + List ls = dao.getbetweenDate("BRKR" , deploy_dt2 , deploy_dt); - - + + //total 이미지 파일 삭제 처리 //DeleteCDPCOMFile("PCKR",hm); //DeletCustomerFile("PCKR",hm); - - + + //file div 11: item 12: optn 13: CATE 14 :cate 15: screen 16: present 17: PRD_TAG 18: LOGO - + // makeItemImageCreate("PCKR","002",deploy_dt,"ITEM","ITEM",ls,hm,"11"); // makeItemImageCreate("PCKR","002",deploy_dt,"OPTN","OPTN",ls,hm,"12"); // makeItemImageCreate("PCKR","002",deploy_dt,"CAMPN","CAMPN",ls,hm,"13"); @@ -169,7 +192,9 @@ public class FileAgentPollingAction extends PollingAction { // makeItemImageCreate("PCKR","002",deploy_dt,"PRESENT","PRESENT",ls,hm,"16"); // makeItemImageCreate("PCKR","002",deploy_dt,"TAG","TAG",ls,hm,"17"); // 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,"OPTN","OPTN",ls,hm,"12"); makeItemImageCreate("BRKR","5000",deploy_dt,"CAMPN","CAMPN",ls,hm,"13"); @@ -178,17 +203,18 @@ public class FileAgentPollingAction extends PollingAction { makeItemImageCreate("BRKR","5000",deploy_dt,"PRESENT","PRESENT",ls,hm,"16"); makeItemImageCreate("BRKR","5000",deploy_dt,"TAG","TAG",ls,hm,"17"); makeItemImageCreate("BRKR","5000",deploy_dt,"LOGO","LOGO",ls,hm,"18"); - - + + logger.debug("[PROCESS] END "); + //makeOptnImageCreate("PCKR","OPTN",hm); //부가옵션이미지 //makeCampnImageCreate("PCKR","CAMPN",hm); //캠페인배너이미지 //makeCateImageCreate("PCKR","CATE",hm); //제품카테고리이미지 - //makeScreenImageCreate("PCKR","SCREEN",hm);//대기화면 이미지/동영상 - //makePresentImageCreate("PCKR","PRESENT",hm);//사은품이미지 - + //makeScreenImageCreate("PCKR","SCREEN",hm);//대기화면 이미지/동영상 + //makePresentImageCreate("PCKR","PRESENT",hm);//사은품이미지 + } } - + catch (Exception e) { logger.debug("[ERROR] " + e.toString()); System.out.println("[ERROR] " + e.toString()); @@ -198,103 +224,103 @@ public class FileAgentPollingAction extends PollingAction { e.printStackTrace(); } } - + //상품이미지 private void makeItemImageCreate(String cmp_cd, String sales_org_cd,String deploy_dt, String imageKindWeb, String imageKindPos, List ls,HashMap hm, String fileDiv ) throws Exception { FileAgentDAO dao = new FileAgentDAO(); CompressionUtil cu = new CompressionUtil(); - + //1.WEB에서 업로드된 파일 폴더 --> /home/hs_dev/upload/PCKR/002/ITEM String webitem_imgdir = (String)hm.get("USER_HOME") + File.separator + - "upload" + File.separator + - cmp_cd + File.separator + - sales_org_cd + File.separator + - imageKindWeb; - + "upload" + File.separator + + cmp_cd + File.separator + + sales_org_cd + File.separator + + imageKindWeb; + //2.POS 압축하기 위한 파일 폴더 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP/ITEM/ String positem_zipMakedir =(String)hm.get("USER_HOME") + File.separator + - "CMBO/temp" + File.separator+ - cmp_cd + File.separator + - sales_org_cd + File.separator + - "CDP" + File.separator+ - imageKindPos; + "CMBO/temp" + File.separator+ + cmp_cd + File.separator + + sales_org_cd + File.separator + + "CDP" + File.separator+ + imageKindPos; //3. POS 압축하기 위한 파일 폴더 전체 --> /home/hs_dev/CMBO/temp/PCKR/002/CDP String positem_zipdir =(String)hm.get("USER_HOME")+ File.separator + - "CMBO/temp" + File.separator + - cmp_cd + File.separator + - sales_org_cd + File.separator + - "CDP"; + "CMBO/temp" + File.separator + + cmp_cd + File.separator + + sales_org_cd + File.separator + + "CDP"; //4. POS 전체폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/ITEM String positem_backupimgdir = (String)hm.get("USER_HOME") + File.separator + - "CMBO" + File.separator + - "TOTAL/CDP" + File.separator+ - imageKindPos;// 전체 백업 저장 폴더 + "CMBO" + File.separator + + "TOTAL/CDP" + File.separator+ + imageKindPos;// 전체 백업 저장 폴더 //5. POS total 압축폴더 --> /home/hs_dev/CMBO/TOTAL/CDP/ String positem_totzipdir =(String)hm.get("USER_HOME") + File.separator + - "CMBO" + File.separator + - "TOTAL" + File.separator + - "CDP"; + "CMBO" + File.separator + + "TOTAL" + File.separator + + "CDP"; // 전체 img 압축 명--> PCKR_POS_ITEM_TOTALIMG.ZIP String positem_totzipNm = cmp_cd + "_"+ sales_org_cd + "_"+ "POS_"+ imageKindPos +"_TOTALIMG.ZIP"; - + try { - + //압축할 temp 폴더 생성 logger.debug("pos positem_zipMakedir --->" + positem_zipMakedir); dao.mkDir(positem_zipMakedir); // /home/hs_dev/CMBO/temp/PCKR/002/CDP/ITEM/ if(ls == null){//테스트용 Map map = new HashMap(); map.put("SYS_DATE","20190327"); - + 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(6,8)); - - + + if (dirList.size()> 0 ) { // 웹경로에 파일이 존재하는 경우 logger.debug("action file copy start " + dirList.size()); - // 4.신규 이미지 카피 + // 4.신규 이미지 카피 for(int k = 0;k < dirList.size();k++) { - try { + try { dao.fileCopy(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(6,8) + File.separator + dirList.get(k) - ,positem_zipMakedir+File.separator + dirList.get(k)); + + 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(6,8) + File.separator + dirList.get(k) + ,positem_zipMakedir+File.separator + dirList.get(k)); } catch (Exception e) { logger.debug(" file backup copy err " + e.toString()); } catch (Throwable e) { - e.printStackTrace(); + e.printStackTrace(); } } } - + }else{ if (ls.size()>0){// 일별 폴더 체크 for(int row = 0; row < ls.size(); row ++){ Map map = (Map)ls.get(row); - + logger.debug((String)map.get("SYS_DATE")); - - + + 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(6,8)); - + + File.separator + ((String)map.get("SYS_DATE")).substring(4,6) + + File.separator + ((String)map.get("SYS_DATE")).substring(6,8)); + if (dirList.size()> 0 ) { // 파일이 존재하는 경우 logger.debug("action file copy start " + dirList.size()); - // 4.신규 이미지 카피 + // 4.신규 이미지 카피 for(int k = 0;k < dirList.size();k++) { - try { + try { dao.fileCopy(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(6,8) + File.separator + dirList.get(k) - ,positem_zipMakedir+File.separator + dirList.get(k)); + + 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(6,8) + File.separator + dirList.get(k) + ,positem_zipMakedir+File.separator + dirList.get(k)); } catch (Exception e) { logger.debug(" file backup copy err " + e.toString()); } catch (Throwable e) { - e.printStackTrace(); + e.printStackTrace(); } } } @@ -302,31 +328,90 @@ public class FileAgentPollingAction extends PollingAction { } } 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+"_" + dao.getFileNm(cmp_cd, deploy_dt, fileDiv) + ".zip"; - + + logger.debug("[INFO] fileName - " + fileName); + File[] filelist = new File(positem_zipMakedir).listFiles(); if (filelist.length >0) { cu.zip(new File(positem_zipMakedir) , new File(basePath) , "UTF-8", true ,fileName.toString()); - + File sftpfile = new File(basePath +File.separator + fileName.toString() ); - + //전체 파일 COPY 처리 // positem_zipMakedir : /home/hs_dev/CMBO/temp/PCKR/002/CDP/ITEM/ // positem_backupimgdir : /home/hs_dev/CMBO/TOTAL/CDP/ITEM // positem_totzipdir : /home/hs_dev/CMBO/TOTAL/CDP/ //int retvalue = dao.setDirFileList(positem_zipMakedir, positem_backupimgdir); //--에러.. - + String uploadPath=(String)hm.get("FTP_USER_HOME") + "/CDP/"+imageKindPos+"/"; - + + logger.debug("[INFO] uploadPath - " + uploadPath); + ArrayList ftplist = new ArrayList(); 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"), (String)hm.get("FTP_PORT"), @@ -335,27 +420,33 @@ public class FileAgentPollingAction extends PollingAction { uploadPath, basePath +File.separator , ftplist); - */ - 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") - ); + */ + // 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); - //10.당일분 upload - String downPath = uploadPath - + File.separator + sftpfile.getName(); - - File uploadFile = new File(basePath +File.separator + fileName); - - //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("")){ //** 배치성으로 프로그램 실행시에는 stsys-property.xml 에 브랜드 회사코드 정보 저장 logger.debug("Database" + "database 생성중 " + filelist.length ); @@ -367,26 +458,26 @@ public class FileAgentPollingAction extends PollingAction { mapFile.put("FILE_NM", fileName); mapFile.put("STOR_CD", ""); 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); //2.배신 테이블에 데이터 생성 - int ret = dao.procMSTINFOCRT(mapFile); + int ret = dao.procMSTINFOCRT(mapFile); }catch(SQLException e){ logger.debug("[ERROR] " + e.toString()); } } - + }else{ logger.debug("[file not found]"); } - - } catch(Exception e) { - logger.debug("[ERROR] " + e.toString()); - } finally { - // 작업 완료 후 폴더 삭제 + + } catch(Exception e) { + logger.debug("[ERROR] " + e.toString()); + } finally { + // 작업 완료 후 폴더 삭제 dao.deleteDirectory(new File(positem_zipMakedir)); } - + } // 브랜드별 파일 생성 관련 프로그램 소스 추가 시작 2017.04.24 끝 @@ -394,100 +485,100 @@ public class FileAgentPollingAction extends PollingAction { { try { - for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) - { - NetworkInterface intf = en.nextElement(); - for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) - { - InetAddress inetAddress = enumIpAddr.nextElement(); - if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress()) - { - return inetAddress.getHostAddress().toString(); - } - } - } + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) + { + NetworkInterface intf = en.nextElement(); + for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) + { + InetAddress inetAddress = enumIpAddr.nextElement(); + if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress()) + { + return inetAddress.getHostAddress().toString(); + } + } + } } catch (SocketException ex) {} return null; } - - public boolean sendFtpServer(String ip, String port, String id, String password, - String folder,String localPath, ArrayList files) { - + + public boolean sendFtpServer(String ip, String port, String id, String password, + String folder,String localPath, ArrayList files) { + boolean isSuccess = false; FTPClient ftp = null; int reply; try { - + ftp = new FTPClient(); ftp.setControlEncoding("UTF-8"); ftp.connect(ip, Integer.parseInt(port)); logger.info("Connected to " + ip + " on "+ftp.getRemotePort()); - + // After connection attempt, you should check the reply code to verify // success. reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { - ftp.disconnect(); - logger.info("FTP server refused connection."); - System.exit(1); + ftp.disconnect(); + logger.info("FTP server refused connection."); + System.exit(1); } - + if(!ftp.login(id, password)) { - ftp.logout(); + ftp.logout(); logger.info("ftp 서버에 로그인하지 못했습니e"); - //throw new Exception("ftp 서버에 로그인하지 못했습니다."); + //throw new Exception("ftp 서버에 로그인하지 못했습니다."); } - + ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.enterLocalPassiveMode(); - + logger.info(ftp.printWorkingDirectory()); try{ - ftp.makeDirectory(folder); + ftp.makeDirectory(folder); }catch(Exception e){ - e.printStackTrace(); - logger.error(e.toString()); + e.printStackTrace(); + logger.error(e.toString()); } ftp.changeWorkingDirectory(folder); logger.info(ftp.printWorkingDirectory()); - - for(int i = 0; i < files.size(); i++) { - String sourceFile = localPath + files.get(i); - File uploadFile = new File(sourceFile); - FileInputStream fis = null; - try { - fis = new FileInputStream(uploadFile); - logger.info(sourceFile + " : 전송시작 = >"); - //logger.info - isSuccess = ftp.storeFile(files.get(i), fis); - logger.info(sourceFile + " : 전송결과 = >" + isSuccess); - } catch(IOException e) { - e.printStackTrace(); - - logger.error( "send err" + e.toString()); - isSuccess = false; - } finally { - if (fis != null) { - try { - fis.close(); - logger.info( "send final ok" ); - } catch(IOException e) - { - logger.error( "send final err" + e.toString()); - } - } - }//end try - }//end for - - ftp.logout(); + for(int i = 0; i < files.size(); i++) { + String sourceFile = localPath + files.get(i); + File uploadFile = new File(sourceFile); + FileInputStream fis = null; + try { + fis = new FileInputStream(uploadFile); + logger.info(sourceFile + " : 전송시작 = >"); + //logger.info + isSuccess = ftp.storeFile(files.get(i), fis); + logger.info(sourceFile + " : 전송결과 = >" + isSuccess); + } catch(IOException e) { + e.printStackTrace(); + + logger.error( "send err" + e.toString()); + isSuccess = false; + } finally { + if (fis != null) { + try { + fis.close(); + logger.info( "send final ok" ); + + } catch(IOException e) + { + logger.error( "send final err" + e.toString()); + } + } + }//end try + }//end for + + ftp.logout(); } catch (Exception e) { e.printStackTrace(); } finally { if (ftp != null && ftp.isConnected()) { - try { ftp.disconnect(); } catch (IOException e) {} + try { ftp.disconnect(); } catch (IOException e) {} } } return isSuccess; diff --git a/xml/stsys-property.xml b/xml/stsys-property.xml index 1b860b0..83971ca 100644 --- a/xml/stsys-property.xml +++ b/xml/stsys-property.xml @@ -182,4 +182,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +