Browse Source

Merge remote-tracking branch 'origin/ywx' into wn

ywx
王宁 3 weeks ago
parent
commit
af3386123b
26 changed files with 1858 additions and 1494 deletions
  1. 55
    2
      smarking/src/main/java/com/xhkjedu/smarking/controller/report/ZhReportController.java
  2. 3
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/exam/MsClassMapper.java
  3. 4
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassActionMapper.java
  4. 5
    1
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassSubjectGradeMapper.java
  5. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportstu/MsrStudentActionMapper.java
  6. 2
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportstu/MsrStudentMapper.java
  7. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectClassMapper.java
  8. 4
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectMapper.java
  9. 3
    1
      smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubject.java
  10. 149
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateActionService.java
  11. 993
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateClassService.java
  12. 173
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateStudentService.java
  13. 223
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateSubjectService.java
  14. 33
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrActionService.java
  15. 12
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrClassService.java
  16. 45
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrSubjectService.java
  17. 36
    1489
      smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java
  18. 9
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrReportparamService.java
  19. 35
    0
      smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java
  20. 4
    0
      smarking/src/main/resources/mapper/exam/MsClassMapper.xml
  21. 13
    0
      smarking/src/main/resources/mapper/report/reportclass/MsrClassActionMapper.xml
  22. 7
    1
      smarking/src/main/resources/mapper/report/reportclass/MsrClassSubjectGradeMapper.xml
  23. 17
    0
      smarking/src/main/resources/mapper/report/reportstu/MsrStudentActionMapper.xml
  24. 7
    0
      smarking/src/main/resources/mapper/report/reportstu/MsrStudentMapper.xml
  25. 5
    0
      smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectClassMapper.xml
  26. 9
    0
      smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectMapper.xml

+ 55
- 2
smarking/src/main/java/com/xhkjedu/smarking/controller/report/ZhReportController.java View File

@@ -4,8 +4,9 @@ import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.smarking.model.exam.MsSubject;
6 6
 import com.xhkjedu.smarking.model.report.reportclass.MsrClassSubjectGrade;
7
-import com.xhkjedu.smarking.service.report.report.MsrClassQuestionService;
8
-import com.xhkjedu.smarking.service.report.report.MsrStudentService;
7
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
8
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
9
+import com.xhkjedu.smarking.service.report.report.*;
9 10
 import com.xhkjedu.smarking.vo.report.reportother.ExamReportParams;
10 11
 import com.xhkjedu.utils.N_Utils;
11 12
 import com.xhkjedu.utils.PageUtil;
@@ -33,6 +34,24 @@ public class ZhReportController {
33 34
     private MsrStudentService msrStudentService;
34 35
     @Resource
35 36
     private MsrClassQuestionService msrClassQuestionService;
37
+    @Resource
38
+    private MsrSubjectService msrSubjectService;
39
+    @Resource
40
+    private MsrActionService msrActionService;
41
+
42
+    /**
43
+     * @Description 总概览
44
+     * @Date 2025/1/3 14:59
45
+     * @Author YWX
46
+     * @Param [subject]
47
+     * @Return com.xhkjedu.vo.ResultVo
48
+     **/
49
+    @PostMapping("/zgl")
50
+    public ResultVo listSubjectForZgl(@RequestBody MsrSubject subject) {
51
+        N_Utils.validation(new Object[]{subject.getExamid(), "考试id", 1});
52
+        return new ResultVo(0, "获取成功", msrSubjectService.listSubjectForZgl(subject));
53
+    }
54
+
36 55
     /*
37 56
      * @Description 小分表-列表
38 57
      * @Date 2024/12/24 10:25:06
@@ -104,4 +123,38 @@ public class ZhReportController {
104 123
         return new ResultVo(0,"获取成功",msrClassQuestionService.listQuestionForAllObjsub(params));
105 124
     }
106 125
 
126
+    /**
127
+     * @Description 违纪优秀-班级统计
128
+     * @Date 2025/1/3 14:47
129
+     * @Author YWX
130
+     * @Param [action]
131
+     * @Return com.xhkjedu.vo.ResultVo
132
+     **/
133
+    @PostMapping("/wjyx_bj")
134
+    public ResultVo listXwBj(@RequestBody MsrStudentAction action) {
135
+        N_Utils.validation(new Object[]{action.getExamid(), "考试id", 1, action.getActiontype(), "类型", 1});
136
+        return new ResultVo(0, "获取成功", msrActionService.listXwBj(action));
137
+    }
138
+
139
+    /**
140
+     * @Description 违纪优秀-学生统计
141
+     * @Date 2025/1/3 14:49
142
+     * @Author YWX
143
+     * @Param [action]
144
+     * @Return com.xhkjedu.vo.ResultVo
145
+     **/
146
+    @PostMapping("/wjyx_bj")
147
+    public ResultVo listXwXs(@RequestBody MsrStudentAction action) {
148
+        N_Utils.validation(new Object[]{action.getExamid(), "考试id", 1, action.getActiontype(), "类型", 1});
149
+        Integer page = action.getPage();
150
+        if (N_Utils.isEmptyInteger(page)) {
151
+            return new ResultVo(0, "获取成功", msrActionService.listXwXs(action));
152
+        } else {
153
+            PageHelper.startPage(page, action.getPageSize());
154
+            List<Map> list = msrActionService.listXwXs(action);
155
+            PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
156
+            return new ResultVo(0, "获取成功", pageResult);
157
+        }
158
+    }
159
+
107 160
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/exam/MsClassMapper.java View File

@@ -53,4 +53,7 @@ public interface MsClassMapper extends TkMapper<MsClass> {
53 53
     List<MsClass> listClassByExamId(@Param("examid") Integer examid);
54 54
     //考试科目关联不安及
55 55
     List<MsClass> listClassByExamidAndSubjectid(@Param("examid") Integer examid, @Param("subjectid") String subjectid);
56
+
57
+    //获取考试关联班级数量
58
+    Integer getClassNumByExamId(@Param("examid") Integer examid);
56 59
 }

+ 4
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassActionMapper.java View File

@@ -2,6 +2,7 @@ package com.xhkjedu.smarking.mapper.report.reportclass;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.report.reportclass.MsrClassAction;
5
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
5 6
 import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 import java.util.List;
@@ -21,4 +22,7 @@ public interface MsrClassActionMapper extends TkMapper<MsrClassAction> {
21 22
 
22 23
     //违规试卷
23 24
     List<Map> listBadQuesActionByExamId(@Param("examid") Integer examid,@Param("subjectids") String subjectids);
25
+
26
+    //行为分析-班级
27
+    List<Map> listXwBj(@Param("action") MsrStudentAction action);
24 28
 }

+ 5
- 1
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassSubjectGradeMapper.java View File

@@ -5,6 +5,7 @@ import com.xhkjedu.smarking.model.report.reportclass.MsrClassSubjectGrade;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 
7 7
 import java.util.List;
8
+import java.util.Map;
8 9
 
9 10
 /**
10 11
  * @Description 阅卷报告-班级学科四率等级分析表 Mapper 接口
@@ -16,6 +17,9 @@ public interface MsrClassSubjectGradeMapper extends TkMapper<MsrClassSubjectGrad
16 17
     //综合报告-试题汇总表-全部班级-科目情况-四率等级分析
17 18
     List<MsrClassSubjectGrade> listSubjectGrade(@Param("sg")MsrClassSubjectGrade sg);
18 19
 
19
-    //综合报告-班级堆积-全科及格率分析
20
+    //综合报告-班级对比-全科及格率分析
20 21
     List<MsrClassSubjectGrade> listSubjectGradeForQk(@Param("examid") Integer examid,@Param("reportcode") String reportcode);
22
+
23
+    //综合报告-整体四率分析
24
+    List<Map<String,Object>> getZfScoreRate(@Param("examid") Integer examid);
21 25
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportstu/MsrStudentActionMapper.java View File

@@ -2,6 +2,10 @@ package com.xhkjedu.smarking.mapper.report.reportstu;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
5 9
 
6 10
 /**
7 11
  * @Description 考试报告学生违纪优秀分析表 Mapper 接口
@@ -9,4 +13,6 @@ import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
9 13
  * @Date 2025-01-03
10 14
  */
11 15
 public interface MsrStudentActionMapper extends TkMapper<MsrStudentAction> {
16
+    //行为分析-学生
17
+    List<Map> listXwBj(@Param("action") MsrStudentAction action);
12 18
 }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportstu/MsrStudentMapper.java View File

@@ -22,4 +22,6 @@ public interface MsrStudentMapper extends TkMapper<MsrStudent> {
22 22
     List<Map<String, Object>> listStuScoreAndRankByExamidAndSubjectid(@Param("examid") int examid, @Param("subjectid") String subjectid);
23 23
     //学生报告-学生学科试题分析
24 24
     List<Map<String, Object>> listStuSubjectQuestions(@Param("params") ExamReportParams params);
25
+    //综合报告-总概览-整体分数分布分析
26
+    List<Map<String, Object>> listScoreForZgl(@Param("examid") Integer examid,@Param("subjectid") String subjectid);
25 27
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectClassMapper.java View File

@@ -1,7 +1,12 @@
1 1
 package com.xhkjedu.smarking.mapper.report.reportsubject;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
4 5
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+import java.util.Map;
5 10
 
6 11
 /**
7 12
  * @Description 阅卷报告-科目班级分数分布区间分析表 Mapper 接口
@@ -9,4 +14,5 @@ import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
9 14
  * @Date 2024-12-09
10 15
  */
11 16
 public interface MsrSubjectClassMapper extends TkMapper<MsrSubjectClass> {
17
+    List<Map> listSubjectClass(@Param("subject") MsrSubject subject);
12 18
 }

+ 4
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectMapper.java View File

@@ -4,6 +4,7 @@ import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 
7
+import java.util.List;
7 8
 import java.util.Map;
8 9
 
9 10
 /**
@@ -15,4 +16,7 @@ public interface MsrSubjectMapper extends TkMapper<MsrSubject> {
15 16
 
16 17
     //综合报告-试题汇总表-全部班级-科目情况
17 18
     Map<String, Object> getSubjectBaseInfo(@Param("examid")Integer examid, @Param("subjectid")String subjectid);
19
+
20
+    //科目分析
21
+    List<Map> listSubjectForZgl(@Param("examid") Integer examid);
18 22
 }

+ 3
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubject.java View File

@@ -39,8 +39,10 @@ public class MsrSubject extends BaseBean {
39 39
     private Double scorerate;
40 40
     //总人数
41 41
     private Integer totalnum;
42
-    //考人数
42
+    //考人数
43 43
     private Integer stunum;
44
+    //参考人数占比
45
+    private Double numrate;
44 46
     //缺考人数
45 47
     private Integer missnum;
46 48
     //标准差

+ 149
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateActionService.java View File

@@ -0,0 +1,149 @@
1
+package com.xhkjedu.smarking.service.report.generate;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassActionMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentActionMapper;
6
+import com.xhkjedu.smarking.model.exam.MsClassStudent;
7
+import com.xhkjedu.smarking.model.paper.MsPaper;
8
+import com.xhkjedu.smarking.model.report.reportclass.MsrClassAction;
9
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
10
+import com.xhkjedu.utils.N_Utils;
11
+import org.springframework.stereotype.Service;
12
+
13
+import javax.annotation.Resource;
14
+import java.util.*;
15
+import java.util.stream.Collectors;
16
+
17
+/**
18
+ *@Description 优秀违纪报告生成服务
19
+ *@Author ywx
20
+ *Date 2025/1/3 11:39
21
+ **/
22
+@Service
23
+public class ReportGenerateActionService {
24
+    @Resource
25
+    private MsrClassActionMapper msrClassActionMapper;
26
+    @Resource
27
+    private MsrStudentActionMapper msrStudentActionMapper;
28
+
29
+    //违纪优秀分析
30
+    public void saveAction(Integer examid, List<MsPaper> subjects, List<MsClassStudent> students) {
31
+        String msids = subjects.stream().map(p -> p.getMsid().toString()).collect(Collectors.joining(","));
32
+        String subjectids = subjects.stream().map(MsPaper::getSubjectid).collect(Collectors.joining("','"));
33
+        Map<Integer, String> subjectIdMap = new HashMap<>();
34
+        Map<String, String> subjectNameMap = new HashMap<>();
35
+        for (MsPaper subject : subjects) {
36
+            String subjectid = subject.getSubjectid();
37
+            String subjectname = subject.getSubjectname();
38
+            subjectIdMap.put(subject.getMsid(), subjectid);
39
+            subjectNameMap.put(subjectid, subjectname);
40
+        }
41
+        Map<String, List<MsClassStudent>> collect = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid() + "_" + s.getStudentid()));
42
+        Map<String, List<Integer>> sscMap = new HashMap<>();//学生科目班级map
43
+        for (Map.Entry<String, List<MsClassStudent>> entry : collect.entrySet()) {
44
+            sscMap.put(entry.getKey(), entry.getValue().stream().map(MsClassStudent::getClassid).distinct().collect(Collectors.toList()));
45
+        }
46
+
47
+        List<MsrClassAction> classActions = new ArrayList<>();
48
+        List<MsrStudentAction> studentActions = new ArrayList<>();
49
+        //违纪行为
50
+        List<Map> bads = msrClassActionMapper.listBadActionByExamId(msids);
51
+        for (Map bad : bads) {
52
+            String subjectid = subjectIdMap.get((Integer) bad.get("msid"));
53
+            bad.put("subjectid", subjectid);
54
+        }
55
+        int actiontype = 1;
56
+        setActions(examid, classActions, studentActions, bads, actiontype, subjectNameMap, sscMap);
57
+        //优秀试卷
58
+        List<Map> goods = msrClassActionMapper.listGoodActionByExamId(examid, subjectids);
59
+        actiontype = 2;
60
+        setActions(examid, classActions, studentActions, goods, actiontype, subjectNameMap, sscMap);
61
+
62
+        //违规试卷
63
+        List<Map> badques = msrClassActionMapper.listBadQuesActionByExamId(examid, subjectids);
64
+        actiontype = 3;
65
+        setActions(examid, classActions, studentActions, badques, actiontype, subjectNameMap, sscMap);
66
+
67
+        if (N_Utils.isListNotEmpty(classActions)) msrClassActionMapper.insertList(classActions);
68
+        if (N_Utils.isListNotEmpty(studentActions)) msrStudentActionMapper.insertList(studentActions);
69
+    }
70
+
71
+    //处理行为数据
72
+    private void setActions(Integer examid, List<MsrClassAction> classActions, List<MsrStudentAction> studentActions
73
+            , List<Map> actionList, Integer actiontype, Map<String, String> subjectNameMap
74
+            , Map<String, List<Integer>> sscMap) {
75
+        if (N_Utils.isListNotEmpty(actionList)) {
76
+            List<Map> actions = new ArrayList<>();
77
+            for (Map map : actionList) {
78
+                String key = map.get("subjectid") + "_" + map.get("studentid");
79
+                List<Integer> classids = sscMap.get(key);
80
+                for (Integer classid : classids) {
81
+                    Map ca = new HashMap(map);
82
+                    ca.put("classid", classid);
83
+                    actions.add(ca);
84
+                }
85
+            }
86
+            //班级行为分析
87
+            Map<Integer, List<Map>> ccollect = actions.stream().collect(Collectors.groupingBy(s -> (Integer) s.get("classid")
88
+                    , LinkedHashMap::new, Collectors.toList()));
89
+            for (Map.Entry<Integer, List<Map>> entry : ccollect.entrySet()) {
90
+                List<Map> subjects = new ArrayList<>();
91
+                Map<String, List<Map>> scollect = entry.getValue().stream().collect(Collectors.groupingBy(s -> s.get("subjectid").toString()
92
+                        , LinkedHashMap::new, Collectors.toList()));
93
+                for (Map.Entry<String, List<Map>> sentry : scollect.entrySet()) {
94
+                    String subjectid = sentry.getKey();
95
+                    int znum = (int) actions.stream().filter(s -> s.get("subjectid").equals(subjectid)).count();//总人数
96
+                    List<Map> list = sentry.getValue();
97
+                    Map subject = new HashMap();
98
+                    subject.put("subjectid", subjectid);
99
+                    subject.put("subjectname", subjectNameMap.get(subjectid));
100
+                    int num = list.size();
101
+                    subject.put("num", num);
102
+                    subject.put("nrate", N_Utils.getIntegerDivideAndMulitiply(num, znum));
103
+                    List<Map> students = new ArrayList<>();
104
+                    for (Map s : list) {
105
+                        Map stu = new HashMap();
106
+                        Integer studentid = (Integer) s.get("studentid");
107
+                        stu.put("studentid", studentid);
108
+                        stu.put("num", s.get("num"));
109
+                        stu.put("studentname", s.get("studentname"));
110
+                        students.add(stu);
111
+                    }
112
+                    subject.put("students", students);
113
+                    subjects.add(subject);
114
+                }
115
+                MsrClassAction ca = new MsrClassAction();
116
+                ca.setClassid(entry.getKey());
117
+                ca.setExamid(examid);
118
+                ca.setActiontype(actiontype);
119
+                String subjectjson = JSON.toJSONString(subjects);
120
+                ca.setSubjectjson(subjectjson);
121
+                classActions.add(ca);
122
+            }
123
+
124
+            //学生行为分析
125
+            Map<Integer, List<Map>> collect = actions.stream().collect(Collectors.groupingBy(s -> (Integer) s.get("studentid")
126
+                    , LinkedHashMap::new, Collectors.toList()));
127
+            for (Map.Entry<Integer, List<Map>> entry : collect.entrySet()) {
128
+                List<Map> list = entry.getValue();
129
+                Map sq = list.get(0);
130
+                MsrStudentAction sa = new MsrStudentAction();
131
+                sa.setClassid((Integer) sq.get("classid"));
132
+                sa.setStudentid(entry.getKey());
133
+                sa.setExamid(examid);
134
+                sa.setActiontype(actiontype);
135
+                for (Map s : list) {
136
+                    s.remove("classid");
137
+                    s.remove("studentid");
138
+                    s.remove("studentname");
139
+                    s.remove("msid");
140
+                    s.put("subjectname", subjectNameMap.get(s.get("subjectid").toString()));
141
+                }
142
+                String subjectjson = JSON.toJSONString(list);
143
+                sa.setSubjectjson(subjectjson);
144
+                studentActions.add(sa);
145
+            }
146
+        }
147
+    }
148
+
149
+}

