Browse Source

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

# Conflicts:
#	smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java
ywx
王宁 2 weeks ago
parent
commit
32fa6b150f

+ 90
- 20
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java View File

1
 package com.xhkjedu.smarking.service.report.reportother;
1
 package com.xhkjedu.smarking.service.report.reportother;
2
 
2
 
3
+import com.alibaba.fastjson.JSON;
3
 import com.xhkjedu.smarking.mapper.exam.*;
4
 import com.xhkjedu.smarking.mapper.exam.*;
4
 import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
5
 import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
6
+import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
5
 import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
7
 import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
8
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectClassMapper;
6
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
9
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
7
 import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
10
 import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
8
 import com.xhkjedu.smarking.model.exam.*;
11
 import com.xhkjedu.smarking.model.exam.*;
9
 import com.xhkjedu.smarking.model.paper.MsPaper;
12
 import com.xhkjedu.smarking.model.paper.MsPaper;
10
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
13
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
14
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
11
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
15
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
12
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
16
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
17
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
13
 import com.xhkjedu.smarking.utils.MarkingUtil;
18
 import com.xhkjedu.smarking.utils.MarkingUtil;
19
+import com.xhkjedu.smarking.vo.report.reportother.StuRankVo;
20
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
14
 import com.xhkjedu.utils.N_Utils;
21
 import com.xhkjedu.utils.N_Utils;
15
 import org.springframework.stereotype.Service;
22
 import org.springframework.stereotype.Service;
16
 
23
 
41
     private MsrSubjectMapper msrSubjectMapper;
48
     private MsrSubjectMapper msrSubjectMapper;
42
     @Resource
49
     @Resource
43
     private MsrStudentMapper msrStudentMapper;
50
     private MsrStudentMapper msrStudentMapper;
51
+    @Resource
52
+    private MsrReportparamMapper msrReportparamMapper;
53
+    @Resource
54
+    private MsrSubjectClassMapper msrSubjectClassMapper;
44
 
55
 
