deason %!s(int64=6) %!d(string=hai) anos
pai
achega
36fc5de5ab

+ 5 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/CoursePaperService.java

@@ -24,6 +24,11 @@ public interface CoursePaperService {
      */
     List<CoursePaperLessInfo> getCoursePaperList(CoursePaperQuery query);
 
+    /**
+     * 获取课程试卷数量
+     */
+    long countCoursePaper(Long orgId, Long examId, Long courseId);
+
     /**
      * 同步更新课程名称信息
      */

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

@@ -82,6 +82,16 @@ public class CoursePaperServiceImpl implements CoursePaperService {
         return CoursePaperConvert.ofList(list);
     }
 
+    @Override
+    public long countCoursePaper(Long orgId, Long examId, Long courseId) {
+        SearchBuilder searches = new SearchBuilder();
+        searches.eq("orgId", orgId);
+        searches.eq("examId", examId);
+        searches.eq("courseId", courseId);
+        Specification<CoursePaper> spec = SpecUtils.buildSearchers(CoursePaper.class, searches.build());
+        return coursePaperRepository.count(spec);
+    }
+
     @Override
     public void syncCourseNameByCourseId(Long courseId, String courseName) {
         if (courseId == null || StringUtils.isBlank(courseName)) {
@@ -397,11 +407,13 @@ public class CoursePaperServiceImpl implements CoursePaperService {
 
             if (needStruct) {
                 //客观题结构
-                List<ObjectiveQuestionStructure> objectives = examQuestionStructureService.getObjectiveQuestionStructureList(statistic.getOrgId(), statistic.getExamId(), paper.getPaperId(), statistic.getPaperType());
+                List<ObjectiveQuestionStructure> objectives = examQuestionStructureService.getObjectiveQuestionStructureList(
+                        statistic.getOrgId(), statistic.getExamId(), paper.getPaperId(), statistic.getPaperType());
                 allObjectives.addAll(objectives);
 
                 //主观题结构
-                List<SubjectiveQuestionStructure> subjectives = examQuestionStructureService.getSubjectiveQuestionStructureList(statistic.getOrgId(), statistic.getExamId(), paper.getPaperId(), statistic.getPaperType());
+                List<SubjectiveQuestionStructure> subjectives = examQuestionStructureService.getSubjectiveQuestionStructureList(
+                        statistic.getOrgId(), statistic.getExamId(), paper.getPaperId(), statistic.getPaperType());
                 allSubjectives.addAll(subjectives);
             }
 

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

@@ -17,6 +17,7 @@ import cn.com.qmth.examcloud.core.print.common.utils.DateUtils;
 import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
 import cn.com.qmth.examcloud.core.print.enums.PaperStatus;
 import cn.com.qmth.examcloud.core.print.repository.CourseStatisticRepository;
+import cn.com.qmth.examcloud.core.print.service.CoursePaperService;
 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.StatisticService;
@@ -52,6 +53,8 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     @Autowired
     private PrintingProjectService printingProjectService;
     @Autowired
+    private CoursePaperService coursePaperService;
+    @Autowired
     private StatisticService statisticService;
     @Autowired
     private JdbcTemplate jdbcTemplate;
@@ -229,7 +232,14 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
         statistic.setCourseName(info.getCourseName());
         statistic.setPaperType(info.getPaperType());
         statistic.setTotalStudent(info.getTotalStudent());
-        statistic.setPaperStatus(PaperStatus.无.getIndex());
+
+        long total = coursePaperService.countCoursePaper(info.getOrgId(), info.getExamId(), info.getCourseId());
+        if (total > 0) {
+            statistic.setPaperStatus(PaperStatus.未指定.getIndex());
+        } else {
+            statistic.setPaperStatus(PaperStatus.无.getIndex());
+        }
+
         courseStatisticRepository.save(statistic);
     }