+ 993
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateClassService.java View File

@@ -0,0 +1,993 @@
1
+package com.xhkjedu.smarking.service.report.generate;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.report.reportclass.*;
5
+import com.xhkjedu.smarking.model.report.reportclass.*;
6
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
7
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
8
+import com.xhkjedu.smarking.service.report.reportother.MsrReportparamService;
9
+import com.xhkjedu.smarking.utils.MarkingUtil;
10
+import com.xhkjedu.smarking.vo.report.reportclass.ClassTopVo;
11
+import com.xhkjedu.smarking.vo.report.reportclass.RankRateGroupVo;
12
+import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
13
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
14
+import com.xhkjedu.utils.N_Utils;
15
+import org.springframework.stereotype.Service;
16
+
17
+import javax.annotation.Resource;
18
+import java.util.*;
19
+import java.util.stream.Collectors;
20
+
21
+/**
22
+ *@Description : 班级生成报告服务
23
+ *@Author ywx
24
+ *Date 2025/1/3 11:07
25
+ **/
26
+@Service
27
+public class ReportGenerateClassService {
28
+    @Resource
29
+    private MsrReportparamService msrReportparamService;
30
+    @Resource
31
+    private MsrClassSubjectMapper msrClassSubjectMapper;
32
+    @Resource
33
+    private MsrClassTopMapper msrClassTopMapper;
34
+    @Resource
35
+    private MsrClassSubjectGradeMapper msrClassSubjectGradeMapper;
36
+    @Resource
37
+    private MsrClassRankgroupMapper msrClassRankgroupMapper;
38
+    @Resource
39
+    private MsrClassRankrateMapper msrClassRankrateMapper;
40
+    @Resource
41
+    private MsrClassSectionMapper msrClassSectionMapper;
42
+    @Resource
43
+    private MsrClassNearlineMapper msrClassNearlineMapper;
44
+    @Resource
45
+    private MsrClassGoodbadMapper msrClassGoodbadMapper;
46
+
47
+    //班级学科前60分析
48
+    public void saveClassTop(Integer examid, List<MsrStudent> msrStudents) {
49
+        List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
50
+        Map<String, ClassTopVo> lsMap = new HashMap<>();//处于年级60%得分map
51
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
52
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
53
+            MarkingUtil.studentsDistinct(entry, null);
54
+            String subjectid = entry.getKey().split("_")[1];
55
+            List<Double> scores = entry.getValue().stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
56
+            Double lsscore = MarkingUtil.cynjdf(scores, 0.6);
57
+            List<MsrStudent> lsstudents = entry.getValue().stream().filter(s -> s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
58
+            ClassTopVo classTopVo = new ClassTopVo();
59
+            classTopVo.setSubjectid(subjectid);
60
+            classTopVo.setLsscore(lsscore);
61
+            classTopVo.setXtnum(lsstudents.size());
62
+            double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
63
+            classTopVo.setXtavgscore(N_Utils.formatDouble(average, 2));
64
+            String xtstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
65
+            classTopVo.setXtstuids(xtstuids);
66
+            lsMap.put(subjectid, classTopVo);
67
+        }
68
+        setClassTop(examid, collect, lsMap, msrClassTops);
69
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
70
+        setClassTop(examid, scCollect, lsMap, msrClassTops);
71
+        msrClassTopMapper.insertList(msrClassTops);
72
+    }
73
+
74
+    //班级学科前60计算
75
+    private void setClassTop(Integer examid, Map<String, List<MsrStudent>> scCollect, Map<String, ClassTopVo> lsMap
76
+            , List<MsrClassTop> msrClassTops) {
77
+        Integer totalnum;
78
+        String subjectid;
79
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
80
+            String key = entry.getKey();
81
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
82
+            subjectid = key.split("_")[1];
83
+            List<MsrStudent> studentList = entry.getValue();
84
+            totalnum = studentList.size();//区间总人数
85
+
86
+            MsrClassTop msrClassTop = new MsrClassTop();
87
+            msrClassTop.setExamid(examid);
88
+            msrClassTop.setClassid(classid);
89
+            msrClassTop.setSubjectid(subjectid);
90
+            msrClassTop.setStunum(totalnum);
91
+            ClassTopVo classTopVo = lsMap.get(subjectid);//处于年级60%得分
92
+            Double lsscore = classTopVo.getLsscore();
93
+            List<MsrStudent> lsstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
94
+            msrClassTop.setBtnum(lsstudents.size());
95
+            msrClassTop.setBtrate(N_Utils.getIntegerDivideAndMulitiply(msrClassTop.getBtnum(), totalnum));
96
+            double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
97
+            msrClassTop.setBtavgscore(N_Utils.formatDouble(average, 2));
98
+            String btstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
99
+            msrClassTop.setBtstuids(btstuids);
100
+            msrClassTop.setXtnum(classTopVo.getXtnum());
101
+            msrClassTop.setXtavgscore(classTopVo.getXtavgscore());
102
+            msrClassTop.setXtstuids(classTopVo.getXtstuids());
103
+            msrClassTops.add(msrClassTop);
104
+        }
105
+    }
106
+
107
+    //班级学科四率等级分析
108
+    public void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
109
+        Map<String, List<SzJsonVo>> qjMap = formatSzJson(msrReportparamService.getMsrReportParams(examid, "scorerate", reportcode));
110
+        List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
111
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
112
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
113
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
114
+            MarkingUtil.studentsDistinct(entry, rsMap);
115
+        }
116
+        setClassSubjectGrade(examid, reportcode, collect, qjMap, msrClassSubjectGrades, rsMap);
117
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
118
+        setClassSubjectGrade(examid, reportcode, scCollect, qjMap, msrClassSubjectGrades, rsMap);
119
+        msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
120
+    }
121
+
122
+    //格式化报告参数
123
+    private Map<String, List<SzJsonVo>> formatSzJson(List<MsrReportparam> list) {
124
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
125
+        for (MsrReportparam param : list) {
126
+            qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
127
+        }
128
+        return qjMap;
129
+    }
130
+
131
+    //班级学科四率等级计算
132
+    private void setClassSubjectGrade(Integer examid, String reportcode, Map<String, List<MsrStudent>> scCollect
133
+            , Map<String, List<SzJsonVo>> qjMap, List<MsrClassSubjectGrade> msrClassSubjectGrades
134
+            , Map<String, Integer> rsMap) {
135
+        int totalnum;
136
+        String subjectid;
137
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
138
+            String key = entry.getKey();
139
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
140
+            subjectid = key.split("_")[1];
141
+            List<SzJsonVo> list = qjMap.get(subjectid);
142
+            List<MsrStudent> studentList = entry.getValue();
143
+            totalnum = rsMap.get(subjectid);//科目总人数
144
+            Double fullscore1 = studentList.get(0).getFullscore();
145
+            for (SzJsonVo rg : list) {
146
+                String qjname = rg.getDjkey();
147
+                double min = MarkingUtil.mul(rg.getMinvalue(), fullscore1);
148
+                double max = MarkingUtil.mul(rg.getMaxvalue(), fullscore1);
149
+                List<MsrStudent> qjstudents;
150
+                if (fullscore1.compareTo(max) == 0) {
151
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
152
+                } else {
153
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0 && s.getStuscore().compareTo(max) < 0).collect(Collectors.toList());
154
+                }
155
+                int qjnum = qjstudents.size();
156
+                MsrClassSubjectGrade classSubjectGrade = new MsrClassSubjectGrade();
157
+                classSubjectGrade.setExamid(examid);
158
+                classSubjectGrade.setSubjectid(subjectid);
159
+                classSubjectGrade.setClassid(classid);
160
+                classSubjectGrade.setReportcode(reportcode);
161
+                classSubjectGrade.setRangename(qjname);
162
+                classSubjectGrade.setRangenum(qjnum);
163
+                classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
164
+                double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
165
+                classSubjectGrade.setDjscore(N_Utils.formatDouble(qjavg, 2));
166
+                classSubjectGrade.setDjrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
167
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
168
+                classSubjectGrade.setStuids(stuids);
169
+                msrClassSubjectGrades.add(classSubjectGrade);
170
+            }
171
+        }
172
+        Map<String, List<MsrClassSubjectGrade>> collect = msrClassSubjectGrades.stream().collect(Collectors.groupingBy(g -> g.getSubjectid() + "_" + g.getRangename()));
173
+        for (Map.Entry<String, List<MsrClassSubjectGrade>> entry : collect.entrySet()) {
174
+            List<MsrClassSubjectGrade> nearlineList = entry.getValue();
175
+            List<Integer> nums = new ArrayList<>();
176
+            for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
177
+                nums.add(classSubjectGrade.getRangenum());
178
+            }
179
+            Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
180
+            for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
181
+                classSubjectGrade.setRangenumrank(rspm.get(classSubjectGrade.getRangenum()));
182
+            }
183
+        }
184
+    }
185
+
186
+    //班级学科分析
187
+    public void saveClassSubject(Integer examid, List<MsrStudent> msrStudents) {
188
+        List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
189
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
190
+        List<MsrReportparam> scorerate = msrReportparamService.getMsrReportParams(examid, "scorerate", "zh");
191
+        Map<String, SzJsonVo> tsMap = new HashMap<>();//得分率头部学生比例map
192
+        int subjectnum = 0;
193
+        for (MsrReportparam reportparam : scorerate) {
194
+            SzJsonVo sz = new SzJsonVo();
195
+            String szjson = reportparam.getSzjson();
196
+            Integer rptype = reportparam.getRptype();
197
+            if (rptype.equals(2)) {
198
+                Map<String, Object> map = JSON.parseObject(szjson, Map.class);
199
+                sz.setAlltop(N_Utils.obj2Int(map.get("alltop")));
200
+                sz.setAllbottom(N_Utils.obj2Int(map.get("allbottom")));
201
+            }
202
+            String subjectid = reportparam.getSubjectid();
203
+            tsMap.put(subjectid, sz);
204
+            if (!"zf".equals(subjectid)) {
205
+                subjectnum++;
206
+            }
207
+        }
208
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
209
+        Map<String, List<Integer>> qkMap = new LinkedHashMap<>();//全科及格率学生map
210
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
211
+            MarkingUtil.studentsDistinct(entry, rsMap);
212
+            String key = entry.getKey();
213
+            String subjectid = key.split("_")[1];
214
+            SzJsonVo sz = tsMap.get(subjectid);
215
+            if (N_Utils.isTrueInteger(sz.getAlltop())) {
216
+                List<MsrStudent> studentList = entry.getValue();
217
+                List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
218
+                int totalnum = scores.size();
219
+                int index = (int) Math.ceil(MarkingUtil.div(MarkingUtil.mul(sz.getAlltop(), totalnum), 100));
220
+                if (index > totalnum) index = totalnum;
221
+                int goodvalue = studentList.subList(totalnum - index, totalnum).stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
222
+                int index2 = (int) Math.ceil(MarkingUtil.div(MarkingUtil.mul(sz.getAllbottom(), totalnum), 100));
223
+                if (index2 > totalnum) index2 = totalnum;
224
+                int badvalue = studentList.subList(0, index2).stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
225
+                sz.setGoodvalue(goodvalue);
226
+                sz.setBadvalue(badvalue);
227
+            }
228
+            //全科及格率
229
+            if (subjectid.equals("zf")) {
230
+                List<MsrClassSubjectGrade> grades = msrClassSubjectGradeMapper.listSubjectGradeForQk(examid, "zh");
231
+                if (N_Utils.isListNotEmpty(grades)) {
232
+                    Map<String, List<MsrClassSubjectGrade>> rcollect = grades.stream().collect(Collectors.groupingBy(MsrClassSubjectGrade::getRangename, LinkedHashMap::new, Collectors.toList()));
233
+                    for (Map.Entry<String, List<MsrClassSubjectGrade>> rentry : rcollect.entrySet()) {
234
+                        String rkey = rentry.getKey();
235
+                        List<MsrClassSubjectGrade> gradeList = rentry.getValue();
236
+                        String stuids = gradeList.get(0).getStuids();
237
+                        List<Integer> ids = new ArrayList<>();
238
+                        for (String id : stuids.split(",")) {
239
+                            ids.add(N_Utils.obj2Int(id));
240
+                        }
241
+                        if (subjectnum == 1) {
242
+                            qkMap.put(rkey, ids);
243
+                        } else if (N_Utils.isListNotEmpty(ids)) {
244
+                            for (int i = 1; i < gradeList.size(); i++) {
245
+                                MsrClassSubjectGrade grade = gradeList.get(i);
246
+                                String stuids2 = grade.getStuids();
247
+                                List<Integer> ids2 = new ArrayList<>();
248
+                                for (String id2 : stuids2.split(",")) {
249
+                                    ids2.add(N_Utils.obj2Int(id2));
250
+                                }
251
+                                //交集
252
+                                if (N_Utils.isListEmpty(ids2)) {
253
+                                    ids = new ArrayList<>();
254
+                                    break;
255
+                                }
256
+                                ids = ids.stream().filter(ids2::contains).collect(Collectors.toList());
257
+                                if (N_Utils.isListEmpty(ids)) {
258
+                                    ids = new ArrayList<>();
259
+                                    break;
260
+                                }
261
+
262
+                            }
263
+                        }
264
+                        qkMap.put(rkey, ids);
265
+                    }
266
+                }
267
+            }
268
+        }
269
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "allrate", "all");
270
+        SzJsonVo vo = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
271
+        String calformula = vo.getCalformula();
272
+        Map<String, MsrClassSubject> csMap = new HashMap<>();//班级学科map
273
+        setClassSubject(examid, collect, msrClassSubjects, csMap, calformula, tsMap, qkMap);
274
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
275
+        setClassSubject(examid, scCollect, msrClassSubjects, csMap, calformula, tsMap, qkMap);
276
+
277
+        Map<String, List<MsrClassSubject>> scollect = msrClassSubjects.stream().collect(Collectors.groupingBy(MsrClassSubject::getSubjectid));
278
+        for (Map.Entry<String, List<MsrClassSubject>> entry : scollect.entrySet()) {
279
+            List<MsrClassSubject> nearlineList = entry.getValue();
280
+            if (entry.getKey().equals("zf")) {
281
+                Map<String, List<Integer>> qknum = new LinkedHashMap<>();
282
+                for (MsrClassSubject cs : nearlineList) {
283
+                    List<MsrClassSubjectGrade> grades = cs.getGrades();
284
+                    for (MsrClassSubjectGrade grade : grades) {
285
+                        String rangename = grade.getRangename();
286
+                        Integer rangenum = grade.getRangenum();
287
+                        if (qknum.containsKey(rangename)) {
288
+                            qknum.get(rangename).add(rangenum);
289
+                        } else {
290
+                            qknum.put(rangename, new ArrayList<>(Collections.singletonList(rangenum)));
291
+                        }
292
+                    }
293
+                }
294
+                Map<String, Map<Integer, Integer>> qkpm = new LinkedHashMap<>();
295
+                for (Map.Entry<String, List<Integer>> entry2 : qknum.entrySet()) {
296
+                    Map<Integer, Integer> rspm = MarkingUtil.rspm(entry2.getValue());
297
+                    qkpm.put(entry2.getKey(), rspm);
298
+                }
299
+
300
+                for (MsrClassSubject cs : nearlineList) {
301
+                    List<MsrClassSubjectGrade> grades = cs.getGrades();
302
+                    for (MsrClassSubjectGrade grade : grades) {
303
+                        String rangename = grade.getRangename();
304
+                        Integer rangenum = grade.getRangenum();
305
+                        Integer rank = qkpm.get(rangename).get(rangenum);
306
+                        grade.setRangenumrank(rank);
307
+                    }
308
+                    cs.setQkjgl(JSON.toJSONString(grades));
309
+                }
310
+            }
311
+            List<Double> classavgscore = new ArrayList<>();//班级平均分列表
312
+            List<Double> bzf = new ArrayList<>();//标准分列表
313
+            List<Double> cjl = new ArrayList<>();//超均率列表
314
+            List<Double> bjl = new ArrayList<>();//比均率列表
315
+            List<Double> zws = new ArrayList<>();//中位数列表
316
+            List<Double> ljc = new ArrayList<>();//离均差列表
317
+            List<Double> zs = new ArrayList<>();//众数列表
318
+            for (MsrClassSubject cs : nearlineList) {
319
+                classavgscore.add(cs.getClassavgscore());
320
+                bzf.add(cs.getBzf());
321
+                cjl.add(cs.getCjl());
322
+                bjl.add(cs.getBjl());
323
+                zws.add(cs.getZws());
324
+                ljc.add(cs.getLjc());
325
+                zs.add(cs.getZsmax());
326
+            }
327
+            Map<Double, Integer> pjfpm = MarkingUtil.fspm(classavgscore);//班级平均分排名
328
+            Map<Double, Integer> bzfpm = MarkingUtil.fspm(bzf);//标准分排名
329
+            Map<Double, Integer> cjlpm = MarkingUtil.fspm(cjl);//超均率排名
330
+            Map<Double, Integer> bjlpm = MarkingUtil.fspm(bjl);//比均率排名
331
+            Map<Double, Integer> zwspm = MarkingUtil.fspm(zws);//中位数排名
332
+            Map<Double, Integer> ljcpm = MarkingUtil.fspm(ljc);//离均差排名
333
+            Map<Double, Integer> zspm = MarkingUtil.fspm(zs);//众数排名
334
+            for (MsrClassSubject cs : nearlineList) {
335
+                cs.setClassavgrank(pjfpm.get(cs.getClassavgscore()));
336
+                cs.setBzfrank(bzfpm.get(cs.getBzf()));
337
+                cs.setCjlrank(cjlpm.get(cs.getCjl()));
338
+                cs.setBjlrank(bjlpm.get(cs.getBjl()));
339
+                cs.setZwsrank(zwspm.get(cs.getZws()));
340
+                cs.setLjcrank(ljcpm.get(cs.getLjc()));
341
+                cs.setZsrank(zspm.get(cs.getZsmax()));
342
+            }
343
+        }
344
+        msrClassSubjectMapper.insertList(msrClassSubjects);
345
+    }
346
+
347
+    //班级学科计算
348
+    private void setClassSubject(Integer examid, Map<String, List<MsrStudent>> scCollect
349
+            , List<MsrClassSubject> msrClassSubjects, Map<String, MsrClassSubject> csMap, String calformula
350
+            , Map<String, SzJsonVo> tsMap, Map<String, List<Integer>> qkMap) {
351
+        String subjectid;
352
+        MsrClassSubject zf = csMap.get("zf");
353
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
354
+            String key = entry.getKey();
355
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
356
+            subjectid = key.split("_")[1];
357
+            SzJsonVo ts = tsMap.get(subjectid);
358
+            MsrClassSubject gs = csMap.get(subjectid);
359
+            List<MsrStudent> studentList = entry.getValue();
360
+            studentList.sort(Comparator.comparing(MsrStudent::getStuscore));
361
+            MsrStudent minStudent = studentList.get(0);
362
+            int stunum = studentList.size();
363
+            MsrStudent maxStudent = studentList.get(stunum - 1);
364
+            Double fullscore = minStudent.getFullscore();
365
+            MsrClassSubject msrClassSubject = new MsrClassSubject();
366
+            if ("zf".equals(subjectid)) {
367
+                List<Integer> studentids = studentList.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
368
+                List<MsrClassSubjectGrade> grades = new ArrayList<>();
369
+                for (Map.Entry<String, List<Integer>> entry2 : qkMap.entrySet()) {
370
+                    String key2 = entry2.getKey();
371
+                    List<Integer> ids = entry2.getValue();
372
+                    //ids与studentList的studentid交集
373
+                    List<Integer> ids2 = ids.stream().filter(studentids::contains).collect(Collectors.toList());
374
+                    MsrClassSubjectGrade grade = new MsrClassSubjectGrade();
375
+                    grade.setRangename(key2);
376
+                    int rangenum = ids2.size();
377
+                    grade.setRangenum(rangenum);
378
+                    grade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(rangenum, stunum));
379
+                    grade.setStuids(ids2.stream().map(Object::toString).collect(Collectors.joining(",")));
380
+                    grades.add(grade);
381
+                }
382
+                msrClassSubject.setGrades(grades);
383
+            }
384
+            msrClassSubject.setExamid(examid);
385
+            msrClassSubject.setSubjectid(subjectid);
386
+            msrClassSubject.setClassid(classid);
387
+            msrClassSubject.setFullscore(fullscore);
388
+            msrClassSubject.setClassmaxscore(maxStudent.getStuscore());
389
+            msrClassSubject.setClassmaxrank(maxStudent.getSchoolrank());
390
+            msrClassSubject.setClassminscore(minStudent.getStuscore());
391
+            msrClassSubject.setClassminrank(minStudent.getSchoolrank());
392
+            List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).collect(Collectors.toList());
393
+            double classavgscore = N_Utils.formatDouble(scores.stream().mapToDouble(Double::doubleValue).summaryStatistics().getAverage(), 2);
394
+            msrClassSubject.setClassavgscore(classavgscore);
395
+            double classavgrate = N_Utils.getDoubleDivideAndMulitiply(classavgscore, fullscore);
396
+            msrClassSubject.setClassavgrate(classavgrate);
397
+            msrClassSubject.setBzc(MarkingUtil.bzc(scores));
398
+            if (classid.equals(0)) {
399
+                msrClassSubject.setSchoolmaxscore(msrClassSubject.getClassmaxscore());
400
+                msrClassSubject.setSchoolminscore(msrClassSubject.getClassminscore());
401
+                msrClassSubject.setSchoolavgscore(msrClassSubject.getClassavgscore());
402
+                msrClassSubject.setSchoolavgrate(msrClassSubject.getClassavgrate());
403
+                msrClassSubject.setBzf(0.0);
404
+                msrClassSubject.setCjl(0.0);
405
+                msrClassSubject.setLjc(0.0);
406
+                msrClassSubject.setBjl(1.0);
407
+                msrClassSubject.setDfgxzs(0.0);
408
+                msrClassSubject.setPjfgxzs(0.0);
409
+            } else {
410
+                Double schoolavgscore = gs.getClassavgscore();
411
+                msrClassSubject.setSchoolmaxscore(gs.getClassmaxscore());
412
+                msrClassSubject.setSchoolminscore(gs.getClassminscore());
413
+                msrClassSubject.setSchoolavgscore(schoolavgscore);
414
+                msrClassSubject.setSchoolavgrate(gs.getClassavgrate());
415
+                msrClassSubject.setBzf(MarkingUtil.bzf(classavgscore, schoolavgscore, gs.getBzc()));
416
+                msrClassSubject.setCjl(MarkingUtil.cjl(classavgscore, schoolavgscore));
417
+                msrClassSubject.setLjc(MarkingUtil.sub(classavgscore, schoolavgscore));
418
+                msrClassSubject.setBjl(1.0);
419
+                msrClassSubject.setDfgxzs(MarkingUtil.sub(classavgrate, zf.getClassavgrate()));
420
+                msrClassSubject.setPjfgxzs(MarkingUtil.sub(classavgscore, zf.getClassavgscore()));
421
+            }
422
+            msrClassSubject.setZws(MarkingUtil.zws(scores));
423
+            List<Double> zs = MarkingUtil.zs(scores);
424
+            msrClassSubject.setZs(JSON.toJSONString(zs));
425
+            msrClassSubject.setZsmax(zs.stream().max(Double::compareTo).orElse(0.0));
426
+            if (N_Utils.isNotEmpty(calformula)) {
427
+                calformula = calformula.replaceAll("平均分", msrClassSubject.getClassavgscore() + "");
428
+                calformula = calformula.replaceAll("标准差", msrClassSubject.getBzc() + "");
429
+                calformula = calformula.replaceAll("最高分", msrClassSubject.getClassmaxscore() + "");
430
+                calformula = calformula.replaceAll("最低分", msrClassSubject.getClassminscore() + "");
431
+                calformula = calformula.replaceAll("超均率", msrClassSubject.getCjl() + "");
432
+                calformula = calformula.replaceAll("标准分", msrClassSubject.getBzf() + "");
433
+                calformula = calformula.replaceAll("中位数", msrClassSubject.getZws() + "");
434
+                calformula = calformula.replaceAll("离均差", msrClassSubject.getLjc() + "");
435
+                calformula = calformula.replaceAll("比均率", msrClassSubject.getBjl() + "");
436
+                calformula = calformula.replaceAll("众数", msrClassSubject.getZsmax() + "");
437
+                msrClassSubject.setZhl(MarkingUtil.evaluate(calformula));
438
+            }
439
+
440
+            if (N_Utils.isTrueInteger(ts.getAlltop())) {
441
+                Double goodAvgScore = N_Utils.formatDouble(studentList.stream().filter(s -> s.getSchoolrank().compareTo(ts.getGoodvalue()) <= 0)
442
+                                                                      .mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
443
+                Double badAvgScore = N_Utils.formatDouble(studentList.stream().filter(s -> s.getSchoolrank().compareTo(ts.getBadvalue()) >= 0)
444
+                                                                     .mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
445
+                msrClassSubject.setJhl(MarkingUtil.div(badAvgScore, goodAvgScore));
446
+            }
447
+
448
+            if (classid.equals(0)) {
449
+                csMap.put(subjectid, msrClassSubject);
450
+            }
451
+            msrClassSubjects.add(msrClassSubject);
452
+        }
453
+    }
454
+
455
+    //学科报告-班级学科名次分组分析
456
+    public void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
457
+        List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
458
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
459
+        Map<String, List<RankGroupVo>> groupsMap = new HashMap<>();
460
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
461
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
462
+            MarkingUtil.studentsDistinct(entry, rsMap);
463
+            List<MsrStudent> studentList = entry.getValue();
464
+            int maxRank = studentList.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
465
+            List<RankGroupVo> groups = MarkingUtil.rankGroup(maxRank, 10);
466
+            groupsMap.put(studentList.get(0).getSubjectid(), groups);
467
+        }
468
+        setClassRankGroup(examid, collect, classRankGroups, groupsMap);
469
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
470
+        setClassRankGroup(examid, scCollect, classRankGroups, groupsMap);
471
+        msrClassRankgroupMapper.insertList(classRankGroups);
472
+    }
473
+
474
+    //学科报告-班级学科名次分组计算
475
+    private void setClassRankGroup(Integer examid, Map<String, List<MsrStudent>> scCollect
476
+            , List<MsrClassRankgroup> classRankGroups, Map<String, List<RankGroupVo>> groupsMap) {
477
+        String subjectid;
478
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
479
+            String key = entry.getKey();
480
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
481
+            subjectid = key.split("_")[1];
482
+            List<MsrStudent> studentList = entry.getValue();
483
+            List<RankGroupVo> groups = groupsMap.get(subjectid);
484
+            for (RankGroupVo group : groups) {
485
+                int maxvalue = group.getMaxvalue();
486
+                int minvalue = group.getMinvalue();
487
+                List<MsrStudent> qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(minvalue) >= 0 && s.getSchoolrank().compareTo(maxvalue) <= 0).collect(Collectors.toList());
488
+                MsrClassRankgroup cg = new MsrClassRankgroup();
489
+                cg.setExamid(examid);
490
+                cg.setClassid(classid);
491
+                cg.setSubjectid(subjectid);
492
+                cg.setRname(group.getGroupname());
493
+                cg.setRnum(qjstudents.size());
494
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
495
+                cg.setStuids(stuids);
496
+                classRankGroups.add(cg);
497
+            }
498
+        }
499
+    }
500
+
501
+    //综合报表-名次和比例分析
502
+    public void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
503
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "rankrate", "zh");
504
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
505
+        Map<String, Integer> tMap = new HashMap<>();
506
+        for (MsrReportparam param : params) {
507
+            String subjectid = param.getSubjectid();
508
+            qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
509
+            tMap.put(subjectid, param.getRptype());
510
+        }
511
+        List<MsrClassRankrate> classRankrates = new ArrayList<>();
512
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
513
+        Map<String, List<RankRateGroupVo>> sgMap = new HashMap<>();//学科名次分组map
514
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
515
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
516
+            MarkingUtil.studentsDistinct(entry, rsMap);
517
+            List<RankRateGroupVo> subjectGroupList = new ArrayList<>();//学科名次分组列表
518
+            String subjectid = entry.getKey().split("_")[1];
519
+            List<SzJsonVo> list = qjMap.get(subjectid);
520
+            Integer rptype = tMap.get(subjectid);
521
+            List<MsrStudent> studentList = entry.getValue();
522
+            if (rptype.equals(3)) {
523
+                studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
524
+            }
525
+            int totalnum = studentList.size();//总人数
526
+            Double max = null;
527
+            Integer minRank = null;
528
+            int minIndex = 0;
529
+            Object minRate = null;
530
+            for (SzJsonVo rg : list) {
531
+                Object djvalue = rg.getDjvalue();
532
+                RankRateGroupVo group = new RankRateGroupVo();
533
+                List<MsrStudent> qjstudents;
534
+                String ztname;
535
+                String ctname;
536
+                if (rptype.equals(1)) {//按名次
537
+                    ztname = "前" + djvalue + "名";
538
+                    Integer rank = N_Utils.obj2Int(djvalue);
539
+                    if (minRank == null) {
540
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
541
+                    } else {
542
+                        Integer finalMinRank = minRank;
543
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) > 0 && s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
544
+                        group.setMinrank(minRank);
545
+                    }
546
+                    group.setMaxrank(rank);
547
+                    minRank = rank;
548
+                    double minScore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
549
+                    ctname = ">=" + minScore + "分";
550
+                } else if (rptype.equals(2)) {//按分数
551
+                    ztname = ">=" + djvalue + "分";
552
+                    Double score = MarkingUtil.objToDouble(djvalue);
553
+                    double minScore = score;
554
+                    if (max == null) {
555
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
556
+                    } else {
557
+                        Double finalMax = max;
558
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
559
+                        group.setMaxscore(max);
560
+                    }
561
+                    group.setMinscore(minScore);
562
+                    max = score;
563
+                    minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
564
+                    ctname = "前" + minRank + "名";
565
+                } else {//按比例
566
+                    if (minIndex == 0) {
567
+                        ztname = "前" + djvalue + "%";
568
+                    } else {
569
+                        ztname = "前" + minRate + "%-" + djvalue + "%";
570
+                    }
571
+                    int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
572
+                    if (index > totalnum) index = totalnum;
573
+                    qjstudents = studentList.subList(minIndex, index);
574
+                    minIndex = index;
575
+                    minRate = djvalue;
576
+                    DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
577
+                    double minScore = N_Utils.handleInfinity(statistics.getMin());
578
+                    double maxScore = N_Utils.handleInfinity(statistics.getMax());
579
+                    ctname = "[" + minScore + "-" + maxScore + "]";
580
+                    group.setMaxscore(maxScore);
581
+                    group.setMinscore(minScore);
582
+                }
583
+                group.setRtype(rptype);
584
+                group.setZtname(ztname);
585
+                group.setCtname(ctname);
586
+                subjectGroupList.add(group);
587
+            }
588
+            sgMap.put(subjectid, subjectGroupList);
589
+        }
590
+        setClassRankRate(examid, collect, classRankrates, sgMap, rsMap);
591
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
592
+        setClassRankRate(examid, scCollect, classRankrates, sgMap, rsMap);
593
+        msrClassRankrateMapper.insertList(classRankrates);
594
+    }
595
+
596
+    //综合报表-名次和比例计算
597
+    private void setClassRankRate(Integer examid, Map<String, List<MsrStudent>> scCollect
598
+            , List<MsrClassRankrate> classRankrates, Map<String, List<RankRateGroupVo>> sgMap
599
+            , Map<String, Integer> rsMap) {
600
+        int totalnum;
601
+        String subjectid;
602
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
603
+            String key = entry.getKey();
604
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
605
+            subjectid = key.split("_")[1];
606
+            totalnum = rsMap.get(subjectid);
607
+            List<RankRateGroupVo> list = sgMap.get(subjectid);
608
+            Integer rptype = list.get(0).getRtype();
609
+            List<MsrStudent> studentList = entry.getValue();
610
+            if (rptype.equals(3)) {
611
+                studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
612
+            }
613
+            int stunum = studentList.size();//参考人数
614
+            for (int i = 0; i < list.size(); i++) {
615
+                RankRateGroupVo rg = list.get(i);
616
+                List<MsrStudent> qjstudents;
617
+                if (rptype.equals(1)) {//按名次
618
+                    if (i == 0) {
619
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0).collect(Collectors.toList());
620
+                    } else {
621
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0 && s.getSchoolrank().compareTo(rg.getMinrank()) < 0).collect(Collectors.toList());
622
+                    }
623
+                } else {//按分数
624
+                    if (i == 0) {
625
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0).collect(Collectors.toList());
626
+                    } else {
627
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0 && s.getStuscore().compareTo(rg.getMaxscore()) < 0).collect(Collectors.toList());
628
+                    }
629
+                }
630
+                int qjnum = qjstudents.size();
631
+                MsrClassRankrate rankrate = new MsrClassRankrate();
632
+                rankrate.setExamid(examid);
633
+                rankrate.setSubjectid(subjectid);
634
+                rankrate.setClassid(classid);
635
+                rankrate.setStunum(stunum);
636
+                rankrate.setRtype(rptype);
637
+                rankrate.setZtname(rg.getZtname());
638
+                rankrate.setCtname(rg.getCtname());
639
+                rankrate.setRnum(qjnum);
640
+                rankrate.setRrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
641
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
642
+                rankrate.setStuids(stuids);
643
+                classRankrates.add(rankrate);
644
+            }
645
+        }
646
+    }
647
+
648
+    //分段统计
649
+    public void saveClassSection(Integer examid, Integer type, String reportcode, List<MsrStudent> msrStudents) {
650
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "scoresection", reportcode);
651
+        Integer rptype = params.get(0).getRptype();
652
+        Map<String, List<RankGroupVo>> fdMap = new HashMap<>();
653
+        if (rptype.equals(0)) {//固定步长
654
+            for (MsrReportparam param : params) {
655
+                SzJsonVo vo = JSON.parseObject(param.getSzjson(), SzJsonVo.class);
656
+                List<RankGroupVo> groups = MarkingUtil.fdScore(N_Utils.obj2Int(vo.getMaxvalue()), N_Utils.obj2Int(vo.getMinvalue()), N_Utils.obj2Int(vo.getDjvalue()), type);
657
+                fdMap.put(param.getSubjectid(), groups);
658
+            }
659
+        } else {//不定步长
660
+            for (MsrReportparam param : params) {
661
+                List<SzJsonVo> vos = JSON.parseArray(param.getSzjson(), SzJsonVo.class);
662
+                List<RankGroupVo> groups = MarkingUtil.fdScore(vos, type);
663
+                fdMap.put(param.getSubjectid(), groups);
664
+            }
665
+        }
666
+
667
+        List<MsrClassSection> classSections = new ArrayList<>();
668
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
669
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
670
+            MarkingUtil.studentsDistinct(entry, null);
671
+        }
672
+        setClassSection(examid, type, reportcode, collect, fdMap, classSections);
673
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
674
+        setClassSection(examid, type, reportcode, scCollect, fdMap, classSections);
675
+        msrClassSectionMapper.insertList(classSections);
676
+    }
677
+
678
+    //分段统计-计算
679
+    private void setClassSection(Integer examid, Integer type, String reportcode, Map<String, List<MsrStudent>> scCollect
680
+            , Map<String, List<RankGroupVo>> fdMap, List<MsrClassSection> classSections) {
681
+        String subjectid;
682
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
683
+            String key = entry.getKey();
684
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
685
+            subjectid = key.split("_")[1];
686
+            List<MsrStudent> studentList = entry.getValue();
687
+            Integer stunum = studentList.size();
688
+            List<RankGroupVo> groups = fdMap.get(subjectid);
689
+            for (int i = 0; i < groups.size(); i++) {
690
+                RankGroupVo group = groups.get(i);
691
+                int maxvalue = group.getMaxvalue();
692
+                int minvalue = group.getMinvalue();
693
+                List<MsrStudent> qjstudents;
694
+                if (type.equals(1)) {
695
+                    if (i == 0) {
696
+                        qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) <= 0).collect(Collectors.toList());
697
+                    } else {
698
+                        qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) < 0).collect(Collectors.toList());
699
+                    }
700
+                } else {
701
+                    qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), maxvalue) >= 0).collect(Collectors.toList());
702
+                }
703
+                MsrClassSection classSection = new MsrClassSection();
704
+                classSection.setExamid(examid);
705
+                classSection.setClassid(classid);
706
+                classSection.setSubjectid(subjectid);
707
+                classSection.setStunum(stunum);
708
+                classSection.setType(type);
709
+                classSection.setReportcode(reportcode);
710
+                classSection.setFzfw(group.getGroupname());
711
+                int qjnum = qjstudents.size();
712
+                classSection.setFzfwnum(qjnum);
713
+                classSection.setFzfwrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, stunum));
714
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
715
+                classSection.setStuids(stuids);
716
+                classSections.add(classSection);
717
+            }
718
+        }
719
+    }
720
+
721
+    //分档上线分析
722
+    public void saveClassNearLine(Integer examid, List<MsrStudent> msrStudents) {
723
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "gradescore", "all");
724
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
725
+        Map<String, Integer> tMap = new HashMap<>();
726
+        for (MsrReportparam param : params) {
727
+            String subjectid = param.getSubjectid();
728
+            qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
729
+            tMap.put(subjectid, param.getRptype());
730
+        }
731
+        params = msrReportparamService.getMsrReportParams(examid, "nearline", "all");
732
+        List<SzJsonVo> vos = JSON.parseArray(params.get(0).getSzjson(), SzJsonVo.class);
733
+        Map<Integer, List<Integer>> zfSx = null;//学生总分是否上线
734
+        List<MsrClassNearline> classNearlines = new ArrayList<>();
735
+        Map<String, List<MsrStudent>> collect0 = MarkingUtil.getSubjectCollect(msrStudents);
736
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
737
+        for (Map.Entry<String, List<MsrStudent>> entry : collect0.entrySet()) {
738
+            MarkingUtil.studentsDistinct(entry, rsMap);
739
+            if (entry.getKey().endsWith("zf")) {
740
+                zfSx = setZfsxMap(entry.getValue(), qjMap, tMap);
741
+            }
742
+            setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
743
+        }
744
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
745
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
746
+            setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
747
+        }
748
+        Map<String, List<MsrClassNearline>> collect = classNearlines.stream().collect(Collectors.groupingBy(l -> l.getSubjectid() + "_" + l.getDworder()));
749
+        for (Map.Entry<String, List<MsrClassNearline>> entry : collect.entrySet()) {
750
+            List<MsrClassNearline> nearlineList = entry.getValue();
751
+            List<Integer> nums = new ArrayList<>();
752
+            for (MsrClassNearline nearline : nearlineList) {
753
+                nums.add(nearline.getSxnum());
754
+            }
755
+            Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
756
+            for (MsrClassNearline nearline : nearlineList) {
757
+                nearline.setSxrank(rspm.get(nearline.getSxnum()));
758
+            }
759
+        }
760
+        msrClassNearlineMapper.insertList(classNearlines);
761
+    }
762
+
763
+    //分档上线计算
764
+    private void setClassNearLine(Integer examid, Map.Entry<String, List<MsrStudent>> entry, Map<String, List<SzJsonVo>> qjMap
765
+            , Map<String, Integer> tMap, List<SzJsonVo> vos, Map<Integer, List<Integer>> zfSx
766
+            , List<MsrClassNearline> classNearlines, Map<String, Integer> rsMap) {
767
+        String key = entry.getKey();
768
+        Integer classid = N_Utils.obj2Int(key.split("_")[0]);
769
+        String subjectid = key.split("_")[1];
770
+        int totalnum = rsMap.get(subjectid);
771
+        List<SzJsonVo> list = qjMap.get(subjectid);
772
+        Integer rptype = tMap.get(subjectid);
773
+        List<MsrStudent> studentList = entry.getValue();
774
+        if (rptype.equals(3)) {
775
+            studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
776
+        }
777
+        Double max = null;
778
+        Integer minRank = null;
779
+        int minIndex = 0;
780
+        for (int i = 0; i < list.size(); i++) {
781
+            SzJsonVo fd = vos.get(i);
782
+            Double fdMaxScore = fd.getMaxvalue();//档位浮动分数
783
+            if (fdMaxScore == null) fdMaxScore = MarkingUtil.objToDouble(fd.getDjvalue());
784
+            Double fdMinScore = fd.getMinvalue();//档位浮动分数
785
+            if (fdMinScore == null) {
786
+                fdMinScore = fdMaxScore;
787
+            }
788
+            SzJsonVo rg = list.get(i);
789
+            Object djvalue = rg.getDjvalue();
790
+            double dwscore;
791
+            List<MsrStudent> qjstudents;//上线学生列表
792
+            List<MsrStudent> ljstudents;//累计上线学生列表
793
+            if (rptype.equals(1)) {//按名次
794
+                Integer rank = N_Utils.obj2Int(djvalue);
795
+                ljstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
796
+                if (minRank == null) {
797
+                    qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
798
+                } else {
799
+                    Integer finalMinRank = minRank;
800
+                    qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
801
+                }
802
+                minRank = rank;
803
+                dwscore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
804
+            } else if (rptype.equals(2)) {//按分数
805
+                Double score = MarkingUtil.objToDouble(djvalue);
806
+                ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
807
+                if (max == null) {
808
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
809
+                } else {
810
+                    Double finalMax = max;
811
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
812
+                }
813
+                dwscore = MarkingUtil.objToDouble(djvalue);
814
+                max = score;
815
+                minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
816
+            } else {//按比例
817
+                int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
818
+                if (index > totalnum) index = totalnum;
819
+                qjstudents = studentList.subList(minIndex, index);
820
+                minIndex = index;
821
+                DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
822
+                dwscore = N_Utils.handleInfinity(statistics.getMin());
823
+                ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(dwscore) >= 0).collect(Collectors.toList());
824
+            }
825
+            int qjnum = qjstudents.size();
826
+            MsrClassNearline nearline = new MsrClassNearline();
827
+            nearline.setExamid(examid);
828
+            nearline.setSubjectid(subjectid);
829
+            nearline.setClassid(classid);
830
+            Integer dworder = i + 1;
831
+            String dwname = N_Utils.NumberToChn(dworder) + "档";
832
+            nearline.setDwname(dwname);
833
+            nearline.setDworder(dworder);
834
+            nearline.setDwscore(dwscore);
835
+            nearline.setSxnum(qjnum);
836
+            nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
837
+            int ljsxnum = ljstudents.size();
838
+            nearline.setLjsxnum(ljsxnum);
839
+            nearline.setLjsxrate(N_Utils.getIntegerDivideAndMulitiply(ljsxnum, totalnum));
840
+            if (!"zf".equals(subjectid)) {
841
+                List<Integer> zfsxIds = zfSx.get(dworder);//总分上线学生id列表
842
+                int zfsxnum = zfsxIds.size();
843
+                List<MsrStudent> ssxIds = qjstudents.stream().filter(s -> zfsxIds.contains(s.getStudentid())).collect(Collectors.toList());
844
+                Integer ssxnum = ssxIds.size();//双上线人数
845
+                nearline.setSsxnum(ssxnum);
846
+                nearline.setStuids2(ssxIds.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
847
+                //总分上线学科未上线人数
848
+                List<Integer> dksxIds = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
849
+                List<Integer> zfsxxkwsxIds = new ArrayList<>(zfsxIds);
850
+                zfsxxkwsxIds.removeAll(dksxIds);
851
+                int zfsxxkwsxnum = zfsxxkwsxIds.size();
852
+                nearline.setZfsxxkwsxnum(zfsxxkwsxnum);
853
+                nearline.setStuids5(zfsxxkwsxIds.stream().map(Object::toString).collect(Collectors.joining(",")));
854
+                nearline.setGxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, zfsxnum));
855
+                nearline.setMzxrate(N_Utils.getIntegerDivideAndMulitiply(ssxnum, qjnum));
856
+            }
857
+            nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
858
+            double ljMax = MarkingUtil.add(dwscore, fdMaxScore);
859
+            double ljMin = MarkingUtil.sub(dwscore, fdMinScore);
860
+            List<MsrStudent> ljStudents = studentList.stream().filter(s -> s.getStuscore().compareTo(ljMax) <= 0 && s.getStuscore().compareTo(ljMin) >= 0).collect(Collectors.toList());
861
+            nearline.setLjsnum(ljStudents.size());
862
+            nearline.setLjsavgscore(N_Utils.formatDouble(ljStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
863
+            nearline.setStuids3(ljStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
864
+            nearline.setStuids4(ljstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
865
+            String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
866
+            nearline.setStuids(stuids);
867
+            classNearlines.add(nearline);
868
+        }
869
+    }
870
+
871
+    //总分上线分析
872
+    private Map<Integer, List<Integer>> setZfsxMap(List<MsrStudent> studentList, Map<String, List<SzJsonVo>> qjMap
873
+            , Map<String, Integer> tMap) {
874
+        Map<Integer, List<Integer>> zfSx = new HashMap<>();
875
+        String subjectid = "zf";
876
+        int totalnum;
877
+        List<SzJsonVo> list = qjMap.get(subjectid);
878
+        Integer rptype = tMap.get(subjectid);
879
+        if (rptype.equals(3)) {
880
+            studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
881
+        }
882
+        totalnum = studentList.size();//总人数
883
+        Double max = null;
884
+        Integer minRank = null;
885
+        int minIndex = 0;
886
+        for (int i = 0; i < list.size(); i++) {
887
+            SzJsonVo rg = list.get(i);
888
+            Object djvalue = rg.getDjvalue();
889
+            List<MsrStudent> qjstudents;//上线学生列表
890
+            if (rptype.equals(1)) {//按名次
891
+                Integer rank = N_Utils.obj2Int(djvalue);
892
+                if (minRank == null) {
893
+                    qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
894
+                } else {
895
+                    Integer finalMinRank = minRank;
896
+                    qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
897
+                }
898
+                minRank = rank;
899
+            } else if (rptype.equals(2)) {//按分数
900
+                Double score = MarkingUtil.objToDouble(djvalue);
901
+                if (max == null) {
902
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
903
+                } else {
904
+                    Double finalMax = max;
905
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
906
+                }
907
+                max = score;
908
+                minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
909
+            } else {//按比例
910
+                int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
911
+                if (index > totalnum) index = totalnum;
912
+                qjstudents = studentList.subList(minIndex, index);
913
+                minIndex = index;
914
+            }
915
+
916
+            Integer dworder = i + 1;
917
+            List<Integer> ids = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
918
+            zfSx.put(dworder, ids);
919
+        }
920
+        return zfSx;
921
+    }
922
+
923
+    //重点学生-优劣名次统计
924
+    public void saveClassGoodBad(Integer examid, String all, List<MsrStudent> msrStudents) {
925
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "keystu", all);
926
+        SzJsonVo fd = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
927
+        List<MsrClassGoodbad> classGoodbads = new ArrayList<>();
928
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
929
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
930
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
931
+            MarkingUtil.studentsDistinct(entry, rsMap);
932
+            setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
933
+        }
934
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
935
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
936
+            setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
937
+        }
938
+        msrClassGoodbadMapper.insertList(classGoodbads);
939
+    }
940
+
941
+    //重点学生-优劣名次计算
942
+    private void setClassGoodBag(Integer examid, Map.Entry<String, List<MsrStudent>> entry, SzJsonVo fd
943
+            , List<MsrClassGoodbad> classGoodbads, Map<String, Integer> rsMap) {
944
+        String key = entry.getKey();
945
+        Integer classid = N_Utils.obj2Int(key.split("_")[0]);
946
+        String subjectid = key.split("_")[1];
947
+        int totalnum;
948
+        Integer goodtype = fd.getGoodtype();
949
+        Integer badtype = fd.getBadtype();
950
+        List<MsrStudent> studentList = entry.getValue().stream().sorted(Comparator.comparing(MsrStudent::getSchoolrank)).collect(Collectors.toList());
951
+        Double avgScore = N_Utils.formatDouble(studentList.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
952
+        totalnum = rsMap.get(subjectid);//科目总人数
953
+        Integer goodvalue = fd.getGoodvalue();
954
+        Integer badvalue = fd.getBadvalue();
955
+        List<MsrStudent> yxStudents;//优秀学生列表
956
+        List<MsrStudent> dtgStudents;//待提高学生列表
957
+        List<MsrStudent> dbStudents;//学科短板学生列表
958
+        if (goodtype.equals(1)) {//按名次
959
+            yxStudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(goodvalue) <= 0).collect(Collectors.toList());
960
+        } else {//按比例
961
+            int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, goodvalue));
962
+            if (index > totalnum) index = totalnum;
963
+            yxStudents = studentList.subList(0, index);
964
+        }
965
+        if (badtype.equals(1)) {//按名次
966
+            dtgStudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(badvalue) <= 0).collect(Collectors.toList());
967
+        } else {//按比例
968
+            int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, badvalue));
969
+            if (index > totalnum) index = totalnum;
970
+            //取后index个
971
+            dtgStudents = studentList.subList(totalnum - index, totalnum);
972
+        }
973
+        dbStudents = studentList.stream().filter(s -> s.getStuscore().compareTo(avgScore) <= 0).collect(Collectors.toList());
974
+        int yxnum = yxStudents.size();
975
+        MsrClassGoodbad goodbad = new MsrClassGoodbad();
976
+        goodbad.setExamid(examid);
977
+        goodbad.setSubjectid(subjectid);
978
+        goodbad.setClassid(classid);
979
+        goodbad.setYxnum(yxnum);
980
+        goodbad.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, totalnum));
981
+        goodbad.setYxavgscore(N_Utils.formatDouble(yxStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
982
+        int dtgnum = dtgStudents.size();
983
+        goodbad.setDtgnum(dtgnum);
984
+        goodbad.setDtgrate(N_Utils.getIntegerDivideAndMulitiply(dtgnum, totalnum));
985
+        goodbad.setDtgavgscore(N_Utils.formatDouble(dtgStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
986
+        goodbad.setDbnum(dbStudents.size());
987
+        goodbad.setStuids(yxStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
988
+        goodbad.setStuids2(dtgStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
989
+        goodbad.setStuids3(dbStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
990
+        classGoodbads.add(goodbad);
991
+    }
992
+
993
+}

+ 173
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateStudentService.java View File

@@ -0,0 +1,173 @@
1
+package com.xhkjedu.smarking.service.report.generate;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
6
+import com.xhkjedu.smarking.model.exam.MsClassStudent;
7
+import com.xhkjedu.smarking.model.paper.MsPaper;
8
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
9
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
10
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
11
+import com.xhkjedu.smarking.utils.MarkingUtil;
12
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
13
+import com.xhkjedu.utils.N_Utils;
14
+import org.springframework.stereotype.Service;
15
+
16
+import javax.annotation.Resource;
17
+import java.util.*;
18
+import java.util.stream.Collectors;
19
+
20
+/**
21
+ *@Description : 学生报告生成服务
22
+ *@Author ywx
23
+ *Date 2025/1/3 11:29
24
+ **/
25
+@Service
26
+public class ReportGenerateStudentService {
27
+    @Resource
28
+    private MsrStudentMapper msrStudentMapper;
29
+    @Resource
30
+    private MsrReportparamMapper msrReportparamMapper;
31
+
32
+    //保存学生成绩分析
33
+    public List<MsrStudent> saveStudent(Integer examid, List<MsPaper> subjects, List<MsrStudent> paperStudents
34
+            , List<MsClassStudent> students, Map<String, MsrSubject> subjectMap) {
35
+        List<MsrStudent> msrStudents = new ArrayList<>();
36
+        //等级参数
37
+        List<MsrReportparam> djParams = msrReportparamMapper.listReportparamByRpbelong(examid, "subjectshow", "all");
38
+        List<SzJsonVo> djList = new ArrayList<>();
39
+        if (N_Utils.isListNotEmpty(djParams)) {
40
+            djList = JSON.parseArray(djParams.get(0).getSzjson(), SzJsonVo.class);
41
+        }
42
+
43
+        double fullscore = subjects.stream().mapToDouble(MsPaper::getPscore).sum();
44
+        List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩(总分)
45
+        List<MsrStudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
46
+        Map<String, Integer> rsMap = new HashMap<>();//各科人数
47
+        Map<Integer, List<MsrStudent>> schoolCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
48
+        List<Double> zfScores = new ArrayList<>();
49
+        rsMap.put("zf", schoolCollect.entrySet().size());
50
+        for (Map.Entry<Integer, List<MsrStudent>> entry : schoolCollect.entrySet()) {
51
+            List<MsrStudent> list = entry.getValue();
52
+            Double stuscore = N_Utils.formatDouble(list.stream().mapToDouble(MsrStudent::getStuscore).sum(), 1);
53
+            zfScores.add(stuscore);
54
+        }
55
+        Map<Double, Integer> zfpm = MarkingUtil.fspm(zfScores);//总分分数排名
56
+        Map<String, Map<Double, Integer>> dkpm = new HashMap<>();//单科分数排名
57
+        for (MsPaper subject : subjects) {
58
+            String subjectid = subject.getSubjectid();
59
+            List<Double> dkScores = paperStudents.stream().filter(s -> s.getSubjectid().equals(subjectid)).map(MsrStudent::getStuscore).collect(Collectors.toList());
60
+            dkpm.put(subjectid, MarkingUtil.fspm(dkScores));
61
+            rsMap.put(subjectid, dkScores.size());
62
+        }
63
+
64
+        List<MsrStudent> paperStudents2 = new ArrayList<>();
65
+        Map<String, List<MsClassStudent>> sClassStudent = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid() + "_" + s.getStudentid()));
66
+        for (MsrStudent paperStudent : paperStudents) {
67
+            String subjectid = paperStudent.getSubjectid();
68
+            Integer studentid = paperStudent.getStudentid();
69
+            Double stuscore = paperStudent.getStuscore();
70
+            Double fullscore1 = paperStudent.getFullscore();
71
+            String key = subjectid + "_" + studentid;
72
+            for (MsClassStudent student : sClassStudent.get(key)) {
73
+                MsrStudent cs = new MsrStudent();
74
+                cs.setExamid(examid);
75
+                cs.setClassid(student.getClassid());
76
+                cs.setStudentid(student.getStudentid());
77
+                cs.setSubjectid(subjectid);
78
+                cs.setStuscore(stuscore);
79
+                cs.setFullscore(fullscore1);
80
+                paperStudents2.add(cs);
81
+            }
82
+        }
83
+        String subjectid;
84
+        Map<String, Double> bjdfMap = new HashMap<>();//班级得分
85
+        Map<Integer, List<MsrStudent>> cCollect = paperStudents2.stream().collect(Collectors.groupingBy(MsrStudent::getClassid));
86
+        Map<String, Map<Double, Integer>> bkpm = new HashMap<>();//班级科目分数排名
87
+        for (Map.Entry<Integer, List<MsrStudent>> entry : cCollect.entrySet()) {
88
+            Integer classid = entry.getKey();
89
+            subjectid = "zf";
90
+            List<MsrStudent> studentList = entry.getValue();
91
+
92
+            Map<Integer, List<MsrStudent>> sCollect = studentList.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
93
+            List<MsrStudent> rstudents = new ArrayList<>();
94
+            int totalnum = rsMap.get(subjectid);
95
+            List<Double> bkScores = new ArrayList<>();
96
+            for (Map.Entry<Integer, List<MsrStudent>> csEntry : sCollect.entrySet()) {
97
+                MsrStudent cs = new MsrStudent();
98
+                cs.setExamid(examid);
99
+                cs.setClassid(classid);
100
+                cs.setStudentid(csEntry.getKey());
101
+                cs.setSubjectid(subjectid);
102
+                Double stuscore = N_Utils.formatDouble(csEntry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum(), 1);
103
+                cs.setStuscore(stuscore);
104
+                cs.setFullscore(fullscore);
105
+                cs.setSchoolrank(zfpm.get(stuscore));
106
+                cs.setHighschool(setHighSchool(studentList, stuscore, totalnum));
107
+                rstudents.add(cs);
108
+                bkScores.add(stuscore);
109
+            }
110
+            bkpm.put(classid + "_" + subjectid, MarkingUtil.fspm(bkScores));
111
+            bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
112
+            classStudents.addAll(rstudents);
113
+            Map<String, List<MsrStudent>> subCollect = studentList.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid));
114
+            for (Map.Entry<String, List<MsrStudent>> ssEntry : subCollect.entrySet()) {
115
+                bkScores = new ArrayList<>();
116
+                subjectid = ssEntry.getKey();
117
+                rstudents = ssEntry.getValue();
118
+                Map<Double, Integer> dk = dkpm.get(subjectid);
119
+                totalnum = rsMap.get(subjectid);
120
+                double csScore = 0;
121
+                for (MsrStudent rstudent : rstudents) {
122
+                    Double stuscore = rstudent.getStuscore();
123
+                    rstudent.setSchoolrank(dk.get(stuscore));
124
+                    rstudent.setHighschool(setHighSchool(rstudents, stuscore, totalnum));
125
+                    csScore = MarkingUtil.add(csScore, stuscore);
126
+                    bkScores.add(stuscore);
127
+                }
128
+                bkpm.put(classid + "_" + subjectid, MarkingUtil.fspm(bkScores));
129
+                bjdfMap.put(classid + "_" + subjectid, csScore);
130
+                classSubjectStudents.addAll(rstudents);
131
+            }
132
+        }
133
+        //学生成绩分析
134
+        for (MsrStudent student : classStudents) {
135
+            setStudent(student, bkpm, bjdfMap, subjectMap, djList);
136
+        }
137
+        for (MsrStudent student : classSubjectStudents) {
138
+            setStudent(student, bkpm, bjdfMap, subjectMap, djList);
139
+        }
140
+        msrStudents.addAll(classStudents);
141
+        msrStudents.addAll(classSubjectStudents);
142
+        if (N_Utils.isListNotEmpty(msrStudents)) msrStudentMapper.insertList(msrStudents);
143
+        return msrStudents;
144
+    }
145
+
146
+    //超过年级百分比
147
+    private Double setHighSchool(List<MsrStudent> studentList, Double stuscore, int totalnum) {
148
+        long num1 = studentList.stream().filter(s -> s.getStuscore().compareTo(stuscore) == 0).count();
149
+        long num2 = studentList.stream().filter(s -> s.getStuscore().compareTo(stuscore) > 0).count();
150
+        int num = totalnum - N_Utils.obj2Int(num1) - N_Utils.obj2Int(num2);
151
+        return N_Utils.getIntegerDivideAndMulitiply(num, totalnum);
152
+    }
153
+
154
+    //设置学生分析计算参数
155
+    private void setStudent(MsrStudent student, Map<String, Map<Double, Integer>> bkpm
156
+            , Map<String, Double> bjdfMap, Map<String, MsrSubject> subjectMap, List<SzJsonVo> djList) {
157
+        String subjectid;
158
+        Integer classid = student.getClassid();
159
+        subjectid = student.getSubjectid();
160
+        student.setClassrank(bkpm.get(classid + "_" + subjectid).get(student.getStuscore()));
161
+        MsrSubject msrSubject = subjectMap.get(subjectid);
162
+        Double pjf = msrSubject.getAvgscore();//年级平均分
163
+        student.setBzf(MarkingUtil.bzf(bjdfMap.get(classid + "_" + subjectid), pjf, msrSubject.getBzc()));
164
+        student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
165
+        Integer totalnum = msrSubject.getTotalnum();
166
+        double rankrate = MarkingUtil.div(student.getSchoolrank(), totalnum);
167
+        student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
168
+        student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
169
+        double dfv = N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), msrSubject.getFullscore());
170
+        student.setGradevalue(MarkingUtil.dj(dfv, djList));
171
+    }
172
+
173
+}

