package com.nstc.safe.action;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.SocketException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.el.parser.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;

import com.nstc.safe.Config;
import com.nstc.safe.domain.SafeErrorFile;
import com.nstc.safe.domain.SafeReport;
import com.nstc.safe.server.CommonServer;
import com.nstc.safe.server.SafeServer;
import com.nstc.safe.server.ServerLocator;

/**
 * 

 * Title:外管局错误文件查看  * 

 *   * 

 * Description:外管局文件下载Action层  * 

 *   * 

 * Company: 北京九恒星科技股份有限公司  * 

 *   * @author zhangyongguang  *   * @since:2015年9月8日 09:48:34  *   * @version 1.0  */ public class SAFE_U01_17 extends ActionSupport { private static final Log log = LogFactory.getLog(SAFE_U01_17.class); /**  * 由于Spring配置quartz在调用action的时候,对应server还没有注入到容器中,  * 所以需要这个action中注入对应server,并且commonServer在spring配置文件中要找得到对应bean,  * 并在commonServer对应的bean中继承事务控制tx  *   * commonServer的注入主要是针对work方法(定时任务方法)所用到的与后台交互的代码,  * */ private CommonServer commonServer; public CommonServer getCommonServer() { return commonServer; } public void setCommonServer(CommonServer commonServer) { this.commonServer = commonServer; } /**  * 查询错误文件列表  */ public String execute(HttpServletRequest request) { String errPath = request.getParameter("errorPath"); String start = request.getParameter("startDate"); String end = request.getParameter("endDate"); // 用于下拉选择框的值 List list = getLocator().getCommonServer().findAll(SafeErrorFile.class); // 列表数据 List list2 = getLocator().getCommonServer().findAll(errPath, start, end, SafeErrorFile.class); //把list放入request对象中,在前台遍历 request.setAttribute("list", list); request.setAttribute("list2", list2); return "page"; }    /**     * 查看XML文件内容,显示在前台的页面上     * @author zhangyonggguang     * @param request     * @param list     * @param id     * */ public String viewXML(HttpServletRequest request) { //接收前台传来的文件ID String id = request.getParameter("errId"); SafeErrorFile sa = new SafeErrorFile(); //根据ID查询对应的文件 sa = (SafeErrorFile) getLocator().getCommonServer().findById(id, SafeErrorFile.class); //把查询的结果放入list集合中, List list = new ArrayList(); list.add(sa); //把list放入request对象中,在前台遍历 request.setAttribute("list", list); return "view"; } /**  * 定时任务,定时读取FTP服务器的文件,做入库操作。  * @author zhangyongguang  * @exception Exception  * @date 2015-09-09 14:35:24  * @return page  * */ public void work()throws Exception {  System.out.println("自动任务执行"+new Date());  //执行查询有多少个路径需要读取的方法,并存入set集合中,遍历set集合,取出有几个路径  Set set=findPath();          Iterator it =set.iterator();          while(it.hasNext()){           //上传路径为配置文件配置的文件路径,与数据库的发送文件加路径组合而成,           String st=it.next().toString();           System.out.println("SET的值为"+st);           listRemoteAllFiles(st);           } } /**  * @author zhangyongguang  * @param  查询FTP服务器有多少路径需要读取  * */ public Set findPath(){ SafeReport sa=new SafeReport(); //定义set集合,去除重复的路径 Set set=new HashSet(); //查询safeReport所有数据 List list=commonServer.findAll(SafeReport.class); for(int i=0;i

下面是spring配置,





	
	
		
			appContext.properties
		
		
			GBK
		
	
	
	
		
			
		
	
	
	
		
			
		
		
			
				PROPAGATION_REQUIRED,-Throwable
				
					PROPAGATION_REQUIRED,-Throwable
				
				PROPAGATION_REQUIRED,-Throwable
				
					PROPAGATION_REQUIRED,-Throwable
				
				PROPAGATION_REQUIRED,-Throwable
			
		
	
	
	
		
			sql-map-config.xml
		
	
	
	
		
			
		
		
			
				
					org.hibernate.dialect.OracleDialect
				
				false
				false
				false
				
				3
				
				8
				
				true
				
				
					true
				
				
				
					true
				
			
		
		
			
				com/nstc/safe/domain/SafeAccount.hbm.xml
				com/nstc/safe/domain/SafeAcntType.hbm.xml
				com/nstc/safe/domain/SafeBalanceChange.hbm.xml
				com/nstc/safe/domain/SafeBz.hbm.xml
				com/nstc/safe/domain/SafeCountry.hbm.xml
				com/nstc/safe/domain/SafeIncomeDetail.hbm.xml
				com/nstc/safe/domain/SafePayoutDetail.hbm.xml
				com/nstc/safe/domain/SafeTransact.hbm.xml
				com/nstc/safe/domain/SafeConfig.hbm.xml
				com/nstc/safe/domain/SafeApNumber.hbm.xml
				com/nstc/safe/domain/SafeExchangeRate.hbm.xml
				com/nstc/safe/domain/SafeTx.hbm.xml
				com/nstc/safe/domain/SafeTxLog.hbm.xml
				com/nstc/safe/domain/SafeRepRows.hbm.xml
				com/nstc/safe/domain/SafeGeneralCash.hbm.xml
				com/nstc/safe/domain/SafeListPrice.hbm.xml
				com/nstc/safe/domain/SafeBigAcnt.hbm.xml
				com/nstc/safe/domain/SafeMonthStat.hbm.xml
				com/nstc/safe/domain/SafeTenDayStat.hbm.xml
				com/nstc/safe/domain/SafeReportFile.hbm.xml
				com/nstc/safe/domain/SafeReport.hbm.xml
				com/nstc/safe/domain/CapitalSafeAccount.hbm.xml
				com/nstc/safe/domain/CapitalBalanceChange.hbm.xml
				com/nstc/safe/domain/SafeForReportFile.hbm.xml
				com/nstc/safe/domain/SafeAcntTypeZB.hbm.xml
				com/nstc/safe/domain/SafeErrorFile.hbm.xml
			
		
	
	
	
		
			
		
		
			
		
		
			
		
	

	
	
	
	
		
			
		
		
			
		
		
			
		
		
			${dbType}
		
	
	
	
	
	
	
	
	
	
	
		
			
		
		
			
		
	
	
	
		
			
		
	
	
		
			
		
	
	
		
			
		
	
	
		
			
		
	

	
		
			/WEB-INF/classes/sql-map-config.xml
		
	
/bean>
				
		
	
	  
         
             
                
             
           
         
	  
	
	  
         
       
        	60/900 * * * * ?