浏览代码

通用工具代码上传

longht 4 年之前
当前提交
8a167ea0ed

+ 21 - 0
.classpath

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/public"/>
+	<classpathentry kind="src" path="src/client"/>
+	<classpathentry kind="src" path="src/private"/>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="META-INF"/>
+	<classpathentry kind="src" path="METADATA"/>
+	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.studio.udt.core.container/Ant_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.studio.udt.core.container/Framework_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.studio.udt.core.container/Generated_EJB"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.studio.udt.core.container/NCCloud_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Product_Common_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Middleware_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Module_Public_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Module_Client_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Module_Private_Library"/>
+	<classpathentry exported="true" kind="con" path="com.yonyou.ria.g2.container/Module_Lang_Library"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/bin/
+/hotwebs/
+/METADATA/

+ 29 - 0
.project

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>custdev</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.yonyou.studio.udt.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.yonyou.ria.g2.riabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>com.yonyou.studio.udt.core.nature</nature>
+		<nature>com.yonyou.ria.g2.rianature</nature>
+	</natures>
+</projectDescription>

+ 11 - 0
META-INF/PubDevTool.upm

@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<module name="PubDevToolEJB">
+	<public>
+		 <component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true">
+		      <interface>nc.itf.pubdev.pubtool.filetool.IDevFileGainTool</interface>
+		      <implementation>nc.impl.pubdev.pubtool.filetool.DevFileGainToolimpl</implementation>
+	      </component>
+	</public>
+	<private>
+	</private>
+</module>

+ 7 - 0
META-INF/module.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="gb2312"?>
+<module name="custdev">
+    <public>
+    </public>
+    <private>
+    </private>
+</module>

+ 36 - 0
META-INF/setup.ini

@@ -0,0 +1,36 @@
+#code
+code=${code}
+#name
+name=${name}
+#version
+version=${version}
+#setup disk type,examples: new(disk) or patch(patch disk)
+disk.type=new
+#Master be install ,values: true or false
+must.selected=false
+#Depend on previous version, Supported wildcards: * or ?
+preversion=
+#Depend on other products [code,name, version1, version2,...]&[code,name, version1, version2,...]
+required.related.module=
+db.create.script=dbcreate
+bill.templet.script=billtemplet
+query.templet.script=querytemplet
+report.templet.script=reporttemplet
+print.templet.script=printtemplet
+sys.templet.script=systemtemplet
+bill.type.script=billtype
+metadata.script=metadata
+busi.type.script=
+system.type.script=systemtype
+subj.class.script=
+voucher.templet.script=
+project.templet.script=
+business.script=business
+menu.script=funcregister
+ml.script=lang
+ddc.initdata=
+hasdynamictempletdata=
+need_deploy_ejb=
+containproductcode=
+dbml.script=dbml
+blob.script=querytemplet

+ 365 - 0
src/private/nc/impl/pubdev/pubtool/ExcelUtil.java