+ 223
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGenerateSubjectService.java View File

@@ -0,0 +1,223 @@
1
+package com.xhkjedu.smarking.service.report.generate;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectClassMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
6
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentQuestionMapper;
7
+import com.xhkjedu.smarking.model.paper.MsPaper;
8
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
9
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
10
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
11
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
12
+import com.xhkjedu.smarking.service.report.reportother.MsrReportparamService;
13
+import com.xhkjedu.smarking.utils.MarkingUtil;
14
+import com.xhkjedu.smarking.vo.paper.SQScoreVo;
15
+import com.xhkjedu.smarking.vo.paper.SQuestionVo;
16
+import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
17
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
18
+import com.xhkjedu.utils.N_Utils;
19
+import org.springframework.stereotype.Service;
20
+
21
+import javax.annotation.Resource;
22
+import java.util.*;
23
+import java.util.stream.Collectors;
24
+
25
+/**
26
+ *@Description 科目生成报告服务
27
+ *@Author ywx
28
+ *Date 2025/1/3 11:08
29
+ **/
30
+@Service
31
+public class ReportGenerateSubjectService {
32
+    @Resource
33
+    private MsPaperStudentQuestionMapper paperStudentQuestionMapper;
34
+    @Resource
35
+    private MsrSubjectMapper msrSubjectMapper;
36
+    @Resource
37
+    private MsrSubjectClassMapper msrSubjectClassMapper;
38
+    @Resource
39
+    private MsrReportparamService msrReportparamService;
40
+
41
+    //保存科目分析
42
+    public Map<String, MsrSubject> saveSubject(Integer examid, List<MsrStudent> paperStudents
43
+            , List<MsPaper> subjects, List<Integer> mpids) {
44
+        double fullscore = subjects.stream().mapToDouble(MsPaper::getPscore).sum();
45
+        String subjectid;
46
+        //科目分析
47
+        Map<String, MsrSubject> subjectMap = new HashMap<>();//科目分析map
48
+        List<MsrSubject> msrSubjects = new ArrayList<>();
49
+        MsrSubject msrSubject = new MsrSubject();
50
+        msrSubject.setExamid(examid);
51
+        subjectid = "zf";
52
+        msrSubject.setSubjectid(subjectid);
53
+        msrSubject.setSubjectname("总分");
54
+        msrSubject.setFullscore(fullscore);
55
+        Map<Integer, List<MsrStudent>> collect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
56
+        List<MsrStudent> studentList = new ArrayList<>();
57
+        for (Map.Entry<Integer, List<MsrStudent>> entry : collect.entrySet()) {
58
+            MsrStudent student = new MsrStudent();
59
+            student.setStudentid(entry.getKey());
60
+            Double stuscore = N_Utils.formatDouble(entry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum(), 1);
61
+            student.setStuscore(stuscore);
62
+            student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(stuscore, fullscore));
63
+            int sstate = 0;
64
+            long count = entry.getValue().stream().filter(s -> s.getSstate().equals(2)).count();
65
+            if (count > 0) {
66
+                sstate = 2;
67
+            }
68
+            student.setSstate(sstate);
69
+            studentList.add(student);
70
+        }
71
+        List<SQScoreVo> questionScores = paperStudentQuestionMapper.listByMpIds(mpids);//获取参与统计科目单题得分情况
72
+        List<Double> zfmtfc = new ArrayList<>();
73
+        Map<String, List<Double>> dkMtfc = new HashMap<>();
74
+        for (SQScoreVo s : questionScores) {
75
+            List<Double> mtfc = new ArrayList<>();
76
+            List<SQuestionVo> questions = s.getQuestions();
77
+            for (SQuestionVo question : questions) {
78
+                double fc = MarkingUtil.fc(question.getStuscores());
79
+                zfmtfc.add(fc);
80
+                mtfc.add(fc);
81
+            }
82
+            dkMtfc.put(s.getSubjectid(), mtfc);
83
+        }
84
+        msrSubject.setMtfc(zfmtfc);
85
+        setSubject(msrSubject, studentList);
86
+        msrSubjects.add(msrSubject);
87
+        subjectMap.put(subjectid, msrSubject);
88
+        for (MsrStudent student : paperStudents) {
89
+            student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), student.getFullscore()));
90
+        }
91
+        Map<String, List<MsrStudent>> subjectCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid));
92
+        for (MsPaper subject : subjects) {
93
+            subjectid = subject.getSubjectid();
94
+            msrSubject = new MsrSubject();
95
+            msrSubject.setExamid(examid);
96
+            msrSubject.setSubjectid(subjectid);
97
+            msrSubject.setSubjectname(subject.getSubjectname());
98
+            msrSubject.setFullscore(subject.getPscore());
99
+            studentList = subjectCollect.get(subjectid);
100
+            msrSubject.setMtfc(dkMtfc.get(subjectid));
101
+            setSubject(msrSubject, studentList);
102
+            msrSubjects.add(msrSubject);
103
+            subjectMap.put(subjectid, msrSubject);
104
+        }
105
+        List<Double> avgScores = msrSubjects.stream().map(MsrSubject::getAvgscore).sorted().collect(Collectors.toList());
106
+        Map<Double, Integer> fspm = MarkingUtil.fspm(avgScores);//平均分排名
107
+        for (MsrSubject subject : msrSubjects) {
108
+            subject.setAvgrank(fspm.get(subject.getAvgscore()));
109
+            subject.setAvgrankrate(MarkingUtil.div(subject.getAvgrank(), subject.getTotalnum()));
110
+            String subjectid1 = subject.getSubjectid();
111
+            int pnum;//试卷中的题目总数
112
+            if ("zf".equals(subjectid1)) {
113
+                pnum = subjects.stream().mapToInt(MsPaper::getPnum).sum();
114
+            } else {
115
+                pnum = subjects.stream().filter(s -> s.getSubjectid().equals(subjectid1)).findFirst().get().getPnum();
116
+            }
117
+            subject.setAxdxs(MarkingUtil.axdxs(pnum, subject.getMtfc(), subject.getZffc()));
118
+        }
119
+        msrSubjectMapper.insertList(msrSubjects);
120
+        return subjectMap;
121
+    }
122
+
123
+    //设置科目分析计算参数
124
+    private void setSubject(MsrSubject msrSubject, List<MsrStudent> studentList) {
125
+        List<MsrStudent> studentList2 = studentList.stream().filter(s -> s.getSstate().equals(2)).collect(Collectors.toList());//参与统计学生列表
126
+        int totalnum = studentList.size();
127
+        int stunum = studentList2.size();
128
+        int missnum = totalnum - stunum;
129
+        msrSubject.setTotalnum(totalnum);
130
+        msrSubject.setStunum(stunum);
131
+        msrSubject.setNumrate(N_Utils.getIntegerDivideAndMulitiply(stunum, totalnum));
132
+        msrSubject.setMissnum(missnum);
133
+        DoubleSummaryStatistics subjectStatistics = studentList2.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
134
+        double subjectStatisticsMax = N_Utils.handleInfinity(subjectStatistics.getMax());
135
+        //最低分均不包括0分
136
+        double subjectStatisticsMin = N_Utils.handleInfinity(subjectStatistics.getMin());
137
+        double subjectStatisticsAverage = N_Utils.formatDouble(subjectStatistics.getAverage(), 2);
138
+        msrSubject.setMaxscore(subjectStatisticsMax);
139
+        msrSubject.setMinscore(subjectStatisticsMin);
140
+        msrSubject.setAvgscore(subjectStatisticsAverage);
141
+        Double avgscore = msrSubject.getAvgscore();
142
+        Double fullscore = msrSubject.getFullscore();
143
+        msrSubject.setScorerate(N_Utils.getDoubleDivideAndMulitiply(avgscore, fullscore));
144
+        List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
145
+        double bzc = MarkingUtil.bzc(scores);
146
+        msrSubject.setBzc(bzc);
147
+        msrSubject.setZffc(MarkingUtil.fc(scores));
148
+        msrSubject.setCyxs(N_Utils.getDoubleDivideAndMulitiply(bzc, avgscore));
149
+        msrSubject.setNd(MarkingUtil.div(avgscore, fullscore));
150
+        msrSubject.setQfd(MarkingUtil.qfd(scores));
151
+        List<Double> scoreRates = studentList.stream().map(MsrStudent::getScorerate).sorted().collect(Collectors.toList());
152
+        double dfllc = MarkingUtil.sub(scoreRates.get(scoreRates.size() - 1), scoreRates.get(0));
153
+        msrSubject.setDfllc(dfllc);
154
+        msrSubject.setDflxdlc(MarkingUtil.div(dfllc, msrSubject.getScorerate()));
155
+        msrSubject.setEsscore(MarkingUtil.cynjdf(scores, 0.2));
156
+        msrSubject.setSsscore(MarkingUtil.cynjdf(scores, 0.4));
157
+        msrSubject.setLsscore(MarkingUtil.cynjdf(scores, 0.6));
158
+        msrSubject.setBsscore(MarkingUtil.cynjdf(scores, 0.8));
159
+    }
160
+
161
+    //科目班级分数分布区间分析
162
+    public void saveSubjectClass(Integer examid, List<MsrStudent> msrStudents) {
163
+        Map<String, SzJsonVo> qjMap = new HashMap<>();
164
+        List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "scoresection", "xk");
165
+        for (MsrReportparam param : params) {
166
+            qjMap.put(param.getSubjectid(), JSON.parseObject(param.getSzjson(), SzJsonVo.class));
167
+        }
168
+        List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();//科目班级分数分布区间分析
169
+        Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
170
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
171
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
172
+            MarkingUtil.studentsDistinct(entry, rsMap);
173
+        }
174
+        setSubjectClass(examid, collect, qjMap, msrSubjectClasses, rsMap);
175
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
176
+        setSubjectClass(examid, scCollect, qjMap, msrSubjectClasses, rsMap);
177
+        msrSubjectClassMapper.insertList(msrSubjectClasses);
178
+    }
179
+
180
+    //科目班级分数分布区间计算
181
+    private void setSubjectClass(Integer examid, Map<String, List<MsrStudent>> scCollect, Map<String, SzJsonVo> qjMap
182
+            , List<MsrSubjectClass> msrSubjectClasses, Map<String, Integer> rsMap) {
183
+        Integer totalnum;
184
+        String subjectid;
185
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
186
+            String key = entry.getKey();
187
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
188
+            subjectid = key.split("_")[1];
189
+            SzJsonVo vo = qjMap.get(subjectid);
190
+            List<MsrStudent> studentList = entry.getValue();
191
+            totalnum = rsMap.get(subjectid);//科目总人数
192
+            Double fullscore = studentList.get(0).getFullscore();
193
+            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore, N_Utils.obj2Int(vo.getDjvalue()));
194
+            for (RankGroupVo rg : fdScore) {
195
+                int minscore = rg.getMinvalue();
196
+                int maxscore = rg.getMaxvalue();
197
+                String qjname = rg.getGroupname();
198
+                double min = MarkingUtil.objToDouble(minscore);
199
+                double max = MarkingUtil.objToDouble(maxscore);
200
+                List<MsrStudent> qjstudents;
201
+                if (fullscore.compareTo(max) == 0) {
202
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
203
+                } else {
204
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0 && s.getStuscore().compareTo(max) < 0).collect(Collectors.toList());
205
+                }
206
+                int qjnum = qjstudents.size();
207
+                MsrSubjectClass msrSubjectClass = new MsrSubjectClass();
208
+                msrSubjectClass.setExamid(examid);
209
+                msrSubjectClass.setSubjectid(subjectid);
210
+                msrSubjectClass.setClassid(classid);
211
+                msrSubjectClass.setQjname(qjname);
212
+                msrSubjectClass.setQjnum(qjnum);
213
+                msrSubjectClass.setQjrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
214
+                double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
215
+                msrSubjectClass.setQjavgrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore));
216
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
217
+                msrSubjectClass.setStuids(stuids);
218
+                msrSubjectClasses.add(msrSubjectClass);
219
+            }
220
+        }
221
+    }
222
+
223
+}

