Browse Source

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

wn
王宁 2 days ago
parent
commit
d01e7d2570

+ 12
- 12
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassSubject.java View File

@@ -9,7 +9,7 @@ import javax.persistence.Table;
9 9
 /**
10 10
  * @Description 阅卷报告-班级学科分析表
11 11
  * @Author auto
12
- * @Date 2024-12-09
12
+ * @Date 2024-12-26
13 13
  */
14 14
 @Data
15 15
 @Table(name = "msr_class_subject")
@@ -32,7 +32,7 @@ public class MsrClassSubject extends BaseBean {
32 32
     //班级最低分
33 33
     private Double classminscore;
34 34
     //班级最低分在校排名
35
-    private String classminrank;
35
+    private Integer classminrank;
36 36
     //班级平均分
37 37
     private Double classavgscore;
38 38
     //班级平均得分率
@@ -48,9 +48,9 @@ public class MsrClassSubject extends BaseBean {
48 48
     //校平均分得分率
49 49
     private Double schoolavgrate;
50 50
     //全科及格率
51
-    private Double qkjgrate;
51
+    private Double qkjgl;
52 52
     //综合率
53
-    private Double zhrate;
53
+    private Double zhl;
54 54
     //标准差
55 55
     private Double bzc;
56 56
     //标准分
@@ -58,29 +58,29 @@ public class MsrClassSubject extends BaseBean {
58 58
     //标准分排名
59 59
     private Integer bzfrank;
60 60
     //超均率
61
-    private Double cjlrate;
61
+    private Double cjl;
62 62
     //超均率在校排名
63 63
     private Integer cjlrank;
64 64
     //比均率
65
-    private Double bjrate;
65
+    private Double bjl;
66 66
     //比均率在校排名
67
-    private Integer bjlrate;
67
+    private Integer bjlrank;
68 68
     //中位数
69 69
     private Double zws;
70 70
     //中位数在校排名
71 71
     private Integer zwsrank;
72 72
     //离均差
73 73
     private Double ljc;
74
-    //离均率
75
-    private Double ljl;
76
-    //离均率在校排名
77
-    private Integer ljlrank;
74
+    //离均差在校排名
75
+    private Integer ljcrank;
78 76
     //众数
79 77
     private String zs;
78
+    //众数最大值
79
+    private Double zsmax;
80 80
     //众数在校排名
81 81
     private Integer zsrank;
82 82
     //均衡率
83
-    private Double jhrate;
83
+    private Double jhl;
84 84
     //得分贡献指数
85 85
     private Double dfgxzs;
86 86
     //平均分贡献指数

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

@@ -19,6 +19,7 @@ import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
19 19
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
20 20
 import com.xhkjedu.smarking.utils.MarkingUtil;
21 21
 import com.xhkjedu.smarking.vo.report.reportclass.ClassTopVo;
22
+import com.xhkjedu.smarking.vo.report.reportclass.RankRateGroupVo;
22 23
 import com.xhkjedu.smarking.vo.report.reportother.*;
23 24
 import com.xhkjedu.utils.N_Utils;
24 25
 import org.springframework.stereotype.Service;
@@ -269,41 +270,59 @@ public class MsrExamService {
269 270
         msrStudents.addAll(classSubjectStudents);
270 271
         if (N_Utils.isListNotEmpty(msrStudents)) msrStudentMapper.insertList(msrStudents);
271 272
 
272
-        //科目班级分数分布区间分析、班级学科分析
273
-        //区间参数
273
+        saveSubjectClass(examid, msrStudents);//科目班级分数分布区间分析
274
+        saveClassSubject(examid, msrStudents);//班级学科分析
275
+        saveClassTop(examid, msrStudents);//班级学科前60分析
276
+
277
+        saveClassSubjectGrade(examid, "zh", msrStudents);//综合报告-班级学科四率等级分析
278
+        saveClassSubjectGrade(examid, "xj", msrStudents);//校级报告-班级学科四率等级分析
279
+        saveClassRankGroup(examid, msrStudents);//学科报告-班级学科名次分组分析
280
+        saveClassRankRate(examid, msrStudents);//综合报表-名次和比例分析
281
+        saveClassSection(examid, 1, "zh", msrStudents);//综合报表-分段统计
282
+        saveClassSection(examid, 2, "zh", msrStudents);//综合报表-累计统计
283
+        saveClassSection(examid, 1, "xj", msrStudents);//校级报告-分段统计
284
+        saveClassSection(examid, 1, "xk", msrStudents);//学科报告-分段统计
285
+        saveClassSection(examid, 1, "bj", msrStudents);//班级报告-分段统计
286
+        saveClassSection(examid, 1, "jxzl", msrStudents);//教学质量-分段统计
287
+        saveClassNearLine(examid, msrStudents);//分档上线统计
288
+        saveClassGoodBad(examid, "all", msrStudents);//重点学生-优劣名次统计
289
+
290
+        examMapper.updateExamState(examid, 3);
291
+    }
292
+
293
+    //科目班级分数分布区间分析
294
+    public void saveSubjectClass(Integer examid, List<MsrStudent> msrStudents) {
274 295
         Map<String, SzJsonVo> qjMap = new HashMap<>();
275 296
         List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", "xk");
276 297
         for (MsrReportparam param : params) {
277 298
             qjMap.put(param.getSubjectid(), JSON.parseObject(param.getSzjson(), SzJsonVo.class));
278 299
         }
279 300
         List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();//科目班级分数分布区间分析
280
-        List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
281
-        List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
282
-        Map<String, ClassTopVo> lsMap = new HashMap<>();//处于年级60%得分map
283
-        for (MsrSubject subject : msrSubjects) {
284
-            Double lsscore = subject.getLsscore();
285
-            String subjectid1 = subject.getSubjectid();
286
-            List<MsrStudent> lsstudents = msrStudents.stream().filter(s -> s.getSubjectid().equals(subjectid1) && s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
287
-            ClassTopVo classTopVo = new ClassTopVo();
288
-            classTopVo.setSubjectid(subjectid1);
289
-            classTopVo.setLsscore(lsscore);
290
-            classTopVo.setXtnum(lsstudents.size());
291
-            double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
292
-            classTopVo.setXtavgscore(N_Utils.formatDouble(average, 2));
293
-            String xtstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
294
-            classTopVo.setXtstuids(xtstuids);
295
-            lsMap.put(subjectid1, classTopVo);
301
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
302
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
303
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
304
+            studentsDistinct(entry, rsMap);
296 305
         }
306
+        setSubjectClass(examid, collect, qjMap, msrSubjectClasses, rsMap);
297 307
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
308
+        setSubjectClass(examid, scCollect, qjMap, msrSubjectClasses, rsMap);
309
+        msrSubjectClassMapper.insertList(msrSubjectClasses);
310
+    }
311
+
312
+    //科目班级分数分布区间计算
313
+    private void setSubjectClass(Integer examid, Map<String, List<MsrStudent>> scCollect, Map<String, SzJsonVo> qjMap
314
+            , List<MsrSubjectClass> msrSubjectClasses, Map<String, Integer> rsMap) {
315
+        Integer totalnum;
316
+        String subjectid;
298 317
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
299 318
             String key = entry.getKey();
300 319
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
301 320
             subjectid = key.split("_")[1];
302 321
             SzJsonVo vo = qjMap.get(subjectid);
303 322
             List<MsrStudent> studentList = entry.getValue();
304
-            totalnum = studentList.size();//区间总人数
305
-            Double fullscore1 = studentList.get(0).getFullscore();
306
-            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(vo.getDjvalue()));
323
+            totalnum = rsMap.get(subjectid);//科目总人数
324
+            Double fullscore = studentList.get(0).getFullscore();
325
+            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore, N_Utils.obj2Int(vo.getDjvalue()));
307 326
             for (RankGroupVo rg : fdScore) {
308 327
                 int minscore = rg.getMinvalue();
309 328
                 int maxscore = rg.getMaxvalue();
@@ -311,7 +330,7 @@ public class MsrExamService {
311 330
                 double min = MarkingUtil.objToDouble(minscore);
312 331
                 double max = MarkingUtil.objToDouble(maxscore);
313 332
                 List<MsrStudent> qjstudents;
314
-                if (fullscore1.compareTo(max) == 0) {
333
+                if (fullscore.compareTo(max) == 0) {
315 334
                     qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
316 335
                 } else {
317 336
                     qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0 && s.getStuscore().compareTo(max) < 0).collect(Collectors.toList());
@@ -325,18 +344,189 @@ public class MsrExamService {
325 344
                 msrSubjectClass.setQjnum(qjnum);
326 345
                 msrSubjectClass.setQjrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
327 346
                 double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
328
-                msrSubjectClass.setQjavgrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
347
+                msrSubjectClass.setQjavgrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore));
329 348
                 String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
330 349
                 msrSubjectClass.setStuids(stuids);
331 350
                 msrSubjectClasses.add(msrSubjectClass);
332 351
             }
352
+        }
353
+    }
354
+
355
+    //班级学科分析
356
+    public void saveClassSubject(Integer examid, List<MsrStudent> msrStudents) {
357
+        List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
358
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
359
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
360
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
361
+            studentsDistinct(entry, rsMap);
362
+        }
363
+        List<MsrReportparam> params = getMsrReportParams(examid, "allrate", "all");
364
+        SzJsonVo vo = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
365
+        String calformula = vo.getCalformula();
366
+        Map<String, MsrClassSubject> csMap = new HashMap<>();//班级学科map
367
+        setClassSubject(examid, collect, msrClassSubjects, csMap, calformula);
368
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
369
+        setClassSubject(examid, scCollect, msrClassSubjects, csMap, calformula);
370
+
371
+        Map<String, List<MsrClassSubject>> scollect = msrClassSubjects.stream().collect(Collectors.groupingBy(MsrClassSubject::getSubjectid));
372
+        for (Map.Entry<String, List<MsrClassSubject>> entry : scollect.entrySet()) {
373
+            List<MsrClassSubject> nearlineList = entry.getValue();
374
+            List<Double> classavgscore = new ArrayList<>();//班级平均分列表
375
+            List<Double> bzf = new ArrayList<>();//标准分列表
376
+            List<Double> cjl = new ArrayList<>();//超均率列表
377
+            List<Double> bjl = new ArrayList<>();//比均率列表
378
+            List<Double> zws = new ArrayList<>();//中位数列表
379
+            List<Double> ljc = new ArrayList<>();//离均差列表
380
+            List<Double> zs = new ArrayList<>();//众数列表
381
+            for (MsrClassSubject cs : nearlineList) {
382
+                classavgscore.add(cs.getClassavgscore());
383
+                bzf.add(cs.getBzf());
384
+                cjl.add(cs.getCjl());
385
+                bjl.add(cs.getBjl());
386
+                zws.add(cs.getZws());
387
+                ljc.add(cs.getLjc());
388
+                zs.add(cs.getZsmax());
389
+            }
390
+            Map<Double, Integer> pjfpm = MarkingUtil.fspm(classavgscore);//班级平均分排名
391
+            Map<Double, Integer> bzfpm = MarkingUtil.fspm(bzf);//标准分排名
392
+            Map<Double, Integer> cjlpm = MarkingUtil.fspm(cjl);//超均率排名
393
+            Map<Double, Integer> bjlpm = MarkingUtil.fspm(bjl);//比均率排名
394
+            Map<Double, Integer> zwspm = MarkingUtil.fspm(zws);//中位数排名
395
+            Map<Double, Integer> ljcpm = MarkingUtil.fspm(ljc);//离均差排名
396
+            Map<Double, Integer> zspm = MarkingUtil.fspm(zs);//众数排名
397
+            for (MsrClassSubject cs : nearlineList) {
398
+                cs.setClassavgrank(pjfpm.get(cs.getClassavgscore()));
399
+                cs.setBzfrank(bzfpm.get(cs.getBzf()));
400
+                cs.setCjlrank(cjlpm.get(cs.getCjl()));
401
+                cs.setBjlrank(bjlpm.get(cs.getBjl()));
402
+                cs.setZwsrank(zwspm.get(cs.getZws()));
403
+                cs.setLjcrank(ljcpm.get(cs.getLjc()));
404
+                cs.setZsrank(zspm.get(cs.getZsmax()));
405
+            }
406
+        }
407
+        msrClassSubjectMapper.insertList(msrClassSubjects);
408
+    }
333 409
 
410
+    //班级学科计算
411
+    private void setClassSubject(Integer examid, Map<String, List<MsrStudent>> scCollect
412
+            , List<MsrClassSubject> msrClassSubjects, Map<String, MsrClassSubject> csMap, String calformula) {
413
+        String subjectid;
414
+        MsrClassSubject zf = csMap.get("zf");
415
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
416
+            String key = entry.getKey();
417
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
418
+            subjectid = key.split("_")[1];
419
+            MsrClassSubject gs = csMap.get(subjectid);
420
+            List<MsrStudent> studentList = entry.getValue();
421
+            studentList.sort(Comparator.comparing(MsrStudent::getStuscore));
422
+            MsrStudent minStudent = studentList.get(0);
423
+            int stunum = studentList.size();
424
+            MsrStudent maxStudent = studentList.get(stunum - 1);
425
+            Double fullscore = minStudent.getFullscore();
334 426
             MsrClassSubject msrClassSubject = new MsrClassSubject();
335 427
             msrClassSubject.setExamid(examid);
336 428
             msrClassSubject.setSubjectid(subjectid);
337 429
             msrClassSubject.setClassid(classid);
338
-            msrClassSubject.setFullscore(fullscore1);
430
+            msrClassSubject.setFullscore(fullscore);
431
+            msrClassSubject.setClassmaxscore(maxStudent.getStuscore());
432
+            msrClassSubject.setClassmaxrank(maxStudent.getSchoolrank());
433
+            msrClassSubject.setClassminscore(minStudent.getStuscore());
434
+            msrClassSubject.setClassminrank(minStudent.getSchoolrank());
435
+            List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).collect(Collectors.toList());
436
+            double classavgscore = N_Utils.formatDouble(scores.stream().mapToDouble(Double::doubleValue).summaryStatistics().getAverage(), 2);
437
+            msrClassSubject.setClassavgscore(classavgscore);
438
+            double classavgrate = N_Utils.getDoubleDivideAndMulitiply(classavgscore, fullscore);
439
+            msrClassSubject.setClassavgrate(classavgrate);
440
+            msrClassSubject.setBzc(MarkingUtil.bzc(scores));
441
+            Double schoolavgscore = gs.getClassavgscore();
442
+            if (classid.equals(0)) {
443
+                msrClassSubject.setSchoolmaxscore(msrClassSubject.getClassmaxscore());
444
+                msrClassSubject.setSchoolminscore(msrClassSubject.getClassminscore());
445
+                msrClassSubject.setSchoolavgrate(msrClassSubject.getClassavgrate());
446
+                msrClassSubject.setSchoolavgrate(msrClassSubject.getClassavgrate());
447
+                msrClassSubject.setBzf(0.0);
448
+                msrClassSubject.setCjl(0.0);
449
+                msrClassSubject.setLjc(0.0);
450
+                msrClassSubject.setBjl(1.0);
451
+                msrClassSubject.setDfgxzs(0.0);
452
+                msrClassSubject.setPjfgxzs(0.0);
453
+            } else {
454
+                msrClassSubject.setSchoolmaxscore(gs.getClassmaxscore());
455
+                msrClassSubject.setSchoolminscore(gs.getClassminscore());
456
+                msrClassSubject.setSchoolavgrate(gs.getClassavgrate());
457
+                msrClassSubject.setSchoolavgrate(gs.getClassavgrate());
458
+                msrClassSubject.setBzf(MarkingUtil.bzf(classavgscore, schoolavgscore, gs.getBzc()));
459
+                msrClassSubject.setCjl(MarkingUtil.cjl(classavgscore, schoolavgscore));
460
+                msrClassSubject.setLjc(MarkingUtil.sub(classavgscore, schoolavgscore));
461
+                msrClassSubject.setBjl(1.0);
462
+                msrClassSubject.setDfgxzs(MarkingUtil.sub(classavgrate, zf.getClassavgrate()));
463
+                msrClassSubject.setPjfgxzs(MarkingUtil.sub(classavgscore, zf.getClassavgscore()));
464
+            }
465
+            msrClassSubject.setZws(MarkingUtil.zws(scores));
466
+            List<Double> zs = MarkingUtil.zs(scores);
467
+            msrClassSubject.setZs(JSON.toJSONString(zs));
468
+            msrClassSubject.setZsmax(zs.stream().max(Double::compareTo).orElse(0.0));
469
+            if (N_Utils.isNotEmpty(calformula)) {
470
+                calformula = calformula.replaceAll("平均分", msrClassSubject.getClassavgscore() + "");
471
+                calformula = calformula.replaceAll("标准差", msrClassSubject.getBzc() + "");
472
+                calformula = calformula.replaceAll("最高分", msrClassSubject.getClassmaxscore() + "");
473
+                calformula = calformula.replaceAll("最低分", msrClassSubject.getClassminscore() + "");
474
+                calformula = calformula.replaceAll("全科及格率", msrClassSubject.getQkjgl() + "");
475
+                calformula = calformula.replaceAll("超均率", msrClassSubject.getCjl() + "");
476
+                calformula = calformula.replaceAll("标准分", msrClassSubject.getBzf() + "");
477
+                calformula = calformula.replaceAll("中位数", msrClassSubject.getZws() + "");
478
+                calformula = calformula.replaceAll("离均差", msrClassSubject.getLjc() + "");
479
+                calformula = calformula.replaceAll("比均率", msrClassSubject.getBjl() + "");
480
+                calformula = calformula.replaceAll("众数", msrClassSubject.getZsmax() + "");
481
+                msrClassSubject.setZhl(MarkingUtil.evaluate(calformula));
482
+            }
483
+            msrClassSubject.setJhl(0.0);
484
+
485
+            if (classid.equals(0)) {
486
+                csMap.put(subjectid, msrClassSubject);
487
+            }
339 488
             msrClassSubjects.add(msrClassSubject);
489
+        }
490
+    }
491
+
492
+    //班级学科前60分析
493
+    public void saveClassTop(Integer examid, List<MsrStudent> msrStudents) {
494
+        List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
495
+        Map<String, ClassTopVo> lsMap = new HashMap<>();//处于年级60%得分map
496
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
497
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
498
+            studentsDistinct(entry, null);
499
+            String subjectid = entry.getKey().split("_")[1];
500
+            List<Double> scores = entry.getValue().stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
501
+            Double lsscore = MarkingUtil.cynjdf(scores, 0.6);
502
+            List<MsrStudent> lsstudents = entry.getValue().stream().filter(s -> s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
503
+            ClassTopVo classTopVo = new ClassTopVo();
504
+            classTopVo.setSubjectid(subjectid);
505
+            classTopVo.setLsscore(lsscore);
506
+            classTopVo.setXtnum(lsstudents.size());
507
+            double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
508
+            classTopVo.setXtavgscore(N_Utils.formatDouble(average, 2));
509
+            String xtstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
510
+            classTopVo.setXtstuids(xtstuids);
511
+            lsMap.put(subjectid, classTopVo);
512
+        }
513
+        setClassTop(examid, collect, lsMap, msrClassTops);
514
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
515
+        setClassTop(examid, scCollect, lsMap, msrClassTops);
516
+        msrClassTopMapper.insertList(msrClassTops);
517
+    }
518
+
519
+    //班级学科前60计算
520
+    private void setClassTop(Integer examid, Map<String, List<MsrStudent>> scCollect, Map<String, ClassTopVo> lsMap
521
+            , List<MsrClassTop> msrClassTops) {
522
+        Integer totalnum;
523
+        String subjectid;
524
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
525
+            String key = entry.getKey();
526
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
527
+            subjectid = key.split("_")[1];
528
+            List<MsrStudent> studentList = entry.getValue();
529
+            totalnum = studentList.size();//区间总人数
340 530
 
341 531
             MsrClassTop msrClassTop = new MsrClassTop();
342 532
             msrClassTop.setExamid(examid);
@@ -357,24 +547,6 @@ public class MsrExamService {
357 547
             msrClassTop.setXtstuids(classTopVo.getXtstuids());
358 548
             msrClassTops.add(msrClassTop);
359 549
         }
360
-        msrSubjectClassMapper.insertList(msrSubjectClasses);
361
-        msrClassSubjectMapper.insertList(msrClassSubjects);
362
-        msrClassTopMapper.insertList(msrClassTops);
363
-
364
-        saveClassSubjectGrade(examid, "zh", msrStudents);//综合报告-班级学科四率等级分析
365
-        saveClassSubjectGrade(examid, "xj", msrStudents);//校级报告-班级学科四率等级分析
366
-        saveClassRankGroup(examid, msrStudents);//学科报告-班级学科名次分组分析
367
-        saveClassRankRate(examid, msrStudents);//综合报表-名次和比例分析
368
-        saveClassSection(examid, 1, "zh", msrStudents);//综合报表-分段统计
369
-        saveClassSection(examid, 2, "zh", msrStudents);//综合报表-累计统计
370
-        saveClassSection(examid, 1, "xj", msrStudents);//校级报告-分段统计
371
-        saveClassSection(examid, 1, "xk", msrStudents);//学科报告-分段统计
372
-        saveClassSection(examid, 1, "bj", msrStudents);//班级报告-分段统计
373
-        saveClassSection(examid, 1, "jxzl", msrStudents);//教学质量-分段统计
374
-        saveClassNearLine(examid, msrStudents);//分档上线统计
375
-        saveClassGoodBad(examid, "all", msrStudents);//重点学生-优劣名次统计
376
-
377
-        examMapper.updateExamState(examid, 3);
378 550
     }
