雍文秀 před 6 dny
rodič
revize
17e4477028

+ 8
- 3
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java Zobrazit soubor

@@ -160,9 +160,14 @@ public class N_Utils {
160 160
      * @Param [str]
161 161
      * @Return java.lang.Integer
162 162
      **/
163
-    public static Integer obj2Int(Object str){
164
-        if (isNotEmpty(str)){
165
-            return Integer.parseInt(str.toString());
163
+    public static Integer obj2Int(Object str) {
164
+        if (isNotEmpty(str)) {
165
+            String num = str.toString();
166
+            if (num.contains(".")) {
167
+                return Integer.parseInt(num.split("\\.")[0]);
168
+            } else {
169
+                return Integer.parseInt(num);
170
+            }
166 171
         } else {
167 172
             return 0;
168 173
         }

+ 0
- 2
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassRankrate.java Zobrazit soubor

@@ -23,8 +23,6 @@ public class MsrClassRankrate extends BaseBean {
23 23
     private String subjectid;
24 24
     //班级ID(含全体)
25 25
     private Integer classid;
26
-    //班级名称
27
-    private String classname;
28 26
     //参考人数
29 27
     private Integer stunum;
30 28
     //类型(1名次 2分数 3比例)

+ 4
- 2
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassSection.java Zobrazit soubor

@@ -27,12 +27,14 @@ public class MsrClassSection extends BaseBean {
27 27
     private Integer stunum;
28 28
     //分段类型(1分段统计 2累计统计)
29 29
     private Integer type;
30
-    //分数区间
31
-    private String sfqj;
30
+    //归属报告模块编码
31
+    private String reportcode;
32 32
     //分值范围
33 33
     private String fzfw;
34 34
     //分值范围人数
35 35
     private Integer fzfwnum;
36 36
     //分值范围人数比例
37 37
     private Double fzfwrate;
38
+    //学生id字符串
39
+    private String stuids;
38 40
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassSubjectGrade.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class MsrClassSubjectGrade extends BaseBean {
26 26
     //归属报告模块编码:zh综合报告 xj校级报告 xk学科报告 bj班级报告 xs学生报告 mtzl命题质量报告 jxzl教学质量报告 xksy学科素养报告
27 27
     private String reportcode;
28 28
     //四率/等级
29
-    private String range;
29
+    private String rangename;
30 30
     //四率对应人数
31 31
     private Integer rangenum;
32 32
     //四率对应人数排名

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

@@ -22,6 +22,7 @@ import com.xhkjedu.smarking.vo.report.reportclass.ClassTopVo;
22 22
 import com.xhkjedu.smarking.vo.report.reportother.*;
23 23
 import com.xhkjedu.utils.N_Utils;
24 24
 import org.springframework.stereotype.Service;
25
+import org.springframework.transaction.annotation.Transactional;
25 26
 
26 27
 import javax.annotation.Resource;
27 28
 import java.util.*;
@@ -64,6 +65,8 @@ public class MsrExamService {
64 65
     private MsrClassRankgroupMapper msrClassRankgroupMapper;
65 66
     @Resource
66 67
     private MsrClassRankrateMapper msrClassRankrateMapper;
68
+    @Resource
69
+    private MsrClassSectionMapper msrClassSectionMapper;
67 70
 
68 71
 
69 72
     /**
@@ -73,6 +76,7 @@ public class MsrExamService {
73 76
      * @Param [examid]
74 77
      * @Return void
75 78
      **/
79
+    @Transactional(rollbackFor = Exception.class)
76 80
     public void generateExamReport(Integer examid) {
77 81
         MsExam exam = examMapper.selectByPrimaryKey(examid);
78 82
         Integer exammode = exam.getExammode();
@@ -263,7 +267,11 @@ public class MsrExamService {
263 267
 
264 268
         //科目班级分数分布区间分析、班级学科分析
265 269
         //区间参数
266
-        Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scoresection", "xk");
270
+        Map<String, SzJsonVo> qjMap = new HashMap<>();
271
+        List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", "xk");
272
+        for (MsrReportparam param : params) {
273
+            qjMap.put(param.getSubjectid(), JSON.parseObject(param.getSzjson(), SzJsonVo.class));
274
+        }
267 275
         List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();//科目班级分数分布区间分析
268 276
         List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
269 277
         List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
@@ -287,11 +295,11 @@ public class MsrExamService {
287 295
             String key = entry.getKey();
288 296
             Integer classid = N_Utils.obj2Int(key.split("_")[0]);
289 297
             subjectid = key.split("_")[1];
290
-            List<SzJsonVo> list = qjMap.get(subjectid);
298
+            SzJsonVo vo = qjMap.get(subjectid);
291 299
             List<MsrStudent> studentList = entry.getValue();
292 300
             totalnum = studentList.size();//区间总人数
293 301
             Double fullscore1 = studentList.get(0).getFullscore();
294
-            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(list.get(0).getDjvalue()));
302
+            List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(vo.getDjvalue()));
295 303
             for (RankGroupVo rg : fdScore) {
296 304
                 int minscore = rg.getMinvalue();
297 305
                 int maxscore = rg.getMaxvalue();
@@ -353,12 +361,80 @@ public class MsrExamService {
353 361
         saveClassSubjectGrade(examid, "xj", msrStudents);//校级报告-班级学科四率等级分析
354 362
         saveClassRankGroup(examid, msrStudents);//学科报告-班级学科名次分组分析
355 363
         saveClassRankRate(examid, msrStudents);//综合报表-名次和比例分析
364
+        saveClassSection(examid, 1, "zh", msrStudents);//综合报表-分段统计
365
+        saveClassSection(examid, 2, "zh", msrStudents);//综合报表-累计统计
366
+        saveClassSection(examid, 1, "xj", msrStudents);//校级报告-分段统计
367
+        saveClassSection(examid, 1, "xk", msrStudents);//学科报告-分段统计
368
+        saveClassSection(examid, 1, "bj", msrStudents);//班级报告-分段统计
369
+        saveClassSection(examid, 1, "jxzl", msrStudents);//教学质量-分段统计
356 370
 
357 371
         examMapper.updateExamState(examid, 3);
358 372
     }
359 373
 
374
+    //分段统计
375
+    public void saveClassSection(Integer examid, Integer type, String reportcode, List<MsrStudent> msrStudents) {
376
+        List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", reportcode);
377
+        Integer rptype = params.get(0).getRptype();
378
+        Map<String, List<RankGroupVo>> fdMap = new HashMap<>();
379
+        if (rptype.equals(0)) {//固定步长
380
+            for (MsrReportparam param : params) {
381
+                SzJsonVo vo = JSON.parseObject(param.getSzjson(), SzJsonVo.class);
382
+                List<RankGroupVo> groups = MarkingUtil.fdScore(N_Utils.obj2Int(vo.getMaxvalue()), N_Utils.obj2Int(vo.getMinvalue()), N_Utils.obj2Int(vo.getDjvalue()), type);
383
+                fdMap.put(param.getSubjectid(), groups);
384
+            }
385
+        } else {//不定步长
386
+            for (MsrReportparam param : params) {
387
+                List<SzJsonVo> vos = JSON.parseArray(param.getSzjson(), SzJsonVo.class);
388
+                List<RankGroupVo> groups = MarkingUtil.fdScore(vos, type);
389
+                fdMap.put(param.getSubjectid(), groups);
390
+            }
391
+        }
392
+
393
+        List<MsrClassSection> classSections = new ArrayList<>();
394
+        String subjectid;
395
+        Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
396
+        for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
397
+            String key = entry.getKey();
398
+            Integer classid = N_Utils.obj2Int(key.split("_")[0]);
399
+            subjectid = key.split("_")[1];
400
+            List<MsrStudent> studentList = entry.getValue();
401
+            Integer stunum = studentList.size();
402
+            List<RankGroupVo> groups = fdMap.get(subjectid);
403
+            for (int i = 0; i < groups.size(); i++) {
404
+                RankGroupVo group = groups.get(i);
405
+                int maxvalue = group.getMaxvalue();
406
+                int minvalue = group.getMinvalue();
407
+                List<MsrStudent> qjstudents;
408
+                if (type.equals(1)) {
409
+                    if (i == 0) {
410
+                        qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) <= 0).collect(Collectors.toList());
411
+                    } else {
412
+                        qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) < 0).collect(Collectors.toList());
413
+                    }
414
+                } else {
415
+                    qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), maxvalue) >= 0).collect(Collectors.toList());
416
+                }
417
+                MsrClassSection classSection = new MsrClassSection();
418
+                classSection.setExamid(examid);
419
+                classSection.setClassid(classid);
420
+                classSection.setSubjectid(subjectid);
421
+                classSection.setStunum(stunum);
422
+                classSection.setType(type);
423
+                classSection.setReportcode(reportcode);
424
+                classSection.setFzfw(group.getGroupname());
425
+                int qjnum = qjstudents.size();
426
+                classSection.setFzfwnum(qjnum);
427
+                classSection.setFzfwrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, stunum));
428
+                String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
429
+                classSection.setStuids(stuids);
430
+                classSections.add(classSection);
431
+            }
432
+        }
433
+        msrClassSectionMapper.insertList(classSections);
434
+    }
435
+
360 436
     //学科报告-班级学科名次分组分析
