deason 6 жил өмнө
parent
commit
fbf02657c4

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

@@ -46,4 +46,10 @@ public class CourseStatisticController extends ControllerSupport {
         return success();
     }
 
+    @GetMapping("/all/init")
+    public Result init() {
+        courseStatisticService.initAllCourseStatistic();
+        return success();
+    }
+
 }

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

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

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

@@ -7,6 +7,8 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
+import cn.com.qmth.examcloud.core.print.common.jpa.SqlWrapper;
+import cn.com.qmth.examcloud.core.print.service.bean.common.ExamCourseInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -33,15 +35,27 @@ public class CommonService {
      * (正式场景数据极少,一次获取全部)
      */
     public List<ExamInfo> getExamList(String examType) {
-        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");
+        SqlWrapper sql = new SqlWrapper()
+                .select("em.id examId,em.name examName,em.root_org_id orgId,org.name orgName").from("ec_e_exam em")
+                .innerJoin("ec_b_org org").on("org.id", "em.root_org_id");
         if (StringUtils.isNotBlank(examType)) {
-            sql.append(" WHERE em.exam_type = '").append(examType).append("'");
+            sql.where().eq("em.exam_type", examType);
         }
-        sql.append(" ORDER BY em.id ASC");
-        //log.debug(sql.toString());
-        return jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(ExamInfo.class));
+        sql.orderBy("em.id", false);
+        //log.debug(sql.build());
+        return jdbcTemplate.query(sql.build(), new BeanPropertyRowMapper(ExamInfo.class));
+    }
+
+    public List<ExamCourseInfo> getExamCourseList(Long orgId, Long examId) {
+        SqlWrapper sql = new SqlWrapper()
+                .select("root_org_id orgId,exam_id,course_id,course_code,course_name,paper_type,count(course_code) totalStudent")
+                .from("ecs_exam_student")//todo ec_e_exam_student
+                .where()
+                .eq("root_org_id", orgId)
+                .and().eq("exam_id", examId)
+                .groupBy("course_id,paper_type");
+        log.debug(sql.build());
+        return jdbcTemplate.query(sql.build(), new BeanPropertyRowMapper(ExamCourseInfo.class));
     }
 
 }

+ 106 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/common/ExamCourseInfo.java

@@ -0,0 +1,106 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-07 14:58:10.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.common;
+
+import java.io.Serializable;
+
+/**
+ * 考试课程信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/07
+ */
+public class ExamCourseInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 学校机构ID
+     */
+    private Long orgId;
+    /**
+     * 考试ID
+     */
+    private Long examId;
+    /**
+     * 课程ID
+     */
+    private Long courseId;
+    /**
+     * 课程代码
+     */
+    private String courseCode;
+    /**
+     * 课程名称
+     */
+    private String courseName;
+    /**
+     * 试卷类型
+     */
+    private String paperType;
+
+    /**
+     * 考生人数
+     */
+    private Integer totalStudent;
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public Integer getTotalStudent() {
+        return totalStudent;
+    }
+
+    public void setTotalStudent(Integer totalStudent) {
+        this.totalStudent = totalStudent;
+    }
+
+}

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

@@ -12,9 +12,12 @@ 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.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
+import cn.com.qmth.examcloud.core.print.enums.ExamType;
 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.common.ExamCourseInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
 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;
@@ -27,6 +30,8 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author: fengdesheng
  * @since: 2018/10/17
@@ -70,12 +75,23 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
 
     @Override
     public void initCourseStatistic(Long orgId, Long examId, Long[] courseIds) {
+        List<ExamCourseInfo> examCourses = commonService.getExamCourseList(orgId, examId);
         //todo
+        System.out.println(examCourses.size());
     }
 
     @Override
     public void initAllCourseStatistic() {
-        //todo
+        //获取所有"传统"考试列表
+        log.debug("initAllCourseStatistic...");
+        List<ExamInfo> exams = commonService.getExamList(ExamType.TRADITION.name());
+        if (exams != null && !exams.isEmpty()) {
+            for (ExamInfo info : exams) {
+                List<ExamCourseInfo> examCourses = commonService.getExamCourseList(info.getOrgId(), info.getExamId());
+                //todo
+                System.out.println(examCourses.size());
+            }
+        }
     }
 
 }

+ 1 - 1
examcloud-core-print-starter/src/main/resources/application-dev.properties

@@ -1,5 +1,5 @@
 # datasource config
-spring.datasource.url=jdbc:mysql://localhost:3306/exam_cloud_kf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
+spring.datasource.url=jdbc:mysql://db-host:3306/exam_cloud_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
 spring.datasource.username=root
 spring.datasource.password=root
 spring.jpa.hibernate.ddl-auto=update

+ 1 - 1
examcloud-core-print-starter/src/main/resources/application.properties

@@ -1,5 +1,5 @@
 #debug=true
-spring.profiles.active=test
+spring.profiles.active=dev
 #mvc config
 server.port=8089
 spring.http.multipart.max-file-size=100Mb

+ 2 - 1
examcloud-core-print-starter/src/main/resources/security-exclusions.conf

@@ -11,7 +11,7 @@
 [${$rmp.ctrl.print}/printing/project][/list][POST]
 [${$rmp.ctrl.print}/printing/project][/{id}][POST]
 [${$rmp.ctrl.print}/printing/project][/update][POST]
-[${$rmp.ctrl.print}/printing/project][/init][GET]
+[${$rmp.ctrl.print}/printing/project][/all/init][GET]
 [${$rmp.ctrl.print}/printing/project/statistic][/{orgId}/{examId}][POST]
 [${$rmp.ctrl.print}/printing/project/statistic][/init/{projectId}][POST]
 [${$rmp.ctrl.print}/project/backup/setting][/{projectId}][POST]
@@ -23,6 +23,7 @@
 [${$rmp.ctrl.print}/project/other/setting][/delete/{id}][POST]
 [${$rmp.ctrl.print}/course/statistic][/list][POST]
 [${$rmp.ctrl.print}/course/statistic][/init][POST]
+[${$rmp.ctrl.print}/course/statistic][/all/init][GET]
 [${$rmp.ctrl.print}/project/template][/{orgId}/{examId}][POST]
 [${$rmp.ctrl.print}/project/template][/save][POST]
 [${$rmp.ctrl.print}/project/template][/{id}][POST]