Browse Source

优化生成报告全班都不参加考试的错误

tags/正式版本
王宁 2 years ago
parent
commit
a9f561d2a2

+ 19
- 6
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

@@ -186,9 +186,10 @@ public class EReportGenerateService {
186 186
         double schoolStatisticsMax = schoolStatistics.getMax();
187 187
         double schoolStatisticsAverage = N_Utils.formatDouble(schoolStatistics.getAverage(), 2);
188 188
         double schoolStatisticsMin = schoolStatistics.getMin();
189
-        if (N_Utils.isListEmpty(students)) {
189
+        if (N_Utils.isListEmpty(students) || N_Utils.isListEmpty(nozeroschoolStudents)) {
190 190
             schoolStatisticsMax = 0;
191 191
             schoolStatisticsMin = 0;
192
+            schoolStatisticsAverage = 0;
192 193
         }
193 194
 
194 195
         ERbase rbase = new ERbase();
@@ -299,9 +300,11 @@ public class EReportGenerateService {
299 300
         DoubleSummaryStatistics statistics = nozerolist.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
300 301
         double maxscore = statistics.getMax();
301 302
         double minscore = statistics.getMin();
302
-        if (N_Utils.isListEmpty(list)) {
303
+        double avgscore = N_Utils.formatDouble(statistics.getAverage(), 2);
304
+        if (N_Utils.isListEmpty(list) || N_Utils.isListEmpty(nozerolist)) {
303 305
             maxscore = 0;
304 306
             minscore = 0;
307
+            avgscore = 0;
305 308
         }
306 309
         ERsubject rs = new ERsubject();
307 310
         rs.setExamid(examid);
@@ -310,7 +313,7 @@ public class EReportGenerateService {
310 313
         rs.setScore(allscore);
311 314
         rs.setMaxscore(maxscore);
312 315
         rs.setMinscore(minscore);
313
-        rs.setAvgscore(N_Utils.formatDouble(statistics.getAverage(), 2));
316
+        rs.setAvgscore(avgscore);
314 317
         int yxnum = list.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
315 318
                 .collect(Collectors.toList()).size();
316 319
         int lhnum = list.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
@@ -338,6 +341,16 @@ public class EReportGenerateService {
338 341
             List<ERstudent> rstudentList = entry.getValue();
339 342
             List<ERstudent> nozerorstudentList = rstudentList.stream().filter(s -> s.getScore()>0).collect(Collectors.toList());
340 343
             DoubleSummaryStatistics claStatistics = nozerorstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
344
+
345
+            double clamaxscore = claStatistics.getMax();
346
+            double claminscore = claStatistics.getMin();
347
+            double claavgscore = N_Utils.formatDouble(claStatistics.getAverage(), 2);
348
+            if (N_Utils.isListEmpty(list) || N_Utils.isListEmpty(nozerorstudentList)) {
349
+                clamaxscore = 0;
350
+                claminscore = 0;
351
+                claavgscore = 0;
352
+            }
353
+
341 354
             ERclass rc = new ERclass();
342 355
             rc.setQkbzc(qkbzc);
343 356
             rc.setExamid(examid);
@@ -345,9 +358,9 @@ public class EReportGenerateService {
345 358
             rc.setSubjectid(subjectid);
346 359
             rc.setSubjectname(subjectname);
347 360
             rc.setAllscore(allscore);
348
-            rc.setClassmaxscore(claStatistics.getMax());
349
-            rc.setClassminscore(claStatistics.getMin());
350
-            rc.setClassavgscore(N_Utils.formatDouble(claStatistics.getAverage(), 2));
361
+            rc.setClassmaxscore(clamaxscore);
362
+            rc.setClassminscore(claminscore);
363
+            rc.setClassavgscore(claavgscore);
351 364
             rc.setSchoolmaxscore(maxscore);
352 365
             rc.setSchoolavgscore(N_Utils.formatDouble(statistics.getAverage(), 2));
353 366
             sknum = rstudentList.stream().filter(l -> l.getSstate() == 2)

Loading…
Cancel
Save