361
-    private void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
437
+    public void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
362 438
         List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
363 439
         int groupNum = 10;
364 440
         String subjectid;
@@ -389,7 +465,7 @@ public class MsrExamService {
389 465
     }
390 466
 
391 467
     //综合报表-名次和比例分析
392
-    private void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
468
+    public void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
393 469
         List<MsrReportparam> params = getMsrReportParams(examid, "rankrate", "zh");
394 470
         Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
395 471
         Map<String, Integer> tMap = new HashMap<>();
@@ -482,7 +558,7 @@ public class MsrExamService {
482 558
     }
483 559
 
484 560
     //班级学科四率等级分析
485
-    private void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
561
+    public void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
486 562
         Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scorerate", reportcode);
487 563
         List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
488 564
         String subjectid;
@@ -513,11 +589,11 @@ public class MsrExamService {
513 589
                 classSubjectGrade.setSubjectid(subjectid);
514 590
                 classSubjectGrade.setClassid(classid);
515 591
                 classSubjectGrade.setReportcode(reportcode);
516
-                classSubjectGrade.setRange(qjname);
592
+                classSubjectGrade.setRangename(qjname);
517 593
                 classSubjectGrade.setRangenum(qjnum);
518 594
                 classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
519 595
                 double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
520
-                classSubjectGrade.setDjscore(qjavg);
596
+                classSubjectGrade.setDjscore(N_Utils.formatDouble(qjavg, 2));
521 597
                 classSubjectGrade.setDjrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
522 598
                 String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
523 599
                 classSubjectGrade.setStuids(stuids);
@@ -604,12 +680,14 @@ public class MsrExamService {
604 680
         student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
605 681
         student.setClassrank(classrank);
606 682
         student.setSchoolrank(schoolrank);
607
-        double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
683
+        Integer totalnum = msrSubject.getTotalnum();
684
+        double rankrate = MarkingUtil.div(schoolrank, totalnum);
608 685
         student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
609 686
         student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
610 687
         double dfv = N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), msrSubject.getFullscore());