+ 33
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrActionService.java View File

@@ -0,0 +1,33 @@
1
+package com.xhkjedu.smarking.service.report.report;
2
+
3
+import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassActionMapper;
4
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentActionMapper;
5
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
6
+import org.springframework.stereotype.Service;
7
+
8
+import javax.annotation.Resource;
9
+import java.util.List;
10
+import java.util.Map;
11
+
12
+/**
13
+ *@Description 优秀违纪报告查询服务
14
+ *@Author ywx
15
+ *Date 2025/1/3 14:33
16
+ **/
17
+@Service
18
+public class MsrActionService {
19
+    @Resource
20
+    private MsrClassActionMapper msrClassActionMapper;
21
+    @Resource
22
+    private MsrStudentActionMapper msrStudentActionMapper;
23
+
24
+    //行为分析-班级
25
+    public List<Map> listXwBj(MsrStudentAction action) {
26
+        return msrClassActionMapper.listXwBj(action);
27
+    }
28
+
29
+    //行为分析-学生
30
+    public List<Map> listXwXs(MsrStudentAction action) {
31
+        return msrStudentActionMapper.listXwBj(action);
32
+    }
33
+}

+ 12
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrClassService.java View File

@@ -0,0 +1,12 @@
1
+package com.xhkjedu.smarking.service.report.report;
2
+
3
+import org.springframework.stereotype.Service;
4
+
5
+/**
6
+ *@Description 班级报告查询服务
7
+ *@Author ywx
8
+ *Date 2025/1/3 14:31
9
+ **/
10
+@Service
11
+public class MsrClassService {
12
+}

