deason 6 years ago
parent
commit
f95f90e120

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

@@ -10,7 +10,7 @@ package cn.com.qmth.examcloud.core.print.api.controller;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshForm;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshReq;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
 import io.swagger.annotations.Api;
@@ -42,7 +42,7 @@ public class CourseStatisticController extends ControllerSupport {
 
     @PostMapping("/init")
     @ApiOperation(value = "刷新某些课程的统计信息")
-    public Result init(@RequestBody CourseRefreshForm form) {
+    public Result init(@RequestBody CourseRefreshReq form) {
         courseStatisticService.initCourseStatistic(form);
         return success();
     }

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

@@ -7,7 +7,7 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshForm;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshReq;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
 import org.springframework.data.domain.Page;
@@ -26,9 +26,9 @@ public interface CourseStatisticService {
     /**
      * 刷新某些课程的统计信息
      *
-     * @param form 请求表单
+     * @param req 请求表单
      */
-    void initCourseStatistic(CourseRefreshForm form);
+    void initCourseStatistic(CourseRefreshReq req);
 
     /**
      * 初始所有课程的统计信息

+ 0 - 79
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursepaper/CoursePaperForm.java

@@ -1,79 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-11-14 16:34:28.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.core.print.service.bean.coursepaper;
-
-import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
-
-/**
- * @author: fengdesheng
- * @since: 2018/11/13
- */
-public class CoursePaperForm implements JsonSerializable {
-    private static final long serialVersionUID = 1L;
-    /**
-     * 学校机构ID
-     */
-    private Long orgId;
-    /**
-     * 考试ID
-     */
-    private Long examId;
-    /**
-     * 课程ID
-     */
-    private Long courseId;
-    /**
-     * 试卷ID
-     */
-    private String paperId;
-    /**
-     * 试卷名称
-     */
-    private String paperName;
-
-    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 getPaperId() {
-        return paperId;
-    }
-
-    public void setPaperId(String paperId) {
-        this.paperId = paperId;
-    }
-
-    public String getPaperName() {
-        return paperName;
-    }
-
-    public void setPaperName(String paperName) {
-        this.paperName = paperName;
-    }
-
-}

+ 2 - 2
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursestatistic/CourseRefreshForm.java → examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/coursestatistic/CourseRefreshReq.java

@@ -11,12 +11,12 @@ import java.io.Serializable;
 import java.util.List;
 
 /**
- * 待刷新统计的课程表单
+ * 待刷新统计的课程(请求表单)
  *
  * @author: fengdesheng
  * @since: 2018/11/08
  */
-public class CourseRefreshForm implements Serializable {
+public class CourseRefreshReq implements Serializable {
     private static final long serialVersionUID = 1L;
     /**
      * 学校机构ID

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

@@ -19,7 +19,7 @@ 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.bean.common.ExamCourseInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshForm;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshReq;
 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;
@@ -78,20 +78,22 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     }
 
     @Override
-    public void initCourseStatistic(CourseRefreshForm form) {
-        Check.isNull(form, "请求参数不能为空!");
-        Check.isNull(form.getOrgId(), "学校ID不能为空!");
-        Check.isNull(form.getExamId(), "考试ID不能为空!");
-        List<CourseRefreshForm.Course> courses = form.getCourses();
+    public void initCourseStatistic(CourseRefreshReq req) {
+        Check.isNull(req, "请求参数不能为空!");
+        Check.isNull(req.getOrgId(), "学校ID不能为空!");
+        Check.isNull(req.getExamId(), "考试ID不能为空!");
+
+        List<CourseRefreshReq.Course> courses = req.getCourses();
         if (courses == null || courses.size() == 0) {
             //课程ID和试卷类型未指定时,则不统计
             return;
         }
-        for (CourseRefreshForm.Course course : courses) {
+
+        for (CourseRefreshReq.Course course : courses) {
             if (course.getCourseId() == null || StringUtils.isBlank(course.getPaperType())) {
                 continue;
             }
-            List<ExamCourseInfo> examCourses = commonService.getExamCourseList(form.getOrgId(), form.getExamId(), course.getCourseId(), course.getPaperType());
+            List<ExamCourseInfo> examCourses = commonService.getExamCourseList(req.getOrgId(), req.getExamId(), course.getCourseId(), course.getPaperType());
             this.syncCourseStatisticList(examCourses);
         }
     }
@@ -117,6 +119,7 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
             if (info.getCourseId() == null) {
                 continue;
             }
+
             boolean isExist = this.isExistCourseStatistic(info);
             if (isExist) {
                 this.syncTotalStudentByOrgExamCourse(info);
@@ -154,8 +157,12 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     }
 
     private void syncTotalStudentByOrgExamCourse(ExamCourseInfo info) {
+        if (info == null || info.getTotalStudent() == null) {
+            return;
+        }
         //仅更新total_student字段
-        courseStatisticRepository.updateTotalStudentByOrgExamCourse(info.getOrgId(), info.getExamId(), info.getCourseId(), info.getPaperType(), info.getTotalStudent());
+        courseStatisticRepository.updateTotalStudentByOrgExamCourse(info.getOrgId(), info.getExamId(), info.getCourseId(), info.getPaperType(),
+                info.getTotalStudent());
     }
 
     @Override

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

@@ -125,6 +125,7 @@ public class ExamStructureServiceImpl implements ExamStructureService {
         if (oldStructure == null) {
             throw new StatusException(Constants.PRT_CODE_500, "原结构信息不存在!");
         }
+
         newStructure = new ExamStructure();
         newStructure.setId(null);
         newStructure.setOrgId(info.getNewOrgId());

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

@@ -207,10 +207,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
 
     @Override
     public List<OrgInfo> getOrgList(Long pmId, Long supplierId) {
-        SqlWrapper sql = new SqlWrapper()
-                .select("org_id,org_name")
-                .from("ec_prt_project")
-                .where().append("1=1");
+        SqlWrapper sql = new SqlWrapper().select("org_id,org_name").from("ec_prt_project").where().append("1=1");
         if (pmId != null) {
             sql.and().eq("pm_id", pmId);
         }
@@ -223,10 +220,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
 
     @Override
     public List<ExamInfo> getExamList(Long orgId) {
-        SqlWrapper sql = new SqlWrapper()
-                .select("org_id,org_name,exam_id,exam_name")
-                .from("ec_prt_project")
-                .where().append("1=1");
+        SqlWrapper sql = new SqlWrapper().select("org_id,org_name,exam_id,exam_name").from("ec_prt_project").where().append("1=1");
         if (orgId != null) {
             sql.and().eq("org_id", orgId);
         }

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

@@ -42,10 +42,12 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
     public ProjectStatisticInfo getPrintingProjectStatistic(Long orgId, Long examId) {
         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, "当前项目统计不存在!");

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

@@ -55,6 +55,7 @@ public class ProjectBackupSettingServiceImpl implements ProjectBackupSettingServ
         Check.isNull(info.getPkgSinglePercent(), "单独备份比例不能为空!");
         Check.isNull(info.getPkgSingleMax(), "单独备份最大值不能为空!");
         Check.isNull(info.getPkgSingleMin(), "单独备份最小值不能为空!");
+
         Specification<ProjectBackupSetting> spec = SearchBuilder.EQ("projectId", info.getProjectId());
         ProjectBackupSetting setting = projectBackupSettingRepository.findOne(spec);
         if (setting != null) {

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

@@ -8,7 +8,7 @@
 package cn.com.qmth.examcloud.core.print.test;
 
 import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
-import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshForm;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseRefreshReq;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticInfo;
 import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
 import org.junit.Test;
@@ -40,14 +40,14 @@ public class CourseStatisticServiceTest extends BaseTest {
 
     @Test
     public void initCourseStatisticTest() throws Exception {
-        CourseRefreshForm form = new CourseRefreshForm();
-        form.setOrgId(109L);
-        form.setExamId(178L);
-        List<CourseRefreshForm.Course> courses = new ArrayList<>();
-        courses.add(new CourseRefreshForm.Course(262L, "O"));
-        courses.add(new CourseRefreshForm.Course(263L, "O"));
-        form.setCourses(courses);
-        courseStatisticService.initCourseStatistic(form);
+        CourseRefreshReq req = new CourseRefreshReq();
+        req.setOrgId(109L);
+        req.setExamId(178L);
+        List<CourseRefreshReq.Course> courses = new ArrayList<>();
+        courses.add(new CourseRefreshReq.Course(262L, "O"));
+        courses.add(new CourseRefreshReq.Course(263L, "O"));
+        req.setCourses(courses);
+        courseStatisticService.initCourseStatistic(req);
 
         //courseStatisticService.initAllCourseStatistic();
         //courseStatisticService.syncCourseNameByCourseId(262L, "测试课程");