|
@@ -0,0 +1,127 @@
|
|
|
+package cn.com.qmth.stmms.admin.thread;
|
|
|
+
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
|
+import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
|
+import cn.com.qmth.stmms.biz.lock.LockService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectClassService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectCollegeService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectGroupService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectQuestionService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherService;
|
|
|
+import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.LockType;
|
|
|
+import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 统计定时任务
|
|
|
+ *
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class ScoreReportJob {
|
|
|
+
|
|
|
+ protected static final Logger log = LoggerFactory.getLogger(ScoreReportJob.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamSubjectService subjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamQuestionService questionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MarkGroupService groupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FileService fileService;
|
|
|
+
|
|
|
+ @Qualifier("task-executor")
|
|
|
+ @Autowired
|
|
|
+ private AsyncTaskExecutor taskExecutor;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LockService lockService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportService reportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectQuestionService reportSubjectQuestionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectClassService reportSubjectClassService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectTeacherService reportSubjectTeacherService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectCollegeService reportSubjectCollegeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectGroupService reportSubjectGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectService reportSubjectService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时更新成绩分析报告
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "${0 0/30 8-22 * * ?}")
|
|
|
+ public void updateReport() {
|
|
|
+ log.info("start auto-update report");
|
|
|
+ try {
|
|
|
+ List<Integer> examIds = groupService.findExamIdByStatus(MarkStatus.FORMAL);
|
|
|
+ for (Integer examId : examIds) {
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ if (ExamStatus.FINISH.equals(exam.getStatus())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ updateReportByExam(examId);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("auto-update report error", e);
|
|
|
+ } finally {
|
|
|
+ log.info("finish auto-report marker");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateReportByExam(Integer examId) {
|
|
|
+ // 获取主观题总分大于0的科目
|
|
|
+ List<ExamSubject> subjects = subjectService.list(examId, 0);
|
|
|
+ Set<String> subjectSet = new HashSet<String>();
|
|
|
+ for (ExamSubject subject : subjects) {
|
|
|
+ if (!lockService.isLocked(LockType.SCORE_CALCULATE, subject.getExamId(), subject.getCode())) {
|
|
|
+ subjectSet.add(subject.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ScoreReportThread thread = new ScoreReportThread(examId, subjectSet, lockService, studentService,
|
|
|
+ questionService, reportService, examService, subjectService, fileService, true,
|
|
|
+ reportSubjectQuestionService, reportSubjectClassService, reportSubjectTeacherService,
|
|
|
+ reportSubjectCollegeService, reportSubjectGroupService, reportSubjectService);
|
|
|
+ taskExecutor.submit(thread);
|
|
|
+ }
|
|
|
+}
|