| | |
| | | if (files.length==0){ |
| | | return new Result(400,null,"未读取到文件",null); |
| | | } else { |
| | | boolean flag = false; |
| | | for (FTPFile file : files){ |
| | | String fileName = file.getName(); |
| | | if (fileName.contains("ni")){ |
| | | System.out.println("-------接收到内网回传的文件: " + fileName); |
| | | //把文件下载到本地 |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | System.out.println("s = " + s); |
| | | //数据处理 |
| | | Result result = DataHandler.handler(s,uuid); |
| | | if (result.getCode()==400){ |
| | | // return new Result(400,null,"uuid 不匹配",null); |
| | | break; |
| | | }else { |
| | | //匹配上了删除文件 |
| | | if (result.getCode()==200) { |
| | | flag = true; |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | // ftp.dele(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | if (result.getCode() == 200) { |
| | | //返回 |
| | | 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); |
| | | } |
| | | if (result.getCode() == 203) { |
| | | //返回 |
| | | return new Result(203, null, result.getMsg(), null); |
| | | } |
| | | if (result.getCode() == 205) { |
| | | //返回 |
| | | return new Result(202, null, "新增失败,找不到该用户", null); |
| | | } |
| | | // ftp.dele(fileName); |
| | | //返回 |
| | | return result.getData().get(0); |
| | | } |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | } |
| | | } |
| | | System.out.println("未读取到对应的文件"); |
| | | // if (!flag){ |
| | | // ftp.logout(); |
| | | // } |
| | | return new Result(400,null,"未读取到对应的文件",null); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | // ftp.dele(fileName); |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | |
| | | //返回 |
| | | return result; |
| | | } |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | } |
| | | } |
| | | if (!flag){ |
| | | ftp.logout(); |
| | | } |
| | | // if (!flag){ |
| | | // ftp.logout(); |
| | | // } |
| | | return new Result(400,null,"未读取到对应的文件",null); |
| | | } |
| | | } catch (Exception e) { |