| | |
| | | public interface FtpConstant { |
| | | |
| | | /** |
| | | * sql connect |
| | | */ |
| | | // String sql_connect_dev = "jdbc:mysql://223.82.109.183:2083/zhbaw"; |
| | | |
| | | /** |
| | | * sql connect |
| | | */ |
| | | String sql_connect_dev = "jdbc:mysql://localhost:2083/zhbaw"; |
| | | |
| | | /** |
| | | * ftp服务器IP地址 |
| | | */ |
| | | String ftpHost = "192.168.0.105"; |
| | | // String ftpHost_dev = "192.168.0.105"; |
| | | |
| | | /** |
| | | * ftp服务器IP地址 |
| | | */ |
| | | String ftpHost_dev = "172.19.1.30"; |
| | | |
| | | /** |
| | | * ftp服务器端口 |
| | |
| | | */ |
| | | String ftpPassword = "Yly@123"; |
| | | |
| | | |
| | | /** |
| | | * ftp服务器路径 |
| | | */ |
| | | String ftpPath = "yly/anbao/"; |
| | | |
| | | /** |
| | | * 本地路径 |
| | | */ |
| | | String localPath = "D:\\anbao"; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | String fileName = "wsql.json"; |
| | | String localPath = "/home/zhongsong/anbao"; |
| | | // String localPath = "D:\\anbao"; |
| | | } |
| | |
| | | public static void sqlFileUpload(String s1){ |
| | | String json1 = JSON.toJSONString(s1); |
| | | String response1 = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json1, "d:/", "w"+response1); |
| | | OutJson.createJsonFile(json1, localPath, "w"+response1); |
| | | FileInputStream in1 = null; |
| | | try { |
| | | in1 = new FileInputStream(new File("D:\\" + "w"+response1+".json")); |
| | | in1 = new FileInputStream(new File(localPath + "w"+response1+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response1+".json", in1); |
| | | FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", "w"+response1+".json", in1); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.SQLException; |
| | | |
| | | import static org.springblade.common.constant.FtpConstant.localPath; |
| | | import static org.springblade.common.constant.FtpConstant.sql_connect_dev; |
| | | |
| | | public class MysqlCenlint { |
| | | |
| | | /** |
| | |
| | | int ColumnCount; |
| | | //int RowCount; |
| | | String driver = "com.mysql.jdbc.Driver"; |
| | | String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息 |
| | | String url = sql_connect_dev; //换成要连接的数据库信息 |
| | | String user = "root"; |
| | | String password = "zhba0728"; |
| | | Class.forName ( driver ); |
| | |
| | | int ColumnCount; |
| | | //int RowCount; |
| | | String driver = "com.mysql.jdbc.Driver"; |
| | | String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息 |
| | | String url = sql_connect_dev; //换成要连接的数据库信息 |
| | | String user = "root"; |
| | | String password = "zhba0728"; |
| | | Class.forName ( driver ); |
| | |
| | | int ColumnCount; |
| | | //int RowCount; |
| | | String driver = "com.mysql.jdbc.Driver"; |
| | | String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息 |
| | | String url = sql_connect_dev; //换成要连接的数据库信息 |
| | | String user = "root"; |
| | | String password = "zhba0728"; |
| | | Class.forName ( driver ); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除本地文件 |
| | | */ |
| | | public static void deletes(String fileName){ |
| | | File file = new File("D:\\"+fileName); |
| | | if (file.isFile() && file.exists()) { |
| | | file.delete(); |
| | | } |
| | | } |
| | | // /** |
| | | // * 删除本地文件 |
| | | // */ |
| | | // public static void deletes(String fileName){ |
| | | // File file = new File("D:\\"+fileName); |
| | | // if (file.isFile() && file.exists()) { |
| | | // file.delete(); |
| | | // } |
| | | // } |
| | | public static void deletess(String fileName){ |
| | | File file = new File("D:\\anbao\\"+fileName); |
| | | File file = new File(localPath+fileName); |
| | | if (file.isFile() && file.exists()) { |
| | | file.delete(); |
| | | } |
| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | import static org.springblade.common.constant.FtpConstant.*; |
| | | |
| | | @Component |
| | | public class monitor { |
| | | //ftp服务器IP地址 |
| | | private static String ftpHost = "192.168.0.105"; |
| | | //ftp服务器端口 |
| | | private static int ftpPort = 21; |
| | | //ftp服务器用户名 |
| | | private static String ftpUserName = "yly"; |
| | | //ftp服务器密码 |
| | | private static String ftpPassword = "Yly@123"; |
| | | //ftp服务器路径 |
| | | private static String ftpPath = "anbao/"; |
| | | //本地路径 |
| | | private static String localPath = "D:\\anbao"; |
| | | //文件名 |
| | | //private static String fileName = "nsql.json"; |
| | | |
| | | |
| | | @Scheduled(cron = "*/30 * * * * ?") |
| | | // @Scheduled(cron = "*/30 * * * * ?") |
| | | public static boolean isFTPFileExist() { |
| | | |
| | | FTPClient ftp = new FTPClient(); |
| | |
| | | |
| | | // 连接ftp服务器 |
| | | |
| | | ftp.connect(ftpHost, ftpPort); |
| | | ftp.connect(ftpHost_dev, ftpPort); |
| | | |
| | | // 登陆 |
| | | |
| | |
| | | String substring1 = fileName.substring(0, 1); |
| | | if (substring1.equals("n")){ |
| | | //把文件下载到本地 |
| | | FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | FtpUtil.downloadFtpFile(ftpHost_dev, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName); |
| | | // |
| | | String s = OutJson.TestJson(fileName); |
| | | //sql语句 |
| | |
| | | } |
| | | } |
| | | //删除本地文件 |
| | | MysqlCenlint.deletes(fileName); |
| | | //MysqlCenlint.deletes(fileName); |
| | | MysqlCenlint.deletess(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | FtpUtil.deleteFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | is.close(); |
| | | ftp.completePendingCommand(); |
| | | } |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.FTP.OutJson; |
| | | import org.springblade.modules.FTP.monitor; |
| | | import org.springblade.modules.apply.entity.Apply; |
| | | import org.springblade.modules.apply.excel.ApplyExcel; |
| | | import org.springblade.modules.apply.excel.ApplyImporter; |
| | |
| | | "values(" + "'" + id + "'" + "," + "'" + apply.getUserId() + "'" + "," + "'" + formatStr + |
| | | "'" + "," + "'" + apply.getApplyStatus() + "'" + "," +"'" + apply.getIsExam() + "'" + ");" + |
| | | "update blade_user set is_apply = " + user1.getIsApply() + " " +"where id = " + "'" + user1.getId() + "'"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | } |
| | | |
| | | |
| | |
| | | String s = |
| | | "update sys_apply set apply_status = " + apply.getApplyStatus() + " " +"where id = " + "'" + apply.getId() + "';" + |
| | | "update blade_user set is_apply = " + user.getIsApply() + " " +"where id = " + "'" + user.getId() + "'"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | } |
| | | |
| | | |
| | |
| | | String s = "insert into ksxt_exam(id,exam_name,exam_type,start_time) " + |
| | | "values(" + "'" + sid + "'" + "," + "'" + examPaper.getExamName() + "'" + "," + "'" + examPaper.getExamType() + |
| | | "'" + "," +"'" + format + "'" + ")"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | |
| | | //修改报名信息 |
| | | list.forEach(id ->{ |
| | |
| | | String s1 = |
| | | "update sys_apply set exam_id = " + apply.getExamId() + "candidate_no = " + "'" + apply.getCandidateNo() + "'" + |
| | | " " +"where id = " + "'" + apply.getId() + "'"; |
| | | String json1 = JSON.toJSONString(s1); |
| | | String response1 = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json1, "d:/", "w"+response1); |
| | | FileInputStream in1 = null; |
| | | try { |
| | | in1 = new FileInputStream(new File("D:\\" + "w"+response1+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response1+".json", in1); |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | |
| | |
| | | String s = "insert into ksxt_exam(id,exam_name,exam_type,start_time) " + |
| | | "values(" + "'" + sid + "'" + "," + "'" + examPaper.getExamName() + "'" + "," + "'" + examPaper.getExamType() + |
| | | "'" + "," +"'" + format + "'" + ")"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | |
| | | |
| | | //修改报名信息 |
| | |
| | | String s1 = |
| | | "update sys_apply set exam_id = " + apply.getExamId() + ",candidate_no = " + "'" + apply.getCandidateNo() + "'" + |
| | | " " +"where id = " + "'" + apply.getId() + "'"; |
| | | String json1 = JSON.toJSONString(s1); |
| | | String response1 = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json1, "d:/", "w"+response1); |
| | | FileInputStream in1 = null; |
| | | try { |
| | | in1 = new FileInputStream(new File("D:\\" + "w"+response1+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response1+".json", in1); |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | } |
| | |
| | | //内网同步 |
| | | Long sid = examScore.getId(); |
| | | String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(examScore.getExamTime()); |
| | | String s = "insert into ksxt_exam(id,exam_time,user_id,exam_id,apply_id) " + |
| | | String s = "insert into exam_score(id,exam_time,user_id,exam_id,apply_id) " + |
| | | "values(" + "'" + sid + "'" + "," + "'" + |
| | | format + "'" + "," + "'" + |
| | | examScore.getUserId() +"'" + "," +"'" + |
| | | examScore.getExamId() +"'" + "," +"'" + |
| | | examScore.getApplyId() + "'" + ")"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | FtpUtil.sqlFileUpload(s); |
| | | return examScore; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * test |
| | | * @return |
| | | */ |
| | | @GetMapping("/test") |
| | | public Object test(){ |
| | | String s1 = "insert into exam_score(id,exam_id,apply_id) values(223,88,315)"; |
| | | String s2 = "111222333"; |
| | | String s3 = "select * from ksxt_exam"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | FtpUtil.sqlFileUpload(s2); |
| | | String json1 = JSON.toJSONString(s3); |
| | | String response1 = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json1, localPath, "f"+response1); |
| | | FileInputStream in1 = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | in1 = new FileInputStream(new File(localPath + "f"+response1+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | return examScore; |
| | | FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", "f"+response1+".json", in1); |
| | | return "成功"; |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.*; |
| | | |
| | | import static org.springblade.common.constant.FtpConstant.*; |
| | | import static org.springblade.common.constant.FtpConstant.fileName; |
| | | |
| | | /** |
| | | * 考试报名服务实现类 |
| | |
| | | "values(" + "'" + id + "'" + "," + "'" + apply1.getUserId() + "'" + "," + "'" + formatStr + |
| | | "'" + "," + "'" + apply1.getApplyStatus() + "'" + "," +"'" + apply1.getIsExam() + "'" + ");" + |
| | | "update blade_user set is_apply = " + "'" + user1.getIsApply() + "'" +"where id = " + "'" + user1.getId() + "'"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | }else { |
| | | if (user1.getIsApply()!=1) { |
| | | Apply apply1 = new Apply(); |
| | |
| | | "values(" + "'" + id + "'" + "," + "'" + apply1.getUserId() + "'" + "," + "'" + formatStr + |
| | | "'" + "," + "'" + apply1.getApplyStatus() + "'" + "," +"'" + apply1.getIsExam() + "'" + ");" + |
| | | "update blade_user set is_apply = " + "'" + user1.getIsApply() + "'" +"where id = " + "'" + user1.getId() + "'"; |
| | | String json = JSON.toJSONString(s); |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = null; |
| | | try { |
| | | in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | } |
| | | } |
| | | } |
| | |
| | | "'" + information.getContacts() + "'" + "," + "'" + information.getContactscell() + "'" + ");" + |
| | | "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category) values(" + "'" + information.getDepartmentid() + "'" + "," + "'" + dept.getParentId() + "'" + "," |
| | | + "'" + dept.getTenantId() + "'" + "," + "'" + information.getEnterprisename() + "'" + "," + "'" + dept.getAncestors() + "'" + "," + "'" + dept.getDeptCategory() + "'" + ")"; |
| | | Object o = s; |
| | | String json = JSON.toJSONString(o); |
| | | //转换提日期输出格式 |
| | | String response = String.valueOf((new Date()).getTime()); |
| | | OutJson.createJsonFile(json, "d:/", "w"+response); |
| | | FileInputStream in = new FileInputStream(new File("D:\\" + "w"+response+".json")); |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "/", "w"+response+".json", in); |
| | | FtpUtil.sqlFileUpload(s); |
| | | return R.success("成功"); |
| | | } |
| | | |