From 8853292babb2ad94de4a3207966f1e83b767cd2d Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Sun, 17 Sep 2023 16:38:34 +0800
Subject: [PATCH] 新增流程节点进程查询接口
---
src/main/java/org/springblade/modules/FTP/monitor.java | 33 +++++++++++----------------------
1 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/src/main/java/org/springblade/modules/FTP/monitor.java b/src/main/java/org/springblade/modules/FTP/monitor.java
index de6068a..fe24233 100644
--- a/src/main/java/org/springblade/modules/FTP/monitor.java
+++ b/src/main/java/org/springblade/modules/FTP/monitor.java
@@ -10,39 +10,26 @@
import java.io.IOException;
import java.io.InputStream;
+import static org.springblade.common.config.FtpConfig.*;
+
+
@Component
public class monitor {
- //ftp服务器IP地址
- private static String ftpHost = "192.168.0.105";
- //ftp服务器端口
- private static int ftpPort = 21;
- //ftp服务器用户名
- private static String ftpUserName = "yly";
- //ftp服务器密码
- private static String ftpPassword = "Yly@123";
- //ftp服务器路径
- private static String ftpPath = "anbao/";
- //本地路径
- private static String localPath = "D:\\anbao";
- //文件名
- //private static String fileName = "nsql.json";
-
- @Scheduled(cron = "*/30 * * * * ?")
+// @Scheduled(cron = "*/30 * * * * ?")
public static boolean isFTPFileExist() {
FTPClient ftp = new FTPClient();
-
try {
// 连接ftp服务器
+// System.out.println("ftpHost = " + ftpHost);
ftp.connect(ftpHost, ftpPort);
// 登陆
ftp.login(ftpUserName, ftpPassword);
-
// 检验登陆操作的返回码是否正确
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
@@ -76,6 +63,7 @@
//ftp.changeWorkingDirectory(new String(dir.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
// 检验文件是否存在
+ ftp.changeWorkingDirectory(ftpPath);
FTPFile[] files = ftp.listFiles();
if (files.length==0){
return false;
@@ -83,6 +71,7 @@
else {
for (FTPFile file : files){
String fileName = file.getName();
+ InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
String substring1 = fileName.substring(0, 1);
if (substring1.equals("n")){
//把文件下载到本地
@@ -110,10 +99,10 @@
}
}
//删除本地文件
- MysqlCenlint.deletes(fileName);
+ //MysqlCenlint.deletes(fileName);
MysqlCenlint.deletess(fileName);
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
- //is.close();
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName);
+ is.close();
ftp.completePendingCommand();
}
}
@@ -162,7 +151,7 @@
} catch (Exception e) {
-
+ System.out.println("ftp连接失败");
e.printStackTrace();
} finally {
--
Gitblit v1.9.3