Procházet zdrojové kódy

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

# Conflicts:
#	smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java
ywx
王宁 před 2 týdny
rodič
revize
32fa6b150f

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

@@ -1,16 +1,23 @@
1 1
 package com.xhkjedu.smarking.service.report.reportother;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.xhkjedu.smarking.mapper.exam.*;
4 5
 import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
6
+import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
5 7
 import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
8
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectClassMapper;
6 9
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
7 10
 import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
8 11
 import com.xhkjedu.smarking.model.exam.*;
9 12
 import com.xhkjedu.smarking.model.paper.MsPaper;
10 13
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
14
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
11 15
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
12 16
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
17
+import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
13 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 21
 import com.xhkjedu.utils.N_Utils;
15 22
 import org.springframework.stereotype.Service;
16 23
 
@@ -41,6 +48,10 @@ public class MsrExamService {
41 48
     private MsrSubjectMapper msrSubjectMapper;
42 49
     @Resource
43 50
     private MsrStudentMapper msrStudentMapper;
51
+    @Resource
52
+    private MsrReportparamMapper msrReportparamMapper;
53
+    @Resource
54
+    private MsrSubjectClassMapper msrSubjectClassMapper;
44 55
 
45 56
     /**
46 57
      * @Description 生成报告
@@ -66,6 +77,13 @@ public class MsrExamService {
66 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 87
         Integer classnum = N_Utils.obj2Int(classes.stream().map(MsClass::getClassid).distinct().count());
70 88
         Integer totalnum = N_Utils.obj2Int(students.stream().map(MsClassStudent::getStudentid).distinct().count());
71 89
         Integer stunum = N_Utils.obj2Int(paperStudents.stream().filter(s -> s.getSstate().equals(2)).map(MsrStudent::getStudentid).distinct().count());
@@ -74,10 +92,10 @@ public class MsrExamService {
74 92
         List<MsrStudent> schoolStudents = new ArrayList<>();//学校学生成绩
75 93
         List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩(总分)
76 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 99
         Map<Integer, List<MsrStudent>> schoolCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getStudentid));
82 100
         for (Map.Entry<Integer, List<MsrStudent>> entry : schoolCollect.entrySet()) {
83 101
             Integer studentid = entry.getKey();
@@ -96,6 +114,7 @@ public class MsrExamService {
96 114
             String subjectid = paperStudent.getSubjectid();
97 115
             Integer studentid = paperStudent.getStudentid();
98 116
             Double stuscore = paperStudent.getStuscore();
117
+            Double fullscore1 = paperStudent.getFullscore();
99 118
             String key = subjectid + "_" + studentid;
100 119
             for (MsClassStudent student : sClassStudent.get(key)) {
101 120
                 MsrStudent cs = new MsrStudent();
@@ -104,6 +123,7 @@ public class MsrExamService {
104 123
                 cs.setStudentid(student.getStudentid());
105 124
                 cs.setSubjectid(subjectid);
106 125
                 cs.setStuscore(stuscore);
126
+                cs.setFullscore(fullscore1);
107 127
                 paperStudents2.add(cs);
108 128
             }
109 129
         }
@@ -124,6 +144,7 @@ public class MsrExamService {
124 144
                 cs.setStudentid(csEntry.getKey());
125 145
                 cs.setSubjectid(subjectid);
126 146
                 cs.setStuscore(csEntry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum());
147
+                cs.setFullscore(fullscore);
127 148
                 rstudents.add(cs);
128 149
             }
129 150
             bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
@@ -217,13 +238,42 @@ public class MsrExamService {
217 238
 
218 239
         //学生成绩分析
219 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 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 278
         examMapper.updateExamState(examid, 3);
229 279
     }
@@ -250,9 +300,9 @@ public class MsrExamService {
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 306
         String subjectid;
257 307
         Integer classid = student.getClassid();
258 308
         Integer studentid = student.getStudentid();
@@ -260,31 +310,39 @@ public class MsrExamService {
260 310
         MsrSubject msrSubject = subjectMap.get(subjectid);
261 311
         Double pjf = msrSubject.getAvgscore();//年级平均分
262 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 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 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 324
         student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
273 325
         student.setClassrank(classrank);
274 326
         student.setSchoolrank(schoolrank);
275 327
         double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
276 328
         student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
277 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 337
         List<Map.Entry<Double, List<MsrStudent>>> gslist2 = students.stream()
283 338
                                                                     .collect(Collectors.groupingBy(MsrStudent::getStuscore)).entrySet()
284 339
                                                                     .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
285 340
         int index = 1;
341
+        StuRankVo rankVo;
286 342
         String key;
343
+        List<StuRankVo> rankVos = new ArrayList<>();
287 344
         for (Map.Entry<Double, List<MsrStudent>> entry : gslist2) {
345
+            int num = entry.getValue().size();
288 346
             for (MsrStudent cgs : entry.getValue()) {
289 347
                 Integer studentid = cgs.getStudentid();
290 348
                 Integer classid = cgs.getClassid();
@@ -298,9 +356,21 @@ public class MsrExamService {
298 356
                 } else {//班级科目学生
299 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 Zobrazit soubor

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
5 5
 import com.xhkjedu.smarking.config.ConfigKey;
6 6
 import com.xhkjedu.smarking.vo.paper.PaperFileVo;
7 7
 import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
8
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
8 9
 import com.xhkjedu.utils.N_Utils;
9 10
 import com.xhkjedu.vo.ResultVo;
10 11
 import lombok.extern.slf4j.Slf4j;
@@ -590,11 +591,25 @@ public class MarkingUtil {
590 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 609
     public static void main(String[] args) {
594 610
         List<int[]> rtnList = fdScore(84.0, 5);
595 611
         for (int[] rtn : rtnList) {
596 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 Zobrazit soubor

@@ -0,0 +1,16 @@
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
+}

Načítá se…
Zrušit
Uložit