Преглед изворни кода

更新预约成功短信链接

Administrator пре 1 година
родитељ
комит
fcf74cde09

+ 5 - 3
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/FormalTeacherClass.java

@@ -79,8 +79,10 @@ public class FormalTeacherClass extends BaseEntity {
      */
     @TableField(exist = false)
     private String type;
+    /**
+     * 手动设置的延迟下课时间
+     */
+    @TableField(exist = false)
+    private String xiakeTime;
 
-    public String getType() {
-        return type;
-    }
 }

+ 6 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/score/vo/ScoreDataStudentVo.java

@@ -46,10 +46,15 @@ public class ScoreDataStudentVo implements Serializable {
     private Long scoreId;
 
     /**
-     * 排序
+     * 班级排序
      */
     @ExcelProperty(value = "排序")
     private int scoreSort;
+    /**
+     * 年级排序
+     */
+    @TableField(exist = false)
+    private int scoreSortGrade;
 
     /**
      * 姓名

+ 5 - 3
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/common/AppletServiceImpl.java

@@ -90,19 +90,21 @@ public class AppletServiceImpl implements IAppletService {
                 String[] split = value.split(":");
                 //下课时间
                 String xiakeTime = split[1] + ":" + split[2] + ":" + split[3];
-                //获取参数中默认下课时间
+              /*  //获取参数中默认下课时间
                 XiakeConfigBo config = new XiakeConfigBo();
                 config.setConfigKey(formalTeacherClass.getClassId() + ":2");
                 XiakeConfigVo retConfig = xiakeConfigMapper.selectConfig(config);
                 //延迟下课的默认值
-                String configValue = retConfig.getConfigValue();
+                String configValue = retConfig.getConfigValue();*/
+                //延迟下课的时间,前端传来
+                String yanChiTime = formalTeacherClass.getXiakeTime();
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 Date date = null;
                 try {
                     date = sdf.parse(xiakeTime);
                     Calendar calendar = Calendar.getInstance();
                     calendar.setTime(date);
-                    calendar.add(Calendar.MINUTE, Integer.parseInt(configValue));
+                    calendar.add(Calendar.MINUTE, Integer.parseInt(yanChiTime));
                     String time = sdf.format(calendar.getTime());
                     value = split[0] + ":" + time;
                     RedisUtils.setCacheObject(key, value);

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

@@ -222,6 +222,8 @@ public class ScoreDataServiceImpl implements IScoreDataService {
         }
         //从考试信息中获取所有学生信息,在获取该学生所有考试成绩
         List<ScoreDataStudentBo> scoreDataStudentBoList = bo.getScoreDataStudentBoList();
+        //存放所有学生的成绩详情,计算各学科排名
+        List<ScoreDataDetailBo> scoreDataDetailBoListAll = new ArrayList<>();
         if (scoreDataStudentBoList != null && scoreDataStudentBoList.size() > 0) {
             for (ScoreDataStudentBo scoreDataStudentBo : scoreDataStudentBoList) {
                 List<ScoreDataDetailBo> scoreDataDetailBoList = scoreDataStudentBo.getScoreDataDetailBoList();
@@ -237,15 +239,14 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                         //scoreDataDetailBo.setScoreDataNameId(scoreDataStudentBo.getScoreDataNameId());
                         //插入满分
                         scoreDataDetailBo.setManfen(map.get(scoreDataDetailBo.getXueke()));
+                        //把所有学生各学科成绩详情放入一个LIST
+                        scoreDataDetailBoListAll.add(scoreDataDetailBo);
                     }
                     classZf = classZf + zf;
                     scoreDataStudentBo.setZongfen(zf);
                     //计算个人平均分 = 总分/学科数
                     scoreDataStudentBo.setAvg(String.valueOf(df.format(zf / scoreDataDetailBoList.size())));
                     scoreDataStudentBo.setScoreId(scoreId);
-
-                    scoreDataDetailMapper.insertBatch(MapstructUtils.convert(scoreDataDetailBoList, ScoreDataDetail.class));
-
                 }
             }
             //成绩排序
@@ -261,6 +262,36 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                 }
                 studentBo.setScoreSort(index);
             }
