deason 6 anni fa
parent
commit
66840c1c35

+ 1 - 1
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/entity/CoursePaper.java

@@ -21,7 +21,7 @@ import javax.persistence.Table;
 @Table(name = "ec_prt_course_paper", indexes = {
         @Index(name = "INDEX_PRT_COURSE_PAPER_01", columnList = "orgId"),
         @Index(name = "INDEX_PRT_COURSE_PAPER_02", columnList = "examId"),
-        @Index(name = "INDEX_PRT_COURSE_PAPER_03", columnList = "paperId", unique = true)})
+        @Index(name = "INDEX_PRT_COURSE_PAPER_03", columnList = "examId,paperId", unique = true)})
 public class CoursePaper extends IdEntity {
     /**
      * 学校机构ID

+ 1 - 1
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/repository/CoursePaperRepository.java

@@ -24,6 +24,6 @@ public interface CoursePaperRepository extends JpaRepository<CoursePaper, Long>,
     @Query("UPDATE CoursePaper SET courseName=:courseName WHERE courseId=:courseId")
     int updateCourseNameByCourseId(@Param("courseId") Long courseId, @Param("courseName") String courseName);
 
-    CoursePaper findByPaperId(String paperId);
+    CoursePaper findByExamIdAndPaperId(Long examId, String paperId);
 
 }

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

@@ -59,13 +59,13 @@ public class PrintingProjectController extends ControllerSupport {
     }
 
     @PostMapping("/org/list")
-    @ApiOperation(value = "获取印刷学校列表")
+    @ApiOperation(value = "获取当前用户相关的学校列表")
     public List<OrgInfo> getOrgList() {
-        //根据登录用户的不同角色获取不同的学校数据
+        //根据登录用户获取该用户相关的学校数据
         UserInfo user = new UserInfo(getAccessUser());
 
         if (user.isSchoolLeader()) {
-            //学校印刷管理员直接返回当前用户的学校机构信息
+            //学校印刷管理员直接返回用户的学校机构信息
             return Lists.newArrayList(user.getOrgInfo());
         }
 
@@ -79,13 +79,9 @@ public class PrintingProjectController extends ControllerSupport {
     }
 
     @PostMapping("/exam/list")
-    @ApiOperation(value = "获取印刷考试列表")
-    public List<ExamInfo> getExamList(@RequestParam Long orgId, @RequestParam(required = false, defaultValue = "true") Boolean needAll) {
-        if (needAll) {
-            return printingProjectService.getExamList(orgId, null, null);
-        }
-
-        //根据登录用户的不同角色获取不同的考试数据
+    @ApiOperation(value = "获取当前用户相关的考试列表")
+    public List<ExamInfo> getExamList(@RequestParam Long orgId) {
+        //根据登录用户获取该用户相关的考试数据
         UserInfo user = new UserInfo(getAccessUser());
         if (user.isPM()) {
             return printingProjectService.getExamList(orgId, user.getUserId(), null);

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

@@ -32,6 +32,15 @@ public class CourseStatisticRefreshReq implements Serializable {
      */
     private List<Course> courses;
 
+    public CourseStatisticRefreshReq(Long orgId, Long examId) {
+        this.orgId = orgId;
+        this.examId = examId;
+    }
+
+    public CourseStatisticRefreshReq() {
+
+    }
+
     public Long getOrgId() {
         return orgId;
     }

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

@@ -127,7 +127,7 @@ public class CoursePaperServiceImpl implements CoursePaperService {
             throw new StatusException(PRT_CODE_400, "试卷页数不能为空!");
         }
 
-        CoursePaper oldCoursePaper = coursePaperRepository.findByPaperId(coursePaper.getPaperId());
+        CoursePaper oldCoursePaper = coursePaperRepository.findByExamIdAndPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
         if (oldCoursePaper != null) {
             //存在则修改
             oldCoursePaper.setPaperName(coursePaper.getPaperName());

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

@@ -112,24 +112,25 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
         Check.isNull(req.getOrgId(), "学校ID不能为空!");
         Check.isNull(req.getExamId(), "考试ID不能为空!");
 
+        //待刷新的课程列表
+        List<ExamCourseInfo> examCourses = null;
+
         List<CourseStatisticRefreshReq.Course> courses = req.getCourses();
         if (courses == null || courses.size() == 0) {
-            //未选择课程时,则跳过统计
-            return;
+            //未选择课程时,则统计当前考试下的所有课程
+            examCourses = statisticService.findExamCourseAndPaperTypes(req.getOrgId(), req.getExamId());
+        } else {
+            examCourses = new ArrayList<>();
+            for (CourseStatisticRefreshReq.Course course : courses) {
+                if (course.getCourseId() == null || StringUtils.isBlank(course.getPaperType())) {
+                    continue;
+                }
+                examCourses.add(new ExamCourseInfo(req.getOrgId(), req.getExamId(), course.getCourseId(), course.getPaperType()));
+            }
         }
 
         //获取当前考试下已有的课程统计信息
         Map<String, CourseStatistic> oldCourseStatisticMaps = this.getCourseStatisticMaps(req.getOrgId(), req.getExamId());
-
-        //待刷新的课程列表
-        List<ExamCourseInfo> examCourses = new ArrayList<>();
-        for (CourseStatisticRefreshReq.Course course : courses) {
-            if (course.getCourseId() == null || StringUtils.isBlank(course.getPaperType())) {
-                continue;
-            }
-            examCourses.add(new ExamCourseInfo(req.getOrgId(), req.getExamId(), course.getCourseId(), course.getPaperType()));
-        }
-
         this.syncCourseStatistics(examCourses, oldCourseStatisticMaps);
     }
 

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

@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.core.print.service.PrintingProjectStatisticService;
 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.coursestatistic.CourseStatisticLessInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticRefreshReq;
 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;
@@ -77,6 +78,9 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
             throw new StatusException(PRT_CODE_500, "当前项目不存在!");
         }
 
+        //刷新课程统计
+        courseStatisticService.refreshCourseStatistic(new CourseStatisticRefreshReq(orgId, examId));
+        //执行项目统计
         this.doStatistic(Lists.newArrayList(new PrintingProjectLessInfo(orgId, examId, project.getId())));
     }
 

+ 1 - 1
pom.xml

@@ -91,7 +91,7 @@
             <dependency>
                 <groupId>com.github.xiaoymin</groupId>
                 <artifactId>swagger-bootstrap-ui</artifactId>
-                <version>1.8.5</version>
+                <version>1.8.8</version>
             </dependency>
             <dependency>
                 <groupId>com.upyun</groupId>