deason 6 жил өмнө
parent
commit
0714e71e18

+ 6 - 5
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/CourseStatisticServiceImpl.java

@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
 import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
 import cn.com.qmth.examcloud.core.print.common.jpa.SqlWrapper;
 import cn.com.qmth.examcloud.core.print.common.utils.Check;
+import cn.com.qmth.examcloud.core.print.common.utils.DateUtils;
 import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
 import cn.com.qmth.examcloud.core.print.enums.PaperStatus;
 import cn.com.qmth.examcloud.core.print.repository.CourseStatisticRepository;
@@ -35,10 +36,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
 
@@ -122,6 +120,9 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
 
         //目前限定仅一个刷新任务可执行
         RefreshInfo.coursesRefreshing = true;
+        Date start = new Date();
+        log.debug("refreshCourseStatistic start...");
+
         try {
             //待刷新的课程列表
             List<ExamCourseInfo> examCourses;
@@ -152,7 +153,7 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
             log.error(e.getMessage(), e);
         } finally {
             RefreshInfo.coursesRefreshing = false;
-            log.debug("refreshCourseStatistic finished...");
+            log.debug("refreshCourseStatistic finished..." + DateUtils.diff(start, new Date()));
         }
     }
 

+ 14 - 6
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/PrintingProjectStatisticServiceImpl.java

@@ -9,6 +9,7 @@ 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.common.utils.DateUtils;
 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;
@@ -32,10 +33,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
 
@@ -87,9 +85,12 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
 
         //目前限定仅一个刷新任务可执行
         RefreshInfo.projectRefreshing = true;
+        Date start = new Date();
+        log.debug("refreshPrintingProjectStatistic start...");
         try {
             //刷新课程统计
             courseStatisticService.refreshCourseStatistic(new CourseStatisticRefreshReq(orgId, examId));
+
             //执行项目统计
             this.doStatistic(Lists.newArrayList(new PrintingProjectLessInfo(orgId, examId, project.getId())));
         } catch (StatusException e) {
@@ -98,7 +99,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
             log.error(e.getMessage(), e);
         } finally {
             RefreshInfo.projectRefreshing = false;
-            log.debug("refreshPrintingProjectStatistic finished...");
+            log.debug("refreshPrintingProjectStatistic finished..." + DateUtils.diff(start, new Date()));
         }
     }
 
@@ -119,7 +120,9 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
 
         List<ProjectStatistic> statistics = new ArrayList<>();
         for (PrintingProjectLessInfo project : projects) {
-            //逐个考试来统计印刷项目的汇总结果,同时多个考试会有严重的查询效率问题(涉及表较多,某些表数据高达百万或以上)
+            Date start = new Date();
+
+            //逐个考试来统计印刷项目的汇总结果,同时多个考试会有查询效率问题(涉及表较多且数据高达百万或以上)
             ProjectStatistic statistic = projectStatisticRepository.getProjectStatisticByProjectId(project.getProjectId());
             if (statistic == null) {
                 statistic = new ProjectStatistic();
@@ -143,6 +146,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
 
             //课程数量(课程代码的数量)
             final int totalCourse = statisticService.countExamTotalCourse(coursePaperTypes);
+            log.debug("常规统计耗时:" + DateUtils.diff(start, new Date()));
 
             //试卷数量(课程代码 + 试卷类型的数量)
             final int totalPaper = coursePaperTypes.size();
@@ -209,6 +213,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
         if (backupSetting.getNeedEachPkg()) {
             //备份A3 = ∑n 试卷袋(X考生 * P%备份比例) * 2
             int eachTotal = 0;
+            Date start = new Date();
 
             Double percent = backupSetting.getEachPkgPercent();//备份比例:高于最大取最大;低于最小则取最小
             if (percent > backupSetting.getEachPkgMax()) {
@@ -223,11 +228,13 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
                 eachTotal += Math.ceil((count * percent) / 100);
             }
             backupA3 += (eachTotal * 2);
+            log.debug("每袋备份统计耗时:" + DateUtils.diff(start, new Date()));
         }
 
         if (backupSetting.getNeedAlonePkg()) {
             //备份A3 = ∑n 学习中心或考点(X考生 * P%备份比例) * 2
             int aloneTotal = 0;
+            Date start = new Date();
 
             Double percent = backupSetting.getAlonePkgPercent();//备份比例:高于最大取最大;低于最小则取最小
             if (percent > backupSetting.getAlonePkgMax()) {
@@ -260,6 +267,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
             }
 
             backupA3 += (aloneTotal * 2);
+            log.debug("单独备份袋统计耗时:" + DateUtils.diff(start, new Date()));
         }
 
         backupMaps.put("backupA3", backupA3);