瀏覽代碼

怡海能达武汉同步

shenliang 3 年之前
父節點
當前提交
a38a9ba00e
共有 3 個文件被更改,包括 85 次插入45 次删除
  1. 27 30
      src/com/uas/fileUtil/FileUtil.java
  2. 39 1
      src/com/uas/main/Download.java
  3. 19 14
      src/properties/dbconfig.properties

+ 27 - 30
src/com/uas/fileUtil/FileUtil.java

@@ -208,45 +208,42 @@ public class FileUtil {
 	public static Boolean fileUp(Connection connection,MultipartFile file,String sob){
 		boolean result = false;
 		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-		String path = saveFile(file, "ADMIN");
 		String filename = file.getOriginalFilename().replaceAll(",", ",");
 		int size = (int) file.getSize();
 		if(size>0) {
 			Statement statement = null;
 			try {
 				statement = connection.createStatement();
-				String sql = "select " + sob + ".EMAILFILEPATH.nextval from dual";
-				ResultSet resultSet = statement.executeQuery(sql);
-				if (resultSet.next()) {
-					int id = resultSet.getInt(1);
-					String sql1 =
-							"INSERT INTO " + sob + ".filepath(fp_id,fp_path,fp_size,fp_man,fp_date,fp_name) values(" + id + ",'" + path +
-									"'," + size + ",'" + "管理员" + "'," + "to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "')";
-					int i = statement.executeUpdate(sql1);
-					if (i > 0) {
-						String substring = null;
-						if (filename.indexOf("-") != -1) {
-							substring = filename.substring(0, filename.indexOf("-"));
-						} else
-							substring = filename.substring(0, filename.indexOf("."));
-						//String sql2 = "select " + sob + ".FTPATTCHTEMP_SEQ.nextval from dual";
-						//ResultSet resultSet2 = statement.executeQuery(sql2);
-						String sql3 = "INSERT INTO " + sob + ".FTPATTCHTEMP(FT_ID,FT_ATTCH,FT_PIINOUTNO,FT_STATUS,FT_INSERTDATE,FT_FILENAME,FT_SOB)values(" + sob + ".FTPATTCHTEMP_SEQ.nextval,'" + id + ";','" + substring + "','GET',to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "','" + sob + "')";
-						int i1 = statement.executeUpdate(sql3);
-						if (i1 > 0) {
-							result = true;
+				ResultSet set = statement.executeQuery("select count(1) from " + sob + ".FTPATTCHTEMP where FT_FILENAME='" + filename + "' and FT_SOB='"+sob+"'");
+				while (set.next()){
+					int count = set.getInt(1);
+					if (count==0){
+						String path = saveFile(file, "FTP");
+						ResultSet resultSet = statement.executeQuery("select " + sob + ".EMAILFILEPATH.nextval from dual");
+						if (resultSet.next()) {
+							int id = resultSet.getInt(1);
+							String sql1 =
+									"INSERT INTO " + sob + ".filepath(fp_id,fp_path,fp_size,fp_man,fp_date,fp_name) values(" + id + ",'" + path +
+											"'," + size + ",'" + "FTP" + "'," + "to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "')";
+							int i = statement.executeUpdate(sql1);
+							if (i > 0) {
+								String substring = null;
+								if (filename.indexOf("-") != -1) {
+									substring = filename.substring(0, filename.indexOf("-"));
+								} else {
+									substring = filename.substring(0, filename.indexOf("."));
+								}
+								String sql3 = "INSERT INTO " + sob + ".FTPATTCHTEMP(FT_ID,FT_ATTCH,FT_PIINOUTNO,FT_STATUS,FT_INSERTDATE,FT_FILENAME,FT_SOB)values(" + sob + ".FTPATTCHTEMP_SEQ.nextval,'" + id + ";','" + substring + "','GET',to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "','" + sob + "')";
+								int i1 = statement.executeUpdate(sql3);
+								if (i1 > 0) {
+									result = true;
+								}
+							}
 						}
+						statement.close();
 					}
-
-				/*String sql2 =
-						"update " + sob + ".prodinout set pi_attach = '" + id + ";' where pi_inoutno ='" + substring+"'";
-					int i = statement.executeUpdate(sql2);
-					if (i > 0) {
-						result = true;
-					}*/
 				}
-				statement.close();
-				return result;
+				result=true;
 			} catch (SQLException e) {
 				e.printStackTrace();
 			}

+ 39 - 1
src/com/uas/main/Download.java

@@ -40,6 +40,7 @@ public class Download {
 						List<File> files = FtpUtil.downloadAllFile(client,directory);
 						List<File> fileListSZ = new ArrayList<>();
 						List<File> fileListHK = new ArrayList<>();
+						List<File> fileListWH = new ArrayList<>();
 						List<File> fileListZX = new ArrayList<>();
 						List<File> fileListERROR = new ArrayList<>();
 						List<File> fileListMove = new ArrayList<>();
@@ -52,7 +53,10 @@ public class Download {
 									fileListHK.add(file);
 								}else if("YTCK".equals(s)){
 									fileListZX.add(file);
-								}else {
+								}else if ("WHCK".equals(s)){
+									fileListWH.add(file);
+								}
+								else {
 									fileListERROR.add(file);
 								}
 							}
@@ -88,6 +92,21 @@ public class Download {
 							}
 							conhk.close();
 						}
+						if (fileListWH!=null&&fileListWH.size()>0){
+							String sob = "YHND_WH";
+							conhk = JdbcUtil.getConnectBySob(sob);
+							for (File file:fileListWH) {
+								fileName += "," + file.getName();
+								MultipartFile multipartFile = FileUtil.FileToMultipartFile(file);
+								if (multipartFile!=null && (int)multipartFile.getSize()>0){
+									bol =FileUtil.fileUp(conhk,multipartFile,sob);
+									if (bol){
+										fileListMove.add(file);
+									}
+								}
+							}
+							conhk.close();
+						}
 						if (fileListZX!=null&&fileListZX.size()>0){
 							String sob = "YITOA_ZX";
 							conzx = JdbcUtil.getConnectBySob(sob);
@@ -118,6 +137,7 @@ public class Download {
 						List<File> files1 = FtpUtil.downloadAllFile(client,directory1);
 						List<File> fileRTSZ = new ArrayList<>();
 						List<File> fileRTHK = new ArrayList<>();
+						List<File> fileRTWH = new ArrayList<>();
 						List<File> fileRTZX = new ArrayList<>();
 						List<File> fileRTERROR = new ArrayList<>();
 						List<File> fileRTMove = new ArrayList<>();
@@ -130,6 +150,8 @@ public class Download {
 									fileRTHK.add(file);
 								}else if("YTCK".equals(s)){
 									fileRTZX.add(file);
+								}else if("WHCK".equals(s)){
+									fileRTWH.add(file);
 								}else {
 									fileRTERROR.add(file);
 								}
@@ -167,6 +189,22 @@ public class Download {
 							}
 							conhk.close();
 						}
+						if (fileRTWH!=null&&fileRTWH.size()>0){
+							String sob = "YHND_WH";
+							conhk = JdbcUtil.getConnectBySob(sob);
+							//Statement statement = conhk.createStatement();
+							for (File file:fileRTWH) {
+								fileName += "," + file.getName();
+								MultipartFile multipartFile = FileUtil.FileToMultipartFile(file);
+								if (multipartFile!=null && (int)multipartFile.getSize()>0){
+									bol =FileUtil.fileUp(conhk,multipartFile,sob);
+									if (bol){
+										fileRTMove.add(file);
+									}
+								}
+							}
+							conhk.close();
+						}
 						if (fileRTZX!=null&&fileRTZX.size()>0){
 							String sob = "YITOA_ZX";
 							conzx = JdbcUtil.getConnectBySob(sob);

+ 19 - 14
src/properties/dbconfig.properties

@@ -1,17 +1,22 @@
 {
-	"YHND_SZ":{
-		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
-		"user":"YHND_SZ",
-		"password":"select!#%*("
-	},
-	"YHND_HK":{
-		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
-		"user":"YHND_HK",
-		"password":"select!#%*("
-	},
-	"YITOA_ZX":{
-		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
-		"user":"YITOA_ZX",
-		"password":"select!#%*("
+"YHND_SZ":{
+"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+"user":"YHND_SZ",
+"password":"select!#%*("
+},
+"YHND_HK":{
+"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+"user":"YHND_HK",
+"password":"select!#%*("
+},
+"YITOA_ZX":{
+"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+"user":"YITOA_ZX",
+"password":"select!#%*("
+},
+"YHND_WH":{
+"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+"user":"YHND_WH",
+"password":"select!#%*("
 }
 }