379 551
 
380 552
     //重点学生-优劣名次统计
@@ -382,43 +554,42 @@ public class MsrExamService {
382 554
         List<MsrReportparam> params = getMsrReportParams(examid, "keystu", all);
383 555
         SzJsonVo fd = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
384 556
         List<MsrClassGoodbad> classGoodbads = new ArrayList<>();
385
-        String subjectid;
386 557
         Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
558
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
387 559
         for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
388
-            Integer classid = 0;
389
-            subjectid = entry.getKey();
390
-            studentsDistinct(entry);
391
-            setClassGoodBag(examid, entry, fd, subjectid, classid, classGoodbads);
560
+            studentsDistinct(entry, rsMap);
561
+            setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
392 562
         }
393 563
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
394 564
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
395
-            String key = entry.getKey();
396
-            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
397
-            subjectid = key.split("_")[1];
398
-            setClassGoodBag(examid, entry, fd, subjectid, classid, classGoodbads);
565
+            setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
399 566
         }
400 567
         msrClassGoodbadMapper.insertList(classGoodbads);
401 568
     }
402 569
 
403 570
     //学生去重
404
-    private void studentsDistinct(Map.Entry<String, List<MsrStudent>> entry) {
571
+    private void studentsDistinct(Map.Entry<String, List<MsrStudent>> entry, Map<String, Integer> rsMap) {
405 572
         //list根据学生id去重
406 573
         Map<Integer, MsrStudent> map = new HashMap<>();
407 574
         for (MsrStudent student : entry.getValue()) {
408 575
             map.putIfAbsent(student.getStudentid(), student);
409 576
         }
410
-        List<MsrStudent> list = map.values().stream().collect(Collectors.toList());
577
+        List<MsrStudent> list = new ArrayList<>(map.values());
411 578
         entry.setValue(list);
579
+        if (rsMap != null) rsMap.put(list.get(0).getSubjectid(), list.size());
412 580
     }
413 581
 
414 582
     //重点学生-优劣名次计算
415
-    private void setClassGoodBag(Integer examid, Map.Entry<String, List<MsrStudent>> entry, SzJsonVo fd, String subjectid, Integer classid, List<MsrClassGoodbad> classGoodbads) {
583
+    private void setClassGoodBag(Integer examid, Map.Entry<String, List<MsrStudent>> entry, SzJsonVo fd, List<MsrClassGoodbad> classGoodbads, Map<String, Integer> rsMap) {
584
+        String key = entry.getKey();
585
+        Integer classid = N_Utils.obj2Int(key.split("_")[0]);
586
+        String subjectid = key.split("_")[1];
416 587
         int totalnum;
417 588
         Integer goodtype = fd.getGoodtype();
418 589
         Integer badtype = fd.getBadtype();
419 590
         List<MsrStudent> studentList = entry.getValue().stream().sorted(Comparator.comparing(MsrStudent::getSchoolrank)).collect(Collectors.toList());
420 591
         Double avgScore = N_Utils.formatDouble(studentList.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
421
-        totalnum = studentList.size();//区间总人数
592
+        totalnum = rsMap.get(subjectid);//科目总人数
422 593
         Integer goodvalue = fd.getGoodvalue();
423 594
         Integer badvalue = fd.getBadvalue();
424 595
         List<MsrStudent> yxStudents;//优秀学生列表
@@ -473,23 +644,18 @@ public class MsrExamService {
473 644
         List<SzJsonVo> vos = JSON.parseArray(params.get(0).getSzjson(), SzJsonVo.class);
474 645
         Map<Integer, List<Integer>> zfSx = null;//学生总分是否上线
475 646
         List<MsrClassNearline> classNearlines = new ArrayList<>();
476
-        String subjectid;
477 647
         Map<String, List<MsrStudent>> collect0 = getSubjectCollect(msrStudents);
648
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
478 649
         for (Map.Entry<String, List<MsrStudent>> entry : collect0.entrySet()) {
479
-            Integer classid = 0;
480
-            subjectid = entry.getKey();
481
-            studentsDistinct(entry);
482
-            if (subjectid.equals("zf")) {
650
+            studentsDistinct(entry, rsMap);
651
+            if (entry.getKey().endsWith("zf")) {
483 652
                 zfSx = setZfsxMap(entry.getValue(), qjMap, tMap);
484 653
             }
485
-            setClassNearLine(examid, entry, qjMap, subjectid, tMap, vos, classid, zfSx, classNearlines);
654
+            setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
486 655
         }
487 656
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
488 657
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
489
-            String key = entry.getKey();
490
-            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
491
-            subjectid = key.split("_")[1];
492
-            setClassNearLine(examid, entry, qjMap, subjectid, tMap, vos, classid, zfSx, classNearlines);
658
+            setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
493 659
         }
494 660
         Map<String, List<MsrClassNearline>> collect = classNearlines.stream().collect(Collectors.groupingBy(l -> l.getSubjectid() + "_" + l.getDworder()));
495 661
         for (Map.Entry<String, List<MsrClassNearline>> entry : collect.entrySet()) {
@@ -508,21 +674,28 @@ public class MsrExamService {
508 674
 
509 675
     //获取科学分组学生
510 676
     private Map<String, List<MsrStudent>> getSubjectCollect(List<MsrStudent> msrStudents) {
511
-        return msrStudents.stream().collect(Collectors.groupingBy(s -> s.getSubjectid(), LinkedHashMap::new, Collectors.toList()));
677
+        Map<String, List<MsrStudent>> map = new LinkedHashMap<>();
678
+        LinkedHashMap<String, List<MsrStudent>> collect = msrStudents.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid, LinkedHashMap::new, Collectors.toList()));
679
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
680
+            map.put("0_" + entry.getKey(), entry.getValue());
681
+        }
682
+        return map;
512 683
     }
513 684
 
514 685
     //分档上线计算
515 686
     private void setClassNearLine(Integer examid, Map.Entry<String, List<MsrStudent>> entry, Map<String, List<SzJsonVo>> qjMap
516
-            , String subjectid, Map<String, Integer> tMap, List<SzJsonVo> vos, Integer classid
517
-            , Map<Integer, List<Integer>> zfSx, List<MsrClassNearline> classNearlines) {
518
-        int totalnum;
687
+            , Map<String, Integer> tMap, List<SzJsonVo> vos, Map<Integer, List<Integer>> zfSx
688
+            , List<MsrClassNearline> classNearlines, Map<String, Integer> rsMap) {
689
+        String key = entry.getKey();
690
+        Integer classid = N_Utils.obj2Int(key.split("_")[0]);
691
+        String subjectid = key.split("_")[1];
692
+        int totalnum = rsMap.get(subjectid);
519 693
         List<SzJsonVo> list = qjMap.get(subjectid);
520 694
         Integer rptype = tMap.get(subjectid);
521 695
         List<MsrStudent> studentList = entry.getValue();
522 696
         if (rptype.equals(3)) {
523 697
             studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
524 698
         }
525
-        totalnum = studentList.size();//区间总人数
526 699
         Double max = null;
527 700
         Integer minRank = null;
528 701
         int minIndex = 0;
@@ -595,12 +768,11 @@ public class MsrExamService {
595 768
                 nearline.setStuids2(ssxIds.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
596 769
                 //总分上线学科未上线人数
597 770
                 List<Integer> dksxIds = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
598
-                List<Integer> zfsxxkwsxIds = new ArrayList<>();
599
-                zfsxxkwsxIds.addAll(zfsxIds);
771
+                List<Integer> zfsxxkwsxIds = new ArrayList<>(zfsxIds);
600 772
                 zfsxxkwsxIds.removeAll(dksxIds);
601 773
                 int zfsxxkwsxnum = zfsxxkwsxIds.size();
602 774
                 nearline.setZfsxxkwsxnum(zfsxxkwsxnum);
603
-                nearline.setStuids5(zfsxxkwsxIds.stream().map(s -> s.toString()).collect(Collectors.joining(",")));
775
+                nearline.setStuids5(zfsxxkwsxIds.stream().map(Object::toString).collect(Collectors.joining(",")));
604 776
                 nearline.setGxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, zfsxnum));
605 777
                 nearline.setMzxrate(N_Utils.getIntegerDivideAndMulitiply(ssxnum, qjnum));
606 778
             }
@@ -629,7 +801,7 @@ public class MsrExamService {
629 801
         if (rptype.equals(3)) {
630 802
             studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
631 803
         }
632
-        totalnum = studentList.size();//区间总人数
804
+        totalnum = studentList.size();//总人数
633 805
         Double max = null;
634 806
         Integer minRank = null;
635 807
         int minIndex = 0;
@@ -690,8 +862,19 @@ public class MsrExamService {
690 862
         }
691 863
 
692 864
         List<MsrClassSection> classSections = new ArrayList<>();
693
-        String subjectid;
865
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
866
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
867
+            studentsDistinct(entry, null);
868
+        }
869
+        setClassSection(examid, type, reportcode, collect, fdMap, classSections);
694 870
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
871
+        setClassSection(examid, type, reportcode, scCollect, fdMap, classSections);
872
+        msrClassSectionMapper.insertList(classSections);
873
+    }
874
+
875
+    //分段统计-计算
876
+    private void setClassSection(Integer examid, Integer type, String reportcode, Map<String, List<MsrStudent>> scCollect, Map<String, List<RankGroupVo>> fdMap, List<MsrClassSection> classSections) {
877
+        String subjectid;
695 878
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
696 879
             String key = entry.getKey();
697 880
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
@@ -729,22 +912,37 @@ public class MsrExamService {
729 912
                 classSections.add(classSection);
730 913
             }
731 914
         }
732
-        msrClassSectionMapper.insertList(classSections);
733 915
     }
734 916
 
735 917
     //学科报告-班级学科名次分组分析
736 918
     public void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
737 919
         List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
738
-        int groupNum = 10;
739
-        String subjectid;
920
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
921
+        Map<String, List<RankGroupVo>> groupsMap = new HashMap<>();
922
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
923
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
924
+            studentsDistinct(entry, rsMap);
925
+            List<MsrStudent> studentList = entry.getValue();
926
+            int maxRank = studentList.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
927
+            List<RankGroupVo> groups = MarkingUtil.rankGroup(maxRank, 10);
928
+            groupsMap.put(studentList.get(0).getSubjectid(), groups);
929
+        }
930
+        setClassRankGroup(examid, collect, classRankGroups, groupsMap);
740 931
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
932
+        setClassRankGroup(examid, scCollect, classRankGroups, groupsMap);
933
+        msrClassRankgroupMapper.insertList(classRankGroups);
934
+    }
935
+
936
+    //学科报告-班级学科名次分组计算
937
+    private void setClassRankGroup(Integer examid, Map<String, List<MsrStudent>> scCollect
938
+            , List<MsrClassRankgroup> classRankGroups, Map<String, List<RankGroupVo>> groupsMap) {
939
+        String subjectid;
741 940
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
742 941
             String key = entry.getKey();
743 942
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
744 943
             subjectid = key.split("_")[1];
745 944
             List<MsrStudent> studentList = entry.getValue();
746
-            int maxRank = studentList.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
747
-            List<RankGroupVo> groups = MarkingUtil.rankGroup(maxRank, groupNum);
945
+            List<RankGroupVo> groups = groupsMap.get(subjectid);
748 946
             for (RankGroupVo group : groups) {
749 947
                 int maxvalue = group.getMaxvalue();
750 948
                 int minvalue = group.getMinvalue();
@@ -760,7 +958,6 @@ public class MsrExamService {
760 958
                 classRankGroups.add(cg);
761 959
             }
762 960
         }
763
-        msrClassRankgroupMapper.insertList(classRankGroups);
764 961
     }
