From 9ad5ed433a44fcce8db3fbd462b4c5879608fd27 Mon Sep 17 00:00:00 2001
From: 钟日健 <5689795+arsn@user.noreply.gitee.com>
Date: Tue, 25 Jan 2022 11:12:55 +0800
Subject: [PATCH] 定时任务修改

---
 src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java |   94 ++++++++++++++++++++++++-----------------------
 src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml             |    2 +
 src/main/java/org/springblade/modules/crontab/Crontab.java                                       |    4 +-
 3 files changed, 52 insertions(+), 48 deletions(-)

diff --git a/src/main/java/org/springblade/modules/crontab/Crontab.java b/src/main/java/org/springblade/modules/crontab/Crontab.java
index 77e53db..41e4819 100644
--- a/src/main/java/org/springblade/modules/crontab/Crontab.java
+++ b/src/main/java/org/springblade/modules/crontab/Crontab.java
@@ -24,8 +24,8 @@
 	 * 定时任务,每天凌晨1点执行一次,
 	 * 自动处理之前报了名,申请了考试又没有去考试的,做缺考标记,并将报名状态修改为已取消报名
 	 */
-	@Scheduled(cron = "0 0 23 * * ?")
-//	@Scheduled(cron = "*/30 * * * * ?")
+//	@Scheduled(cron = "0 0 23 * * ?")
+	@Scheduled(cron = "*/10 * * * * ?")
 	@GetMapping("/examApplyStatus")
 	public void examApplyStatus(){
 		System.out.println("定时任务1:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
diff --git a/src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml b/src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml
index f415f7b..f147539 100644
--- a/src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml
+++ b/src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml
@@ -267,6 +267,8 @@
         ke.id = sr.train_exam_id
         WHERE
         1=1
+        and bu.is_deleted = 0
+        and bu.status = 1
         <if test="trainingRegistration.isExam!=null">
             and is_exam = #{trainingRegistration.isExam}
         </if>
diff --git a/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java b/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
index ef535ec..0cad646 100644
--- a/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
+++ b/src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
@@ -357,54 +357,56 @@
 						this.updateById(trainingRegistration1);
 						//修改保安报名状态
 						User user = userService.getById(trainingRegistration1.getUserId());
-						//考试结束
-						user.setIsTrain(3);
-						userService.updateById(user);
-						//生成缺考记录
-						AbsentRecords absentRecords = new AbsentRecords();
-						absentRecords.setUserId(user.getId());
-						absentRecords.setApplyId(trainingRegistration1.getId());
-						absentRecords.setExamId(Long.parseLong(trainingRegistration1.getTrainExamId()));
-						absentRecords.setCandidateNo(trainingRegistration1.getCandidateNo());
-						absentRecords.setCreateTime(new Date());
-						//新增
-						absentRecordsService.save(absentRecords);
+						if (null != user) {
+							//考试结束
+							user.setIsTrain(3);
+							userService.updateById(user);
+							//生成缺考记录
+							AbsentRecords absentRecords = new AbsentRecords();
+							absentRecords.setUserId(user.getId());
+							absentRecords.setApplyId(trainingRegistration1.getId());
+							absentRecords.setExamId(Long.parseLong(trainingRegistration1.getTrainExamId()));
+							absentRecords.setCandidateNo(trainingRegistration1.getCandidateNo());
+							absentRecords.setCreateTime(new Date());
+							//新增
+							absentRecordsService.save(absentRecords);
 
-						//新增成绩,成绩为0
-						ExamScore examScore = new ExamScore();
-						examScore.setCandidateNo(trainingRegistration1.getCandidateNo());
-						examScore.setTheoryGrade(0);
-						examScore.setAllGrade(0);
-						examScore.setQualified(3);
-						examScore.setUserId(user.getId().toString());
-						examScore.setApplyId(trainingRegistration1.getId());
-						examScore.setExamId(trainingRegistration1.getTrainExamId());
-						//新增
-						examScoreService.save(examScore);
+							//新增成绩,成绩为0
+							ExamScore examScore = new ExamScore();
+							examScore.setCandidateNo(trainingRegistration1.getCandidateNo());
+							examScore.setTheoryGrade(0);
+							examScore.setAllGrade(0);
+							examScore.setQualified(3);
+							examScore.setUserId(user.getId().toString());
+							examScore.setApplyId(trainingRegistration1.getId());
+							examScore.setExamId(trainingRegistration1.getTrainExamId());
+							//新增
+							examScoreService.save(examScore);
 
-						//内网同步
-						String s =
-							"update sys_training_registration set cancel = " + trainingRegistration1.getCancel() +
-								",is_exam = " + "'" + trainingRegistration1.getIsExam() + "'" +
-								" " + "where id = " + "'" + trainingRegistration1.getId() + "';" +
-							"update blade_user set is_train = " + user.getIsTrain() + " " + "where id = " + "'" + user.getId() + "';" +
-							"insert into sys_absent_records(id,user_id,create_time,exam_id,apply_id,candidate_no) " +
-								"values(" + "'" + absentRecords.getId() + "'" + ","
-								+ "'" + absentRecords.getUserId() + "'" + ","
-								+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(absentRecords.getCreateTime()) + "'" + ","
-								+ "'" + absentRecords.getExamId() + "'" + ","
-								+ "'" + absentRecords.getApplyId() + "'" + ","
-								+ "'" + absentRecords.getCandidateNo() + "'" + ");" +
-							"insert into exam_score(id,candidate_no,theory_grade,all_grade,qualified,user_id,apply_id,exam_id) " +
-								"values(" + "'" + examScore.getId() + "'" + ","
-								+ "'" + examScore.getCandidateNo() + "'" + ","
-								+ "'" + examScore.getTheoryGrade() + "'" + ","
-								+ "'" + examScore.getAllGrade() + "'" + ","
-								+ "'" + examScore.getQualified() + "'" + ","
-								+ "'" + examScore.getUserId() + "'" + ","
-								+ "'" + examScore.getApplyId() + "'" + ","
-								+ "'" + examScore.getExamId() + "'" + ")";
-						FtpUtil.sqlFileUpload(s);
+							//内网同步
+							String s =
+								"update sys_training_registration set cancel = " + trainingRegistration1.getCancel() +
+									",is_exam = " + "'" + trainingRegistration1.getIsExam() + "'" +
+									" " + "where id = " + "'" + trainingRegistration1.getId() + "';" +
+								"update blade_user set is_train = " + user.getIsTrain() + " " + "where id = " + "'" + user.getId() + "';" +
+								"insert into sys_absent_records(id,user_id,create_time,exam_id,apply_id,candidate_no) " +
+									"values(" + "'" + absentRecords.getId() + "'" + ","
+									+ "'" + absentRecords.getUserId() + "'" + ","
+									+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(absentRecords.getCreateTime()) + "'" + ","
+									+ "'" + absentRecords.getExamId() + "'" + ","
+									+ "'" + absentRecords.getApplyId() + "'" + ","
+									+ "'" + absentRecords.getCandidateNo() + "'" + ");" +
+								"insert into exam_score(id,candidate_no,theory_grade,all_grade,qualified,user_id,apply_id,exam_id) " +
+									"values(" + "'" + examScore.getId() + "'" + ","
+									+ "'" + examScore.getCandidateNo() + "'" + ","
+									+ "'" + examScore.getTheoryGrade() + "'" + ","
+									+ "'" + examScore.getAllGrade() + "'" + ","
+									+ "'" + examScore.getQualified() + "'" + ","
+									+ "'" + examScore.getUserId() + "'" + ","
+									+ "'" + examScore.getApplyId() + "'" + ","
+									+ "'" + examScore.getExamId() + "'" + ")";
+							FtpUtil.sqlFileUpload(s);
+						}
 					}
 				}
 			});

--
Gitblit v1.9.3