파일에이전트 버그 수정

- 같은 서버일경우 복사
프로시저 인덱스 수정
This commit is contained in:
snoop 2019-07-24 20:44:26 +09:00
parent 6082912a54
commit 4389ebaeb5
3 changed files with 331 additions and 204 deletions

View File

@ -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");

View File

@ -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;
@ -126,22 +127,44 @@ public class FileAgentPollingAction extends PollingAction {
// 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,6 +204,7 @@ 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); //캠페인배너이미지
@ -304,10 +330,13 @@ 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,20 +351,46 @@ 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");
boolean re = sendFtpServer((String)hm.get("FTP_SERVER"), String server2 = (String) hm.get("FTP_SERVER2");
(String)hm.get("FTP_PORT"),
(String)hm.get("FTP_ID"), if(localIp.equals(server1) || localIp.equals(server2)) {
(String)hm.get("FTP_PWD"),
uploadPath, logger.debug("[INFO] local file copy start");
basePath +File.separator ,
ftplist); 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")); String port = String.valueOf(hm.get("FTP_PORT"));
JSCHFTPManager jsFtpMgr =null ; JSCHFTPManager jsFtpMgr =null ;
jsFtpMgr = new JSCHFTPManager( jsFtpMgr = new JSCHFTPManager(
@ -349,12 +404,48 @@ public class FileAgentPollingAction extends PollingAction {
String downPath = uploadPath String downPath = uploadPath
+ File.separator + sftpfile.getName(); + File.separator + sftpfile.getName();
logger.debug("[PROCESS] downPath - " + downPath);
File uploadFile = new File(basePath +File.separator + fileName); File uploadFile = new File(basePath +File.separator + fileName);
// jsFtpMgr.upload(basePath +File.separator + fileName, remoteFile); // jsFtpMgr.upload(basePath +File.separator + fileName, remoteFile);
jsFtpMgr.upload(uploadPath, uploadFile); jsFtpMgr.upload(uploadPath, uploadFile);
}
/*
boolean re = sendFtpServer((String)hm.get("FTP_SERVER"),
(String)hm.get("FTP_PORT"),
(String)hm.get("FTP_ID"),
(String)hm.get("FTP_PWD"),
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")
// );
//
// //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);
//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 브랜드 회사코드 정보 저장

View File

@ -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>