765 962
 
766 963
     //综合报表-名次和比例分析
@@ -774,26 +971,27 @@ public class MsrExamService {
774 971
             tMap.put(subjectid, param.getRptype());
775 972
         }
776 973
         List<MsrClassRankrate> classRankrates = new ArrayList<>();
777
-        String subjectid;
778
-        int totalnum;
779
-        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
780
-        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
781
-            String key = entry.getKey();
782
-            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
783
-            subjectid = key.split("_")[1];
974
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
975
+        Map<String, List<RankRateGroupVo>> sgMap = new HashMap<>();//学科名次分组map
976
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
977
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
978
+            studentsDistinct(entry, rsMap);
979
+            List<RankRateGroupVo> subjectGroupList = new ArrayList<>();//学科名次分组列表
980
+            String subjectid = entry.getKey().split("_")[1];
784 981
             List<SzJsonVo> list = qjMap.get(subjectid);
785 982
             Integer rptype = tMap.get(subjectid);
786 983
             List<MsrStudent> studentList = entry.getValue();
787 984
             if (rptype.equals(3)) {
788 985
                 studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
789 986
             }
790
-            totalnum = studentList.size();//区间总人数
987
+            int totalnum = studentList.size();//总人数
791 988
             Double max = null;
792 989
             Integer minRank = null;
793 990
             int minIndex = 0;
794 991
             Object minRate = null;
795 992
             for (SzJsonVo rg : list) {
796 993
                 Object djvalue = rg.getDjvalue();
994
+                RankRateGroupVo group = new RankRateGroupVo();
797 995
                 List<MsrStudent> qjstudents;
798 996
                 String ztname;
799 997
                 String ctname;
@@ -801,23 +999,28 @@ public class MsrExamService {
801 999
                     ztname = "前" + djvalue + "名";
802 1000
                     Integer rank = N_Utils.obj2Int(djvalue);
803 1001
                     if (minRank == null) {
804
-                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) >= 0).collect(Collectors.toList());
1002
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
805 1003
                     } else {
806 1004
                         Integer finalMinRank = minRank;
807
-                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
1005
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) > 0 && s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
1006
+                        group.setMinrank(minRank);
808 1007
                     }
1008
+                    group.setMaxrank(rank);
809 1009
                     minRank = rank;
810 1010
                     double minScore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
811 1011
                     ctname = ">=" + minScore + "分";
812 1012
                 } else if (rptype.equals(2)) {//按分数
813 1013
                     ztname = ">=" + djvalue + "分";
814 1014
                     Double score = MarkingUtil.objToDouble(djvalue);
1015
+                    double minScore = score;
815 1016
                     if (max == null) {
816 1017
                         qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
817 1018
                     } else {
818 1019
                         Double finalMax = max;
819 1020
                         qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
1021
+                        group.setMaxscore(max);
820 1022
                     }
1023
+                    group.setMinscore(minScore);
821 1024
                     max = score;
822 1025
                     minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
823 1026
                     ctname = "前" + minRank + "名";
@@ -836,16 +1039,65 @@ public class MsrExamService {
836 1039
                     double minScore = N_Utils.handleInfinity(statistics.getMin());
837 1040
                     double maxScore = N_Utils.handleInfinity(statistics.getMax());
838 1041
                     ctname = "[" + minScore + "-" + maxScore + "]";
1042
+                    group.setMaxscore(maxScore);
1043
+                    group.setMinscore(minScore);
1044
+                }
1045
+                group.setRtype(rptype);
1046
+                group.setZtname(ztname);
1047
+                group.setCtname(ctname);
1048
+                subjectGroupList.add(group);
1049
+            }
1050
+            sgMap.put(subjectid, subjectGroupList);
1051
+        }
1052
+        setClassRankRate(examid, collect, classRankrates, sgMap, rsMap);
1053
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
1054
+        setClassRankRate(examid, scCollect, classRankrates, sgMap, rsMap);
1055
+        msrClassRankrateMapper.insertList(classRankrates);
1056
+    }
1057
+
1058
+    //综合报表-名次和比例计算
1059
+    private void setClassRankRate(Integer examid, Map<String, List<MsrStudent>> scCollect
1060
+            , List<MsrClassRankrate> classRankrates, Map<String, List<RankRateGroupVo>> sgMap
1061
+            , Map<String, Integer> rsMap) {
1062
+        int totalnum;
1063
+        String subjectid;
1064
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
1065
+            String key = entry.getKey();
1066
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
1067
+            subjectid = key.split("_")[1];
1068
+            totalnum = rsMap.get(subjectid);
1069
+            List<RankRateGroupVo> list = sgMap.get(subjectid);
1070
+            Integer rptype = list.get(0).getRtype();
1071
+            List<MsrStudent> studentList = entry.getValue();
1072
+            if (rptype.equals(3)) {
1073
+                studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
1074
+            }
1075
+            int stunum = studentList.size();//参考人数
1076
+            for (int i = 0; i < list.size(); i++) {
1077
+                RankRateGroupVo rg = list.get(i);
1078
+                List<MsrStudent> qjstudents;
1079
+                if (rptype.equals(1)) {//按名次
1080
+                    if (i == 0) {
1081
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0).collect(Collectors.toList());
1082
+                    } else {
1083
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0 && s.getSchoolrank().compareTo(rg.getMinrank()) < 0).collect(Collectors.toList());
1084
+                    }
1085
+                } else {//按分数
1086
+                    if (i == 0) {
1087
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0).collect(Collectors.toList());
1088
+                    } else {
1089
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0 && s.getStuscore().compareTo(rg.getMaxscore()) < 0).collect(Collectors.toList());
1090
+                    }
839 1091
                 }
