智慧保安后台管理-外网项目备份
钟日健
2022-01-25 9ad5ed433a44fcce8db3fbd462b4c5879608fd27
定时任务修改
3 files modified
100 ■■■■ changed files
src/main/java/org/springblade/modules/crontab/Crontab.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/training/mapper/TrainingRegistrationMapper.xml 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java 94 ●●●● patch | view | raw | blame | history
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()));
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>
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);
                        }
                    }
                }
            });