智慧保安后台管理-外网
钟日健
2022-05-26 48b0a1e6cdfa5381731d6f814cea9c4eca99a0e5
src/main/java/org/springblade/modules/quartz/task/Task.java
@@ -62,9 +62,15 @@
//   @Scheduled(cron = "*/30 * * * * ?")
   public boolean readFile() {
      FTPClient ftp = new FTPClient();
      System.out.println("ftp 创建客户端");
      try {
         //设置传输超时时间为60秒
         ftp.setDataTimeout(10000);
         //连接超时为60秒
         ftp.setConnectTimeout(10000);
         //连接
         ftp.connect(ftpHost, ftpPort);
         System.out.println("ftp 连接成功!"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
         // 登陆
         ftp.login(ftpUserNameIn, ftpPasswordIn);
         // 检验登陆操作的返回码是否正确
@@ -89,6 +95,7 @@
         FTPFile[] files = ftp.listFiles();
         if (files.length==0){
            ftp.logout();
            return false;
         }
         else {
@@ -96,6 +103,7 @@
               String fileName = file.getName();
               InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
               if (null == is) {
                  ftp.logout();
                  return false;
               } else {
                  String substring1 = fileName.substring(0, 4);
@@ -132,6 +140,7 @@
                  //关闭流
                  is.close();
                  ftp.completePendingCommand();
                  ftp.logout();
               }
               return true;
            }
@@ -140,7 +149,7 @@
         System.out.println("ftp连接失败");
         e.printStackTrace();
      } finally {
         if (ftp != null) {
         if (ftp.isConnected()) {
            try {
               ftp.disconnect();
            } catch (IOException e) {