| | |
| | | try { |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | |
| | | // 登陆 |
| | | ftp.login(ftpUserName, ftpPassword); |
| | | ftp.login(ftpUserNameIn, ftpPasswordIn); |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | | return new Result(400,null,"ftp 连接失败",null); |
| | | } |
| | | |
| | | System.out.println("开始读取内网回传消息"); |
| | | ftp.enterLocalActiveMode(); |
| | | |
| | | // 设置文件类型为二进制,与ASCII有区别 |
| | |
| | | ftp.changeWorkingDirectory(ftpPath); |
| | | FTPFile[] files = ftp.listFiles(); |
| | | if (files.length==0){ |
| | | System.out.println("未读取到文件"); |
| | | return new Result(400,null,"未读取到文件",null); |
| | | } else { |
| | | for (FTPFile file : files){ |
| | |
| | | InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING)); |
| | | String substring1 = fileName.substring(0, 1); |
| | | if (substring1.equals("n")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | System.out.println("-------接收到内网回传的文件: " + substring1); |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | Result result = DataHandler.handler(s,uuid); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | is.close(); |
| | | ftp.completePendingCommand(); |
| | | if (result.getCode()==200) { |
| | |
| | | } |
| | | } |
| | | } |
| | | System.out.println("未读取到对应的文件"); |
| | | return new Result(400,null,"未读取到对应的文件",null); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | // 登陆 |
| | | ftp.login(ftpUserName, ftpPassword); |
| | | ftp.login(ftpUserNameIn, ftpPasswordIn); |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | |
| | | String substring1 = fileName.substring(0, 2); |
| | | if (substring1.equals("nl")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | //返回 |
| | | return result; |
| | | } |
| | |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | // 登陆 |
| | | ftp.login(ftpUserName, ftpPassword); |
| | | ftp.login(ftpUserNameIn, ftpPasswordIn); |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | |
| | | String substring1 = fileName.substring(0, 2); |
| | | if (substring1.equals("nt")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | //返回 |
| | | return result; |
| | | } |
| | |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | // 登陆 |
| | | ftp.login(ftpUserName, ftpPassword); |
| | | ftp.login(ftpUserNameIn, ftpPasswordIn); |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | |
| | | String substring1 = fileName.substring(0, 4); |
| | | if (substring1.equals("nsql")) { |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // |
| | | String s = OutJson.TestJson(fileName); |
| | | //sql语句 |
| | |
| | | //删除本地服务器文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 服务器文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | } |
| | | //关闭流 |
| | | is.close(); |
| | |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | // 登陆 |
| | | ftp.login(ftpUserName, ftpPassword); |
| | | ftp.login(ftpUserNameIn, ftpPasswordIn); |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | |
| | | String substring1 = fileName.substring(0, 2); |
| | | if (substring1.equals("ns")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | //返回 |
| | | return result; |
| | | } |