智慧保安后台管理-外网项目备份
zhongrj
2023-09-17 8853292babb2ad94de4a3207966f1e83b767cd2d
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;
@@ -111,9 +99,9 @@
                     }
                  }
                  //删除本地文件
                  MysqlCenlint.deletes(fileName);
                  //MysqlCenlint.deletes(fileName);
                  MysqlCenlint.deletess(fileName);
                  FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
                  FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName);
                  is.close();
                  ftp.completePendingCommand();
               }
@@ -163,7 +151,7 @@
      } catch (Exception e) {
         System.out.println("ftp连接失败");
         e.printStackTrace();
      } finally {