| | |
| | | import org.apache.commons.net.ftp.FTPReply; |
| | | import org.springblade.common.utils.DesensitizedUtil; |
| | | import org.springblade.modules.FTP.*; |
| | | import org.springblade.modules.exam.entity.ExamAnswerRecord; |
| | | import org.springblade.modules.exam.entity.ExamScore; |
| | | import org.springblade.modules.exam.service.ExamAnswerRecordService; |
| | | import org.springblade.modules.exam.service.ExamScoreService; |
| | | import org.springblade.modules.log.entity.HandlerLog; |
| | | import org.springblade.modules.log.service.HandlerLogService; |
| | | import org.springblade.modules.system.entity.User; |
| | |
| | | @Autowired |
| | | private MyAsyncService myAsyncService; |
| | | |
| | | |
| | | @Autowired |
| | | private ExamAnswerRecordService examAnswerRecordService; |
| | | |
| | | @Autowired |
| | | private ExamScoreService examScoreService; |
| | | |
| | | public void testTask(){ |
| | | System.out.println("测试定时任务执行-----------------"); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | ftp.enterLocalActiveMode(); |
| | | //主动模式 |
| | | // ftp.enterLocalActiveMode(); |
| | | |
| | | // 设置文件类型为二进制,与ASCII有区别 |
| | | ftp.setFileType(FTP.BINARY_FILE_TYPE); |
| | |
| | | // 检验文件是否存在 |
| | | ftp.changeWorkingDirectory(ftpPath); |
| | | |
| | | // Use passive mode as default |
| | | // Use passive mode as default 被动模式 |
| | | ftp.enterLocalPassiveMode(); |
| | | |
| | | FTPFile[] files = ftp.listFiles(); |
| | | if (files.length==0){ |
| | | ftp.logout(); |
| | | return false; |
| | | } |
| | | else { |
| | |
| | | } |
| | | } |
| | | //关闭流 |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | // ftp.completePendingCommand(); |
| | | // ftp.logout(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | ftp.logout(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (ftp.isConnected()) { |
| | | try { |
| | | ftp.disconnect(); |
| | |
| | | return false; |
| | | } |
| | | |
| | | ftp.enterLocalActiveMode(); |
| | | // ftp.enterLocalActiveMode(); |
| | | |
| | | // 设置文件类型为二进制,与ASCII有区别 |
| | | ftp.setFileType(FTP.BINARY_FILE_TYPE); |
| | |
| | | //文件个数大于10个时开始处理 |
| | | // if (files.length==0 || files.length<10){ |
| | | if (files.length==0){ |
| | | ftp.logout(); |
| | | // ftp.logout(); |
| | | return false; |
| | | } |
| | | else { |
| | |
| | | } |
| | | } |
| | | //关闭流 |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | // ftp.completePendingCommand(); |
| | | // ftp.logout(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | ftp.logout(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (ftp.isConnected()) { |
| | | try { |
| | | ftp.disconnect(); |
| | |
| | | return false; |
| | | } |
| | | |
| | | ftp.enterLocalActiveMode(); |
| | | // ftp.enterLocalActiveMode(); |
| | | |
| | | // 设置文件类型为二进制,与ASCII有区别 |
| | | ftp.setFileType(FTP.BINARY_FILE_TYPE); |
| | |
| | | FTPFile[] files = ftp.listFiles(); |
| | | //文件个数大于10个时开始处理 |
| | | if (files.length==0){ |
| | | ftp.logout(); |
| | | |
| | | return false; |
| | | } |
| | | else { |
| | |
| | | } |
| | | } |
| | | //关闭流 |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | // ftp.completePendingCommand(); |
| | | // ftp.logout(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | ftp.logout(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (ftp.isConnected()) { |
| | | try { |
| | | ftp.disconnect(); |
| | |
| | | * 用户集合信息处理 |
| | | * @param result |
| | | */ |
| | | private void userListInfoHandler(Result result) { |
| | | @Async |
| | | public void userListInfoHandler(Result result) { |
| | | //获取 result |
| | | List<Result> data1 = result.getData(); |
| | | System.out.println("批量导入数据 = " + data1); |
| | |
| | | } |
| | | if (result1.getCode()==203){ |
| | | //保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请! 内网用户已存在情况 |
| | | user.setId(result.getUserId()); |
| | | user.setHold("2"); |
| | | user.setSecuritynumber(""); |
| | | user.setId(result1.getUserId()); |
| | | //先查询当前库是否有改用户? |
| | | User user2 = userService.getById(result.getUserId()); |
| | | User user2 = userService.getById(result1.getUserId()); |
| | | //判断 |
| | | if (null != user2) { |
| | | //修改 |
| | |
| | | return false; |
| | | } |
| | | |
| | | ftp.enterLocalActiveMode(); |
| | | // ftp.enterLocalActiveMode(); |
| | | |
| | | // 设置文件类型为二进制,与ASCII有区别 |
| | | ftp.setFileType(FTP.BINARY_FILE_TYPE); |
| | |
| | | ftp.setControlEncoding("GBK"); |
| | | |
| | | // 检验文件是否存在 |
| | | ftp.changeWorkingDirectory(ftpPath); |
| | | // ftp.changeWorkingDirectory(ftpPath); |
| | | |
| | | // Use passive mode as default |
| | | ftp.enterLocalPassiveMode(); |
| | |
| | | FTPFile[] files = ftp.listFiles(); |
| | | //文件个数大于10个时开始处理 |
| | | if (files.length==0){ |
| | | ftp.logout(); |
| | | // ftp.logout(); |
| | | return false; |
| | | } |
| | | else { |
| | |
| | | } |
| | | } |
| | | //关闭流 |
| | | ftp.completePendingCommand(); |
| | | ftp.logout(); |
| | | // ftp.completePendingCommand(); |
| | | // ftp.logout(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | ftp.logout(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (ftp.isConnected()) { |
| | | try { |
| | | ftp.disconnect(); |
| | |
| | | * 报名信息处理 |
| | | * @param result |
| | | */ |
| | | private void applyHandler(String uuid,Result result) { |
| | | @Async |
| | | public void applyHandler(String uuid,Result result) { |
| | | //取出培训学校id |
| | | //从redis 中获取用户数据 |
| | | String s = redisTemplate.opsForValue().get(uuid).toString(); |
| | | //删除 |
| | | redisTemplate.delete(uuid); |
| | | if (null!=s && !s.equals("")) { |
| | | //创建集合,存年龄符合要求 |
| | | List<String> ageList = new ArrayList<>(); |
| | |
| | | } |
| | | } else if (result.getCode() == 203) { |
| | | //保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请! 用户为新增 |
| | | users.setHold("2"); |
| | | users.setSecuritynumber(""); |
| | | //新增 |
| | | users.setId(result.getUserId()); |
| | | //插入数据库 |
| | |
| | | handlerLogService.save(handlerLog); |
| | | } else if (result.getCode() == 204) { |
| | | //保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请! 内网用户已存在情况 |
| | | users.setHold("2"); |
| | | users.setSecuritynumber(""); |
| | | users.setId(result.getUserId()); |
| | | //先查询当前库是否有改用户? |
| | | User user2 = userService.getById(result.getUserId()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 考试成绩同步 |
| | | * @return |
| | | */ |
| | | public void examScoreSync() { |
| | | System.out.println("考试成绩同步"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | //查询当天的考试成绩 |
| | | List<ExamScore> examScoreList = examScoreService.getExamScoreList(); |
| | | if (examScoreList.size()>0) { |
| | | //遍历计算成绩 |
| | | for (ExamScore examScore : examScoreList) { |
| | | ExamAnswerRecord record = new ExamAnswerRecord(); |
| | | record.setScoreId(examScore.getId()); |
| | | List<ExamAnswerRecord> list = examAnswerRecordService.list(new QueryWrapper<>(record)); |
| | | if (list.size()>0){ |
| | | int num = 0; |
| | | for (ExamAnswerRecord examAnswerRecord : list) { |
| | | num = num + examAnswerRecord.getAnswerScore(); |
| | | examScore.setExamEndTime(examAnswerRecord.getAnswerTime()); |
| | | } |
| | | examScore.setTheoryGrade(num); |
| | | examScore.setAllGrade(Math.round(num/2)); |
| | | //设置状态 |
| | | if (num >= 60) { |
| | | examScore.setQualified(2); |
| | | } else { |
| | | examScore.setQualified(1); |
| | | } |
| | | String s1 = |
| | | "update exam_score set exam_id = " + examScore.getExamId() + |
| | | ",theory_grade = " + "'" + examScore.getTheoryGrade() + "'" + |
| | | ",all_grade = " + "'" + examScore.getAllGrade() + "'" + |
| | | ",exam_end_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(examScore.getExamEndTime()) + "'" + |
| | | ",qualified = " + "'" + examScore.getQualified() + "'" + |
| | | " " + "where id = " + "'" + examScore.getId() + "'"; |
| | | myAsyncService.FTP(s1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |