Quellcode durchsuchen

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

ywx
王宁 vor 3 Tagen
Ursprung
Commit
575e1a1ef3

+ 6
- 2
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassNearline.java Datei anzeigen

@@ -39,8 +39,6 @@ public class MsrClassNearline extends BaseBean {
39 39
     private Integer ljsxnum;
40 40
     //累计上线率
41 41
     private Double ljsxrate;
42
-    //单科上线人数
43
-    private Integer dksxnum;
44 42
     //双上线人数
45 43
     private Integer ssxnum;
46 44
     //总分上线学科未上线人数
@@ -53,4 +51,10 @@ public class MsrClassNearline extends BaseBean {
53 51
     private Integer ljsnum;
54 52
     //临界生平均分
55 53
     private Double ljsavgscore;
54
+    //单上线学生id字符串
55
+    private String stuids;
56
+    //双上线学生id字符串
57
+    private String stuids2;
58
+    //临界生id字符串
59
+    private String stuids3;
56 60
 }

+ 149
- 7
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java Datei anzeigen

@@ -67,6 +67,8 @@ public class MsrExamService {
67 67
     private MsrClassRankrateMapper msrClassRankrateMapper;
68 68
     @Resource
69 69
     private MsrClassSectionMapper msrClassSectionMapper;
70
+    @Resource
71
+    private MsrClassNearlineMapper msrClassNearlineMapper;
70 72
 
71 73
 
72 74
     /**
@@ -367,10 +369,146 @@ public class MsrExamService {
367 369
         saveClassSection(examid, 1, "xk", msrStudents);//学科报告-分段统计
368 370
         saveClassSection(examid, 1, "bj", msrStudents);//班级报告-分段统计
369 371
         saveClassSection(examid, 1, "jxzl", msrStudents);//教学质量-分段统计
372
+        saveClassNearLine(examid, msrStudents);//分档上线统计
370 373
 
371 374
         examMapper.updateExamState(examid, 3);
372 375
     }
373 376
 
377
+    //分档上线分析
378
+    public void saveClassNearLine(Integer examid, List<MsrStudent> msrStudents) {
379
+        List<MsrReportparam> params = getMsrReportParams(examid, "gradescore", "all");
380
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
381
+        Map<String, Integer> tMap = new HashMap<>();
382
+        for (MsrReportparam param : params) {
383
+            String subjectid = param.getSubjectid();
384
+            qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
385
+            tMap.put(subjectid, param.getRptype());
386
+        }
387
+        params = getMsrReportParams(examid, "nearline", "all");
388
+        List<SzJsonVo> vos = JSON.parseArray(params.get(0).getSzjson(), SzJsonVo.class);
389
+        Map<Integer, List<Integer>> zfSx = new HashMap<>();//学生总分是否上线
390
+        List<MsrClassNearline> classNearlines = new ArrayList<>();
391
+        String subjectid;
392
+        int totalnum;
393
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
394
+        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
+            List<SzJsonVo> list = qjMap.get(subjectid);
399
+            Integer rptype = tMap.get(subjectid);
400
+            List<MsrStudent> studentList = entry.getValue();
401
+            if (rptype.equals(3)) {
402
+                studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
403
+            }
404
+            totalnum = studentList.size();//区间总人数
405
+            Double max = null;
406
+            Integer minRank = null;
407
+            int minIndex = 0;
408
+            for (int i = 0; i < list.size(); i++) {
409
+                SzJsonVo fd = vos.get(i);
410
+                Double fdMaxScore = fd.getMaxvalue();//档位浮动分数
411
+                if (fdMaxScore == null) fdMaxScore = MarkingUtil.objToDouble(fd.getDjvalue());
412
+                Double fdMinScore = fd.getMinvalue();//档位浮动分数
413
+                if (fdMinScore == null) {
414
+                    fdMinScore = fdMaxScore;
415
+                }
416
+                SzJsonVo rg = list.get(i);
417
+                Object djvalue = rg.getDjvalue();
418
+                double dwscore;
419
+                List<MsrStudent> qjstudents;//上线学生列表
420
+                List<MsrStudent> ljstudents;//累计上线学生列表
421
+                if (rptype.equals(1)) {//按名次
422
+                    Integer rank = N_Utils.obj2Int(djvalue);
423
+                    ljstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
424
+                    if (minRank == null) {
425
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
426
+                    } else {
427
+                        Integer finalMinRank = minRank;
428
+                        qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
429
+                    }
430
+                    minRank = rank;
431
+                    dwscore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
432
+                } else if (rptype.equals(2)) {//按分数
433
+                    Double score = MarkingUtil.objToDouble(djvalue);
434
+                    ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
435
+                    if (max == null) {
436
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
437
+                    } else {
438
+                        Double finalMax = max;
439
+                        qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
440
+                    }
441
+                    dwscore = MarkingUtil.objToDouble(djvalue);
442
+                    max = score;
443
+                    minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
444
+                } else {//按比例
445
+                    int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
446
+                    if (index > totalnum) index = totalnum;
447
+                    qjstudents = studentList.subList(minIndex, index);
448
+                    minIndex = index;
449
+                    DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
450
+                    dwscore = N_Utils.handleInfinity(statistics.getMin());
451
+                    ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(dwscore) >= 0).collect(Collectors.toList());
452
+                }
453
+                int qjnum = qjstudents.size();
454
+                MsrClassNearline nearline = new MsrClassNearline();
455
+                nearline.setExamid(examid);
456
+                nearline.setSubjectid(subjectid);
457
+                nearline.setClassid(classid);
458
+                Integer dworder = i + 1;
459
+                String dwname = N_Utils.NumberToChn(dworder) + "档";
460
+                nearline.setDwname(dwname);
461
+                nearline.setDworder(dworder);
462
+                nearline.setDwscore(dwscore);
463
+                nearline.setSxnum(qjnum);
464
+                nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
465
+                int ljsxnum = ljstudents.size();
466
+                nearline.setLjsxnum(ljsxnum);
467
+                nearline.setLjsxrate(N_Utils.getIntegerDivideAndMulitiply(ljsxnum, totalnum));
468
+                if ("zf".equals(subjectid)) {
469
+                    List<Integer> ids = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
470
+                    zfSx.put(dworder, ids);
471
+                } else {
472
+                    List<Integer> zfsxIds = zfSx.get(dworder);//总分上线学生id列表
473
+                    int zfsxnum = zfsxIds.size();
474
+                    List<MsrStudent> ssxIds = qjstudents.stream().filter(s -> zfsxIds.contains(s.getStudentid())).collect(Collectors.toList());
475
+                    Integer ssxnum = ssxIds.size();//双上线人数
476
+                    nearline.setSsxnum(ssxnum);
477
+                    nearline.setStuids2(ssxIds.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
478
+                    //总分上线学科未上线人数
479
+                    List<Integer> dksxIds = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
480
+                    zfsxIds.removeAll(dksxIds);
481
+                    int zfsxxkwsxnum = zfsxIds.size();
482
+                    nearline.setZfsxxkwsxnum(zfsxxkwsxnum);
483
+                    nearline.setGxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, zfsxnum));
484
+                    nearline.setMzxrate(N_Utils.getIntegerDivideAndMulitiply(ssxnum, qjnum));
485
+                }
486
+                nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
487
+                double ljMax = MarkingUtil.add(dwscore, fdMaxScore);
488
+                double ljMin = MarkingUtil.sub(dwscore, fdMinScore);
489
+                List<MsrStudent> ljStudents = studentList.stream().filter(s -> s.getStuscore().compareTo(ljMax) <= 0 && s.getStuscore().compareTo(ljMin) >= 0).collect(Collectors.toList());
490
+                nearline.setLjsnum(ljStudents.size());
491
+                nearline.setStuids3(ljStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
492
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
493
+                nearline.setStuids(stuids);
494
+                classNearlines.add(nearline);
495
+            }
496
+        }
497
+        Map<String, List<MsrClassNearline>> collect = classNearlines.stream().collect(Collectors.groupingBy(l -> l.getSubjectid() + "_" + l.getDworder()));
498
+        for (Map.Entry<String, List<MsrClassNearline>> entry : collect.entrySet()) {
499
+            List<MsrClassNearline> nearlineList = entry.getValue();
500
+            List<Integer> nums = new ArrayList<>();
501
+            for (MsrClassNearline nearline : nearlineList) {
502
+                nums.add(nearline.getSxnum());
503
+            }
504
+            Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
505
+            for (MsrClassNearline nearline : nearlineList) {
506
+                nearline.setSxrank(rspm.get(nearline.getSxnum()));
507
+            }
508
+        }
509
+        msrClassNearlineMapper.insertList(classNearlines);
510
+    }
511
+
374 512
     //分段统计
375 513
     public void saveClassSection(Integer examid, Integer type, String reportcode, List<MsrStudent> msrStudents) {
376 514
         List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", reportcode);
@@ -564,7 +702,6 @@ public class MsrExamService {
564 702
         String subjectid;
565 703
         int totalnum;
566 704
         Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
567
-        List<Integer> nums = new ArrayList<>();
568 705
         for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
569 706
             String key = entry.getKey();
570 707
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
@@ -598,14 +735,19 @@ public class MsrExamService {
598 735
                 String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
599 736
                 classSubjectGrade.setStuids(stuids);
600 737
                 msrClassSubjectGrades.add(classSubjectGrade);
601
-                nums.add(qjnum);
602 738
             }
603 739
         }
604
-        Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
605
-        for (MsrClassSubjectGrade classSubjectGrade : msrClassSubjectGrades) {
606
-            int rangenum = classSubjectGrade.getRangenum();
607
-            int rank = rspm.get(rangenum);
608
-            classSubjectGrade.setRangenumrank(rank);
740
+        Map<String, List<MsrClassSubjectGrade>> collect = msrClassSubjectGrades.stream().collect(Collectors.groupingBy(g -> g.getSubjectid() + "_" + g.getRangename()));
741
+        for (Map.Entry<String, List<MsrClassSubjectGrade>> entry : collect.entrySet()) {
742
+            List<MsrClassSubjectGrade> nearlineList = entry.getValue();
743
+            List<Integer> nums = new ArrayList<>();
744
+            for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
745
+                nums.add(classSubjectGrade.getRangenum());
746
+            }
747
+            Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
748
+            for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
749
+                classSubjectGrade.setRangenumrank(rspm.get(classSubjectGrade.getRangenum()));
750
+            }
609 751
         }
610 752
         msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
611 753
     }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java Datei anzeigen

@@ -132,6 +132,8 @@ public class MarkingUtil {
132 132
      * @return 两个参数的和
133 133
      */
134 134
     public static double add(Object v1, Object v2) {
135
+        if (v1 == null) v1 = 0;
136
+        if (v2 == null) v2 = 0;
135 137
         BigDecimal b1 = new BigDecimal(v1.toString());
136 138
         BigDecimal b2 = new BigDecimal(v2.toString());
137 139
         return b1.add(b2).doubleValue();

Laden…
Abbrechen
Speichern