deason há 6 anos atrás
pai
commit
a1be508f5f

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

@@ -7,11 +7,14 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticRefreshReq;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticLessInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticRefreshReq;
 import org.springframework.data.domain.Page;
 
+import java.util.List;
+
 /**
  * @author: fengdesheng
  * @since: 2018/10/22
@@ -23,6 +26,16 @@ public interface CourseStatisticService {
      */
     Page<CourseStatisticInfo> getCourseStatisticList(CourseStatisticQuery query);
 
+    /**
+     * 同步更新课程名称信息
+     */
+    void syncCourseNameByCourseId(Long courseId, String courseName);
+
+    /**
+     * 获取某考试的所有课程的试卷页数和考生人数信息列表
+     */
+    List<CourseStatisticLessInfo> getCourseStatisticLessInfoList(Long orgId, Long examId);
+
     /**
      * 刷新某些课程的统计信息
      *
@@ -35,9 +48,4 @@ public interface CourseStatisticService {
      */
     void initAllCourseStatistic();
 
-    /**
-     * 同步更新课程名称信息
-     */
-    void syncCourseNameByCourseId(Long courseId, String courseName);
-
 }

+ 8 - 8
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/StatisticService.java

@@ -41,23 +41,23 @@ public interface StatisticService {
     PaperQuestionStructureInfo findStructureByPaperId(Long examId, String paperId);
 
     /**
-     * 获取某考试的课程和试卷类型列表
+     * 获取考试的人科次(考生的数量)
      */
-    List<ExamPaperTypeRelation> findExamCourseAndPaperTypes(Long orgId, Long examId);
+    int findExamTotalStudent(Long orgId, Long examId);
 
     /**
-     * 获取试卷袋列表
+     * 获取某考试的课程和试卷类型列表
      */
-    List<String> findExamPackageCodes(Long orgId, Long examId);
+    List<ExamPaperTypeRelation> findExamCourseAndPaperTypes(Long orgId, Long examId);
 
     /**
-     * 获取人科次
+     * 获取考试的课程数量
      */
-    int getTotalStudent(Long orgId, Long examId);
+    int parseExamTotalCourse(List<ExamPaperTypeRelation> coursePaperTypes);
 
     /**
-     * 获取课程数量
+     * 获取考试的试卷袋列表
      */
-    int getTotalCourse(List<ExamPaperTypeRelation> coursePaperTypes);
+    List<String> findExamPackageCodes(Long orgId, Long examId);
 
 }

+ 63 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursestatistic/CourseStatisticLessInfo.java

@@ -0,0 +1,63 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-28 09:19:53.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.coursestatistic;
+
+import java.io.Serializable;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/11/13
+ */
+public class CourseStatisticLessInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Long id;
+    /**
+     * 试卷P数(1P为1面,1张纸为2P)
+     */
+    private Integer paperP;
+    /**
+     * 考生人数
+     */
+    private Integer totalStudent;
+
+    public Integer getMultiplicationValue() {
+        if (paperP == null) {
+            paperP = 0;
+        }
+        if (totalStudent == null) {
+            totalStudent = 0;
+        }
+        //返回相乘的结果
+        return paperP * totalStudent;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Integer getPaperP() {
+        return paperP;
+    }
+
+    public void setPaperP(Integer paperP) {
+        this.paperP = paperP;
+    }
+
+    public Integer getTotalStudent() {
+        return totalStudent;
+    }
+
+    public void setTotalStudent(Integer totalStudent) {
+        this.totalStudent = totalStudent;
+    }
+
+}

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

@@ -10,6 +10,7 @@ package cn.com.qmth.examcloud.core.print.service.impl;
 import cn.com.qmth.examcloud.core.print.common.jpa.OrderBuilder;
 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.entity.CourseStatistic;
 import cn.com.qmth.examcloud.core.print.enums.PaperStatus;
@@ -19,10 +20,7 @@ import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
 import cn.com.qmth.examcloud.core.print.service.StatisticService;
 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;
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticRefreshReq;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,6 +28,8 @@ 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.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -47,6 +47,8 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     private PrintingProjectService printingProjectService;
     @Autowired
     private StatisticService statisticService;
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
 
     @Override
     public Page<CourseStatisticInfo> getCourseStatisticList(CourseStatisticQuery query) {
@@ -77,6 +79,23 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
         return CourseStatisticConvert.ofPage(page);
     }
 