@@ -0,0 +1,365 @@
+package nc.impl.pubdev.pubtool;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
+
+  
+public class ExcelUtil {
+	//默认单元格内容为数字时格式  
+    private static DecimalFormat df = new DecimalFormat("0");  
+    // 默认单元格格式化日期字符串   
+    private static SimpleDateFormat sdf = new SimpleDateFormat(  "yyyy-MM-dd HH:mm:ss");   
+    // 格式化数字  
+    private static DecimalFormat nf = new DecimalFormat("0.00");    
+    public static ArrayList<ArrayList<Object>> readFile(File file){  
+        if(file == null){  
+            return null;  
+        }  
+        String filename = file.getName().toLowerCase();
+        
+        if(filename.endsWith("xlsx")){  
+            //处理ecxel2007  
+        	
+            try {
+				return readExcel2007(new FileInputStream(file));
+			} catch (FileNotFoundException e) {
+				// TODO Auto-generated catch block
+				return null;
+			}  
+        }else if(filename.endsWith("xls")){  
+            //处理ecxel2003  
+            try {
+				return readExcel2003(new FileInputStream(file));
+			} catch (FileNotFoundException e) {
+				// TODO Auto-generated catch block
+				return null;
+			}  
+        }else if(filename.endsWith("csv"))  {
+        	try {
+				return readCsv(new FileInputStream(file));
+			} catch (FileNotFoundException e) {
+				// TODO Auto-generated catch block
+				return null;
+			}
+        }else {
+        	ExceptionUtils.wrappBusinessException("导入失败,系统只接收xls,xlsx,csv类型文件");
+        	return null;
+        }
+    }  
+    /*  
+     * @return 将返回结果存储在ArrayList内,存储结构与二位数组类似  
+     * lists.get(0).get(0)表示过去Excel中0行0列单元格  
+     */  
+    public static ArrayList<ArrayList<Object>> readExcel2003(InputStream input){  
+        try{  
+            ArrayList<ArrayList<Object>> rowList = new ArrayList<ArrayList<Object>>();  
+            ArrayList<Object> colList;  
+            HSSFWorkbook wb = new HSSFWorkbook(input);  
+            HSSFSheet sheet = wb.getSheetAt(0);  
+            HSSFRow row;  
+            HSSFCell cell;  
+            Object value;  
+            for(int i = sheet.getFirstRowNum() , rowCount = 0; rowCount < sheet.getPhysicalNumberOfRows() ; i++ ){  
+                row = sheet.getRow(i);  
+                colList = new ArrayList<Object>();  
+                if(row == null){  
+                    //当读取行为空时  
+                    if(i != sheet.getPhysicalNumberOfRows()){//判断是否是最后一行  
+                        rowList.add(colList);  
+                    }  
+                    continue;  
+                }else{  
+                    rowCount++;  
+                }  
+                for( int j = row.getFirstCellNum() ; j <= row.getLastCellNum() ;j++){  
+                    cell = row.getCell(j);  
+                    if(cell == null || cell.getCellType() == CellType.BLANK){  
+                        //当该单元格为空  
+                        if(j != row.getLastCellNum()){//判断是否是该行中最后一个单元格  
+                            colList.add("");  
+                        }  
+                        continue;  
+                    }  
+                    switch(cell.getCellType()){  
+                     case STRING:    
+                            value = cell.getStringCellValue();    
+                            break;    
+                        case NUMERIC:    
+                            if ("@".equals(cell.getCellStyle().getDataFormatString())) {    
+                                value = df.format(cell.getNumericCellValue());    
+                            } else if ("General".equals(cell.getCellStyle()    
+                                    .getDataFormatString())) {    
+                                value = nf.format(cell.getNumericCellValue());    
+                            } else {    
+                                value = sdf.format(HSSFDateUtil.getJavaDate(cell    
+                                        .getNumericCellValue()));    
+                            }    
+                            break;    
+                        case BOOLEAN:    
+                            value = Boolean.valueOf(cell.getBooleanCellValue());  
+                            break;    
+                        case BLANK:    
+                            value = "";    
+                            break;    
+                        default:    
+                            value = cell.toString();    
+                    }// end switch  
+                    colList.add(value);  
+                }//end for j  
+                rowList.add(colList);  
+            }//end for i  
+              
+            return rowList;  
+        }catch(Exception e){  
+            return null;  
+        }  
+    }  
+      
+    public static ArrayList<ArrayList<Object>> readExcel2007(InputStream input){  
+        try{  
+            ArrayList<ArrayList<Object>> rowList = new ArrayList<ArrayList<Object>>();  
+            ArrayList<Object> colList;  
+            XSSFWorkbook wb = new XSSFWorkbook(input);  
+            XSSFSheet sheet = wb.getSheetAt(0);  
+            XSSFRow row;  
+            XSSFCell cell;  
+            Object value;  
+            for(int i = sheet.getFirstRowNum() , rowCount = 0; rowCount < sheet.getPhysicalNumberOfRows() ; i++ ){  
+                row = sheet.getRow(i);  
+                colList = new ArrayList<Object>();  
+                if(row == null){  
+                    //当读取行为空时  
+                    if(i != sheet.getPhysicalNumberOfRows()){//判断是否是最后一行  
+                        rowList.add(colList);  
+                    }  
+                    continue;  
+                }else{  
+                    rowCount++;  
+                }  
+                for( int j = row.getFirstCellNum() ; j <= row.getLastCellNum() ;j++){  
+                    cell = row.getCell(j);  
+                    if(cell == null || cell.getCellType() == CellType.BLANK){  
+                        //当该单元格为空  
+                        if(j != row.getLastCellNum()){//判断是否是该行中最后一个单元格  
+                            colList.add("");  
+                        }  
+                        continue;  
+                    }  
+                    switch(cell.getCellType()){  
+                     case STRING:    
+                            value = cell.getStringCellValue();    
+                            break;    
+                        case NUMERIC:    
+                            if ("@".equals(cell.getCellStyle().getDataFormatString())) {    
+                                value = df.format(cell.getNumericCellValue());    
+                            } else if ("General".equals(cell.getCellStyle()    
+                                    .getDataFormatString())) {    
+                                value = nf.format(cell.getNumericCellValue());    
+                            } else {    
+                                value = sdf.format(HSSFDateUtil.getJavaDate(cell    
+                                        .getNumericCellValue()));    
+                            }    
+                            break;    
+                        case BOOLEAN:    
+                            value = Boolean.valueOf(cell.getBooleanCellValue());  
+                            break;    
+                        case BLANK:    
+                            value = "";    
+                            break;    
+                        default:    
+                            value = cell.toString();    
+                    }// end switch  
+                   
+                    colList.add(cell.toString());  
+                }//end for j  
+                rowList.add(colList);  
+            }//end for i  
+              
+            return rowList;  
+        }catch(Exception e){  
+            System.out.println("exception");  
+            return null;  
+        }  
+    }  
+      
+    public static void writeExcel(ArrayList<ArrayList<Object>> result,String path){  
+        if(result == null){  
+            return;  
+        }  
+        HSSFWorkbook wb = new HSSFWorkbook();  
+        HSSFSheet sheet = wb.createSheet("sheet1");  
+        for(int i = 0 ;i < result.size() ; i++){  
+             HSSFRow row = sheet.createRow(i);  
+            if(result.get(i) != null){  
+                for(int j = 0; j < result.get(i).size() ; j ++){  
+                    HSSFCell cell = row.createCell(j);  
+                    cell.setCellValue(result.get(i).get(j).toString());  
+                }  
+            }  
+        }  
+        ByteArrayOutputStream os = new ByteArrayOutputStream();  
+        try  
+        {  
+            wb.write(os);  
+        } catch (IOException e){  
+            e.printStackTrace();  
+        }  
+        byte[] content = os.toByteArray();  
+        File file = new File(path);//Excel文件生成后存储的位置。  
+        OutputStream fos  = null;  
+        try  
+        {  
+            fos = new FileOutputStream(file);  
+            fos.write(content);  
+            os.close();  
+            fos.close();  
+        }catch (Exception e){  
+            e.printStackTrace();  
+        }             
+    }  
+    
+    
+    
+   
+        
+        /**
+         * 导出
+         * 
+         * @param file csv文件(路径+文件名),csv文件不存在会自动创建
+         * @param dataList 数据
+         * @return
+         */
+        public static boolean exportCsv(File file, List<String> dataList){
+            boolean isSucess=false;
+            
+            FileOutputStream out=null;
+            OutputStreamWriter osw=null;
+            BufferedWriter bw=null;
+            try {
+                out = new FileOutputStream(file);
+                osw = new OutputStreamWriter(out);
+                bw =new BufferedWriter(osw);
+                if(dataList!=null && !dataList.isEmpty()){
+                    for(String data : dataList){
+                        bw.append(data).append("\r");
+                    }
+                }
+                isSucess=true;
+            } catch (Exception e) {
+                isSucess=false;
+            }finally{
+                if(bw!=null){
+                    try {
+                        bw.close();
+                        bw=null;
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } 
+                }
+                if(osw!=null){
+                    try {
+                        osw.close();
+                        osw=null;
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } 
+                }
+                if(out!=null){
+                    try {
+                        out.close();
+                        out=null;
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } 
+                }
+            }
+            
+            return isSucess;
+        }
+        
+        /**
+         * 导入
+         * 
+         * @param input csv文件(路径+文件)
+         * @return
+         */
+        public static ArrayList<ArrayList<Object>> readCsv(InputStream input){
+        	
+        	 ArrayList<ArrayList<Object>> rowList = new ArrayList<ArrayList<Object>>();  
+            BufferedReader br=null;
+            try { 
+                br = new BufferedReader(new InputStreamReader(input,"GBK"));
+                String line = ""; 
+                ArrayList<Object> colList;  
+                while ((line = br.readLine()) != null) { 
+                	colList = new ArrayList<Object>();
+                	String[] datas = line.split(",");
+                	for (String data : datas) {
+                		colList.add(data);
+					}
+                	rowList.add(colList);
+                }
+            }catch (Exception e) {
+            }finally{
+                if(br!=null){
+                    try {
+                        br.close();
+                        br=null;
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+     
+            return rowList;
+        }
+    
+    
+      
+    public static DecimalFormat getDf() {  
+        return df;  
+    }  
+    public static void setDf(DecimalFormat df) {  
+        ExcelUtil.df = df;  
+    }  
+    public static SimpleDateFormat getSdf() {  
+        return sdf;  
+    }  
+    public static void setSdf(SimpleDateFormat sdf) {  
+        ExcelUtil.sdf = sdf;  
+    }  
+    public static DecimalFormat getNf() {  
+        return nf;  
+    }  
+    public static void setNf(DecimalFormat nf) {  
+        ExcelUtil.nf = nf;  
+    }  
+      
+}

+ 229 - 0
src/private/nc/impl/pubdev/pubtool/FtpUtil.java

@@ -0,0 +1,229 @@
+package nc.impl.pubdev.pubtool;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.SocketException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+
+import nc.pub.Proptool.PropertiesUtil;
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
+
+public class FtpUtil {
+	
+	private FTPClient ftpClient;
+	private String strencoding = "ISO-8859-1";
+	private String ip = ""; // 服务器IP地址
+	private String userName = ""; // 用户名
+	private String userPwd = ""; // 密码
+	private int port = 21; // 端口号
+	private String basePath = ""; // 读取文件的存放目录
+
+    /**
+     * @author longht
+     * @param propfilename  ftp参数文件
+     * @param type 1对应读取excel文件类型
+     * @return 返回类型为Map<String,Object> key =文件名  value=对应的数据 
+     * 
+     */
+	public Map<String, Object>  doFtpReadFile(String propfilename,int type) {
+		Map<String, Object> result =null;
+		try {
+			ftpConnectSet(propfilename);
+			result = readFileList(null, type);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} finally {
+			closeServer();
+		}
+		return result;
+	}
+
+
+	
+	//设置ftp连接参数
+	private void ftpConnectSet(String propfilename) {
+		
+		ip = PropertiesUtil.getProperty(propfilename, "ftp_ip");
+		userName = PropertiesUtil.getProperty(propfilename, "ftp_username");
+		userPwd = PropertiesUtil.getProperty(propfilename, "ftp_pwd");
+		port = Integer.parseInt(PropertiesUtil.getProperty(propfilename, "ftp_port"));
+		basePath = PropertiesUtil.getProperty(propfilename, "ftp_basePath");
+		// 以当前系统时间拼接文件名
+		this.connectServer(ip, port, userName, userPwd, basePath);
+	}
+
+	/**
+	 * 连接并登陆ftp
+	 * @param ip
+	 * @param port
+	 * @param userName
+	 * @param userPwd
+	 * @param path
+	 * @throws SocketException
+	 * @throws IOException     function:连接到服务器
+	 */
+	private  void connectServer(String ip, int port, String userName, String userPwd, String path) {
+		ftpClient = new FTPClient();
+		try {
+			ftpClient.setDataTimeout(300 * 1000);
+			ftpClient.setDefaultTimeout(300 * 1000);
+			// 连接
+			ftpClient.connect(ip, port);
+			// 登录
+			ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+			boolean flag = ftpClient.login(userName, userPwd);
+			if (path != null && path.length() > 0) {
+				// 跳转到指定目录
+				ftpClient.changeWorkingDirectory(path);
+				strencoding = ftpClient.getControlEncoding();
+			}
+		} catch (SocketException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 关闭连接
+	 * @throws IOException function:关闭连接
+	 */
+	private void closeServer() {
+		if (ftpClient.isConnected()) {
+			try {
+				ftpClient.logout();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}finally {
+				try {
+					ftpClient.disconnect();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				
+			}
+		}
+	}
+
+	/**
+	 * @param path
+	 * @return function:读取指定目录下的文件名
+	 * @throws IOException
+	 */
+	private Map<String, Object> readFileList(Map<String, String> mapdir, int type) throws IOException {
+		// 构造返回值
+		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);
+				}
+			}
+		}
+		return reDatas;
+	}
+
+	/**
+	 * @param ftpfile
+	 * @return function:从服务器上读取指定的文件
+	 * @throws ParseException
+	 * @throws IOException
+	 */
+	private ArrayList<ArrayList<Object>> readExcelFile(String ftpfile) {
+		ArrayList<ArrayList<Object>> datas = null;
+		InputStream ins = null;
+		try {
+			ftpClient.enterLocalPassiveMode();
+			// 从服务器上读取指定的文件
+			ins = ftpClient.retrieveFileStream(ftpfile);
+			if (null == ins)
+				return null;
+			if (ftpfile.endsWith("xlsx")) {
+				// 处理ecxel2007
+				datas = new ExcelUtil().readExcel2007(ins);
+			} else if (ftpfile.endsWith("xls")) {
+				// 处理ecxel2003
+				datas = new ExcelUtil().readExcel2003(ins);
+			} else if (ftpfile.endsWith("csv")) {
+				datas = new ExcelUtil().readCsv(ins);
+			} else {
+				ExceptionUtils.wrappBusinessException("导入失败,系统只接收xls,xlsx,csv类型文件");
+				return null;
+			}
+
+		} catch (IOException e) {
+
+			e.printStackTrace();
+		} finally {
+			if (ins != null) {
+				try {
+					ins.close();
+					// 主动调用一次getReply()把接下来的226消费掉. 这样做是可以解决这个返回null问题
+					ftpClient.getReply();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		}
+		return datas;
+	}
+
+	/**
+	 * @param fileName
+	 * @return function:从服务器上读取指定的文件
+	 * @throws ParseException
+	 * @throws IOException
+	 */
+	private List<String> readFile(String fileName, List<String> list) throws ParseException {
+		if (!(null != list && list.size() > 0))
+			list = new ArrayList<String>();
+		InputStream ins = null;
+		try {
+			ftpClient.enterLocalPassiveMode();
+			// 从服务器上读取指定的文件
+			ins = ftpClient.retrieveFileStream(fileName);
+			if (null == ins)
+				return list;
+			BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "GBK"));
+			String line;
+			while ((line = reader.readLine()) != null) {
+				line = "," + line;
+				line = line.replaceAll(";", ",");
+				list.add(line);
+			}
+			reader.close();
+			if (ins != null) {
+				ins.close();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return list;
+	}
+}

+ 13 - 0
src/private/nc/impl/pubdev/pubtool/PubDevTool.java

@@ -0,0 +1,13 @@
+package nc.impl.pubdev.pubtool;
+
+import java.io.File;
+import java.util.ArrayList;
+
+public class PubDevTool {
+
+	public ArrayList<ArrayList<Object>> AnalizyExcelimp(File file) {
+		// TODO Auto-generated method stub
+		return  new ExcelUtil().readFile(file);
+	}
+
+}

+ 27 - 0
src/private/nc/impl/pubdev/pubtool/filetool/DevFileGainToolimpl.java

@@ -0,0 +1,27 @@
+package nc.impl.pubdev.pubtool.filetool;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Map;
+
+import nc.impl.pubdev.pubtool.FtpUtil;
+import nc.impl.pubdev.pubtool.PubDevTool;
+import nc.itf.pubdev.pubtool.filetool.IDevFileGainTool;
+import nc.vo.pub.BusinessException;
+
+public class DevFileGainToolimpl implements IDevFileGainTool{
+
+	@Override
+	public ArrayList<ArrayList<Object>> GainExcelDatasByFile(File file) throws BusinessException{
+		// TODO Auto-generated method stub
+		return new PubDevTool().AnalizyExcelimp(file);
+	}
+
+	@Override
+	public Map<String, Object> GainDatasByFtp(String propfilename, int type) throws BusinessException {
+		// TODO Auto-generated method stub
+		return new FtpUtil().doFtpReadFile(propfilename, type);
+	}
+
+
+}

+ 33 - 0
src/public/nc/itf/pubdev/pubtool/filetool/IDevFileGainTool.java

@@ -0,0 +1,33 @@
+package nc.itf.pubdev.pubtool.filetool;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Map;
+
+import nc.vo.pub.BusinessException;
+
+
+public interface IDevFileGainTool {
+	
+	/**
+	 * @param file 文件
+	 * 导入文件只能是xls,xlsx,csv
+	 * @return 将返回结果存储在ArrayList内,存储结构与二位数组类似  
+     * lists.get(0).get(0)表示Excel中0行0列单元格  
+	 * 
+	 **/
+	public abstract ArrayList<ArrayList<Object>> GainExcelDatasByFile(File file) throws BusinessException;
+	
+	
+	 /**
+     * @author longht
+     * @param propfilename  ftp参数文件
+     * @param type 1 = 获取excel文件类型
+     * @return 返回类型为Map<String,Object> key =文件名  value=对应的数据 
+     * 
+     */
+	public abstract Map<String,Object> GainDatasByFtp(String propfilename,int type) throws BusinessException;
+
+
+
+}

+ 37 - 0
src/public/nc/pub/Proptool/PropertiesUtil.java

@@ -0,0 +1,37 @@
+package nc.pub.Proptool;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class PropertiesUtil {
+
+
+    private static Properties _prop = new Properties();
+
+   
+    
+    /**
+     * 读取配置文件
+     * @param fileName
+     */
+    public static void readProperties(String propname){
+        try {
+            InputStream in = PropertiesUtil.class.getResourceAsStream(propname);
+            _prop.load(in);
+        }catch (IOException e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 根据key读取对应的value
+     * @param key
+     * @return
+     */
+    public static String getProperty(String propname,String key){
+    	readProperties(propname);
+        return _prop.getProperty(key);
+    }
+    
+}

+ 14 - 0
src/public/nc/pub/Proptool/ftp_settings.properties

@@ -0,0 +1,14 @@
+# FSGAS-UNIONPAYFTP
+#ftp_ip=218.19.140.180
+#ftp_username=004-FSRQ
+#ftp_pwd=FsRq123!@#
+#ftp_basePath=/
+#ftp_port=990
+#
+#
+# Localtest
+ftp_ip=10.10.21.191
+ftp_port=21
+ftp_username=draght
+ftp_pwd=dragon!18
+ftp_basePath=/