+
+            //插入学生成绩详情表
+            //计算各学科排名
+            //首先根据各学科进行分组
+            List<ScoreDataDetailBo> scoreDataDetailBoListResult = new ArrayList<>();
+
+            Map<String, List<ScoreDataDetailBo>> scoreDataDetailBoListAllXueKe = scoreDataDetailBoListAll.stream().collect(Collectors.groupingBy(ScoreDataDetailBo::getXueke));
+            if (scoreDataDetailBoListAllXueKe != null && scoreDataDetailBoListAllXueKe.size() > 0) {
+                int indexD = 0;// 排名
+                double  lastScoreD = -1;// 最近一次的分
+                for (List<ScoreDataDetailBo> value : scoreDataDetailBoListAllXueKe.values()) {
+                    //根据学科成绩进行倒序排序
+                    value = value.stream().sorted(Comparator.comparingDouble(ScoreDataDetailBo::getScore).reversed()).collect(Collectors.toList());
+                     indexD = 0;// 排名
+                      lastScoreD = -1;// 最近一次的分
+                    for (int i = 0; i < value.size(); i++) {
+                        ScoreDataDetailBo scoreDataDetailBo = value.get(i);
+                        if (Double.compare(lastScoreD, scoreDataDetailBo.getScore()) != 0) {
+                            // 如果成绩和上一名的成绩不相同,那么排名+1
+                            lastScoreD = scoreDataDetailBo.getScore();
+                            indexD++;
+                        }
+                        scoreDataDetailBo.setScoreSort(indexD);
+                        scoreDataDetailBoListResult.add(scoreDataDetailBo);
+                    }
+                }
+            }
+            scoreDataDetailMapper.insertBatch(MapstructUtils.convert(scoreDataDetailBoListResult, ScoreDataDetail.class));
+
+            //插入到学生表
             scoreDataStudentMapper.insertBatch(MapstructUtils.convert(scoreDataStudentBoList, ScoreDataStudent.class));
 
             //计算班级总分平均分=各学生总分/学生人数
@@ -473,6 +504,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
         List<ScoreDataStudentVo> scoreDataStudentVos = scoreDataStudentMapper.gradeRank(scoreData);
         Long scoreId = scoreData.getScoreId();
         Map<String, Double> map = new HashMap<>();
+        DecimalFormat df = new DecimalFormat("#.00");
         if (scoreId != null) {
             //过滤出本班学生id
             scoreDataStudentVos = scoreDataStudentVos.stream().filter(scoreDataStudentVo -> scoreDataStudentVo.getScoreId().equals(scoreId)).sorted(Comparator.comparing(ScoreDataStudentVo::getZongfen).reversed()).collect(Collectors.toList());
@@ -489,7 +521,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                     double sum = scoreDataDetailVosXueke.stream().mapToDouble(ScoreDataDetailVo::getScore).sum();
                     //计算学科平均分 = 学科总分 /人数
                     double xueKeAvg = sum / studentNumberList.size();
-                    map.put(xueke, xueKeAvg);
+                    map.put(xueke, Double.valueOf(df.format(xueKeAvg)));
                 }
             }
             //总成绩均分
@@ -500,7 +532,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
             //对学生成绩根据学生身份证进行分组
             Map<String, List<ScoreDataDetailVo>> studentNumberCollect = scoreDataDetailVos.parallelStream().collect(Collectors.groupingBy(ScoreDataDetailVo::getStudentNumber));
             for (ScoreDataStudentVo scoreDataStudentVo : scoreDataStudentVos) {
-                scoreDataStudentVo.setAvg(String.valueOf(zongFenAvg));
+                scoreDataStudentVo.setAvg(String.valueOf(df.format(zongFenAvg)));
                 List<ScoreDataDetailVo> scoreDataDetailVosList = studentNumberCollect.get(scoreDataStudentVo.getStudentNumber());
                 if (scoreDataDetailVosList != null && scoreDataDetailVosList.size() > 0) {
                     for (ScoreDataDetailVo scoreDataDetailVo : scoreDataDetailVosList) {
@@ -593,8 +625,10 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                     y2.add(scoreDataStudentVosListDown.size());
                 }
             }
+            DecimalFormat df = new DecimalFormat("#.00");
+
             map.put("x", x);
-            map.put("avg", avg);
+            map.put("avg", df.format(avg));
             map.put("y1", y1);
             map.put("y2", y2);
         }
@@ -631,7 +665,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                 if (scoreDataStudentVosList != null && scoreDataStudentVosList.size() > 0) {
                     List<ScoreDataStudentVo> scoreDataStudentVosListUp = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen() >= avg)
                         .collect(Collectors.toList());
-                    List<ScoreDataStudentVo> scoreDataStudentVosListDown = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen()< avg)
+                    List<ScoreDataStudentVo> scoreDataStudentVosListDown = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen() < avg)
                         .collect(Collectors.toList());
                     scoreDataVo.setUp(scoreDataStudentVosListUp.size());
                     scoreDataVo.setDown(scoreDataStudentVosListDown.size());
@@ -701,41 +735,41 @@ public class ScoreDataServiceImpl implements IScoreDataService {
                 }
             }
             //总人数
