智慧保安后台管理-外网
Administrator
2022-06-08 7f36a55767f870937a473f9c0eebf0240300a5ef
src/main/java/org/springblade/modules/FTP/FtpUtil.java
@@ -6,13 +6,14 @@
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.springblade.modules.system.entity.User;
import java.io.*;
import java.net.SocketException;
import java.util.Date;
import java.util.Map;
import static org.springblade.common.constant.FtpConstant.*;
import static org.springblade.common.constant.FtpConstant.ftpPassword;
import static org.springblade.common.config.FtpConfig.*;
/**
 * ftp工具类
@@ -302,7 +303,116 @@
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "w"+response1+".json", in1);
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "w"+response1+".json", in1);
      MysqlCenlint.deletess("w"+response1+".json");
   }
   /**
    * 执行 对象数据(用户,报名对象信息等) 上传
    * @param obj 对象信息
    */
   public static void objectFileUpload(Object obj){
      String json1 = JSON.toJSONString(obj);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "o"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "o"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "o"+response1+".json", in1);
      MysqlCenlint.deletess("o"+response1+".json");
   }
   /**
    * 文件 file 上传(word,图片的文件的传输)
    * @param obj 对象信息
    */
   public static void fileUpload(Object obj){
      String json1 = JSON.toJSONString(obj);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "f"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "f"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "f"+response1+".json", in1);
      MysqlCenlint.deletess("f"+response1+".json");
   }
   /**
    *  用户集合
    * @param map
    */
   public static void objectFileUploadList(Map<String, Object> map) {
      String json1 = JSON.toJSONString(map);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "l"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "l"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "l"+response1+".json", in1);
      MysqlCenlint.deletess("l"+response1+".json");
   }
   /**
    * 报名信息查验
    * @param map
    */
   public static void objectFileUploadListUserId(Map<String, Object> map){
      String json1 = JSON.toJSONString(map);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "t"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "t"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "t"+response1+".json", in1);
      MysqlCenlint.deletess("t"+response1+".json");
   }
   /**
    * 查询保安员证编号位数
    * @param map
    */
   public static void getSecurityNumberBit(Map<String, Object> map) {
      String json1 = JSON.toJSONString(map);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "s"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "s"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "s"+response1+".json", in1);
      MysqlCenlint.deletess("s"+response1+".json");
   }
   /**
    * 用户审查
    * @param user
    */
   public static void sqlFileUploadUserExamine(User user) {
      String json1 = JSON.toJSONString(user);
      String response1 = String.valueOf((new Date()).getTime());
      OutJson.createJsonFile(json1, localPath, "u"+response1);
      FileInputStream in1 = null;
      try {
         in1 = new FileInputStream(new File(localPath + "u"+response1+".json"));
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "u"+response1+".json", in1);
      MysqlCenlint.deletess("u"+response1+".json");
   }
}