浏览代码

修改接口传入参数

longht 4 年之前
父节点
当前提交
f726c41371

+ 25 - 19
src/private/nc/impl/pubdev/pubtool/execmethod/FtpsUtil.java

@@ -17,6 +17,8 @@ import org.apache.commons.net.ftp.FTPSClient;
 
 import nc.pub.Proptool.PropertiesUtil;
 import nc.vo.pubapp.pattern.exception.ExceptionUtils;
+import nc.vo.pubapp.pattern.pub.PubAppTool;
+import nccloud.commons.collections.CollectionUtils;
 
 public class FtpsUtil {
 	
@@ -33,13 +35,14 @@ public class FtpsUtil {
      * @param propfilename  ftp参数文件
      * @param type 1对应读取excel文件类型
      * @return 返回类型为Map<String,Object> key =文件名  value=对应的数据 
+     * @throws Exception 
      * 
      */
-	public Map<String, Object>  doFtpReadFile(String propfilename,int type) {
+	public Map<String, Object>  doFtpReadFile(String propfilename,int type,String path,List<String> filenamelsit) throws Exception {
 		Map<String, Object> result =null;
 		try {
 			ftpConnectSet(propfilename);
-			result = readFileList(null, type);
+			result = readFileList(path,filenamelsit, type);
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -123,26 +126,30 @@ public class FtpsUtil {
 	 * @return function:读取指定目录下的文件名
 	 * @throws IOException
 	 */
-	private Map<String, Object> readFileList(Map<String, String> mapdir, int type) throws IOException {
+	private Map<String, Object> readFileList(String path,List<String> filenamelsit, int type) throws Exception {
+		if(PubAppTool.isNull(path))
+			throw new Exception("路径不能为空");
 		// 构造返回值
 		Map<String, Object> reDatas = new HashMap<String, Object>();
 		// 获得指定目录下所有文件名
 		FTPFile[] ftpFiles = null;
-		try {
-			ftpClient.enterLocalPassiveMode();
-			ftpFiles = ftpClient.listFiles();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		for (int i = 0; ftpFiles != null && i < ftpFiles.length; i++) {
-			ftpClient.changeWorkingDirectory(this.basePath);
-			FTPFile file = ftpFiles[i];
-			if (file.isFile()) {
-				String filename = new String(file.getName().getBytes(strencoding), "GBK").toLowerCase();
-				if (1 == type) {
-
-					ArrayList<ArrayList<Object>> result = readExcelFile(file.getName());
-					reDatas.put(filename, result);
+		ftpClient.enterLocalPassiveMode();
+        //指定目录及文件的直接获取数据
+		if(!CollectionUtils.isEmpty(filenamelsit)) {
+			for (String filename : filenamelsit) {
+				ArrayList<ArrayList<Object>> result = readExcelFile(path+filename);
+				reDatas.put(filename, result);
+			}
+		}else {
+			for (int i = 0; ftpFiles != null && i < ftpFiles.length; i++) {
+				ftpClient.changeWorkingDirectory(path);
+				FTPFile file = ftpFiles[i];
+				if (file.isFile()) {
+					String filename = new String(file.getName().getBytes(strencoding), "GBK").toLowerCase();
+					if (1 == type) {
+						ArrayList<ArrayList<Object>> result = readExcelFile(file.getName());
+						reDatas.put(filename, result);
+					}
 				}
 			}
 		}
@@ -184,7 +191,6 @@ public class FtpsUtil {
 			if (ins != null) {
 				try {
 					ins.close();
-					// 主动调用一次getReply()把接下来的226消费掉. 这样做是可以解决这个返回null问题
 					ftpClient.getReply();
 				} catch (IOException e) {
 					// TODO Auto-generated catch block

+ 1 - 1
src/private/nc/impl/pubdev/pubtool/execmethod/GainBDDataUtil.java

@@ -48,7 +48,7 @@ public class GainBDDataUtil {
 		List<BusitypeVO> resultList =null;
 		try {
 			resultList = (List<BusitypeVO>) getBaseDAO().executeQuery(querysql,
-					new BeanListProcessor(DefdocVO.class));
+					new BeanListProcessor(BusitypeVO.class));
 			Logger.info("²éѯҵÎñÁ÷³Ì¡¾"+busitypecode+"¡¿end");
 		} catch (DAOException e1) {
 			// TODO Auto-generated catch block

+ 3 - 2
src/private/nc/impl/pubdev/pubtool/filetool/DevFileGainToolimpl.java

@@ -2,6 +2,7 @@ package nc.impl.pubdev.pubtool.filetool;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import nc.impl.pubdev.pubtool.execmethod.FtpUtil;
@@ -25,9 +26,9 @@ public class DevFileGainToolimpl implements IDevFileGainTool{
 	}
 
 	@Override
-	public Map<String, Object> GainDatasByFtps(String propfilename, int type) throws BusinessException {
+	public Map<String, Object> GainDatasByFtps(String propfilename,int type,String path,List<String> filenamelsit) throws Exception {
 		// TODO Auto-generated method stub
-		return new FtpsUtil().doFtpReadFile(propfilename, type);
+		return new FtpsUtil().doFtpReadFile(propfilename, type,path,filenamelsit);
 	}
 
 

+ 4 - 1
src/public/nc/itf/pubdev/pubtool/filetool/IDevFileGainTool.java

@@ -2,6 +2,7 @@ package nc.itf.pubdev.pubtool.filetool;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import nc.vo.pub.BusinessException;
@@ -33,10 +34,12 @@ public interface IDevFileGainTool {
 	 * @author longht
 	 * @param propfilename  ftp参数文件
 	 * @param type 1 = 获取excel文件类型
+	 * @param 文件路径
+	 * @param filenamelsit List 需要读取的文件,为空则读取路径下的所以文件
 	 * @return 返回类型为Map<String,Object> key =文件名  value=对应的数据 
 	 * 
 	 */
-	public abstract Map<String,Object> GainDatasByFtps(String propfilename,int type) throws BusinessException;
+	public abstract Map<String,Object> GainDatasByFtps(String propfilename,int type,String path,List<String> filenamelsit) throws Exception;