| | |
| | | private static String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | private static String ftpPath = "anbao/wsql.json"; |
| | | //本地路径 |
| | | private static String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | private static String fileName = "wsql.json"; |
| | | |
| | | @Scheduled(cron = "*/30 * * * * ?") |
| | | public static boolean isFTPFileExist() { |
| | |
| | | } |
| | | |
| | | if (is != null) { |
| | | System.out.println(true); |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | // |
| | | String s = OutJson.TestJson(); |
| | | //sql语句 |
| | | String sql = OutJson.stringReplace(s); |
| | | String[] split = sql.split(";");//以逗号分割 |
| | | for (String sqls : split) { |
| | | //判断是否是新增,删除,修改 |
| | | String substring = sqls.substring(0, 2); |
| | | //新增 |
| | | if (substring.equals("in")) { |
| | | //运行sql语句 |
| | | MysqlCenlint.inster(sqls); |
| | | } |
| | | //修改 |
| | | else if (substring.equals("up")) { |
| | | MysqlCenlint.update(sqls); |
| | | } |
| | | //删除 |
| | | else { |
| | | MysqlCenlint.delete(sqls); |
| | | } |
| | | } |
| | | //删除本地文件 |
| | | MysqlCenlint.delete(); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "wsql.json"); |
| | | is.close(); |
| | | |
| | | ftp.completePendingCommand(); |
| | | |
| | | } |