deason 6 anni fa
parent
commit
5c00d9263f
13 ha cambiato i file con 90 aggiunte e 60 eliminazioni
  1. 1 1
      examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/CourseStatisticController.java
  2. 1 1
      examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/PrintingProjectController.java
  3. 43 0
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CommonService.java
  4. 2 2
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CourseStatisticService.java
  5. 7 7
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/PrintingProjectService.java
  6. 1 1
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/PrintingProjectStatisticService.java
  7. 5 5
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursestatistic/CourseStatisticQuery.java
  8. 8 4
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/CourseStatisticServiceImpl.java
  9. 1 1
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/ExamStructureServiceImpl.java
  10. 15 32
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/PrintingProjectServiceImpl.java
  11. 1 1
      examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/PrintingProjectStatisticServiceImpl.java
  12. 3 3
      examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/CourseStatisticServiceTest.java
  13. 2 2
      examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/ProjectStatisticServiceTest.java

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

@@ -42,7 +42,7 @@ public class CourseStatisticController extends ControllerSupport {
     @PostMapping("/init")
     @ApiOperation(value = "刷新某些课程的统计信息")
     public Result init(@RequestParam Long orgId, @RequestParam Long examId, @RequestParam Long[] courseIds) {
-        courseStatisticService.initCourseStatistics(orgId, examId, courseIds);
+        courseStatisticService.initCourseStatistic(orgId, examId, courseIds);
         return success();
     }
 

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

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

+ 43 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CommonService.java

@@ -0,0 +1,43 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-07 10:17:17.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service;
+
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.OrgExamInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/11/7
+ */
+@Component
+public class CommonService {
+    private static final Logger log = LoggerFactory.getLogger(CommonService.class);
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    /**
+     * 获取所有"传统"考试列表
+     * (正式场景数据极少,一次获取全部)
+     */
+    public List<OrgExamInfo> getTraditionExamList() {
+        StringBuilder sql = new StringBuilder()
+                .append("SELECT em.id AS examId,em.name AS examName,em.root_org_id AS orgId,org.name AS orgName FROM ec_e_exam em")
+                .append(" INNER JOIN ec_b_org org ON org.id = em.root_org_id")
+                .append(" WHERE em.exam_type = 'TRADITION' ORDER BY em.id ASC");
+        //log.debug(sql.toString());
+        return jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(OrgExamInfo.class));
+    }
+
+}

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

@@ -25,11 +25,11 @@ public interface CourseStatisticService {
     /**
      * 刷新某些课程的统计信息
      */
-    void initCourseStatistics(Long orgId, Long examId, Long[] courseIds);
+    void initCourseStatistic(Long orgId, Long examId, Long[] courseIds);
 
     /**
      * 初始所有课程的统计信息
      */
-    void initCourseStatistics();
+    void initAllCourseStatistic();
 
 }

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