840 1092
                 int qjnum = qjstudents.size();
841 1093
                 MsrClassRankrate rankrate = new MsrClassRankrate();
842 1094
                 rankrate.setExamid(examid);
843 1095
                 rankrate.setSubjectid(subjectid);
844 1096
                 rankrate.setClassid(classid);
845
-                rankrate.setStunum(totalnum);
1097
+                rankrate.setStunum(stunum);
846 1098
                 rankrate.setRtype(rptype);
847
-                rankrate.setZtname(ztname);
848
-                rankrate.setCtname(ctname);
1099
+                rankrate.setZtname(rg.getZtname());
1100
+                rankrate.setCtname(rg.getCtname());
849 1101
                 rankrate.setRnum(qjnum);
850 1102
                 rankrate.setRrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
851 1103
                 String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
@@ -853,23 +1105,36 @@ public class MsrExamService {
853 1105
                 classRankrates.add(rankrate);
854 1106
             }
855 1107
         }
856
-        msrClassRankrateMapper.insertList(classRankrates);
857 1108
     }
858 1109
 
859 1110
     //班级学科四率等级分析
860 1111
     public void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
861
-        Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scorerate", reportcode);
1112
+        Map<String, List<SzJsonVo>> qjMap = formatSzJson(getMsrReportParams(examid, "scorerate", reportcode));
862 1113
         List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
