| | |
| | | * @param uuid 随机数 |
| | | * @return |
| | | */ |
| | | public static R isFTPFileExist(String uuid) { |
| | | public static Result isFTPFileExist(String uuid) { |
| | | //创建 ftp 对象 |
| | | FTPClient ftp = new FTPClient(); |
| | | boolean flag = false; |
| | |
| | | // 检验登陆操作的返回码是否正确 |
| | | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { |
| | | ftp.disconnect(); |
| | | return R.data(400,null,"ftp 连接失败"); |
| | | return new Result(400,null,"ftp 连接失败",null); |
| | | } |
| | | |
| | | ftp.enterLocalActiveMode(); |
| | |
| | | ftp.changeWorkingDirectory(ftpPath); |
| | | FTPFile[] files = ftp.listFiles(); |
| | | if (files.length==0){ |
| | | return R.data(400,null,"未读取到文件"); |
| | | return new Result(400,null,"未读取到文件",null); |
| | | } else { |
| | | for (FTPFile file : files){ |
| | | String fileName = file.getName(); |
| | |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | R result = DataHandler.handler(s,uuid); |
| | | Result result = DataHandler.handler(s,uuid); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, fileName); |
| | |
| | | ftp.completePendingCommand(); |
| | | if (result.getCode()==200) { |
| | | //返回 |
| | | return R.data(result); |
| | | return new Result(200,null,"新增成功",null); |
| | | } |
| | | if (result.getCode()==201) { |
| | | //返回 |
| | | return new Result(201,null,"修改成功",null); |
| | | } |
| | | if (result.getCode()==202) { |
| | | //返回 |
| | | return new Result(202,null,result.getMsg(),null); |
| | | } |
| | | } |
| | | } |
| | | return R.data(400,null,"未读取到对应的文件"); |
| | | return new Result(400,null,"未读取到对应的文件",null); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.data(400,null,"失败"); |
| | | return new Result(400,null,"失败",null); |
| | | } |
| | | |
| | | /** |