deason il y a 6 ans
Parent
commit
63db24928d

+ 1 - 1
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/PrintingProjectController.java

@@ -60,7 +60,7 @@ public class PrintingProjectController extends ControllerSupport {
 
     @GetMapping("/all/init")
     public Result initAllData() {
-        printingProjectService.syncAllPrintingProject();
+        printingProjectService.initAllPrintingProject();
         return success();
     }
 

+ 2 - 2
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/PrintingProjectService.java

@@ -51,9 +51,9 @@ public interface PrintingProjectService {
     void syncPrintingProject(ExamInfo examInfo);
 
     /**
-     * 同步所有印刷项目的基本信息
+     * 初始所有印刷项目的基本信息
      */
-    void syncAllPrintingProject();
+    void initAllPrintingProject();
 
     /**
      * 同步更新学校名称信息

+ 2 - 2
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/PrintingProjectServiceImpl.java

@@ -162,9 +162,9 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
     }
 
     @Override
-    public void syncAllPrintingProject() {
+    public void initAllPrintingProject() {
         //获取所有"传统"考试列表
-        log.debug("syncAllPrintingProject...");
+        log.debug("initAllPrintingProject...");
         List<ExamInfo> list = commonService.findExams(ExamType.TRADITION.name());//todo
         if (list != null && !list.isEmpty()) {
             for (ExamInfo info : list) {

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

@@ -52,15 +52,25 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
         }
 
         ProjectStatistic statistic = projectStatisticRepository.getProjectStatisticByProjectId(project.getId());
-        if (statistic == null) {
-            //throw new StatusException(PRT_CODE_500, "当前项目统计不存在!");
-        }
         return PrintingStatisticConvert.of(project, statistic);
     }
 
     @Override
     public void initPrintingProjectStatistic(Long orgId, Long examId) {
-        //todo init
+        Check.isNull(orgId, "学校ID不能为空!");
+        Check.isNull(examId, "考试ID不能为空!");
+
+        PrintingProject project = printingProjectService.getPrintingProjectByOrgIdAndExamId(orgId, examId);
+        if (project == null) {
+            throw new StatusException(PRT_CODE_500, "当前项目不存在!");
+        }
+
+        ProjectStatistic statistic = projectStatisticRepository.getProjectStatisticByProjectId(project.getId());
+        if (statistic == null) {
+            throw new StatusException(PRT_CODE_500, "当前项目统计不存在!");
+        }
+
+        //todo
     }
 
     @Override

+ 48 - 0
examcloud-core-print-starter/src/main/java/cn/com/qmth/examcloud/core/print/config/StatisticScheduler.java

@@ -0,0 +1,48 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-23 15:50:18.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.config;
+
+import cn.com.qmth.examcloud.core.print.common.utils.DateUtils;
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Component
+public class StatisticScheduler implements Serializable {
+    private static final Logger log = LoggerFactory.getLogger(StatisticScheduler.class);
+    private static final long serialVersionUID = 1L;
+    @Autowired
+    private CourseStatisticService courseStatisticService;
+    @Autowired
+    private PrintingProjectService printingProjectService;
+    @Autowired
+    private PrintingProjectStatisticService printingProjectStatisticService;
+
+    /**
+     * 定时统计数据(每N分钟执行)
+     */
+    //@Scheduled(cron = "0 1/1 * * * ?")
+    public void execute() throws Exception {
+        Date start = new Date();
+        printingProjectService.initAllPrintingProject();
+
+        courseStatisticService.initAllCourseStatistic();
+
+        printingProjectStatisticService.initAllPrintingProjectStatistic();
+        log.info("统计耗时:" + DateUtils.diff(start, new Date()));
+    }
+
+}