611 688
         student.setGradevalue(MarkingUtil.dj(dfv, djList));
612
-        student.setHighschool(N_Utils.getIntegerDivideAndMulitiply(schoolrank, schoolRankVo.getNum2()));
689
+        int num = totalnum - schoolRankVo.getNum() - schoolRankVo.getNum2();
690
+        student.setHighschool(N_Utils.getIntegerDivideAndMulitiply(num, totalnum));
613 691
     }
614 692
 
615 693
     //分数排名

+ 56
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java Zobrazit soubor

@@ -609,6 +609,62 @@ public class MarkingUtil {
609 609
         return scoreCountMap;
610 610
     }
611 611
 
612
+    // 分数段 分数分段(固定步长)
613
+    public static List<RankGroupVo> fdScore(Integer maxScore, Integer minScore, int fdscore, Integer type) {
614
+        List<RankGroupVo> rtnList = new ArrayList<>();
615
+        for (int i = minScore; i < maxScore; i += fdscore) {
616
+            int end = Math.min(i + fdscore, maxScore);
617
+
618
+            String groupname;
619
+            if (type.equals(1)) {
620
+
621
+                groupname = "[" + i + "~" + end;
622
+                if (end == maxScore) {
623
+                    groupname += "]";
624
+                } else {
625
+                    groupname += ")";
626
+                }
627
+            } else {
628
+                groupname = ">=" + end;
629
+            }
630
+
631
+            RankGroupVo rgvo = new RankGroupVo();
632
+            rgvo.setGroupname(groupname);
633
+            rgvo.setMinvalue(i);
634
+            rgvo.setMaxvalue(end);
635
+            rtnList.add(rgvo);
636
+        }
637
+        return rtnList;
638
+    }
639
+
640
+    // 分数段 分数分段(不定步长)
641
+    public static List<RankGroupVo> fdScore(List<SzJsonVo> vos, Integer type) {
642
+        List<RankGroupVo> rtnList = new ArrayList<>();
643
+        for (int i = 0; i < vos.size(); i++) {
644
+            SzJsonVo vo = vos.get(i);
645
+            Integer minvalue = N_Utils.obj2Int(vo.getMinvalue());
646
+            Integer maxvalue = N_Utils.obj2Int(vo.getMaxvalue());
647
+            String groupname;
648
+            if (type.equals(1)) {
649
+                groupname = "[" + minvalue + "~" + maxvalue;
650
+                if (i == 0) {
651
+                    groupname += "]";
652
+                } else {
653
+                    groupname += ")";
654
+                }
655
+            } else {
656
+                groupname = ">=" + maxvalue;
657
+            }
658
+
659
+            RankGroupVo rgvo = new RankGroupVo();
660
+            rgvo.setGroupname(groupname);
661
+            rgvo.setMinvalue(minvalue);
662
+            rgvo.setMaxvalue(maxvalue);
663
+            rtnList.add(rgvo);
664
+        }
665
+        return rtnList;
666
+    }
667
+
612 668
     // 分数段 分数分段
613 669
     public static List<RankGroupVo> fdScore(Double totalScore,int fdscore){
614 670
         List<RankGroupVo> rtnList = new ArrayList<>();

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