|
@@ -10,9 +10,14 @@ package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
|
|
|
+import cn.com.qmth.examcloud.core.print.entity.ProjectBackupSetting;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.ProjectStatistic;
|
|
|
+import cn.com.qmth.examcloud.core.print.repository.ProjectBackupSettingRepository;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.ProjectStatisticRepository;
|
|
|
-import cn.com.qmth.examcloud.core.print.service.*;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.PrintingProjectStatisticService;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.StatisticService;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticLessInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.printingproject.PrintingProjectLessInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.printingprojectstatistic.PrintingProjectStatisticConvert;
|
|
@@ -43,7 +48,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
|
|
|
@Autowired
|
|
|
private CourseStatisticService courseStatisticService;
|
|
|
@Autowired
|
|
|
- private ProjectBackupSettingService projectBackupSettingService;
|
|
|
+ private ProjectBackupSettingRepository projectBackupSettingRepository;
|
|
|
@Autowired
|
|
|
private StatisticService statisticService;
|
|
|
|
|
@@ -91,6 +96,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
|
|
|
|
|
|
List<ProjectStatistic> statistics = new ArrayList<>();
|
|
|
for (PrintingProjectLessInfo project : projects) {
|
|
|
+ //逐个考试来统计印刷项目的汇总结果,同时多个考试会有严重的查询效率问题(涉及表较多,某些表数据高达百万或以上)
|
|
|
ProjectStatistic statistic = projectStatisticRepository.getProjectStatisticByProjectId(project.getProjectId());
|
|
|
if (statistic == null) {
|
|
|
statistic = new ProjectStatistic();
|
|
@@ -100,12 +106,15 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
|
|
|
//获取某考试的课程和试卷类型列表
|
|
|
List<ExamPaperTypeRelation> coursePaperTypes = statisticService.findExamCourseAndPaperTypes(project.getOrgId(), project.getExamId());
|
|
|
|
|
|
- //获取试卷袋列表
|
|
|
+ //获取某考试的试卷袋列表
|
|
|
List<String> packageCodes = statisticService.findExamPackageCodes(project.getOrgId(), project.getExamId());
|
|
|
|
|
|
//获取某考试的所有课程的试卷页数和考生人数信息列表
|
|
|
List<CourseStatisticLessInfo> courseStatistics = courseStatisticService.getCourseStatisticLessInfoList(project.getOrgId(), project.getExamId());
|
|
|
|
|
|
+ //获取某个项目的备份设置信息
|
|
|
+ ProjectBackupSetting backupSetting = projectBackupSettingRepository.findByProjectId(project.getProjectId());
|
|
|
+
|
|
|
//人科次(考生的数量)
|
|
|
final int totalStudent = statisticService.findExamTotalStudent(project.getOrgId(), project.getExamId());
|
|
|
|
|
@@ -118,19 +127,14 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
|
|
|
//试卷袋数量
|
|
|
final int totalPkg = packageCodes.size();
|
|
|
|
|
|
- //常规-A3数量(总试卷A3数 + 总答题卡A3数) == 总(试卷P数 * 当前试卷人科次数) + (总科次人数) * 2
|
|
|
- int sumPaperA3 = 0;
|
|
|
- for (CourseStatisticLessInfo courseStatistic : courseStatistics) {
|
|
|
- sumPaperA3 += courseStatistic.getMultiplicationValue();
|
|
|
- }
|
|
|
- final int normalA3 = sumPaperA3 + (totalStudent * 2);
|
|
|
-
|
|
|
+ //常规-A3数量(总试卷A3数 + 总答题卡A3数)
|
|
|
+ final int normalA3 = this.parseNormalA3(courseStatistics, totalStudent);
|
|
|
|
|
|
//常规-A4数量(试卷袋数 * 4)
|
|
|
final int normalA4 = totalPkg * 4;
|
|
|
|
|
|
- //备份-A3数量
|
|
|
- final int backupA3 = 0;//todo
|
|
|
+ //备份-A3数量(每袋冗余数 + 单独备份袋数)
|
|
|
+ final int backupA3 = this.parseBackupA3(backupSetting);
|
|
|
|
|
|
//备份-A4数量(试卷袋数 * 2)
|
|
|
final int backupA4 = totalPkg * 2;
|
|
@@ -145,7 +149,44 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
|
|
|
statistic.setBackupA4(backupA4);
|
|
|
statistics.add(statistic);
|
|
|
}
|
|
|
+
|
|
|
+ //批量保存
|
|
|
projectStatisticRepository.save(statistics);
|
|
|
}
|
|
|
|
|
|
+ private int parseNormalA3(List<CourseStatisticLessInfo> courseStatistics, int totalStudent) {
|
|
|
+ int sumPaperA3 = 0;
|
|
|
+ if (courseStatistics != null && !courseStatistics.isEmpty()) {
|
|
|
+ for (CourseStatisticLessInfo courseStatistic : courseStatistics) {
|
|
|
+ sumPaperA3 += courseStatistic.getMultiplicationValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //∑n 试卷(试卷P数 * 当前试卷人科次数) + (总科次人数) * 2
|
|
|
+ return sumPaperA3 + (totalStudent * 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int parseBackupA3(ProjectBackupSetting backupSetting) {
|
|
|
+ if (backupSetting == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!backupSetting.getNeedEachPkg() && !backupSetting.getNeedAlonePkg()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ int sumA3 = 0;
|
|
|
+
|
|
|
+ if (backupSetting.getNeedEachPkg()) {
|
|
|
+ //备份A3 = ∑n 试卷袋(X考生 * P%备份比例) * 2
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (backupSetting.getNeedAlonePkg()) {
|
|
|
+ //备份A3 = ∑n 学习中心或考点(X考生 * P%备份比例) * 2
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|