|
@@ -1,11 +1,6 @@
|
|
package cn.com.qmth.stmms.biz.exam.service.impl;
|
|
package cn.com.qmth.stmms.biz.exam.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -147,22 +142,29 @@ public class SelectiveGroupServiceImpl extends BaseQueryService<SelectiveGroup>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public double sumScoreByExamIdAndSubjectCode(int examId, String subjectCode) {
|
|
public double sumScoreByExamIdAndSubjectCode(int examId, String subjectCode) {
|
|
- List<SelectiveGroup> list = selectiveGroupDao.findByExamIdAndSubjectCode(examId, subjectCode);
|
|
|
|
- Map<Integer, SelectiveGroup> map = new HashMap<>();
|
|
|
|
- for (SelectiveGroup selectiveGroup : list) {
|
|
|
|
- map.put(selectiveGroup.getSelectiveIndex(), selectiveGroup);
|
|
|
|
- }
|
|
|
|
List<ExamQuestion> questionList = questionService.findMainByExamAndSubjectAndObjective(examId, subjectCode,
|
|
List<ExamQuestion> questionList = questionService.findMainByExamAndSubjectAndObjective(examId, subjectCode,
|
|
false);
|
|
false);
|
|
Map<Integer, Double> mainScoreMap = new HashMap<Integer, Double>();
|
|
Map<Integer, Double> mainScoreMap = new HashMap<Integer, Double>();
|
|
for (ExamQuestion question : questionList) {
|
|
for (ExamQuestion question : questionList) {
|
|
mainScoreMap.put(question.getMainNumber(), question.getTotalScore());
|
|
mainScoreMap.put(question.getMainNumber(), question.getTotalScore());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Map<Integer, List<SelectiveGroup>> indexMap = this.findGroupByExamIdAndSubjectCode(examId, subjectCode);
|
|
double totalScore = 0d;
|
|
double totalScore = 0d;
|
|
- for (SelectiveGroup selectiveGroup : map.values()) {
|
|
|
|
- Double mainScore = mainScoreMap.get(selectiveGroup.getMainNumber());
|
|
|
|
- totalScore = BigDecimalUtils.add(totalScore,
|
|
|
|
- BigDecimalUtils.mul(mainScore, selectiveGroup.getSelectiveCount()));
|
|
|
|
|
|
+ for (Integer index : indexMap.keySet()) {
|
|
|
|
+ // 循环选做题组
|
|
|
|
+ List<SelectiveGroup> indexGroup = indexMap.get(index);
|
|
|
|
+ Integer selectiveCount = 0;
|
|
|
|
+ double partScore = 0d;
|
|
|
|
+ for (SelectiveGroup selectiveGroup : indexGroup) {
|
|
|
|
+ if (selectiveCount == 0) {
|
|
|
|
+ selectiveCount = selectiveGroup.getSelectiveCount();
|
|
|
|
+ }
|
|
|
|
+ if (selectiveGroup.getSelectivePart().intValue() == 1) {
|
|
|
|
+ partScore = BigDecimalUtils.add(partScore, mainScoreMap.get(selectiveGroup.getMainNumber()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ totalScore = BigDecimalUtils.add(totalScore, BigDecimalUtils.mul(partScore, selectiveCount));
|
|
}
|
|
}
|
|
return totalScore;
|
|
return totalScore;
|
|
}
|
|
}
|