|
@@ -19,14 +19,13 @@ import cn.com.qmth.stmms.biz.exam.model.ScoreRate;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
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.ExamSubjectService;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ScoreRateService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ScoreRateService;
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
-import cn.com.qmth.stmms.biz.mark.service.MarkLibraryService;
|
|
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreCalculateUtil;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreCalculateUtil;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreInfo;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreInfo;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
-import cn.com.qmth.stmms.common.enums.LibraryStatus;
|
|
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
|
|
|
|
public class ScoreCalculateThread implements Runnable {
|
|
public class ScoreCalculateThread implements Runnable {
|
|
@@ -41,9 +40,9 @@ public class ScoreCalculateThread implements Runnable {
|
|
|
|
|
|
private MarkService markService;
|
|
private MarkService markService;
|
|
|
|
|
|
- private ScoreRateService scoreRateService;
|
|
|
|
|
|
+ private MarkGroupService groupService;
|
|
|
|
|
|
- private MarkLibraryService libraryService;
|
|
|
|
|
|
+ private ScoreRateService scoreRateService;
|
|
|
|
|
|
private int examId;
|
|
private int examId;
|
|
|
|
|
|
@@ -59,15 +58,15 @@ public class ScoreCalculateThread implements Runnable {
|
|
|
|
|
|
public ScoreCalculateThread(int examId, LockService lockService, ExamStudentService studentService,
|
|
public ScoreCalculateThread(int examId, LockService lockService, ExamStudentService studentService,
|
|
ExamQuestionService questionService, ExamSubjectService subjectService, ScoreRateService scoreRateService,
|
|
ExamQuestionService questionService, ExamSubjectService subjectService, ScoreRateService scoreRateService,
|
|
- MarkLibraryService libraryService, MarkService markService) {
|
|
|
|
|
|
+ MarkService markService, MarkGroupService groupService) {
|
|
this.examId = examId;
|
|
this.examId = examId;
|
|
this.lockService = lockService;
|
|
this.lockService = lockService;
|
|
this.studentService = studentService;
|
|
this.studentService = studentService;
|
|
this.questionService = questionService;
|
|
this.questionService = questionService;
|
|
this.subjectService = subjectService;
|
|
this.subjectService = subjectService;
|
|
this.scoreRateService = scoreRateService;
|
|
this.scoreRateService = scoreRateService;
|
|
- this.libraryService = libraryService;
|
|
|
|
this.markService = markService;
|
|
this.markService = markService;
|
|
|
|
+ this.groupService = groupService;
|
|
this.objectiveMap = new HashMap<String, List<ExamQuestion>>();
|
|
this.objectiveMap = new HashMap<String, List<ExamQuestion>>();
|
|
this.subjectiveMap = new HashMap<String, List<ExamQuestion>>();
|
|
this.subjectiveMap = new HashMap<String, List<ExamQuestion>>();
|
|
this.scoreRateMap = new HashMap<String, Double>();
|
|
this.scoreRateMap = new HashMap<String, Double>();
|
|
@@ -90,12 +89,11 @@ public class ScoreCalculateThread implements Runnable {
|
|
pageNumber++;
|
|
pageNumber++;
|
|
list = studentService.findByExamIdAndUploadAndAbsent(examId, true, false, pageNumber, pageSize);
|
|
list = studentService.findByExamIdAndUploadAndAbsent(examId, true, false, pageNumber, pageSize);
|
|
}
|
|
}
|
|
|
|
+
|
|
// 统计各科目下每题得分率,主观题评卷完成才统计
|
|
// 统计各科目下每题得分率,主观题评卷完成才统计
|
|
- double total = libraryService.countByExamAndSubjectAndGroupAndStatus(examId, null, 0, null);
|
|
|
|
- double finish = libraryService.countByExamAndSubjectAndGroupAndStatus(examId, null, 0,
|
|
|
|
- LibraryStatus.MARKED);
|
|
|
|
- double percent = total > 0 ? (finish * 100 / total) : 0;
|
|
|
|
- if (percent >= 100) {
|
|
|
|
|
|
+ double total = groupService.sumLibraryCount(examId);
|
|
|
|
+ double finish = groupService.sumMarkedCount(examId);
|
|
|
|
+ if (total == finish) {
|
|
statistics();
|
|
statistics();
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -147,46 +145,51 @@ public class ScoreCalculateThread implements Runnable {
|
|
}
|
|
}
|
|
|
|
|
|
private void calculate(ExamStudent student) {
|
|
private void calculate(ExamStudent student) {
|
|
- ScoreCalculateUtil util = ScoreCalculateUtil.instance(student);
|
|
|
|
- ScoreInfo info = util.calculate(findQuestionList(student.getSubjectCode(), true), null);
|
|
|
|
|
|
+ try {
|
|
|
|
+ ScoreCalculateUtil util = ScoreCalculateUtil.instance(student);
|
|
|
|
+ ScoreInfo info = util.calculate(findQuestionList(student.getSubjectCode(), true), null);
|
|
|
|
|
|
- student.setObjectiveScore(info.getObjectiveScore());
|
|
|
|
- student.setScoreList(info.getScoreList(), true);
|
|
|
|
|
|
+ student.setObjectiveScore(info.getObjectiveScore());
|
|
|
|
+ student.setScoreList(info.getScoreList(), true);
|
|
|
|
|
|
- studentService.save(student);
|
|
|
|
- // 增加主观题总分统计
|
|
|
|
- markService.scoreCalculate(student.getExamId(), student.getSubjectCode(), student.getId());
|
|
|
|
|
|
+ studentService.save(student);
|
|
|
|
|
|
- try {
|
|
|
|
- if (!student.getScoreList(false).isEmpty()) {// 主观题有分数明细才统分
|
|
|
|
- statistics(student);
|
|
|
|
- }
|
|
|
|
|
|
+ // 增加主观题总分统计
|
|
|
|
+ markService.scoreCalculate(student.getExamId(), student.getSubjectCode(), student.getId());
|
|
|
|
+
|
|
|
|
+ // 主观题得分统计
|
|
|
|
+ // 需要重新从数据库读取一遍考生信息
|
|
|
|
+ statistics(studentService.findById(student.getId()));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("statistic error", e);
|
|
log.error("statistic error", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void statistics(ExamStudent student) {
|
|
private void statistics(ExamStudent student) {
|
|
- Set<String> campusNames = campusNameMap.get(student.getSubjectCode());
|
|
|
|
- if (campusNames == null || campusNames.isEmpty()) {
|
|
|
|
- campusNames = new HashSet<>();
|
|
|
|
- campusNames.add(student.getCampusName());
|
|
|
|
- } else {
|
|
|
|
- campusNames.add(student.getCampusName());
|
|
|
|
- }
|
|
|
|
- this.campusNameMap.put(student.getSubjectCode(), campusNames);
|
|
|
|
List<ScoreItem> items = student.getScoreList(false);
|
|
List<ScoreItem> items = student.getScoreList(false);
|
|
|
|
+ if (items.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
List<ExamQuestion> list = this.findQuestionList(student.getSubjectCode(), false);
|
|
List<ExamQuestion> list = this.findQuestionList(student.getSubjectCode(), false);
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- ScoreItem scoreItem = items.get(i);
|
|
|
|
- String key = getKey(student.getSubjectCode(), student.getCampusName(), list.get(i).getQuestionNumber());
|
|
|
|
- Double totalScore = scoreRateMap.get(key);
|
|
|
|
- if (totalScore == null) {
|
|
|
|
- scoreRateMap.put(key, scoreItem.getScore());
|
|
|
|
- } else {
|
|
|
|
- scoreRateMap.put(key, totalScore + scoreItem.getScore());
|
|
|
|
|
|
+ int count = list.size();
|
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
|
+ ScoreItem scoreItem = items.size() > i ? items.get(i) : null;
|
|
|
|
+ if (scoreItem != null) {
|
|
|
|
+ String key = getKey(student.getSubjectCode(), student.getCampusName(), list.get(i).getQuestionNumber());
|
|
|
|
+ Double totalScore = scoreRateMap.get(key);
|
|
|
|
+ if (totalScore == null) {
|
|
|
|
+ scoreRateMap.put(key, scoreItem.getScore());
|
|
|
|
+ } else {
|
|
|
|
+ scoreRateMap.put(key, totalScore + scoreItem.getScore());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ Set<String> campusNames = campusNameMap.get(student.getSubjectCode());
|
|
|
|
+ if (campusNames == null) {
|
|
|
|
+ campusNames = new HashSet<>();
|
|
|
|
+ campusNameMap.put(student.getSubjectCode(), campusNames);
|
|
|
|
+ }
|
|
|
|
+ campusNames.add(student.getCampusName());
|
|
}
|
|
}
|
|
|
|
|
|
private String getKey(String subjectCode, String campusName, String questionNumber) {
|
|
private String getKey(String subjectCode, String campusName, String questionNumber) {
|