Browse Source

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

# Conflicts:
#	sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java
tags/正式3.13.3
王宁 1 year ago
parent
commit
94dd364b3e

+ 48
- 39
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

@@ -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,15 @@ 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);//班级等级分布--优困生
299
+
303 300
         setAction(examid, userMap);//行为分析
304 301
         eBaseMapper.updateExamState(examid,3);
305 302
         htmlToPdf(examid, classes, schoolStudents, userMap2);//考试报告html转pdf
@@ -393,16 +390,22 @@ public class EReportGenerateService {
393 390
 
394 391
     //科目统计
395 392
     private void setSubject(Integer examid, Integer fbstunum, String subjectid, String subjectname, List<ERsubject> subjectList,
396
-                            List<ERclass> classList, List<ERstudent> list, Double allscore) {
393
+                            List<ERclass> classList, List<ERstudent> list, Double allscore, Integer stuzero) {
397 394
         double yxscore = ExamUtil.mul(allscore, 0.85);//优秀分
398 395
         double lhscore = ExamUtil.mul(allscore, 0.7);//良好分
399 396
         double jgscore = ExamUtil.mul(allscore, 0.6);//及格分
400 397
         double dfscore = ExamUtil.mul(allscore, 0.4);//低分
401 398
 
402
-        int stunum = list.size();//参与统计学生人数
403
-        DoubleSummaryStatistics statistics = list.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
399
+        List<ERstudent> list2;//参与统计学生列表
400
+        if (stuzero.equals(0)) {//0分学生不参与统计
401
+            list2 = list.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
402
+        } else {
403
+            list2 = list;
404
+        }
405
+
406
+        DoubleSummaryStatistics statistics = list2.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
404 407
         double maxscore = statistics.getMax();
405
-        double minscore = statistics.getMin();
408
+        double minscore = list.stream().mapToDouble(s -> s.getScore()).summaryStatistics().getMin();
406 409
         double avgscore = N_Utils.formatDouble(statistics.getAverage(), 2);
407 410
         if (N_Utils.isListEmpty(list)) {
408 411
             maxscore = 0;
@@ -417,19 +420,20 @@ public class EReportGenerateService {
417 420
         rs.setMaxscore(maxscore);
418 421
         rs.setMinscore(minscore);
419 422
         rs.setAvgscore(avgscore);
420
-        int yxnum = list.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
423
+        int stunum = list2.size();//参与统计学生人数
424
+        int yxnum = list2.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
421 425
                 .collect(Collectors.toList()).size();
422
-        int lhnum = list.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
426
+        int lhnum = list2.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
423 427
                 .collect(Collectors.toList()).size();
424
-        int jgnum = list.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
428
+        int jgnum = list2.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
425 429
                 .collect(Collectors.toList()).size();
426
-        int dfnum = list.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
430
+        int dfnum = list2.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
427 431
                 .collect(Collectors.toList()).size();
428
-        List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
429 432
         rs.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
430 433
         rs.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
431 434
         rs.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
432 435
         rs.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
436
+        List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
433 437
         double qkbzc = ExamUtil.standardDiviation(scores);
434 438
         rs.setBzc(qkbzc);
435 439
         int sknum = list.stream().filter(l -> l.getSstate() == 2)
@@ -442,10 +446,15 @@ public class EReportGenerateService {
442 446
         for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
443 447
             Integer classid = entry.getKey();
444 448
             List<ERstudent> rstudentList = entry.getValue();
445
-            DoubleSummaryStatistics claStatistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
446
-
449
+            List<ERstudent> rstudentList2;//参与统计学生列表
450
+            if (stuzero.equals(0)) {//0分学生不参与统计
451
+                rstudentList2 = rstudentList.stream().filter(s -> s.getScore() > 0).collect(Collectors.toList());
452
+            } else {
453
+                rstudentList2 = list;
454
+            }
455
+            DoubleSummaryStatistics claStatistics = rstudentList2.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
447 456
             double clamaxscore = claStatistics.getMax();
448
-            double claminscore = claStatistics.getMin();
457
+            double claminscore = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics().getMin();
449 458
             double claavgscore = N_Utils.formatDouble(claStatistics.getAverage(), 2);
450 459
             if (N_Utils.isListEmpty(list)) {
451 460
                 clamaxscore = 0;
@@ -468,17 +477,17 @@ public class EReportGenerateService {
468 477
             sknum = rstudentList.stream().filter(l -> l.getSstate() == 2)
469 478
                     .map(l -> l.getStudentid()).distinct().collect(Collectors.toList()).size();
470 479
             rc.setStunum(sknum);//实考人数
471
-            stunum = rstudentList.size();//参与统计学生人数
472 480
             rc.setMissnum(fbstunum - sknum);//缺考人数=计划人数-实考人数
473
-            yxnum = rstudentList.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
481
+            scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
482
+            stunum = rstudentList2.size();//参与统计学生人数
483
+            yxnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
474 484
                     .collect(Collectors.toList()).size();
475
-            lhnum = rstudentList.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
485
+            lhnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
476 486
                     .collect(Collectors.toList()).size();
477
-            jgnum = rstudentList.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
487
+            jgnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
478 488
                     .collect(Collectors.toList()).size();
479
-            dfnum = rstudentList.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
489
+            dfnum = rstudentList2.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
480 490
                     .collect(Collectors.toList()).size();
481
-            scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
482 491
             rc.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
483 492
             rc.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
484 493
             rc.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));

Loading…
Cancel
Save