Browse Source

更新学生成绩后台首页

Administrator 1 year ago
parent
commit
18d0ddba71

+ 21 - 18
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/score/ScoreDataServiceImpl.java

@@ -216,25 +216,27 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                     scoreDataStudentBo.setZongfen(zf);
                     //计算平均分 = 总分/学科数
                     scoreDataStudentBo.setAvg(String.valueOf(zf / scoreDataDetailBoList.size()));
-                    ScoreDataStudent scoreDataStudent = MapstructUtils.convert(scoreDataStudentBo, ScoreDataStudent.class);
-                    scoreDataStudent.setScoreId(scoreId);
-                    //成绩排序
-                    scoreDataStudentBoList = scoreDataStudentBoList.stream().sorted(Comparator.comparingLong(ScoreDataStudentBo::getZongfen).reversed()).collect(Collectors.toList());
-                    int index = 0;// 排名
-                    double lastScore = -1;// 最近一次的分
-                    for (int i = 0; i < scoreDataStudentBoList.size(); i++) {
-                        ScoreDataStudentBo studentBo = scoreDataStudentBoList.get(i);
-                        if (Double.compare(lastScore, studentBo.getZongfen()) != 0) {
-                            // 如果成绩和上一名的成绩不相同,那么排名+1
-                            lastScore = studentBo.getZongfen();
-                            index++;
-                        }
-                        studentBo.setScoreSort(index + "");
-                    }
-                    scoreDataStudentMapper.insert(scoreDataStudent);
+                    scoreDataStudentBo.setScoreId(scoreId);
+
                     scoreDataDetailMapper.insertBatch(MapstructUtils.convert(scoreDataDetailBoList, ScoreDataDetail.class));
+
                 }
             }
+            //成绩排序
+            scoreDataStudentBoList = scoreDataStudentBoList.stream().sorted(Comparator.comparingLong(ScoreDataStudentBo::getZongfen).reversed()).collect(Collectors.toList());
+            int index = 0;// 排名
+            double lastScore = -1;// 最近一次的分
+            for (int i = 0; i < scoreDataStudentBoList.size(); i++) {
+                ScoreDataStudentBo studentBo = scoreDataStudentBoList.get(i);
+                if (Double.compare(lastScore, studentBo.getZongfen()) != 0) {
+                    // 如果成绩和上一名的成绩不相同,那么排名+1
+                    lastScore = studentBo.getZongfen();
+                    index++;
+                }
+                studentBo.setScoreSort(index + "");
+            }
+            scoreDataStudentMapper.insertBatch(MapstructUtils.convert(scoreDataStudentBoList, ScoreDataStudent.class));
+
             //计算班级总分平均分=各学生总分/学生人数
             long classAvg = classZf / scoreDataStudentBoList.size();
             add.setAvg(String.valueOf(classAvg));
@@ -424,6 +426,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
 
     /**
      * 成绩年级统计
+     *
      * @param scoreData
      * @return
      */
@@ -473,8 +476,8 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                 stdId = new StringBuilder(stdId.substring(0, stdId.length() - 1));
             }
 
-            Map<String,Object> map = new HashMap<>();
-            map.put("stdId",stdId.toString());
+            Map<String, Object> map = new HashMap<>();
+            map.put("stdId", stdId.toString());
             scoreData.setParams(map);
             //获取查看人数
             Object chaKanCount = RedisUtils.getCacheObject(SCORE_PEOPLE_CHAKAN_COUNT + scoreId);