| src/main/java/org/springblade/common/config/ScheduleConfig.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/crontab/Crontab.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/org/springblade/modules/system/mapper/UserMapper.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/org/springblade/common/config/ScheduleConfig.java
New file @@ -0,0 +1,25 @@ package org.springblade.common.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** * 定时任务多线程配置,解决定时任务执行一次后就不执行问题 * @author zhongrj * @since 2021-12-14 */ @Configuration @EnableScheduling public class ScheduleConfig implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(100)); } } src/main/java/org/springblade/modules/crontab/Crontab.java
@@ -1,6 +1,5 @@ package org.springblade.modules.crontab; import org.springblade.modules.training.entity.TrainingRegistration; import org.springblade.modules.training.service.TrainingRegistrationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -29,8 +28,17 @@ // @Scheduled(cron = "*/30 * * * * ?") @GetMapping("/examApplyStatus") public void examApplyStatus(){ System.out.println("执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); System.out.println("定时任务1:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //自动处理之前报了名,申请了考试又没有去考试的,做缺考标记,并将报名状态修改为已取消报名 trainingRegistrationService.examApplyStatus(); } // @Scheduled(cron = "*/30 * * * * ?") @GetMapping("/aaa") public void aa(){ System.out.println("定时任务2:执行时间:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //自动处理之前报了名,申请了考试又没有去考试的,做缺考标记,并将报名状态修改为已取消报名 // trainingRegistrationService.examApplyStatus(); } } src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -273,45 +273,44 @@ if (null!=examScore) { //查询当前保安信息 UserVO user = userService.getUserAgeById(Long.parseLong(examScore.getUserId())); //设置实操成绩 examScore.setLearnGrade(examScoreExcel.getLearnGrade()); if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) { //合格 examScore.setQualified(0); //修改制证状态为未制证 user.setUserType(7); //正式考试通过生成保安证编号 // if (examPaper.getExamType()==1) { //如果已有保安证编号,不更新用户信息 if (null==user.getSecuritynumber() || user.getSecuritynumber().equals("")) { //去生成保安证编号 String pre = SecurityPaperUtil.getSecurityPaper(); //查询当前年份已有的保安证编号 int count = userService.getSecurityPaperCount(pre); String result = null; if (count == 0) { result = pre + "00001"; } else { //格式化 DecimalFormat decimalFormat = new DecimalFormat("00000"); count++; result = pre + (decimalFormat.format(count)); } user.setSecuritynumber(result); //发证日期 // user.setPaperTime(new Date()); //修改为持证保安 user.setHold("1"); user.setUpdateTime(new Date()); //更新保安数据 userService.updateById(user); if (null!=examScore.getTheoryGrade()){ if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) { //合格 examScore.setQualified(0); //修改制证状态为未制证 user.setUserType(7); //如果已有保安证编号,不更新用户信息 if (null == user.getSecuritynumber() || user.getSecuritynumber().equals("")) { //去生成保安证编号 String pre = SecurityPaperUtil.getSecurityPaper(); //查询当前年份已有的保安证编号 int count = userService.getSecurityPaperCount(pre); String result = null; if (count == 0) { result = pre + "00001"; } else { //格式化 DecimalFormat decimalFormat = new DecimalFormat("00000"); count++; result = pre + (decimalFormat.format(count)); } user.setSecuritynumber(result); //修改为持证保安 user.setHold("1"); user.setUpdateTime(new Date()); //更新保安数据 userService.updateById(user); String s1 = "update blade_user set hold = " + "'" + user.getHold() + "'" + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" + ",user_type = " + "'" + user.getUserType() + "'" + " " + "where id = " + "'" + user.getId() + "'"; FtpUtil.sqlFileUpload(s1); String s1 = "update blade_user set hold = " + "'" + user.getHold() + "'" + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" + ",user_type = " + "'" + user.getUserType() + "'" + " " + "where id = " + "'" + user.getId() + "'"; FtpUtil.sqlFileUpload(s1); } } } else { //不合格 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -142,7 +142,12 @@ and bu.real_name like concat('%', #{user.realName},'%') </if> <if test="user.dispatch!=null and user.dispatch != ''"> and bu.dispatch = #{user.dispatch} <if test="user.dispatch == 0"> and bu.dispatch = #{user.dispatch} </if> <if test="user.dispatch == 1"> and bu.dispatch = #{user.dispatch} </if> </if> <if test="user.userType!=null and user.userType != ''"> and bu.user_type = #{user.userType}