863
-        String subjectid;
864
-        int totalnum;
1114
+        Map<String, List<MsrStudent>> collect = getSubjectCollect(msrStudents);
1115
+        Map<String, Integer> rsMap = new HashMap<>();//学科人数map
1116
+        for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
1117
+            studentsDistinct(entry, rsMap);
1118
+        }
1119
+        setClassSubjectGrade(examid, reportcode, collect, qjMap, msrClassSubjectGrades, rsMap);
865 1120
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
1121
+        setClassSubjectGrade(examid, reportcode, scCollect, qjMap, msrClassSubjectGrades, rsMap);
1122
+        msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
1123
+    }
1124
+
1125
+    //班级学科四率等级计算
1126
+    private void setClassSubjectGrade(Integer examid, String reportcode, Map<String, List<MsrStudent>> scCollect
1127
+            , Map<String, List<SzJsonVo>> qjMap, List<MsrClassSubjectGrade> msrClassSubjectGrades
1128
+            , Map<String, Integer> rsMap) {
1129
+        int totalnum;
1130
+        String subjectid;
866 1131
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
867 1132
             String key = entry.getKey();
868 1133
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
869 1134
             subjectid = key.split("_")[1];
870 1135
             List<SzJsonVo> list = qjMap.get(subjectid);
871 1136
             List<MsrStudent> studentList = entry.getValue();
872
-            totalnum = studentList.size();//区间总人数
1137
+            totalnum = rsMap.get(subjectid);//科目总人数
873 1138
             Double fullscore1 = studentList.get(0).getFullscore();
874 1139
             for (SzJsonVo rg : list) {
875 1140
                 String qjname = rg.getDjkey();
@@ -910,13 +1175,6 @@ public class MsrExamService {
910 1175
                 classSubjectGrade.setRangenumrank(rspm.get(classSubjectGrade.getRangenum()));
911 1176
             }
912 1177
         }
913
-        msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
914
-    }
915
-
916
-    //获取报告参数
917
-    private Map<String, List<SzJsonVo>> getReportParams(Integer examid, String rpbelong, String reportcode) {
918
-        List<MsrReportparam> list = getMsrReportParams(examid, rpbelong, reportcode);
919
-        return formatSzJson(list);
920 1178
     }
