deason 6 年之前
父节点
当前提交
4980140c4a

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

@@ -0,0 +1,52 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 09:37:37.
+ * *************************************************
+ */
+
+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.CourseStatisticInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import static cn.com.qmth.examcloud.core.print.common.Result.success;
+
+/**
+ * 课程统计相关接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/01
+ */
+@RestController
+@Api(tags = "课程统计相关接口")
+@RequestMapping("${$rmp.ctrl.print}/course/statistic")
+public class CourseStatisticController extends ControllerSupport {
+    @Autowired
+    private CourseStatisticService courseStatisticService;
+
+    @PostMapping("/list")
+    @ApiOperation(value = "获取课程统计信息列表(分页)")
+    public Page<CourseStatisticInfo> list(@RequestBody CourseStatisticQuery query) {
+        return courseStatisticService.getCourseStatisticList(query);
+    }
+
+    @PostMapping("/init")
+    @ApiOperation(value = "初始课程的统计信息")
+    public Result init() {
+        courseStatisticService.initCourseStatistics();
+        return success();
+    }
+
+}

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

@@ -7,10 +7,24 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
+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;
+
 /**
  * @author: fengdesheng
  * @since: 2018/10/22
  */
 public interface CourseStatisticService {
 
+    /**
+     * 获取课程统计信息列表(分页)
+     */
+    Page<CourseStatisticInfo> getCourseStatisticList(CourseStatisticQuery query);
+
+    /**
+     * 初始课程的统计信息
+     */
+    void initCourseStatistics();
+
 }

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

@@ -0,0 +1,177 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 09:42:18.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.coursestatistic;
+
+import java.io.Serializable;
+
+/**
+ * 课程的统计信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/11/01
+ */
+public class CourseStatisticInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 学校机构ID
+     */
+    private Long orgId;
+    /**
+     * 考试ID
+     */
+    private Long examId;
+    /**
+     * 课程ID
+     */
+    private Long courseId;
+    /**
+     * 课程代码
+     */
+    private String courseCode;
+    /**
+     * 课程名称
+     */
+    private String courseName;
+    /**
+     * 试卷ID
+     */
+    private Long paperId;
+    /**
+     * 试卷名称
+     */
+    private String paperName;
+    /**
+     * 试卷类型
+     */
+    private String paperType;
+    /**
+     * 试卷状态
+     */
+    private String paperStatus;
+    /**
+     * 试卷文件URL
+     */
+    private String paperFileUrl;
+    /**
+     * 答案文件URL
+     */
+    private String answerFileUrl;
+    /**
+     * 试卷P数
+     */
+    private Integer totalP;
+    /**
+     * 考生人数
+     */
+    private Integer totalStudent;
+
+    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 getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Long getPaperId() {
+        return paperId;
+    }
+
+    public void setPaperId(Long paperId) {
+        this.paperId = paperId;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getPaperStatus() {
+        return paperStatus;
+    }
+
+    public void setPaperStatus(String paperStatus) {
+        this.paperStatus = paperStatus;
+    }
+
+    public String getPaperFileUrl() {
+        return paperFileUrl;
+    }
+
+    public void setPaperFileUrl(String paperFileUrl) {
+        this.paperFileUrl = paperFileUrl;
+    }
+
+    public String getAnswerFileUrl() {
+        return answerFileUrl;
+    }
+
+    public void setAnswerFileUrl(String answerFileUrl) {
+        this.answerFileUrl = answerFileUrl;
+    }
+
+    public Integer getTotalP() {
+        return totalP != null ? totalP : 0;
+    }
+
+    public void setTotalP(Integer totalP) {
+        this.totalP = totalP;
+    }
+
+    public Integer getTotalStudent() {
+        return totalStudent != null ? totalStudent : 0;
+    }
+
+    public void setTotalStudent(Integer totalStudent) {
+        this.totalStudent = totalStudent;
+    }
+
+}

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

@@ -0,0 +1,80 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 09:42:42.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.coursestatistic;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+import cn.com.qmth.examcloud.core.print.common.PageQuery;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/11/01
+ */
+public class CourseStatisticQuery extends PageQuery implements JsonSerializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 学校机构ID
+     */
+    private Long orgId;
+    /**
+     * 考试ID
+     */
+    private Long examId;
+    /**
+     * 课程ID
+     */
+    private Long courseId;
+    /**
+     * 试卷ID
+     */
+    private Long paperId;
+    /**
+     * 试卷状态
+     */
+    private String paperStatus;
+
+    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 Long getPaperId() {
+        return paperId;
+    }
+
+    public void setPaperId(Long paperId) {
+        this.paperId = paperId;
+    }
+
+    public String getPaperStatus() {
+        return paperStatus;
+    }
+
+    public void setPaperStatus(String paperStatus) {
+        this.paperStatus = paperStatus;
+    }
+
+}

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

@@ -9,7 +9,10 @@ package cn.com.qmth.examcloud.core.print.service.impl;
 
 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.bean.coursestatistic.CourseStatisticInfo;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
 /**
@@ -21,4 +24,15 @@ public class CourseStatisticServiceImpl implements CourseStatisticService {
     @Autowired
     private CourseStatisticRepository courseStatisticsRepository;
 
+    @Override
+    public Page<CourseStatisticInfo> getCourseStatisticList(CourseStatisticQuery query) {
+        //todo
+        return null;
+    }
+
+    @Override
+    public void initCourseStatistics() {
+        //todo
+    }
+
 }

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

@@ -7,6 +7,7 @@
 
 package cn.com.qmth.examcloud.core.print.service.impl;
 
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
 import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
 import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
@@ -16,6 +17,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
+
 /**
  * @author: fengdesheng
  * @since: 2018/10/26
@@ -29,12 +32,14 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
 
     @Override
     public ProjectStatisticInfo getPrintingProjectStatistic(Long orgId, Long examId) {
-        ProjectStatisticInfo info = new ProjectStatisticInfo();
         PrintingProject project = printingProjectService.getPrintingProjectByOrgExam(orgId, examId);
-        if (project != null) {
-            BeanUtils.copyProperties(project, info);
-            //todo total
+        if (project == null) {
+            throw new StatusException(PRT_CODE_500, "当前项目统计不存在!");
         }
+        ProjectStatisticInfo info = new ProjectStatisticInfo();
+        BeanUtils.copyProperties(project, info);
+        info.setProjectId(project.getId());
+        //todo total
         return info;
     }
 

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

@@ -0,0 +1,42 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-01 10:03:07.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.test;
+
+import cn.com.qmth.examcloud.core.print.PrintApplication;
+import cn.com.qmth.examcloud.core.print.service.CourseStatisticService;
+import cn.com.qmth.examcloud.core.print.service.bean.coursestatistic.CourseStatisticQuery;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/10/17
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = PrintApplication.class)
+public class CourseStatisticServiceTest {
+    @Autowired
+    private CourseStatisticService courseStatisticService;
+
+    @Test
+    public void getCourseStatisticListTest() throws Exception {
+        CourseStatisticQuery query = new CourseStatisticQuery();
+        query.setOrgId(1L);
+        query.setExamId(1L);
+        courseStatisticService.getCourseStatisticList(query);
+    }
+
+    @Test
+    public void initCourseStatisticsTest() throws Exception {
+        courseStatisticService.initCourseStatistics();
+    }
+
+}