+ 45
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrSubjectService.java View File

@@ -0,0 +1,45 @@
1
+package com.xhkjedu.smarking.service.report.report;
2
+
3
+import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassSubjectGradeMapper;
4
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
6
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
7
+import org.springframework.stereotype.Service;
8
+
9
+import javax.annotation.Resource;
10
+import java.util.LinkedHashMap;
11
+import java.util.Map;
12
+
13
+/**
14
+ *@Description 科目报告查询服务
15
+ *@Author ywx
16
+ *Date 2025/1/3 14:32
17
+ **/
18
+@Service
19
+public class MsrSubjectService {
20
+    @Resource
21
+    private MsrSubjectMapper msrSubjectMapper;
22
+    @Resource
23
+    private MsrStudentMapper msrStudentMapper;
24
+    @Resource
25
+    private MsrClassSubjectGradeMapper msrClassSubjectGradeMapper;
26
+
27
+    /**
28
+     * @Description 总概览
29
+     * @Date 2025/1/3 15:49
30
+     * @Author YWX
31
+     * @Param [subject]
32
+     * @Return java.util.Map
33
+     **/
34
+    public Map<String, Object> listSubjectForZgl(MsrSubject subject) {
35
+        Integer examid = subject.getExamid();
36
+        Map<String, Object> map = new LinkedHashMap<>();
37
+        //总人数、平均分、标准差、难度、差异系数分析
38
+        map.put("subjects", msrSubjectMapper.listSubjectForZgl(examid));
39
+        //整体分数分布分析
40
+        map.put("scores", msrStudentMapper.listScoreForZgl(examid,"zf"));
41
+        //整体四率分析
42
+        map.put("scorerates", msrClassSubjectGradeMapper.getZfScoreRate(examid));
43
+        return map;
44
+    }
45
+}

