Browse Source

班级学科四率等级分析

ywx
雍文秀 4 weeks ago
parent
commit
474969dcce

+ 4
- 6
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassSubjectGrade.java View File

@@ -23,6 +23,8 @@ public class MsrClassSubjectGrade extends BaseBean {
23 23
     private Integer classid;
24 24
     //科目ID(含总分)
25 25
     private String subjectid;
26
+    //归属报告模块编码:zh综合报告 xj校级报告 xk学科报告 bj班级报告 xs学生报告 mtzl命题质量报告 jxzl教学质量报告 xksy学科素养报告
27
+    private String reportcode;
26 28
     //四率/等级
27 29
     private String range;
28 30
     //四率对应人数
@@ -31,14 +33,10 @@ public class MsrClassSubjectGrade extends BaseBean {
31 33
     private Integer rangenumrank;
32 34
     //四率对应率
33 35
     private Double rangerate;
34
-    //全科四率对应人数
35
-    private Integer qkrangenum;
36
-    //全科四率对应人数排名
37
-    private Integer qkrangenumrank;
38
-    //全科四率对应率
39
-    private Double qkrangerate;
40 36
     //等级分值
41 37
     private Double djscore;
42 38
     //等级得分率比例
43 39
     private Double djrate;
40
+    //学生id字符串
41
+    private String stuids;
44 42
 }

+ 2
- 2
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassTop.java View File

@@ -31,12 +31,12 @@ public class MsrClassTop extends BaseBean {
31 31
     private Double btrate;
32 32
     //班前60%人数平均分
33 33
     private Double btavgscore;
34
-    //班前60%学id字符串
34
+    //班前60%学id字符串
35 35
     private String btstuids;
36 36
     //校级前60%人数
37 37
     private Integer xtnum;
38 38
     //校前60%人数平均分
39 39
     private Double xtavgscore;
40
-    //校前60%学id字符串
40
+    //校前60%学id字符串
41 41
     private String xtstuids;
42 42
 }

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

@@ -31,6 +31,6 @@ public class MsrSubjectClass extends BaseBean {
31 31
     private Double qjrate;
32 32
     //区间平均得分率
33 33
     private Double qjavgrate;
34
-    //学id字符串
34
+    //学id字符串
35 35
     private String stuids;
36 36
 }

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

@@ -2,8 +2,7 @@ package com.xhkjedu.smarking.service.report.reportother;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.xhkjedu.smarking.mapper.exam.*;
5
-import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassSubjectMapper;
6
-import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassTopMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportclass.*;
7 6
 import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
8 7
 import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
9 8
 import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
@@ -12,8 +11,7 @@ import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
12 11
 import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
13 12
 import com.xhkjedu.smarking.model.exam.*;
14 13
 import com.xhkjedu.smarking.model.paper.MsPaper;
15
-import com.xhkjedu.smarking.model.report.reportclass.MsrClassSubject;
16
-import com.xhkjedu.smarking.model.report.reportclass.MsrClassTop;
14
+import com.xhkjedu.smarking.model.report.reportclass.*;
17 15
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
18 16
 import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
19 17
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
@@ -60,6 +58,8 @@ public class MsrExamService {
60 58
     private MsrClassSubjectMapper msrClassSubjectMapper;
61 59
     @Resource
62 60
     private MsrClassTopMapper msrClassTopMapper;
61
+    @Resource
62
+    private MsrClassSubjectGradeMapper msrClassSubjectGradeMapper;
63 63
 
64 64
 
65 65
     /**
@@ -87,7 +87,7 @@ public class MsrExamService {
87 87
         }
88 88
 
89 89
         //等级参数
90
-        List<MsrReportparam> djParams = msrReportparamMapper.listReportparamByRpbelong(examid, "subjectshow", "");
90
+        List<MsrReportparam> djParams = msrReportparamMapper.listReportparamByRpbelong(examid, "subjectshow", "all");
91 91
         List<SzJsonVo> djList = new ArrayList<>();
92 92
         if (N_Utils.isListNotEmpty(djParams)) {
93 93
             djList = JSON.parseArray(djParams.get(0).getSzjson(), SzJsonVo.class);
@@ -259,11 +259,7 @@ public class MsrExamService {
259 259
 
260 260
         //科目班级分数分布区间分析、班级学科分析
261 261
         //区间参数
262
-        List<MsrReportparam> qjParams = msrReportparamMapper.listReportparamByRpbelong(examid, "scoresection", "xk");
263
-        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
264
-        for (MsrReportparam param : qjParams) {
265
-            qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
266
-        }
262
+        Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scoresection", "xk");
267 263
         List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();//科目班级分数分布区间分析
268 264
         List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
269 265
         List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
@@ -349,9 +345,80 @@ public class MsrExamService {
349 345
         msrClassSubjectMapper.insertList(msrClassSubjects);
350 346
         msrClassTopMapper.insertList(msrClassTops);
351 347
 
348
+        saveClassSubjectGrade(examid, "scorerate", "zh", msrStudents);//综合报告-班级学科四率等级分析
349
+        saveClassSubjectGrade(examid, "scorerate", "xj", msrStudents);//校级报告-班级学科四率等级分析
350
+
352 351
         examMapper.updateExamState(examid, 3);
353 352
     }
354 353
 
354
+    //班级学科四率等级分析
355
+    private void saveClassSubjectGrade(Integer examid, String rpbelong, String reportcode, List<MsrStudent> msrStudents) {
356
+        Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, rpbelong, reportcode);
357
+        List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
358
+        String subjectid;
359
+        int totalnum;
360
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
361
+        List<Integer> nums = new ArrayList<>();
362
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
363
+            String key = entry.getKey();
364
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
365
+            subjectid = key.split("_")[1];
366
+            List<SzJsonVo> list = qjMap.get(subjectid);
367
+            List<MsrStudent> studentList = entry.getValue();
368
+            totalnum = studentList.size();//区间总人数
369
+            Double fullscore1 = studentList.get(0).getFullscore();
370
+            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(list.get(0).getDjvalue()));
371
+            for (RankGroupVo rg : fdScore) {
372
+                int minscore = rg.getMinvalue();
373
+                int maxscore = rg.getMaxvalue();
374
+                String qjname = rg.getGroupname();
375
+                double min = MarkingUtil.objToDouble(minscore);
376
+                double max = MarkingUtil.objToDouble(maxscore);
377
+                List<MsrStudent> qjstudents;
378
+                if (fullscore1.compareTo(max) == 0) {
379
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
380
+                } else {
381
+                    qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0 && s.getStuscore().compareTo(max) < 0).collect(Collectors.toList());
382
+                }
383
+                int qjnum = qjstudents.size();
384
+                MsrClassSubjectGrade classSubjectGrade = new MsrClassSubjectGrade();
385
+                classSubjectGrade.setExamid(examid);
386
+                classSubjectGrade.setSubjectid(subjectid);
387
+                classSubjectGrade.setClassid(classid);
388
+                classSubjectGrade.setReportcode(reportcode);
389
+                classSubjectGrade.setRange(qjname);
390
+                classSubjectGrade.setRangenum(qjnum);
391
+                classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
392
+                //double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
393
+                //classSubjectGrade.setQjavgrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
394
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
395
+                classSubjectGrade.setStuids(stuids);
396
+                msrClassSubjectGrades.add(classSubjectGrade);
397
+                nums.add(qjnum);
398
+            }
399
+        }
400
+        Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
401
+        for (MsrClassSubjectGrade classSubjectGrade : msrClassSubjectGrades) {
402
+            int rangenum = classSubjectGrade.getRangenum();
403
+            int rank = rspm.get(rangenum);
404
+            classSubjectGrade.setRangenumrank(rank);
405
+        }
406
+        msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
407
+    }
408
+
409
+    //获取报告参数
410
+    private Map<String, List<SzJsonVo>> getReportParams(Integer examid, String rpbelong, String reportcode) {
411
+        List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
412
+        if (N_Utils.isListEmpty(list)) {
413
+            list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
414
+        }
415
+        Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
416
+        for (MsrReportparam param : list) {
417
+            qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
418
+        }
419
+        return qjMap;
420
+    }
421
+
355 422
     //设置科目分析计算参数
356 423
     private void setSubject(MsrSubject msrSubject, List<MsrStudent> schoolStudents2) {
357 424
         Double avgscore = msrSubject.getAvgscore();

+ 25
- 3
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

@@ -577,12 +577,34 @@ public class MarkingUtil {
577 577
 
578 578
     //分数排名
579 579
     public static Map<Double,Integer> fspm(List<Double> scores) {
580
+        //倒序排
581
+        Collections.sort(scores, Collections.reverseOrder());
580 582
         // 创建一个地图来存储分数和出现次数
581 583
         Map<Double, Integer> scoreCountMap = new HashMap<>();
582 584
 
583
-        // 遍历 scores 计算分数出现的次数
584
-        for (Double score : scores) {
585
-            scoreCountMap.put(score, scoreCountMap.getOrDefault(score, 0) + 1);
585
+        int rank = 1;
586
+        Map<Double, List<Double>> collect = scores.stream().collect(Collectors.groupingBy(s -> s, LinkedHashMap::new, Collectors.toList()));
587
+        for (Map.Entry<Double, List<Double>> entry : collect.entrySet()) {
588
+            Double key = entry.getKey();
589
+            scoreCountMap.put(key, rank);
590
+            rank += entry.getValue().size();
591
+        }
592
+        return scoreCountMap;
593
+    }
594
+
595
+    //人数排名
596
+    public static Map<Integer,Integer> rspm(List<Integer> nums) {
597
+        //倒序排
598
+        Collections.sort(nums, Collections.reverseOrder());
599
+        // 创建一个地图来存储分数和出现次数
600
+        Map<Integer, Integer> scoreCountMap = new HashMap<>();
601
+
602
+        int rank = 1;
603
+        Map<Integer, List<Integer>> collect = nums.stream().collect(Collectors.groupingBy(s -> s, LinkedHashMap::new, Collectors.toList()));
604
+        for (Map.Entry<Integer, List<Integer>> entry : collect.entrySet()) {
605
+            Integer key = entry.getKey();
606
+            scoreCountMap.put(key, rank);
607
+            rank += entry.getValue().size();
586 608
         }
587 609
         return scoreCountMap;
588 610
     }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/vo/report/reportclass/ClassTopVo.java View File

@@ -17,6 +17,6 @@ public class ClassTopVo {
17 17
     private Integer xtnum;
18 18
     //校前60%人数平均分
19 19
     private Double xtavgscore;
20
-    //校前60%学id字符串
20
+    //校前60%学id字符串
21 21
     private String xtstuids;
22 22
 }

+ 2
- 1
smarking/src/main/resources/mapper/exam/MsExamMapper.xml View File

@@ -24,7 +24,8 @@
24 24
     </delete>
25 25
     <!--考试科目列表-->
26 26
     <select id="listSubject" resultType="java.util.Map">
27
-        select subjectname,if(pstate=1 and ptstate=2 and pbstate=2 and checkstate!=0 and checkset=1
27
+        select subjectid,subjectname
28
+        ,if(pstate=1 and ptstate=2 and pbstate=2 and checkstate!=0 and checkset=1
28 29
         and (#{exammode}!=3 or invigilatestate=2)
29 30
         and (select count(ps.mpsid) from ms_paper_student ps where ps.msid=s.msid and ps.sstate=2 and ps.checked!=2)=0
30 31
         ,1,0) as state

Loading…
Cancel
Save