| | |
| | | * @return |
| | | */ |
| | | public static Result isFTPFileExist(String uuid) { |
| | | System.out.println("uuid = " + uuid); |
| | | // System.out.println("uuid = " + uuid); |
| | | //创建 ftp 对象 |
| | | FTPClient ftp = new FTPClient(); |
| | | boolean flag = false; |
| | |
| | | ftp.setControlEncoding("GBK"); |
| | | // 检验文件是否存在 |
| | | boolean ftpFile = ftp.changeWorkingDirectory(ftpPath); |
| | | System.out.println("检验文件是否存在 = " + ftpFile); |
| | | // System.out.println("检验文件是否存在 = " + ftpFile); |
| | | // Use passive mode as default |
| | | ftp.enterLocalPassiveMode(); |
| | | |
| | | FTPFile[] files = ftp.listFiles(); |
| | | System.out.println("files = " + files); |
| | | System.out.println("开始读取内网回传消息"); |
| | | // System.out.println("files = " + files); |
| | | // System.out.println("开始读取内网回传消息"); |
| | | if (files.length==0){ |
| | | System.out.println("未读取到文件"); |
| | | // System.out.println("未读取到文件"); |
| | | return new Result(400,null,"未读取到文件",null); |
| | | } else { |
| | | System.out.println("-----有读取到文件--------"); |
| | | // System.out.println("-----有读取到文件--------"); |
| | | for (FTPFile file : files){ |
| | | String fileName = file.getName(); |
| | | System.out.println("fileName = " + fileName); |
| | | // System.out.println("fileName = " + fileName); |
| | | InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING)); |
| | | String substring1 = fileName.substring(0, 1); |
| | | System.out.println("substring1 = " + substring1); |
| | | // System.out.println("substring1 = " + substring1); |
| | | if (substring1.equals("n")){ |
| | | System.out.println("-------接收到内网回传的文件: " + substring1); |
| | | System.out.println("-------接收到内网回传的文件: " + fileName); |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | |
| | | if (result.getCode()==203) { |
| | | //返回 |
| | | return new Result(203,null,result.getMsg(),null); |
| | | } |
| | | if (result.getCode()==205){ |
| | | //返回 |
| | | return new Result(202,null,"新增失败,找不到该用户",null); |
| | | } |
| | | } |
| | | } |
| | |
| | | public static boolean isFTPFileExist() { |
| | | FTPClient ftp = new FTPClient(); |
| | | try { |
| | | //设置超时时间 |
| | | ftp.setConnectTimeout(2000); |
| | | //连接 |
| | | ftp.connect(ftpHost, ftpPort); |
| | | // 登陆 |