921 1179
 
922 1180
     //格式化报告参数
@@ -931,7 +1189,7 @@ public class MsrExamService {
931 1189
     //获取报告参数
932 1190
     private List<MsrReportparam> getMsrReportParams(Integer examid, String rpbelong, String reportcode) {
933 1191
         List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
934
-        if (N_Utils.isListEmpty(list)) {
1192
+        if (N_Utils.isListEmpty(list) && !"all".equals(reportcode)) {
935 1193
             list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
936 1194
         }
937 1195
         return list;
@@ -951,7 +1209,7 @@ public class MsrExamService {
951 1209
         List<Double> scoreRates = schoolStudents2.stream().map(MsrStudent::getScorerate).sorted().collect(Collectors.toList());
952 1210
         double dfllc = MarkingUtil.sub(scoreRates.get(scoreRates.size() - 1), scoreRates.get(0));
953 1211
         msrSubject.setDfllc(dfllc);
954
-        msrSubject.setDflxdlc(MarkingUtil.div(dfllc, avgscore));
1212
+        msrSubject.setDflxdlc(MarkingUtil.div(dfllc, msrSubject.getScorerate()));
955 1213
         msrSubject.setEsscore(MarkingUtil.cynjdf(scores, 0.2));
956 1214
         msrSubject.setSsscore(MarkingUtil.cynjdf(scores, 0.4));
957 1215
         msrSubject.setLsscore(MarkingUtil.cynjdf(scores, 0.6));

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

@@ -469,7 +469,7 @@ public class MarkingUtil {
469 469
         if (N_Utils.isListEmpty(list)) return modes;
470 470
 
471 471
         // 使用HashMap来统计每个元素出现的次数
472
-        Map<Double, Long> countMap = list.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()));
472
+        Map<Double, Long> countMap = list.stream().filter(s -> s > 0).collect(Collectors.groupingBy(e -> e, Collectors.counting()));
473 473
 
474 474
         long maxCount = 0;
475 475
         // 找出最大的出现次数
@@ -729,6 +729,61 @@ public class MarkingUtil {
729 729
         }
730 730
         return "";
731 731
     }
732
+
733
+    private static int index = 0;
734
+    //根据表达式计算
735
+    public static double evaluate(String expression) {
736
+        index = 0;
737
+        return parseExpression(expression);
738
+    }
739
+
740
+    private static double parseExpression(String expr) {
741
+        try {
742
+            double result = parseTerm(expr);
743
+            while (index < expr.length() && (expr.charAt(index) == '+' || expr.charAt(index) == '-')) {
744
+                char op = expr.charAt(index);
745
+                index++;
746
+                if (op == '+') {
747
+                    result += parseTerm(expr);
748
+                } else if (op == '-') {
749
+                    result -= parseTerm(expr);
750
+                }
751
+            }
752
+            return result;
753
+        } catch (Exception e) {
754
+            return 0.0;
755
+        }
756
+    }
757
+
758
+    private static double parseTerm(String expr) {
759
+        double result = parseFactor(expr);
760
+        while (index < expr.length() && (expr.charAt(index) == '*' || expr.charAt(index) == '/')) {
761
+            char op = expr.charAt(index);
762
+            index++;
763
+            if (op == '*') {
764
+                result *= parseFactor(expr);
765
+            } else if (op == '/') {
766
+                result /= parseFactor(expr);
767
+            }
768
+        }
769
+        return result;
770
+    }
771
+
772
+    private static double parseFactor(String expr) {
773
+        if (expr.charAt(index) == '(') {
774
+            index++;  // Skip '('
775
+            double result = parseExpression(expr);
776
+            index++;  // Skip ')'
777
+            return result;
778
+        } else {
779
+            int start = index;
780
+            while (index < expr.length() && Character.isDigit(expr.charAt(index))) {
781
+                index++;
782
+            }
783
+            return Double.parseDouble(expr.substring(start, index));  // Convert substring to double
784
+        }
785
+    }
786
+
732 787
     public static void main(String[] args) {
733 788
         List<String> options = Arrays.asList("A","B","D","F","","C","E");
734 789
         List<String> newOptions = options.stream().map(s -> s != null && !s.isEmpty() ? s : "未作答").sorted().collect(Collectors.toList());

+ 26
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/report/reportclass/RankRateGroupVo.java View File

@@ -0,0 +1,26 @@
1
+package com.xhkjedu.smarking.vo.report.reportclass;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @Description 名次和比例分组
7
+ * @Author YWX
8
+ * @Date 2024/12/26 14:17
9
+ **/
10
+@Data
11
+public class RankRateGroupVo {
12
+    //主类型名(综合里表格头展示用)
13
+    private String ztname;
14
+    //次类型名(综合里表格头展示用)
15
+    private String ctname;
16
+    //类型(1名次 2分数 3比例)
17
+    private Integer rtype;
18
+    //最大名次
19
+    private Integer maxrank;
20
+    //最小名次
21
+    private Integer minrank;
22
+    //最高分
23
+    private Double maxscore;
24
+    //最低分
25
+    private Double minscore;
26
+}

Loading…
Cancel
Save