@@ -42,11 +42,16 @@ public interface PrintingProjectService {
     void updatePrintingProject(PrintingProjectInfo info);
 
     /**
-     * 同步(新增或更新)印刷项目信息
-     * 仅同步学校、考试的基本信息
+     * 同步(新增或更新)某个印刷项目的基本信息
+     * 仅同步学校、考试信息
      */
     void syncPrintingProject(OrgExamInfo examInfo);
 
+    /**
+     * 同步所有印刷项目的基本信息
+     */
+    void syncAllPrintingProject();
+
     /**
      * 同步更新学校名称信息
      */
@@ -67,9 +72,4 @@ public interface PrintingProjectService {
      */
     void syncPrintingProjectSupplierName(Long supplierId, String supplierName);
 
-    /**
-     * 印刷项目数据初始化
-     */
-    void initAllData();
-
 }

+ 1 - 1
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/PrintingProjectStatisticService.java

@@ -34,6 +34,6 @@ public interface PrintingProjectStatisticService {
     /**
      * 初始所有印刷项目的统计信息
      */
-    void initPrintingProjectStatistics();
+    void initAllPrintingProjectStatistic();
 
 }

+ 5 - 5
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursestatistic/CourseStatisticQuery.java

@@ -31,7 +31,7 @@ public class CourseStatisticQuery extends PageQuery implements JsonSerializable
     /**
      * 试卷ID
      */
-    private Long paperId;
+    private String paperName;
     /**
      * @See PaperBindingStatus.java
      * 试卷绑定状态
@@ -62,12 +62,12 @@ public class CourseStatisticQuery extends PageQuery implements JsonSerializable
         this.courseId = courseId;
     }
 
-    public Long getPaperId() {
-        return paperId;
+    public String getPaperName() {
+        return paperName;
     }
 
-    public void setPaperId(Long paperId) {
-        this.paperId = paperId;
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
     }
 
     public Integer getPaperBindingStatus() {

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

@@ -13,10 +13,12 @@ import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
 import cn.com.qmth.examcloud.core.print.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
 import cn.com.qmth.examcloud.core.print.repository.CourseStatisticRepository;
+import cn.com.qmth.examcloud.core.print.service.CommonService;
 import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticConvert;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +36,8 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     private static final Logger log = LoggerFactory.getLogger(CourseStatisticServiceImpl.class);
     @Autowired
     private CourseStatisticRepository courseStatisticsRepository;
+    @Autowired
+    private CommonService commonService;
 
     @Override
     public Page<CourseStatisticInfo> getCourseStatisticList(CourseStatisticQuery query) {
@@ -52,8 +56,8 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
         if (query.getPaperBindingStatus() != null) {
             searches.eq("paperBindingStatus", query.getPaperBindingStatus());
         }
-        if (query.getPaperId() != null) {
-            searches.eq("coursePaper.id", query.getPaperId());
+        if (StringUtils.isBlank(query.getPaperName())) {
+            searches.like("coursePaper.paperName", query.getPaperName());
         }
         Specification<CourseStatistic> spec = SpecUtils.buildSearchers(CourseStatistic.class, searches.build());
         //排序条件
@@ -65,12 +69,12 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     }
 
     @Override
-    public void initCourseStatistics(Long orgId, Long examId, Long[] courseIds) {
+    public void initCourseStatistic(Long orgId, Long examId, Long[] courseIds) {
         //todo
     }
 
     @Override
-    public void initCourseStatistics() {
+    public void initAllCourseStatistic() {
         //todo
     }
 

+ 1 - 1
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/ExamStructureServiceImpl.java

@@ -90,7 +90,7 @@ public class ExamStructureServiceImpl implements ExamStructureService {
             try {
                 examStructureRepository.delete(id);
             } catch (Exception e) {
-                // ignore record not exist
+                // ignore: record not exist
                 log.warn(e.getMessage());
             }
         }

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

@@ -14,6 +14,7 @@ import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
 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.repository.PrintingProjectRepository;
+import cn.com.qmth.examcloud.core.print.service.CommonService;
 import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
 import cn.com.qmth.examcloud.core.print.service.bean.printingproject.OrgExamInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.printingproject.PrintingProjectConvert;
@@ -27,13 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
-import org.springframework.jdbc.core.BatchPreparedStatementSetter;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
 import java.util.List;
 
 import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
@@ -50,6 +47,8 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
     @Autowired
     private PrintingProjectRepository printingProjectRepository;
     @Autowired
+    private CommonService commonService;
+    @Autowired
     private JdbcTemplate jdbcTemplate;
 
     @Override
@@ -158,6 +157,18 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
         printingProjectRepository.save(project);
     }
 
+    @Override
+    public void syncAllPrintingProject() {
+        //获取所有"传统"考试列表
+        log.debug("syncAllPrintingProject...");
+        List<OrgExamInfo> list = commonService.getTraditionExamList();
+        if (list != null && !list.isEmpty()) {
+            for (OrgExamInfo info : list) {
+                syncPrintingProject(info);
+            }
+        }
+    }
+
     @Override
     public void syncPrintingProjectOrgName(Long orgId, String orgName) {
         if (orgId == null || StringUtils.isBlank(orgName)) {
@@ -194,32 +205,4 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
         jdbcTemplate.update(updateSql);
     }
 
-    @Override
-    public void initAllData() {
-        //查询所有传统考试记录(实际数据未超过100条)
-        StringBuilder sql = new StringBuilder()
-                .append("SELECT em.id as examId,em.name as examName,em.root_org_id as orgId,org.name as orgName FROM ec_e_exam em ")
-                .append("INNER JOIN ec_b_org org ON org.id = em.root_org_id WHERE em.exam_type = 'TRADITION' ORDER BY em.id ASC");
-        List<OrgExamInfo> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(OrgExamInfo.class));
-
-        //批量保存数据
-        String insertSql = "INSERT INTO ec_prt_project(exam_id,exam_name,org_id,org_name,completed,creation_time,update_time) VALUES (?,?,?,?,?,NOW(),NOW())";
-        jdbcTemplate.batchUpdate(insertSql, new BatchPreparedStatementSetter() {
-            @Override
-            public void setValues(PreparedStatement ps, int i) throws SQLException {
-                OrgExamInfo row = list.get(i);
-                ps.setLong(1, row.getExamId());
-                ps.setString(2, row.getExamName());
-                ps.setLong(3, row.getOrgId());
-                ps.setString(4, row.getOrgName());
-                ps.setBoolean(5, false);
-            }
-
-            @Override
-            public int getBatchSize() {
-                return list.size();
-            }
-        });
-    }
-
 }

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

@@ -59,7 +59,7 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
     }
 
     @Override
-    public void initPrintingProjectStatistics() {
+    public void initAllPrintingProjectStatistic() {
         //todo init
     }
 

+ 3 - 3
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/CourseStatisticServiceTest.java

@@ -35,12 +35,12 @@ public class CourseStatisticServiceTest extends BaseTest {
     }
 
     @Test
-    public void initCourseStatisticsTest() throws Exception {
+    public void initCourseStatisticTest() throws Exception {
         Long orgId = 1L;
         Long examId = 1L;
         Long[] courseIds = {1L};
-        courseStatisticService.initCourseStatistics(orgId, examId, courseIds);
-        courseStatisticService.initCourseStatistics();
+        courseStatisticService.initCourseStatistic(orgId, examId, courseIds);
+        courseStatisticService.initAllCourseStatistic();
     }
 
 }

+ 2 - 2
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/ProjectStatisticServiceTest.java

@@ -27,10 +27,10 @@ public class ProjectStatisticServiceTest extends BaseTest {
     }
 
     @Test
-    public void initPrintingProjectStatisticsTest() throws Exception {
+    public void initPrintingProjectStatisticTest() throws Exception {
         Long projectId = 1L;
         printingProjectStatisticService.initPrintingProjectStatistic(projectId);
-        printingProjectStatisticService.initPrintingProjectStatistics();
+        printingProjectStatisticService.initAllPrintingProjectStatistic();
     }
 
 }