فهرست منبع

Merge remote-tracking branch 'origin/dev_1.3.15' into release_1.3.15

yin 1 سال پیش
والد
کامیت
c34d764d2b
1فایلهای تغییر یافته به همراه17 افزوده شده و 15 حذف شده
  1. 17 15
      stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/SelectiveGroupServiceImpl.java

+ 17 - 15
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/SelectiveGroupServiceImpl.java

@@ -1,11 +1,6 @@
 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.springframework.beans.factory.annotation.Autowired;
@@ -147,22 +142,29 @@ public class SelectiveGroupServiceImpl extends BaseQueryService<SelectiveGroup>
 
     @Override
     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,
                 false);
         Map<Integer, Double> mainScoreMap = new HashMap<Integer, Double>();
         for (ExamQuestion question : questionList) {
             mainScoreMap.put(question.getMainNumber(), question.getTotalScore());
         }
+
+        Map<Integer, List<SelectiveGroup>> indexMap = this.findGroupByExamIdAndSubjectCode(examId, subjectCode);
         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;
     }