-            float  size = scoreDataStudentVos.size();
+            float size = scoreDataStudentVos.size();
 
             if (size > 0) {
                 NumberFormat nf = NumberFormat.getPercentInstance();
                 nf.setMaximumFractionDigits(2);
                 if (a > 0) {
-                    map.put("OneZ", nf.format((float) a/size));
+                    map.put("OneZ", nf.format((float) a / size));
 
                 }
                 if (b > 0) {
-                    map.put("TowZ", nf.format((float) b/size));
+                    map.put("TowZ", nf.format((float) b / size));
 
                 }
                 if (c > 0) {
-                    map.put("ThrZ", nf.format((float) c/size));
+                    map.put("ThrZ", nf.format((float) c / size));
 
                 }
                 if (d > 0) {
-                    map.put("ForZ", nf.format((float) d/size));
+                    map.put("ForZ", nf.format((float) d / size));
 
                 }
                 if (e > 0) {
-                    map.put("FivZ", nf.format((float) e/size));
+                    map.put("FivZ", nf.format((float) e / size));
 
                 }
                 if (f > 0) {
-                    map.put("SixZ", nf.format((float) f/size));
+                    map.put("SixZ", nf.format((float) f / size));
 
                 }
                 if (g > 0) {
-                    map.put("SevZ", nf.format((float) g/size));
+                    map.put("SevZ", nf.format((float) g / size));
 
                 }
                 if (h > 0) {
-                    map.put("EigZ", nf.format((float) h/size));
+                    map.put("EigZ", nf.format((float) h / size));
 
                 }
             }
@@ -810,7 +844,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
             scoreDataVo.setScoreDataStudentVoList(scoreDataStudentVos);
             return scoreDataVo;
         }
-        //查询考试对应的学生和成绩
+        //查询考试所有的学生和成绩
         List<ScoreDataStudentVo> scoreDataStudentVos = scoreDataStudentMapper.selectScoreByScoreId(scoreData.getScoreId());
         scoreDataVo.setScoreDataStudentVoList(scoreDataStudentVos);
         return scoreDataVo;

+ 10 - 5
ruoyi-modules/ruoyi-system/src/main/resources/mapper/score/ScoreDataStudentMapper.xml

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="scoreStudentId"    column="score_student_id"    />
         <result property="scoreId"    column="score_id"    />
         <result property="scoreSort"    column="score_sort"    />
+        <result property="scoreSortGrade"    column="score_sort_grade"    />
         <result property="scoreDataName"    column="score_data_name"    />
         <result property="scoreDataNameId"    column="score_data_name_id"    />
         <result property="studentNumber"    column="student_number"    />
@@ -52,11 +53,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             b.student_number ,
             d.xueke as sdd_xueke,
             d.score as sdd_score,
+            d.score_sort as sdd_score_sort,
             d.score_data_name as sdd_score_data_name
         FROM
             score_data_student b
-                LEFT JOIN score_data_detail d ON d.student_number = b.student_number
-        where b.score_id = #{scoreId} and  find_in_set(b.score_data_name_id,#{params.stdId}) order by  b.score_sort
+                LEFT JOIN score_data_detail d  ON (d.student_number = b.student_number and b.score_id = d.score_id)
+        where b.score_id = #{scoreId}
+          and  find_in_set(b.score_data_name_id,#{params.stdId})
+        order by  b.score_sort
     </select>
 
     <select id="selectScoreByScoreId" parameterType="Long" resultMap="ScoreDataStudentResult">
@@ -71,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             d.score_data_name as sdd_score_data_name
         FROM
             score_data_student b
-                LEFT JOIN score_data_detail d ON d.student_number = b.student_number
+                LEFT JOIN score_data_detail d ON (d.student_number = b.student_number and b.score_id = d.score_id)
         where b.score_id = #{scoreId} order by  b.score_sort
     </select>
 
@@ -90,14 +94,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="gradeRank" parameterType="org.dromara.system.domain.score.ScoreData" resultMap="ScoreDataStudentResult">
-        select ( @INDEX := @INDEX + 1 ) AS `score_sort`,
+        select ( @INDEX := @INDEX + 1 ) AS `score_sort_grade`,
         a.score_data_name,
+        a.score_sort,
         a.score_data_name_id,
         a.student_number,
         a.zongfen,
         a.score_id
         FROM
-        (select s.score_data_name,s.score_data_name_id,s.zongfen,s.score_id,s.student_number
+        (select s.score_data_name,s.score_data_name_id,s.zongfen,s.score_id,s.student_number,s.score_sort
         FROM score_data_student s
         <where>
          score_id IN (