Jelajahi Sumber

增加处理失败后文件处理

koul 5 tahun lalu
induk
melakukan
b901372532

+ 8 - 0
src/main/java/com/uas/service/Impl/DownloadFilePathServiceImpl.java

@@ -67,6 +67,11 @@ public class DownloadFilePathServiceImpl implements DownloadFilePathService {
                                                     sftp.rename("/" + ftpMap.get("file").toString() + "/" + file.getName(),
                                                             "/outbounddeliverydetails/backup/" + file.getName());
                                         }
+									}else {
+										if ("N_YITOA_LHCT-SF".equals(depot)) {
+											Boolean rename =
+													sftp.rename(ftpMap.get("downloadpath").toString() + "/" + file.getName(), "goodsreceipt/backup/" + file.getName());
+										}
 									}
 								} catch (Exception e) {
 									e.printStackTrace();
@@ -96,6 +101,9 @@ public class DownloadFilePathServiceImpl implements DownloadFilePathService {
 									if (bol) {
 										//移动处理完的文件到bak文件夹下
 										client.rename(file.getName(), "bak/" + file.getName());
+									}else {
+										//移动处理完的文件到failed文件夹下
+										client.rename(file.getName(), "failed/" + file.getName());
 									}
 								} catch (Exception e) {
 									e.printStackTrace();

+ 9 - 1
src/main/java/com/uas/service/Impl/DownloadServiceImpl.java

@@ -100,7 +100,9 @@ public class DownloadServiceImpl implements DownloadService {
 								}
 								Statement statement = connect.createStatement();
 								sqls = parseXmlFileToSqls(file, statement);
+								String s = file.getName().substring(0, file.getName().indexOf(".")) + ".xml";
 								if (sqls == null) {
+									sftp.rename(ftpMap.get("downloadpath").toString() + "/" + s, "goodsreceipt/backup/" + s);
 									continue;
 								}
 
@@ -108,12 +110,18 @@ public class DownloadServiceImpl implements DownloadService {
 
 								if (executeRes) {
 									if ("N_YITOA_LHCT-SF".equals(depot)) {
-										String s = file.getName().substring(0, file.getName().indexOf(".")) + ".xml";
 										Boolean rename = sftp.rename(ftpMap.get("downloadpath").toString() + "/" + s, "goodsreceipt/backup/" + s);
 									} else {
 										//移动处理完的文件到bak文件夹下
 										client.rename(file.getName(), "bak/" + file.getName());
 									}
+								}else{
+									if ("N_YITOA_LHCT-SF".equals(depot)) {
+										Boolean rename = sftp.rename(ftpMap.get("downloadpath").toString() + "/" + s, "goodsreceipt/backup/" + s);
+									} else {
+										//移动处理完的文件到failed文件夹下
+										client.rename(file.getName(), "failed/" + file.getName());
+									}
 								}
 								statement.close();
 							} catch (Exception e) {

+ 1 - 1
src/main/java/com/uas/util/FtpUtil.java

@@ -202,7 +202,7 @@ public class FtpUtil {
 			ftpClient.changeWorkingDirectory("/"+dir+"/");
 			FTPFile[] ftpFiles = ftpClient.listFiles("/"+dir+"/");
 			for (FTPFile file : ftpFiles) {
-				if(!".".equals(file.getName()) && !"..".equals(file.getName())&& !"bak".equals(file.getName())){
+				if(!".".equals(file.getName()) && !"..".equals(file.getName())&& !"bak".equals(file.getName())&& !"failed".equals(file.getName())){
 					File localFile = new File(System.getProperty("java.io.tmpdir") + File.separator + file.getName());
 					OutputStream os = new FileOutputStream(localFile);
 					ftpClient.retrieveFile(file.getName(), os);

+ 1 - 1
src/main/resources/properties/ftpconfig.properties

@@ -42,7 +42,7 @@
         "password":"yc00lk",
         "downloadpath":"UFCT/send",
         "in":"UFCT/recv",
-        "file":""
+        "file":"UFCT/signback"
     },
     "N_YITOA_LHCT-SF":{
         "ip":"mcs-cas-api-sftp.sf-express.com",