deason 6 years ago
parent
commit
379f0c50f5

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

@@ -7,6 +7,7 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
+import cn.com.qmth.examcloud.core.print.service.bean.common.CourseInfo;
 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.examquestionstructure.ExamQuestionStructureInfo;
@@ -69,6 +70,11 @@ public interface StatisticService {
      */
     int countExamTotalStudentBySite(Long examId, String site);
 
+    /**
+     * 获取课程基本信息
+     */
+    CourseInfo findCourseInfo(Long orgId, Long courseId);
+
     /**
      * 获取考试的试卷试题结构信息
      */

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

@@ -0,0 +1,67 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-30 11:10:19.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.common;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+
+/**
+ * 课程信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/10/26
+ */
+public class CourseInfo implements JsonSerializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 课程ID
+     */
+    private Long id;
+    /**
+     * 课程代码
+     */
+    private String code;
+    /**
+     * 课程名称
+     */
+    private String name;
+
+    public CourseInfo(Long id, String code, String name) {
+        this.id = id;
+        this.code = code;
+        this.name = name;
+    }
+
+    public CourseInfo() {
+
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

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

@@ -18,6 +18,7 @@ import cn.com.qmth.examcloud.core.print.repository.CourseStatisticRepository;
 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;
+import cn.com.qmth.examcloud.core.print.service.bean.common.CourseInfo;
 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.*;
@@ -158,6 +159,9 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
             return;
         }
 
+        //课程基本信息Maps
+        Map<Long, CourseInfo> courseMaps = new HashMap<>();
+
         //按课程和试卷类型逐个更新统计信息
         for (ExamCourseInfo info : examCourses) {
             //Key: examId_courseId_paperType
@@ -172,6 +176,15 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
                 this.updateTotalStudentByOrgExamCourse(info);
                 oldCourseStatisticMaps.remove(key);
             } else {
+                //获取并设置课程基本信息
+                CourseInfo course = courseMaps.get(info.getCourseId());
+                if (course == null) {
+                    course = statisticService.findCourseInfo(info.getOrgId(), info.getCourseId());
+                    courseMaps.put(course.getId(), course);
+                }
+                info.setCourseCode(course.getCode());
+                info.setCourseName(course.getName());
+
                 //不存在则新增
                 this.addCourseStatistic(info);
             }
@@ -188,8 +201,8 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
         statistic.setOrgId(info.getOrgId());
         statistic.setExamId(info.getExamId());
         statistic.setCourseId(info.getCourseId());
-        statistic.setCourseCode(info.getCourseCode());//todo
-        statistic.setCourseName(info.getCourseName());//todo
+        statistic.setCourseCode(info.getCourseCode());
+        statistic.setCourseName(info.getCourseName());
         statistic.setPaperType(info.getPaperType());
         statistic.setTotalStudent(info.getTotalStudent());
         statistic.setPaperStatus(PaperStatus.无.getIndex());

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

@@ -7,9 +7,14 @@
 
 package cn.com.qmth.examcloud.core.print.service.impl;
 
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
 import cn.com.qmth.examcloud.core.print.common.jpa.SqlWrapper;
 import cn.com.qmth.examcloud.core.print.enums.ExamType;
 import cn.com.qmth.examcloud.core.print.service.StatisticService;
+import cn.com.qmth.examcloud.core.print.service.bean.common.CourseInfo;
 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.examquestionstructure.ExamQuestionStructureInfo;
@@ -43,6 +48,8 @@ import java.util.Set;
 public class StatisticServiceImpl implements StatisticService {
     private static final Logger log = LoggerFactory.getLogger(StatisticServiceImpl.class);
     @Autowired
+    private CourseCloudService courseCloudService;
+    @Autowired
     private ExamCloudService examCloudService;
     @Autowired
     private JdbcTemplate jdbcTemplate;
@@ -192,6 +199,16 @@ public class StatisticServiceImpl implements StatisticService {
         return properties;
     }
 
+    @Override
+    public CourseInfo findCourseInfo(Long orgId, Long courseId) {
+        GetCourseReq req = new GetCourseReq();
+        req.setRootOrgId(orgId);
+        req.setId(courseId);
+        GetCourseResp resp = courseCloudService.getCourse(req);
+        CourseBean bean = resp.getCourseBean();
+        return new CourseInfo(bean.getId(), bean.getCode(), bean.getName());
+    }
+
     @Override
     public ExamQuestionStructureInfo findStructureByPaperId(Long examId, String paperId) {
         ExamQuestionStructureInfo info = new ExamQuestionStructureInfo();