45
     /**
56
     /**
46
      * @Description 生成报告
57
      * @Description 生成报告
66
             student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), student.getFullscore()));
77
             student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), student.getFullscore()));
67
         }
78
         }
68
 
79
 
80
+        //等级参数
81
+        List<MsrReportparam> djParams = msrReportparamMapper.listReportparamByRpbelong(examid, "subjectshow", "");
82
+        List<SzJsonVo> djList = new ArrayList<>();
83
+        if (N_Utils.isListNotEmpty(djParams)) {
84
+            djList = JSON.parseArray(djParams.get(0).getSzjson(), SzJsonVo.class);
85
+        }
86
+
69
         Integer classnum = N_Utils.obj2Int(classes.stream().map(MsClass::getClassid).distinct().count());
87
         Integer classnum = N_Utils.obj2Int(classes.stream().map(MsClass::getClassid).distinct().count());
70
         Integer totalnum = N_Utils.obj2Int(students.stream().map(MsClassStudent::getStudentid).distinct().count());
88
         Integer totalnum = N_Utils.obj2Int(students.stream().map(MsClassStudent::getStudentid).distinct().count());
71
         Integer stunum = N_Utils.obj2Int(paperStudents.stream().filter(s -> s.getSstate().equals(2)).map(MsrStudent::getStudentid).distinct().count());
89
         Integer stunum = N_Utils.obj2Int(paperStudents.stream().filter(s -> s.getSstate().equals(2)).map(MsrStudent::getStudentid).distinct().count());
74
         List<MsrStudent> schoolStudents = new ArrayList<>();//学校学生成绩
92
         List<MsrStudent> schoolStudents = new ArrayList<>();//学校学生成绩
75
         List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩(总分)
93
         List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩(总分)
76
         List<MsrStudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
94
         List<MsrStudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
77
-        Map<String, Integer> schoolStuRank = new HashMap<>();//学校学生分数排名
78
-        Map<String, Integer> schoolSubStuRank = new HashMap<>();//学校科目学生分数排名
79
-        Map<String, Integer> classStuRank = new HashMap<>();//班级学生分数排名
80
-        Map<String, Integer> classSubStuRank = new HashMap<>();//班级科目学生分数排名
95
+        Map<String, StuRankVo> schoolStuRank = new HashMap<>();//学校学生分数排名
96
+        Map<String, StuRankVo> schoolSubStuRank = new HashMap<>();//学校科目学生分数排名
97
+        Map<String, StuRankVo> classStuRank = new HashMap<>();//班级学生分数排名
98
+        Map<String, StuRankVo> classSubStuRank = new HashMap<>();//班级科目学生分数排名
81
         Map<Integer, List<MsrStudent>> schoolCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
99
         Map<Integer, List<MsrStudent>> schoolCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
82
         for (Map.Entry<Integer, List<MsrStudent>> entry : schoolCollect.entrySet()) {
100
         for (Map.Entry<Integer, List<MsrStudent>> entry : schoolCollect.entrySet()) {
83
             Integer studentid = entry.getKey();
101
             Integer studentid = entry.getKey();
96
             String subjectid = paperStudent.getSubjectid();
114
             String subjectid = paperStudent.getSubjectid();
97
             Integer studentid = paperStudent.getStudentid();
115
             Integer studentid = paperStudent.getStudentid();
98
             Double stuscore = paperStudent.getStuscore();
116
             Double stuscore = paperStudent.getStuscore();
117
+            Double fullscore1 = paperStudent.getFullscore();
99
             String key = subjectid + "_" + studentid;
118
             String key = subjectid + "_" + studentid;
100
             for (MsClassStudent student : sClassStudent.get(key)) {
119
             for (MsClassStudent student : sClassStudent.get(key)) {
101
                 MsrStudent cs = new MsrStudent();
120
                 MsrStudent cs = new MsrStudent();
104
                 cs.setStudentid(student.getStudentid());
123
                 cs.setStudentid(student.getStudentid());
105
                 cs.setSubjectid(subjectid);
124
                 cs.setSubjectid(subjectid);
106
                 cs.setStuscore(stuscore);
125
                 cs.setStuscore(stuscore);
126
+                cs.setFullscore(fullscore1);
107
                 paperStudents2.add(cs);
127
                 paperStudents2.add(cs);
108
             }
128
             }
109
         }
129
         }
124
                 cs.setStudentid(csEntry.getKey());
144
                 cs.setStudentid(csEntry.getKey());
125
                 cs.setSubjectid(subjectid);
145
                 cs.setSubjectid(subjectid);
126
                 cs.setStuscore(csEntry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum());
146
                 cs.setStuscore(csEntry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum());
147
+                cs.setFullscore(fullscore);
127
                 rstudents.add(cs);
148
                 rstudents.add(cs);
128
             }
149
             }
129
             bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
150
             bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
217
 
238
 
218
         //学生成绩分析
239
         //学生成绩分析
219
         for (MsrStudent student : classStudents) {
240
         for (MsrStudent student : classStudents) {
220
-            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap);
241
+            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap, djList);
221
         }
242
         }
222
         for (MsrStudent student : classSubjectStudents) {
243
         for (MsrStudent student : classSubjectStudents) {
223
-            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap);
244
+            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap, djList);
245
+        }
246
+        List<MsrStudent> msrStudents = new ArrayList<>();
247
+        msrStudents.addAll(classStudents);
248
+        msrStudents.addAll(classSubjectStudents);
249
+        if (N_Utils.isListNotEmpty(msrStudents)) msrStudentMapper.insertList(msrStudents);
250
+
251
+        //科目班级分数分布区间分析
252
+        //区间参数
253
+        List<MsrReportparam> qjParams = msrReportparamMapper.listReportparamByRpbelong(examid, "scoresection", "");
254
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
255
+        for (MsrReportparam param : qjParams) {
256
+            qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
224
         }
257
         }
225
-        if (N_Utils.isListNotEmpty(classStudents)) msrStudentMapper.insertList(classStudents);
226
-        if (N_Utils.isListNotEmpty(classSubjectStudents)) msrStudentMapper.insertList(classSubjectStudents);
258
+        List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();
259
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
260
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
261
+            String key = entry.getKey();
262
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
263
+            subjectid = key.split("_")[1];
264
+            List<SzJsonVo> list = qjMap.get(subjectid);
265
+            List<MsrStudent> studentList = entry.getValue();
266
+            for (SzJsonVo vo : list) {
267
+                Object djvalue = vo.getDjvalue();
268
+                MsrSubjectClass msrSubjectClass = new MsrSubjectClass();
269
+                msrSubjectClass.setExamid(examid);
270
+                msrSubjectClass.setClassid(classid);
271
+                msrSubjectClass.setSubjectid(subjectid);
272
+                msrSubjectClass.setQjname(vo.getDjkey());
273
+                msrSubjectClasses.add(msrSubjectClass);
274
+            }
275
+        }
276
+        msrSubjectClassMapper.insertList(msrSubjectClasses);
227
 
277
 
228
         examMapper.updateExamState(examid, 3);
278
         examMapper.updateExamState(examid, 3);
229
     }
279
     }
250
     }
300
     }
251
 
301
 
252
     //设置学生分析计算参数
302
     //设置学生分析计算参数
253
-    private void setStudent(MsrStudent student, Map<String, Integer> classStuRank, Map<String, Integer> schoolStuRank
254
-            , Map<String, Integer> classSubStuRank, Map<String, Integer> schoolSubStuRank
255
-            , Map<String, Double> bjdfMap, Map<String, MsrSubject> subjectMap) {
303
+    private void setStudent(MsrStudent student, Map<String, StuRankVo> classStuRank, Map<String, StuRankVo> schoolStuRank
304
+            , Map<String, StuRankVo> classSubStuRank, Map<String, StuRankVo> schoolSubStuRank
305
+            , Map<String, Double> bjdfMap, Map<String, MsrSubject> subjectMap, List<SzJsonVo> djList) {
256
         String subjectid;
306
         String subjectid;
257
         Integer classid = student.getClassid();
307
         Integer classid = student.getClassid();
258
         Integer studentid = student.getStudentid();
308
         Integer studentid = student.getStudentid();
260
         MsrSubject msrSubject = subjectMap.get(subjectid);
310
         MsrSubject msrSubject = subjectMap.get(subjectid);
261
         Double pjf = msrSubject.getAvgscore();//年级平均分
311
         Double pjf = msrSubject.getAvgscore();//年级平均分
262
         student.setBzf(MarkingUtil.bzf(bjdfMap.get(classid + "_" + subjectid), pjf, msrSubject.getBzc()));
312
         student.setBzf(MarkingUtil.bzf(bjdfMap.get(classid + "_" + subjectid), pjf, msrSubject.getBzc()));
263
-        Integer classrank;
264
-        Integer schoolrank;
313
+        StuRankVo classRankVo;
314
+        StuRankVo schoolRankVo;
265
         if (subjectid.equals("zf")) {
315
         if (subjectid.equals("zf")) {
266
-            classrank = classStuRank.get(classid + "_" + studentid);
267
-            schoolrank = schoolStuRank.get(studentid.toString());
316
+            classRankVo = classStuRank.get(classid + "_" + studentid);
317
+            schoolRankVo = schoolStuRank.get(studentid.toString());
268
         } else {
318
         } else {
269
-            classrank = classSubStuRank.get(classid + "_" + subjectid + "_" + studentid);
270
-            schoolrank = schoolSubStuRank.get(subjectid + "_" + studentid);
319
+            classRankVo = classSubStuRank.get(classid + "_" + subjectid + "_" + studentid);
320
+            schoolRankVo = schoolSubStuRank.get(subjectid + "_" + studentid);
271
         }
321
         }
322
+        Integer classrank = classRankVo.getRank();
323
+        Integer schoolrank = schoolRankVo.getRank();
272
         student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
324
         student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
273
         student.setClassrank(classrank);
325
         student.setClassrank(classrank);
274
         student.setSchoolrank(schoolrank);
326
         student.setSchoolrank(schoolrank);
275
         double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
327
         double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
276
         student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
328
         student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
277
         student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
329
         student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
330
+        double dfv = N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), msrSubject.getFullscore());
331
+        student.setGradevalue(MarkingUtil.dj(dfv, djList));
332
+        student.setHighschool(N_Utils.getIntegerDivideAndMulitiply(schoolrank, schoolRankVo.getNum2()));
278
     }
333
     }
279
 
334
 
280
     //分数排名
335
     //分数排名
281
-    private void setRank(List<MsrStudent> students, Map<String, Integer> rank, Integer code) {
336
+    private void setRank(List<MsrStudent> students, Map<String, StuRankVo> rank, Integer code) {
282
         List<Map.Entry<Double, List<MsrStudent>>> gslist2 = students.stream()
337
         List<Map.Entry<Double, List<MsrStudent>>> gslist2 = students.stream()
283
                                                                     .collect(Collectors.groupingBy(MsrStudent::getStuscore)).entrySet()
338
                                                                     .collect(Collectors.groupingBy(MsrStudent::getStuscore)).entrySet()
284
                                                                     .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
339
                                                                     .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
285
         int index = 1;
340
         int index = 1;
341
+        StuRankVo rankVo;
286
         String key;
342
         String key;
343
+        List<StuRankVo> rankVos = new ArrayList<>();
287
         for (Map.Entry<Double, List<MsrStudent>> entry : gslist2) {
344
         for (Map.Entry<Double, List<MsrStudent>> entry : gslist2) {
345
+            int num = entry.getValue().size();
288
             for (MsrStudent cgs : entry.getValue()) {
346
             for (MsrStudent cgs : entry.getValue()) {
289
                 Integer studentid = cgs.getStudentid();
347
                 Integer studentid = cgs.getStudentid();
290
                 Integer classid = cgs.getClassid();
348
                 Integer classid = cgs.getClassid();
298
                 } else {//班级科目学生
356
                 } else {//班级科目学生
299
                     key = classid + "_" + subjectid + "_" + studentid;
357
                     key = classid + "_" + subjectid + "_" + studentid;
300
                 }
358
                 }
301
-                rank.put(key, index);
359
+                rankVo = new StuRankVo();
360
+                rankVo.setKey(key);
361
+                rankVo.setRank(index);
362
+                rankVo.setNum(num);
363
+                rankVos.add(rankVo);
364
+                rank.put(key, rankVo);
302
             }
365
             }
303
-            index = index + entry.getValue().size();
366
+            index = index + num;
367
+        }
368
+        List<Integer> codes = Arrays.asList(1, 2);//计算超过当前排名人数
369
+        if (!codes.contains(code)) return;
370
+        for (StuRankVo vo : rankVos) {
371
+            Integer rank1 = vo.getRank();
372
+            int sum = rankVos.stream().filter(r -> rank1.compareTo(r.getRank()) < 0).mapToInt(StuRankVo::getNum).sum();
373
+            vo.setNum2(sum);
304
         }
374
         }
305
     }
375
     }
306
 }
376
 }

+ 16
- 1
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

5
 import com.xhkjedu.smarking.config.ConfigKey;
5
 import com.xhkjedu.smarking.config.ConfigKey;
6
 import com.xhkjedu.smarking.vo.paper.PaperFileVo;
6
 import com.xhkjedu.smarking.vo.paper.PaperFileVo;
7
 import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
7
 import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
8
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
8
 import com.xhkjedu.utils.N_Utils;
9
 import com.xhkjedu.utils.N_Utils;
9
 import com.xhkjedu.vo.ResultVo;
10
 import com.xhkjedu.vo.ResultVo;
10
 import lombok.extern.slf4j.Slf4j;
11
 import lombok.extern.slf4j.Slf4j;
590
         return rtnList;
591
         return rtnList;
591
     }
592
     }
592
 
593
 
594
+    //object转double
595
+    public static double objToDouble(Object v1) {
596
+        if (N_Utils.isEmpty(v1)) return 0.0;
597
+        return Double.parseDouble(v1.toString());
598
+    }
599
+
600
+    //等级
601
+    public static String dj(Double dfv, List<SzJsonVo> djList) {
602
+        for (SzJsonVo vo : djList) {
603
+            if (dfv.compareTo(objToDouble(vo.getDjvalue())) >= 0) {
604
+                return vo.getDjkey();
605
+            }
606
+        }
607
+        return "";
608
+    }
593
     public static void main(String[] args) {
609
     public static void main(String[] args) {
594
         List<int[]> rtnList = fdScore(84.0, 5);
610
         List<int[]> rtnList = fdScore(84.0, 5);
595
         for (int[] rtn : rtnList) {
611
         for (int[] rtn : rtnList) {
596
             System.out.println(rtn[0] + "-" + rtn[1]);
612
             System.out.println(rtn[0] + "-" + rtn[1]);
597
         }
613
         }
598
     }
614
     }
599
-
600
 }
615
 }

+ 16
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/report/reportother/StuRankVo.java View File

1
+package com.xhkjedu.smarking.vo.report.reportother;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @Description
7
+ * @Author ywx
8
+ * Date 2024/12/11 17:37
9
+ **/
10
+@Data
11
+public class StuRankVo {
12
+    private String key;//排名key
13
+    private Integer rank;//排名
14
+    private Integer num;//排名人数
15
+    private Integer num2;//超过当前排名人数
16
+}

Loading…
Cancel
Save