智慧保安后台管理-外网
Administrator
2022-05-16 c9d0b30ddbe7cf2d682545bf50b6a85c9806da43
ftp path 路径修改
3 files modified
41 ■■■■■ changed files
src/main/java/org/springblade/common/config/FtpConfig.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/Monitor.java 30 ●●●● patch | view | raw | blame | history
src/main/resources/application-dev.yml 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/config/FtpConfig.java
@@ -58,6 +58,12 @@
     */
    public static String ftpPath;
    /**
     * ftp服务器路径(接收内网)
     */
    public static String ftpPathIn;
    /**
     * 本地路径
     */
@@ -123,6 +129,10 @@
        FtpConfig.ftpPath = ftpPath;
    }
    public void setFtpPathIn(String ftpPathIn) {
        FtpConfig.ftpPathIn = ftpPathIn;
    }
    public void setLocalPath(String localPath) {
        FtpConfig.localPath = localPath;
    }
src/main/java/org/springblade/modules/FTP/Monitor.java
@@ -53,7 +53,7 @@
            // 设置编码格式
            ftp.setControlEncoding("GBK");
            // 检验文件是否存在
            boolean ftpFile = ftp.changeWorkingDirectory(ftpPath);
            boolean ftpFile = ftp.changeWorkingDirectory(ftpPathIn);
            System.out.println("检验文件是否存在 = " + ftpFile);
            FTPFile[] files = ftp.listFiles();
            System.out.println("files = " + files);
@@ -72,14 +72,14 @@
                    if (substring1.equals("n")){
                        System.out.println("-------接收到内网回传的文件: " + substring1);
                        //把文件下载到本地
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
                        // 解析数据
                        String s = OutJson.TestJson(fileName);
                        //数据处理
                        Result result = DataHandler.handler(s,uuid);
                        //删除本地文件
                        MysqlCenlint.deletess(fileName);
                        FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
                        FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
                        is.close();
                        ftp.completePendingCommand();
                        if (result.getCode()==200) {
@@ -147,7 +147,7 @@
            ftp.setControlEncoding("GBK");
            // 检验文件是否存在
            ftp.changeWorkingDirectory(ftpPath);
            ftp.changeWorkingDirectory(ftpPathIn);
            FTPFile[] files = ftp.listFiles();
            if (files.length==0){
                return new Result(400,null,"未读取到文件",null);
@@ -158,7 +158,7 @@
                    String substring1 = fileName.substring(0, 2);
                    if (substring1.equals("nl")){
                        //把文件下载到本地
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
                        // 解析数据
                        String s = OutJson.TestJson(fileName);
                        //数据处理
@@ -168,7 +168,7 @@
                            //删除本地文件
                            MysqlCenlint.deletess(fileName);
                            //删除 ftp 文件
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
                            //返回
                            return result;
                        }
@@ -222,7 +222,7 @@
            ftp.setControlEncoding("GBK");
            // 检验文件是否存在
            ftp.changeWorkingDirectory(ftpPath);
            ftp.changeWorkingDirectory(ftpPathIn);
            FTPFile[] files = ftp.listFiles();
            if (files.length==0){
                return new Result(400,null,"未读取到文件",null);
@@ -233,7 +233,7 @@
                    String substring1 = fileName.substring(0, 2);
                    if (substring1.equals("nt")){
                        //把文件下载到本地
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
                        // 解析数据
                        String s = OutJson.TestJson(fileName);
                        //数据处理
@@ -243,7 +243,7 @@
                            //删除本地文件
                            MysqlCenlint.deletess(fileName);
                            //删除 ftp 文件
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
                            //返回
                            return result;
                        }
@@ -295,7 +295,7 @@
            ftp.setControlEncoding("GBK");
            // 检验文件是否存在
            ftp.changeWorkingDirectory(ftpPath);
            ftp.changeWorkingDirectory(ftpPathIn);
            FTPFile[] files = ftp.listFiles();
            if (files.length==0){
                return false;
@@ -310,7 +310,7 @@
                        String substring1 = fileName.substring(0, 4);
                        if (substring1.equals("nsql")) {
                            //把文件下载到本地
                            FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
                            FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
                            //
                            String s = OutJson.TestJson(fileName);
                            //sql语句
@@ -336,7 +336,7 @@
                            //删除本地服务器文件
                            MysqlCenlint.deletess(fileName);
                            //删除 ftp 服务器文件
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
                        }
                        //关闭流
                        is.close();
@@ -389,7 +389,7 @@
            ftp.setControlEncoding("GBK");
            // 检验文件是否存在
            ftp.changeWorkingDirectory(ftpPath);
            ftp.changeWorkingDirectory(ftpPathIn);
            FTPFile[] files = ftp.listFiles();
            if (files.length==0){
                return new Result(400,null,"未读取到文件",null);
@@ -400,7 +400,7 @@
                    String substring1 = fileName.substring(0, 2);
                    if (substring1.equals("ns")){
                        //把文件下载到本地
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
                        FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
                        // 解析数据
                        String s = OutJson.TestJson(fileName);
                        //数据处理
@@ -410,7 +410,7 @@
                            //删除本地文件
                            MysqlCenlint.deletess(fileName);
                            //删除 ftp 文件
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
                            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
                            //返回
                            return result;
                        }
src/main/resources/application-dev.yml
@@ -45,6 +45,7 @@
  ftpUserNameIn: baftpout
  ftpPasswordIn: baftpout
  ftpPath: yly/anbao/
  ftpPathIn: yly/anbao/
  localPath: /home/zhongsong/anbao/
  ip: http://47.49.36.190:9000
  jsonUrl: /home/zhongsong/anbao/