|
@@ -39,25 +39,26 @@ public class ScoreCalculateThread implements Runnable {
|
|
private ExamService examService;
|
|
private ExamService examService;
|
|
|
|
|
|
private ExamQuestionService questionService;
|
|
private ExamQuestionService questionService;
|
|
-
|
|
|
|
|
|
+
|
|
private ExamSubjectService subjectService;
|
|
private ExamSubjectService subjectService;
|
|
-
|
|
|
|
|
|
+
|
|
private ScoreRateService scoreRateService;
|
|
private ScoreRateService scoreRateService;
|
|
-
|
|
|
|
|
|
+
|
|
private MarkLibraryService libraryService;
|
|
private MarkLibraryService libraryService;
|
|
-
|
|
|
|
|
|
+
|
|
private Exam exam;
|
|
private Exam exam;
|
|
|
|
|
|
private Map<String, List<ExamQuestion>> objectiveMap;
|
|
private Map<String, List<ExamQuestion>> objectiveMap;
|
|
-
|
|
|
|
|
|
+
|
|
private Map<String, List<ExamQuestion>> subjectiveMap;
|
|
private Map<String, List<ExamQuestion>> subjectiveMap;
|
|
-
|
|
|
|
- private Map<String,Set<String>> campusNameMap;
|
|
|
|
-
|
|
|
|
- private Map<String,Double> scoreRateMap;
|
|
|
|
|
|
+
|
|
|
|
+ private Map<String, Set<String>> campusNameMap;
|
|
|
|
+
|
|
|
|
+ private Map<String, Double> scoreRateMap;
|
|
|
|
|
|
public ScoreCalculateThread(Exam exam, ExamService examService, ExamStudentService studentService,
|
|
public ScoreCalculateThread(Exam exam, ExamService examService, ExamStudentService studentService,
|
|
- ExamQuestionService questionService,ExamSubjectService subjectService,ScoreRateService scoreRateService,MarkLibraryService libraryService) {
|
|
|
|
|
|
+ ExamQuestionService questionService, ExamSubjectService subjectService, ScoreRateService scoreRateService,
|
|
|
|
+ MarkLibraryService libraryService) {
|
|
this.exam = exam;
|
|
this.exam = exam;
|
|
this.examService = examService;
|
|
this.examService = examService;
|
|
this.studentService = studentService;
|
|
this.studentService = studentService;
|
|
@@ -77,24 +78,22 @@ public class ScoreCalculateThread implements Runnable {
|
|
try {
|
|
try {
|
|
int pageNumber = 1;
|
|
int pageNumber = 1;
|
|
int pageSize = 1000;
|
|
int pageSize = 1000;
|
|
- List<ExamStudent> list = studentService.findByExamIdAndUploadAndAbsent(exam.getId(), true, false,
|
|
|
|
- pageNumber, pageSize);
|
|
|
|
|
|
+ List<ExamStudent> list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
|
|
while (list != null && list.size() > 0) {
|
|
while (list != null && list.size() > 0) {
|
|
for (ExamStudent student : list) {
|
|
for (ExamStudent student : list) {
|
|
calculate(student);
|
|
calculate(student);
|
|
}
|
|
}
|
|
-
|
|
|
|
pageNumber++;
|
|
pageNumber++;
|
|
- list = studentService.findByExamIdAndUploadAndAbsent(exam.getId(), true, false, pageNumber, pageSize);
|
|
|
|
|
|
+ list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
|
|
}
|
|
}
|
|
- //统计各科目下每题得分率,主观题评卷完成才统计
|
|
|
|
|
|
+ // 统计各科目下每题得分率,主观题评卷完成才统计
|
|
long total = subjectService.sumLibraryCount(exam.getId(), 0, 0);
|
|
long total = subjectService.sumLibraryCount(exam.getId(), 0, 0);
|
|
long finish = libraryService.countByExamAndStatus(exam.getId(), LibraryStatus.MARKED);
|
|
long finish = libraryService.countByExamAndStatus(exam.getId(), LibraryStatus.MARKED);
|
|
- int percent = total > 0 ? (int) (finish * 100.00 / total) : 0;
|
|
|
|
- if(percent>=100){
|
|
|
|
- statistics();
|
|
|
|
|
|
+ // int percent = total > 0 ? (int) (finish * 100.00 / total) : 0;
|
|
|
|
+ if (finish >= total) {
|
|
|
|
+ statistics();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("calculate exception for examId=" + exam.getId(), e);
|
|
log.error("calculate exception for examId=" + exam.getId(), e);
|
|
} finally {
|
|
} finally {
|
|
@@ -105,16 +104,18 @@ public class ScoreCalculateThread implements Runnable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void statistics() {
|
|
|
|
- List<ExamSubject> examSubjects = subjectService.list(exam.getId());
|
|
|
|
- for (ExamSubject examSubject : examSubjects) {
|
|
|
|
- Set<String> campusNameList = campusNameMap.get(examSubject.getCode());
|
|
|
|
- if(campusNameList != null){
|
|
|
|
|
|
+ private void statistics() {
|
|
|
|
+ List<ExamSubject> examSubjects = subjectService.list(exam.getId());
|
|
|
|
+ for (ExamSubject examSubject : examSubjects) {
|
|
|
|
+ Set<String> campusNameList = campusNameMap.get(examSubject.getCode());
|
|
|
|
+ if (campusNameList != null) {
|
|
for (String campusName : campusNameList) {
|
|
for (String campusName : campusNameList) {
|
|
List<ExamQuestion> questions = this.findQuestionList(examSubject.getCode(), false);
|
|
List<ExamQuestion> questions = this.findQuestionList(examSubject.getCode(), false);
|
|
- Long count = studentService.countByExamIdAndSubjectCodeAndCampus(exam.getId(),examSubject.getCode(), campusName, true,false);
|
|
|
|
|
|
+ Long count = studentService.countByExamIdAndSubjectCodeAndCampus(exam.getId(),
|
|
|
|
+ examSubject.getCode(), campusName, true, false);
|
|
for (ExamQuestion examQuestion : questions) {
|
|
for (ExamQuestion examQuestion : questions) {
|
|
- ScoreRate scoreRate = scoreRateService.findOne(exam.getId(), examSubject.getCode(), campusName,false, examQuestion.getMainNumber(),examQuestion.getSubNumber());
|
|
|
|
|
|
+ ScoreRate scoreRate = scoreRateService.findOne(exam.getId(), examSubject.getCode(), campusName,
|
|
|
|
+ false, examQuestion.getMainNumber(), examQuestion.getSubNumber());
|
|
if (scoreRate == null) {
|
|
if (scoreRate == null) {
|
|
scoreRate = new ScoreRate();
|
|
scoreRate = new ScoreRate();
|
|
scoreRate.setExamId(exam.getId());
|
|
scoreRate.setExamId(exam.getId());
|
|
@@ -126,92 +127,96 @@ public class ScoreCalculateThread implements Runnable {
|
|
scoreRate.setMainTitle(examQuestion.getMainTitle());
|
|
scoreRate.setMainTitle(examQuestion.getMainTitle());
|
|
scoreRate.setTotalScore(examQuestion.getTotalScore());
|
|
scoreRate.setTotalScore(examQuestion.getTotalScore());
|
|
}
|
|
}
|
|
- String key = getKey(examSubject.getCode(), campusName,examQuestion.getQuestionNumber());
|
|
|
|
|
|
+ String key = getKey(examSubject.getCode(), campusName, examQuestion.getQuestionNumber());
|
|
BigDecimal bg = new BigDecimal(scoreRateMap.get(key) * 1.00 / count);
|
|
BigDecimal bg = new BigDecimal(scoreRateMap.get(key) * 1.00 / count);
|
|
double avgScore = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
double avgScore = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
- if(scoreRate.getAvgScore()==null || scoreRate.getAvgScore()!=avgScore){
|
|
|
|
|
|
+ if (scoreRate.getAvgScore() == null || scoreRate.getAvgScore() != avgScore) {
|
|
scoreRate.setAvgScore(avgScore);
|
|
scoreRate.setAvgScore(avgScore);
|
|
}
|
|
}
|
|
- if(scoreRate.getTotalScore()!=examQuestion.getTotalScore()){
|
|
|
|
|
|
+ if (scoreRate.getTotalScore() != examQuestion.getTotalScore()) {
|
|
scoreRate.setTotalScore(examQuestion.getTotalScore());
|
|
scoreRate.setTotalScore(examQuestion.getTotalScore());
|
|
}
|
|
}
|
|
scoreRateService.save(scoreRate);
|
|
scoreRateService.save(scoreRate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
private void calculate(ExamStudent student) {
|
|
private void calculate(ExamStudent student) {
|
|
ScoreCalculateUtil util = ScoreCalculateUtil.instance(student);
|
|
ScoreCalculateUtil util = ScoreCalculateUtil.instance(student);
|
|
- ScoreInfo info = util.calculate(findQuestionList(student.getSubjectCode(),true), null);
|
|
|
|
|
|
+ ScoreInfo info = util.calculate(findQuestionList(student.getSubjectCode(), true), null);
|
|
|
|
|
|
student.setObjectiveScore(info.getObjectiveScore());
|
|
student.setObjectiveScore(info.getObjectiveScore());
|
|
student.setScoreList(info.getScoreList(), true);
|
|
student.setScoreList(info.getScoreList(), true);
|
|
- if(("".equals(student.getSubjectiveScoreString()) || "0".equals(student.getSubjectiveScoreString()))){//当考生的主观分等于0时,同时该考生的试卷已经评卷的情况,再获取一次评卷分数
|
|
|
|
- MarkLibrary markLibrary = libraryService.findByStudentId(student.getId());
|
|
|
|
- if(markLibrary != null){//并且存在评卷记录的
|
|
|
|
- student.setSubjectiveScore(markLibrary.getMarkerScore());
|
|
|
|
- student.setScoreList(markLibrary.getScoreList(), false);
|
|
|
|
- }
|
|
|
|
|
|
+ if (student.getSubjectiveScore() == null || StringUtils.isBlank(student.getSubjectiveScoreList())) {
|
|
|
|
+ // 当考生的主观分或得分明细为空时,再尝试同步一次评卷任务的分数
|
|
|
|
+ MarkLibrary markLibrary = libraryService.findByStudentId(student.getId());
|
|
|
|
+ if (markLibrary != null && markLibrary.getStatus() == LibraryStatus.MARKED) {
|
|
|
|
+ // 存在评卷记录且已完成评卷时,同步评卷分数与明细
|
|
|
|
+ student.setSubjectiveScore(markLibrary.getMarkerScore());
|
|
|
|
+ student.setScoreList(markLibrary.getScoreList(), false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
studentService.save(student);
|
|
studentService.save(student);
|
|
-
|
|
|
|
- if(!student.getScoreList(false).isEmpty()){//主观题有分数明细才统分
|
|
|
|
- statistics(student);
|
|
|
|
|
|
+
|
|
|
|
+ // 主观题有分数明细才统计
|
|
|
|
+ if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
|
|
|
|
+ statistics(student);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
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<ExamQuestion> list = this.findQuestionList(student.getSubjectCode(),false);
|
|
|
|
- if(!items.isEmpty() && list != null){
|
|
|
|
- if(items.size()!=list.size()){
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
- 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());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private String getKey(String subjectCode,String campusName,String questionNumber) {
|
|
|
|
- List<String> list = new ArrayList<String>();
|
|
|
|
- list.add(subjectCode);
|
|
|
|
- list.add(campusName);
|
|
|
|
- list.add(questionNumber);
|
|
|
|
- return StringUtils.join(list, "-");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private List<ExamQuestion> findQuestionList(String subjectCode, boolean objective) {
|
|
|
|
- if(objective){
|
|
|
|
- List<ExamQuestion> list = objectiveMap.get(subjectCode);
|
|
|
|
- if (list == null) {
|
|
|
|
- list = questionService.findByExamAndSubjectAndObjective(exam.getId(), subjectCode, true);
|
|
|
|
- objectiveMap.put(subjectCode, list);
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
- }else{
|
|
|
|
- List<ExamQuestion> list = subjectiveMap.get(subjectCode);
|
|
|
|
- if (list == null) {
|
|
|
|
- list = questionService.findByExamAndSubjectAndObjective(exam.getId(), subjectCode, false);
|
|
|
|
- subjectiveMap.put(subjectCode, list);
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
|
|
+ List<ScoreItem> items = student.getScoreList(false);
|
|
|
|
+ List<ExamQuestion> list = findQuestionList(student.getSubjectCode(), false);
|
|
|
|
+ if (!items.isEmpty() && list != null) {
|
|
|
|
+ int count = list.size();
|
|
|
|
+ if (items.size() != count) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < count; 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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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) {
|
|
|
|
+ List<String> list = new ArrayList<String>();
|
|
|
|
+ list.add(subjectCode);
|
|
|
|
+ list.add(campusName);
|
|
|
|
+ list.add(questionNumber);
|
|
|
|
+ return StringUtils.join(list, "-");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ExamQuestion> findQuestionList(String subjectCode, boolean objective) {
|
|
|
|
+ if (objective) {
|
|
|
|
+ List<ExamQuestion> list = objectiveMap.get(subjectCode);
|
|
|
|
+ if (list == null) {
|
|
|
|
+ list = questionService.findByExamAndSubjectAndObjective(exam.getId(), subjectCode, true);
|
|
|
|
+ objectiveMap.put(subjectCode, list);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ } else {
|
|
|
|
+ List<ExamQuestion> list = subjectiveMap.get(subjectCode);
|
|
|
|
+ if (list == null) {
|
|
|
|
+ list = questionService.findByExamAndSubjectAndObjective(exam.getId(), subjectCode, false);
|
|
|
|
+ subjectiveMap.put(subjectCode, list);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|