+    @Override
+    public void syncCourseNameByCourseId(Long courseId, String courseName) {
+        if (courseId == null || StringUtils.isBlank(courseName)) {
+            return;
+        }
+        courseStatisticRepository.updateCourseNameByCourseId(courseId, courseName);
+    }
+
+    @Override
+    public List<CourseStatisticLessInfo> getCourseStatisticLessInfoList(Long orgId, Long examId) {
+        SqlWrapper sql = new SqlWrapper()
+                .select("cs.id,cs.total_student,cp.paper_p").from("ec_prt_course_statistic cs")
+                .innerJoin("ec_prt_course_paper cp").on("cp.id", "cs.course_paper_id")
+                .where().eq("cs.org_id", orgId).and().eq("cs.exam_id", examId);
+        return jdbcTemplate.query(sql.build(), new BeanPropertyRowMapper(CourseStatisticLessInfo.class));
+    }
+
     @Override
     public void refreshCourseStatistic(CourseStatisticRefreshReq req) {
         Check.isNull(req, "请求参数不能为空!");
@@ -170,12 +189,4 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
                 info.getTotalStudent());
     }
 
-    @Override
-    public void syncCourseNameByCourseId(Long courseId, String courseName) {
-        if (courseId == null || StringUtils.isBlank(courseName)) {
-            return;
-        }
-        courseStatisticRepository.updateCourseNameByCourseId(courseId, courseName);
-    }
-
 }

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

@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
 import cn.com.qmth.examcloud.core.print.entity.ProjectStatistic;
 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.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;
 import cn.com.qmth.examcloud.core.print.service.bean.printingprojectstatistic.PrintingProjectStatisticInfo;
@@ -102,11 +103,14 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
             //获取试卷袋列表
             List<String> packageCodes = statisticService.findExamPackageCodes(project.getOrgId(), project.getExamId());
 
+            //获取某考试的所有课程的试卷页数和考生人数信息列表
+            List<CourseStatisticLessInfo> courseStatistics = courseStatisticService.getCourseStatisticLessInfoList(project.getOrgId(), project.getExamId());
+
             //人科次(考生的数量)
-            final int totalStudent = statisticService.getTotalStudent(project.getOrgId(), project.getExamId());
+            final int totalStudent = statisticService.findExamTotalStudent(project.getOrgId(), project.getExamId());
 
             //课程数量(课程代码的数量)
-            final int totalCourse = statisticService.getTotalCourse(coursePaperTypes);
+            final int totalCourse = statisticService.parseExamTotalCourse(coursePaperTypes);
 
             //试卷数量(课程代码 + 试卷类型的数量)
             final int totalPaper = coursePaperTypes.size();
@@ -114,8 +118,13 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
             //试卷袋数量
             final int totalPkg = packageCodes.size();
 
-            //常规-A3数量(总试卷A3数 + 总答题卡A3数)
-            final int normalA3 = 0;//todo
+            //常规-A3数量(总试卷A3数 + 总答题卡A3数) == 总(试卷P数 * 当前试卷人科次数) + (总科次人数) * 2
+            int sumPaperA3 = 0;
+            for (CourseStatisticLessInfo courseStatistic : courseStatistics) {
+                sumPaperA3 += courseStatistic.getMultiplicationValue();
+            }
+            final int normalA3 = sumPaperA3 + (totalStudent * 2);
+
 
             //常规-A4数量(试卷袋数 * 4)
             final int normalA4 = totalPkg * 4;

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

@@ -88,6 +88,14 @@ public class StatisticServiceImpl implements StatisticService {
         return info;
     }
 
+    @Override
+    public int findExamTotalStudent(Long orgId, Long examId) {
+        CountExamStudentReq req = new CountExamStudentReq();
+        req.setExamId(examId);
+        CountExamStudentResp resp = examCloudService.countExamStudent(req);
+        return resp.getCount().intValue();
+    }
+
     public List<ExamPaperTypeRelation> findExamCourseAndPaperTypes(Long orgId, Long examId) {
         //获取某考试的课程和试卷类型列表
         List<ExamPaperTypeRelation> coursePaperTypes = new ArrayList<>();
@@ -113,21 +121,7 @@ public class StatisticServiceImpl implements StatisticService {
     }
 
     @Override
-    public List<String> findExamPackageCodes(Long orgId, Long examId) {
-        //todo
-        return Lists.newArrayList("abc");
-    }
-
-    @Override
-    public int getTotalStudent(Long orgId, Long examId) {
-        CountExamStudentReq req = new CountExamStudentReq();
-        req.setExamId(examId);
-        CountExamStudentResp resp = examCloudService.countExamStudent(req);
-        return resp.getCount().intValue();
-    }
-
-    @Override
-    public int getTotalCourse(List<ExamPaperTypeRelation> coursePaperTypes) {
+    public int parseExamTotalCourse(List<ExamPaperTypeRelation> coursePaperTypes) {
         //获取实际课程数量
         Set<Long> ids = new HashSet<>();
         for (ExamPaperTypeRelation relation : coursePaperTypes) {
@@ -136,4 +130,10 @@ public class StatisticServiceImpl implements StatisticService {
         return ids.size();
     }
 
+    @Override
+    public List<String> findExamPackageCodes(Long orgId, Long examId) {
+        //todo
+        return Lists.newArrayList("abc");
+    }
+
 }