| | |
| | | } else { |
| | | for (FTPFile file : files) { |
| | | fileName = file.getName(); |
| | | InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING)); |
| | | if (null == is) { |
| | | ftp.disconnect(); |
| | | } else { |
| | | String substring1 = fileName.substring(0, 1); |
| | | String substring1 = fileName.substring(0, 1); |
| | | if (substring1.equals("w")) { |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | if (substring1.equals("w")) { |
| | | String s = OutJson.TestJson(fileName); |
| | | //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); |
| | | } |
| | | String s = OutJson.TestJson(fileName); |
| | | //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); |
| | | } |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("o")){ |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handler(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("l")){ |
| | | //用户集合数据,批量导入用户 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerList(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("t")){ |
| | | //培训报名数据 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerListTrain(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("s")){ |
| | | //获取保安员证编号数据 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerSecurityNumerBit(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("u")){ |
| | | //保安员审查 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerUserExamine(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | //修改 |
| | | else if (substring.equals("up")) { |
| | | MysqlCenlint.update(sqls); |
| | | } |
| | | //删除 |
| | | else { |
| | | MysqlCenlint.delete(sqls); |
| | | } |
| | | } |
| | | else if(substring1.equals("f")){ |
| | | //把文件下载到本地(图片文件类),测试内外网使用同一台服务器 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, minioPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | // ftp.dele(fileName); |
| | | } |
| | | // else { |
| | | // //把文件下载到本地(图片文件类),ftp 内外网服务器分开时使用 |
| | | // FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, minioPath, fileName); |
| | | // FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | // } |
| | | //删除本地文件,ftp 文件没有对应读取的不删除 |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | is.close(); |
| | | ftp.completePendingCommand(); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("o")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handler(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("l")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //用户集合数据,批量导入用户 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerList(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("t")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //培训报名数据 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerListTrain(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("s")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //获取保安员证编号数据 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerSecurityNumerBit(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | // ftp.dele(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("u")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //保安员审查 |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //数据处理 |
| | | DataHanlder.handlerUserExamine(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | //考试实操成绩导入 |
| | | if(substring1.equals("e")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | //获取对象字符串 |
| | | String json = OutJson.TestJson(fileName); |
| | | //考试实操成绩数据处理 |
| | | DataHanlder.handlerUserExamScore(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | if(substring1.equals("f")){ |
| | | //把文件下载到本地(图片文件类),测试内外网使用同一台服务器 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, minioPath, fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | //删除本地文件,ftp 文件没有对应读取的不删除 |
| | | MysqlCenlint.deletess(fileName); |
| | | // ftp.completePendingCommand(); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | // FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | ftp.logout(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //如果ftp 没有关闭,则关闭ftp |
| | | if (ftp.isConnected()) { |
| | | try { |