+ 36
- 1489
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java
File diff suppressed because it is too large
View File


+ 9
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrReportparamService.java View File

@@ -126,4 +126,13 @@ public class MsrReportparamService {
126 126
         msrReportparamMapper.insertList(saveParams);
127 127
         return saveParams;
128 128
     }
129
+
130
+    //获取报告参数
131
+    public List<MsrReportparam> getMsrReportParams(Integer examid, String rpbelong, String reportcode) {
132
+        List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
133
+        if (N_Utils.isListEmpty(list) && !"all".equals(reportcode)) {
134
+            list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
135
+        }
136
+        return list;
137
+    }
129 138
 }

+ 35
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

@@ -3,6 +3,9 @@ package com.xhkjedu.smarking.utils;
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.alibaba.fastjson.JSONArray;
5 5
 import com.xhkjedu.smarking.config.ConfigKey;
6
+import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
7
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
8
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
6 9
 import com.xhkjedu.smarking.vo.paper.PaperFileVo;
7 10
 import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
8 11
 import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
@@ -799,6 +802,38 @@ public class MarkingUtil {
799 802
         return N_Utils.formatDouble((k / (k - 1)) * (1 - (sumA / b)), 2);
800 803
     }
801 804
 
805
+    //获取科学分组学生
806
+    public static Map<String, List<MsrStudent>> getSubjectCollect(List<MsrStudent> msrStudents) {
807
+        Map<String, List<MsrStudent>> map = new LinkedHashMap<>();
808
+        LinkedHashMap<String, List<MsrStudent>> collect = msrStudents.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid, LinkedHashMap::new, Collectors.toList()));
809
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
810
+            map.put("0_" + entry.getKey(), entry.getValue());
811
+        }
812
+        return map;
813
+    }
814
+
815
+    //学生去重
816
+    public static void studentsDistinct(Map.Entry<String, List<MsrStudent>> entry, Map<String, Integer> rsMap) {
817
+        //list根据学生id去重
818
+        Map<Integer, MsrStudent> map = new HashMap<>();
819
+        for (MsrStudent student : entry.getValue()) {
820
+            map.putIfAbsent(student.getStudentid(), student);
821
+        }
822
+        List<MsrStudent> list = new ArrayList<>(map.values());
823
+        entry.setValue(list);
824
+        if (rsMap != null) rsMap.put(list.get(0).getSubjectid(), list.size());
825
+    }
826
+
827
+    //获取报告参数
828
+    public static List<MsrReportparam> getMsrReportParams(MsrReportparamMapper msrReportparamMapper
829
+            ,Integer examid, String rpbelong, String reportcode) {
830
+        List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
831
+        if (N_Utils.isListEmpty(list) && !"all".equals(reportcode)) {
832
+            list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
833
+        }
834
+        return list;
835
+    }
836
+
802 837
     public static void main(String[] args) {
803 838
        List<RankGroupVo> list = fdScore(1.0,5);
804 839
        for (RankGroupVo rgvo : list) {

+ 4
- 0
smarking/src/main/resources/mapper/exam/MsClassMapper.xml View File

@@ -119,4 +119,8 @@
119 119
     <select id="listClassByExamidAndSubjectid" resultType="com.xhkjedu.smarking.model.exam.MsClass">
120 120
         select classid,classname,classtype from ms_class where examid=#{examid} and subjectid=#{subjectid} order by mcid
121 121
     </select>
122
+    <!--获取考试关联班级数量-->
123
+    <select id="getClassNumByExamId" resultType="java.lang.Integer">
124
+        select count(distinct classid) from ms_class where examid=#{examid}
125
+    </select>
122 126
 </mapper>

+ 13
- 0
smarking/src/main/resources/mapper/report/reportclass/MsrClassActionMapper.xml View File

@@ -22,4 +22,17 @@
22 22
         where psq.examid=#{examid} and psq.subjectid in(#{subjectids}) and hasbad=1
23 23
         group by psq.studentid, psq.subjectid
24 24
     </select>
25
+    <!--行为分析-班级-->
26
+    <select id="listXwBj" resultType="java.util.Map">
27
+        select c.classname,ca.classid,ca.subjectjson
28
+        from msr_rclass_action ca left join t_class c on ca.classid = c.classid
29
+        where ca.examid=#{action.examid} and ca.actiontype=#{action.actiontype}
30
+        <if test="action.classid!=null and action.classid!=0">
31
+            and ca.classid=#{action.classid}
32
+        </if>
33
+        <foreach collection="action.classids" item="classid" open="and ca.classid in(0," separator="," close=")">
34
+            ${classid}
35
+        </foreach>
36
+        order by c.classtype,c.classorder,c.classid
37
+    </select>
25 38
 </mapper>

+ 7
- 1
smarking/src/main/resources/mapper/report/reportclass/MsrClassSubjectGradeMapper.xml View File

@@ -7,12 +7,18 @@
7 7
         select * from msr_class_subject_grade where examid = #{sg.examid} and subjectid = #{sg.subjectId}
8 8
         and reportcode = #{sg.reportCode} and classid = #{sg.classId}
9 9
     </select>
10
-    <!--综合报告-班级堆积-全科及格率分析-->
10
+    <!--综合报告-班级对比-全科及格率分析-->
11 11
     <select id="listSubjectGradeForQk" resultType="com.xhkjedu.smarking.model.report.reportclass.MsrClassSubjectGrade">
12 12
         select subjectid,rangename,stuids
13 13
         from msr_class_subject_grade
14 14
         where examid = #{examid} and classid = 0 and reportcode = #{reportcode}
15 15
     </select>
16
+    <!--综合报告-整体四率分析-->
17
+    <select id="getZfScoreRate" resultType="java.util.Map">
18
+        select rangename,rangenum,rangerate
19
+        from msr_class_subject_grade
20
+        where examid = #{examid} and reportcode = #{reportcode} and classid = 0 and subjectid = 'zf'
21
+    </select>
16 22
 
17 23
 </mapper>
18 24
 

+ 17
- 0
smarking/src/main/resources/mapper/report/reportstu/MsrStudentActionMapper.xml View File

@@ -1,4 +1,21 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentActionMapper">
4
+    <!--行为分析-学生-->
5
+    <select id="listXwBj" resultType="java.util.Map">
6
+        select c.classname,sa.classid,sa.studentid,sa.subjectjson,u.username,u.loginname
7
+        from msr_student_action sa left join t_class c on sa.classid = c.classid
8
+        left join t_user u on sa.studentid=u.userid
9
+        where sa.examid=#{action.examid} and sa.actiontype=#{action.actiontype}
10
+        <if test="action.classid!=null and action.classid!=0">
11
+            and sa.classid=#{action.classid}
12
+        </if>
13
+        <foreach collection="action.classids" item="classid" open="and sa.classid in(0," separator="," close=")">
14
+            ${classid}
15
+        </foreach>
16
+        <if test="action.createname!=null and action.createname!=''">
17
+            and (u.username like '%${action.createname}%' or u.loginname like '%${action.createname}%')
18
+        </if>
19
+        order by c.classtype,c.classorder,c.classid
20
+    </select>
4 21
 </mapper>

+ 7
- 0
smarking/src/main/resources/mapper/report/reportstu/MsrStudentMapper.xml View File

@@ -65,4 +65,11 @@
65 65
         where q.examid=#{params.examid} and q.subjectid=#{params.subjectid} and q.studentid=#{params.studentid}
66 66
         order by q.mptqid
67 67
     </select>
68
+    <!--综合报告-总概览-整体分数分布分析-->
69
+    <select id="listScoreForZgl" resultType="java.util.Map">
70
+        select stuscore,count(*) as num
71
+        from msr_student
72
+        where examid=#{examid} and subjectid=#{subjectid}
73
+        group by stuscore
74
+    </select>
68 75
 </mapper>

+ 5
- 0
smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectClassMapper.xml View File

@@ -1,4 +1,9 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectClassMapper">
4
+    <select id="listSubjectClass" resultType="java.util.Map">
5
+        select *
6
+        from msr_subject_class
7
+        where examid = #{subject.examid}
8
+    </select>
4 9
 </mapper>

+ 9
- 0
smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectMapper.xml View File

@@ -7,5 +7,14 @@
7 7
         select sid,examid,subjectid,avgscore,nd,qfd,maxscore,minscore,stunum from msr_subject
8 8
         where examid=#{examid} and subjectid=#{subjectid}
9 9
     </select>
10
+    <!--综合报告-总概览-->
11
+    <select id="listSubjectForZgl" resultType="java.util.Map">
12
+        select sid,subjectid,subjectname
13
+        ,totalnum,stunum,numrate
14
+        ,fullscore,avgscore,scorerate
15
+        ,bzc,nd,cyxs
16
+        from msr_subject
17
+        where examid=#{examid}
18
+    </select>
10 19
 
11 20
 </mapper>

Loading…
Cancel
Save