| | |
| | | package org.springblade.modules.FTP; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import org.apache.commons.net.ftp.FTP; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | | import org.apache.commons.net.ftp.FTPFile; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.SocketException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.common.config.FtpConfig.*; |
| | | |
| | |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName); |
| | | // 解析数据 |
| | | String s = OutJson.TestJson(fileName); |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | Result result = DataHandler.handler(s,uuid); |
| | | //匹配上了删除文件 |
| | | if (result.getCode()==200) { |
| | | flag = true; |
| | | Map map = JSON.parseObject(json, Map.class); |
| | | //获取结果 |
| | | Object o = map.get(uuid); |
| | | if (null!= o || !o.equals("")){ |
| | | Result result = JSON.parseObject(o.toString(), Result.class); |
| | | System.out.println("读取返回结果 result = " + result); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | // ftp.dele(fileName); |
| | | List<Result> list = new ArrayList<>(); |
| | | list.add(result); |
| | | //返回 |
| | | return result; |
| | | return new Result(200,null,list); |
| | | } |
| | | } |
| | | } |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | // if (!flag){ |
| | | // ftp.logout(); |
| | | // } |
| | | return new Result(400,null,"未读取到对应的文件",null); |
| | | } |
| | | } catch (Exception e) { |