浏览代码

考试报告0分学生是否参与统计

tags/正式3.13.3
雍文秀 1年前
父节点
当前提交
418fb734a2
共有 1 个文件被更改,包括 47 次插入39 次删除
  1. 47
    39
      sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java

+ 47
- 39
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java 查看文件

@@ -32,7 +32,6 @@ import com.xhkjedu.sexam.vo.report.ERPaperVo;
32 32
 import com.xhkjedu.utils.N_Utils;
33 33
 import com.xhkjedu.vo.system.UserVo;
34 34
 import lombok.extern.slf4j.Slf4j;
35
-import org.springframework.beans.factory.annotation.Autowired;
36 35
 import org.springframework.scheduling.annotation.Async;
37 36
 import org.springframework.scheduling.annotation.AsyncResult;
38 37
 import org.springframework.stereotype.Service;
@@ -80,7 +79,7 @@ public class EReportGenerateService {
80 79
     private ERclassActionMapper eRclassActionMapper;
81 80
     @Resource
82 81
     private ERstudentActionMapper eRstudentActionMapper;
83
-    @Autowired
82
+    @Resource
84 83
     private ConvertUtil convertUtil;
85 84
     @Resource
86 85
     private EReportGenerateQuestionService eReportGenerateQuestionService;
@@ -132,14 +131,8 @@ public class EReportGenerateService {
132 131
         Map<String, Integer> classStuRank = new HashMap<>();//班级学生分数排名
133 132
         Map<String, Integer> classSubStuRank = new HashMap<>();//班级科目学生分数排名
134 133
         Integer stuzero = base.getStuzero();
135
-        List<ERstudent> allStudents = ePaperStudentMapper.listByExamId(examid, epids);
136
-        List<ERstudent> students;
137
-        int sknum = allStudents.stream().filter(l -> l.getSstate() == 2).map(l -> l.getStudentid()).distinct().collect(Collectors.toList()).size();
138
-        if (stuzero.equals(0)) {//0分学生不参与统计
139
-            students = allStudents.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
140
-        } else {
141
-            students = allStudents;
142
-        }
134
+        List<ERstudent> students = ePaperStudentMapper.listByExamId(examid, epids);
135
+        int sknum = students.stream().filter(l -> l.getSstate() == 2).map(l -> l.getStudentid()).distinct().collect(Collectors.toList()).size();
143 136
         Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
144 137
         for (Map.Entry<Integer, List<ERstudent>> entry : schoolCollect.entrySet()) {
145 138
             Integer studentid = entry.getKey();
@@ -187,11 +180,17 @@ public class EReportGenerateService {
187 180
             }
188 181
         }
189 182
 
190
-        DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
183
+        List<ERstudent> schoolStudents2;//参与统计学生列表
184
+        if (stuzero.equals(0)) {//0分学生不参与统计
185
+            schoolStudents2 = schoolStudents.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
186
+        } else {
187
+            schoolStudents2 = schoolStudents;
188
+        }
189
+        DoubleSummaryStatistics schoolStatistics = schoolStudents2.stream().filter(s -> s.getScore() > 0).mapToDouble(s -> s.getScore()).summaryStatistics();
191 190
         double schoolStatisticsMax = schoolStatistics.getMax();
192 191
         double schoolStatisticsAverage = N_Utils.formatDouble(schoolStatistics.getAverage(), 2);
193 192
         //最低分均不包括0分
194
-        double schoolStatisticsMin = schoolStudents.stream().filter(s -> s.getScore() > 0).mapToDouble(s -> s.getScore()).min().getAsDouble();
193
+        double schoolStatisticsMin = schoolStudents.stream().filter(s -> s.getScore() > 0).mapToDouble(s -> s.getScore()).summaryStatistics().getMin();
195 194
         if (N_Utils.isListEmpty(students)) {
196 195
             schoolStatisticsMax = 0;
197 196
             schoolStatisticsMin = 0;
@@ -213,7 +212,7 @@ public class EReportGenerateService {
213 212
         List<ERsubject> subjectList = new ArrayList<>();//考试报告科目情况
214 213
         List<ERclass> classList = new ArrayList<>();//考试报告班级情况
215 214
         setSubject(examid, stunum, "zf", "总分", subjectList, classList, schoolStudents
216
-                , papers.stream().mapToDouble(p -> p.getPscore()).sum());
215
+                , papers.stream().mapToDouble(p -> p.getPscore()).sum(), stuzero);
217 216
         for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
218 217
             subjectid = ssEntry.getKey();
219 218
             subjectname = subjectMap.get(subjectid);
@@ -234,7 +233,7 @@ public class EReportGenerateService {
234 233
             schoolSubjectStudents.addAll(rstudents);
235 234
             ERPaperVo rp = paperMap.get(subjectid);
236 235
             Double allscore = rp.getPscore();//满分
237
-            setSubject(examid, stunum, subjectid, subjectname, subjectList, classList, list, allscore);
236
+            setSubject(examid, stunum, subjectid, subjectname, subjectList, classList, list, allscore, stuzero);
238 237
         }
239 238
 
240 239
         setClassAvgRank(classList);//班级科目平均分排名
@@ -289,17 +288,14 @@ public class EReportGenerateService {
289 288
             userMap = users.stream().collect(Collectors.toMap(UserVo::getUserid, UserVo::getUsername));
290 289
             userMap2 = users.stream().collect(Collectors.toMap(UserVo::getUserid, u -> u.getLoginname() + "_" + u.getUsername()));
291 290
         }
292
-        List<ERstudent> classSubjectStudents2 = new ArrayList<>();
291
+        List<ERstudent> classSubjectStudents2;//参与统计学生列表
293 292
         if (stuzero.equals(0)) {//0分学生不参与统计
294
-            Map<String, List<ERstudent>> collect = allStudents.stream().collect(Collectors.groupingBy(s -> s.getSubjectid() + "_" + s.getClassid()));
295
-            for (Map.Entry<String, List<ERstudent>> ssEntry : collect.entrySet()) {
296
-                classSubjectStudents2.addAll(ssEntry.getValue());
297
-            }
293
+            classSubjectStudents2 = classSubjectStudents.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
298 294
         } else {
299 295
             classSubjectStudents2 = classSubjectStudents;
300 296
         }
301
-        setClassGradeRankAll(examid, stunum, papers, classSubjectStudents2, createid, userMap);//班级等级分布
302
-        setClassGradeRank(examid, stunum, papers, classSubjectStudents, setRrank(5), createid, userMap);//班级等级分布--优困生
297
+        setClassGradeRankAll(examid, stunum, papers, classSubjectStudents, createid, userMap);//班级等级分布
298
+        setClassGradeRank(examid, stunum, papers, classSubjectStudents2, setRrank(5), createid, userMap);//班级等级分布--优困生
303 299
         setAction(examid, userMap);//行为分析
304 300
         eBaseMapper.updateExamState(examid,3);
305 301
         htmlToPdf(examid, classes, schoolStudents, userMap2);//考试报告html转pdf
@@ -393,16 +389,22 @@ public class EReportGenerateService {
393 389
 
394 390
     //科目统计
395 391
     private void setSubject(Integer examid, Integer fbstunum, String subjectid, String subjectname, List<ERsubject> subjectList,
396
-                            List<ERclass> classList, List<ERstudent> list, Double allscore) {
392
+                            List<ERclass> classList, List<ERstudent> list, Double allscore, Integer stuzero) {
397 393
         double yxscore = ExamUtil.mul(allscore, 0.85);//优秀分
398 394
         double lhscore = ExamUtil.mul(allscore, 0.7);//良好分
399 395
         double jgscore = ExamUtil.mul(allscore, 0.6);//及格分
400 396
         double dfscore = ExamUtil.mul(allscore, 0.4);//低分
401 397
 
402
-        int stunum = list.size();//参与统计学生人数
403
-        DoubleSummaryStatistics statistics = list.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
398
+        List<ERstudent> list2;//参与统计学生列表
399
+        if (stuzero.equals(0)) {//0分学生不参与统计
400
+            list2 = list.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
401
+        } else {
402
+            list2 = list;
403
+        }
404
+
405
+        DoubleSummaryStatistics statistics = list2.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
404 406
         double maxscore = statistics.getMax();
405
-        double minscore = statistics.getMin();
407
+        double minscore = list.stream().mapToDouble(s -> s.getScore()).summaryStatistics().getMin();
406 408
         double avgscore = N_Utils.formatDouble(statistics.getAverage(), 2);
407 409
         if (N_Utils.isListEmpty(list)) {
408 410
             maxscore = 0;
@@ -417,19 +419,20 @@ public class EReportGenerateService {
417 419
         rs.setMaxscore(maxscore);
418 420
         rs.setMinscore(minscore);
419 421
         rs.setAvgscore(avgscore);
420
-        int yxnum = list.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
422
+        int stunum = list2.size();//参与统计学生人数
423
+        int yxnum = list2.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
421 424
                 .collect(Collectors.toList()).size();
422
-        int lhnum = list.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
425
+        int lhnum = list2.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
423 426
                 .collect(Collectors.toList()).size();
424
-        int jgnum = list.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
427
+        int jgnum = list2.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
425 428
                 .collect(Collectors.toList()).size();
426
-        int dfnum = list.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
429
+        int dfnum = list2.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
427 430
                 .collect(Collectors.toList()).size();
428
-        List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
429 431
         rs.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
430 432
         rs.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
431 433
         rs.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
432 434
         rs.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
435
+        List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
433 436
         double qkbzc = ExamUtil.standardDiviation(scores);
434 437
         rs.setBzc(qkbzc);
435 438
         int sknum = list.stream().filter(l -> l.getSstate() == 2)
@@ -442,10 +445,15 @@ public class EReportGenerateService {
442 445
         for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
443 446
             Integer classid = entry.getKey();
444 447
             List<ERstudent> rstudentList = entry.getValue();
445
-            DoubleSummaryStatistics claStatistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
446
-
448
+            List<ERstudent> rstudentList2;//参与统计学生列表
449
+            if (stuzero.equals(0)) {//0分学生不参与统计
450
+                rstudentList2 = rstudentList.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
451
+            } else {
452
+                rstudentList2 = list;
453
+            }
454
+            DoubleSummaryStatistics claStatistics = rstudentList2.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
447 455
             double clamaxscore = claStatistics.getMax();
448
-            double claminscore = claStatistics.getMin();
456
+            double claminscore = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics().getMin();
449 457
             double claavgscore = N_Utils.formatDouble(claStatistics.getAverage(), 2);
450 458
             if (N_Utils.isListEmpty(list)) {
451 459
                 clamaxscore = 0;
@@ -468,17 +476,17 @@ public class EReportGenerateService {
468 476
             sknum = rstudentList.stream().filter(l -> l.getSstate() == 2)
469 477
                     .map(l -> l.getStudentid()).distinct().collect(Collectors.toList()).size();
470 478
             rc.setStunum(sknum);//实考人数
471
-            stunum = rstudentList.size();//参与统计学生人数
472 479
             rc.setMissnum(fbstunum - sknum);//缺考人数=计划人数-实考人数
473
-            yxnum = rstudentList.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
480
+            scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
481
+            stunum = rstudentList2.size();//参与统计学生人数
482
+            yxnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
474 483
                     .collect(Collectors.toList()).size();
475
-            lhnum = rstudentList.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
484
+            lhnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
476 485
                     .collect(Collectors.toList()).size();
477
-            jgnum = rstudentList.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
486
+            jgnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
478 487
                     .collect(Collectors.toList()).size();
479
-            dfnum = rstudentList.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
488
+            dfnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
480 489
                     .collect(Collectors.toList()).size();
481
-            scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
482 490
             rc.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
483 491
             rc.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
484 492
             rc.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));

正在加载...
取消
保存