Эх сурвалжийг харах

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-2/examcloud-core-print

weiwenhai 6 жил өмнө
parent
commit
d190830bc2

+ 5 - 0
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/Result.java

@@ -7,6 +7,7 @@
 
 package cn.com.qmth.examcloud.core.print.common;
 
+import cn.com.qmth.examcloud.core.print.common.utils.JsonMapper;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import springfox.documentation.annotations.ApiIgnore;
 
@@ -84,4 +85,8 @@ public class Result<T> implements Serializable {
         return data;
     }
 
+    public String toJson() {
+        return new JsonMapper().toJson(this);
+    }
+
 }

+ 14 - 13
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/aspect/AspectController.java

@@ -11,39 +11,40 @@ import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import static cn.com.qmth.examcloud.core.print.common.Result.error;
-
 @ControllerAdvice(annotations = Controller.class)
 public class AspectController {
     private final static Logger log = LoggerFactory.getLogger(AspectController.class);
+    public final static HttpStatus ERROR_CODE = HttpStatus.INTERNAL_SERVER_ERROR;
+    public final static String ERROR_CONTENT = "系统异常!";
 
     @ResponseBody
     @ExceptionHandler(value = RuntimeException.class)
-    public Result handle(RuntimeException e) {
-        if (e instanceof StatusException) {
-            StatusException se = (StatusException) e;
-            log.error(se.toJson());
-            return new Result(se.getCode(), se.getDesc());
-        }
-        log.error(e.getMessage(), e);
-        return error(e.getMessage());
+    public ResponseEntity<String> handle(RuntimeException e) {
+        return doHandle(e);
     }
 
     @ResponseBody
     @ExceptionHandler(value = Exception.class)
-    public Result handle(Exception e) {
+    public ResponseEntity<String> handle(Exception e) {
+        return doHandle(e);
+    }
+
+    public static ResponseEntity<String> doHandle(Exception e) {
         if (e instanceof StatusException) {
             StatusException se = (StatusException) e;
             log.error(se.toJson());
-            return new Result(se.getCode(), se.getDesc());
+            return new ResponseEntity<>(se.toJson(), ERROR_CODE);
         }
         log.error(e.getMessage(), e);
-        return error(e.getMessage());
+        String errorJson = Result.error(ERROR_CONTENT).toJson();
+        return new ResponseEntity<>(errorJson, ERROR_CODE);
     }
 
 }

+ 5 - 23
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/aspect/AspectRestController.java

@@ -7,43 +7,25 @@
 
 package cn.com.qmth.examcloud.core.print.common.aspect;
 
-import cn.com.qmth.examcloud.commons.base.exception.StatusException;
-import cn.com.qmth.examcloud.core.print.common.Result;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 
-import static cn.com.qmth.examcloud.core.print.common.Result.error;
-
 @RestControllerAdvice(annotations = RestController.class)
 public class AspectRestController {
-    private final static Logger log = LoggerFactory.getLogger(AspectRestController.class);
 
     @ResponseBody
     @ExceptionHandler(value = RuntimeException.class)
-    public Result handle(RuntimeException e) {
-        if (e instanceof StatusException) {
-            StatusException se = (StatusException) e;
-            log.error(se.toJson());
-            return new Result(se.getCode(), se.getDesc());
-        }
-        log.error(e.getMessage(), e);
-        return error(e.getMessage());
+    public ResponseEntity<String> handle(RuntimeException e) {
+        return AspectController.doHandle(e);
     }
 
     @ResponseBody
     @ExceptionHandler(value = Exception.class)
-    public Result handle(Exception e) {
-        if (e instanceof StatusException) {
-            StatusException se = (StatusException) e;
-            log.error(se.toJson());
-            return new Result(se.getCode(), se.getDesc());
-        }
-        log.error(e.getMessage(), e);
-        return error(e.getMessage());
+    public ResponseEntity<String> handle(Exception e) {
+        return AspectController.doHandle(e);
     }
 
 }

+ 15 - 16
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/entity/PrintingProject.java

@@ -20,27 +20,26 @@ import java.util.Date;
  */
 @Entity
 @Table(name = "ec_prt_project", indexes = {
-        @Index(name = "INDEX_PRT_PROJECT_01", columnList = "orgId"),
-        @Index(name = "INDEX_PRT_PROJECT_02", columnList = "examId")})
+        @Index(name = "INDEX_PRT_PROJECT_01", columnList = "orgId,examId", unique = true)})
 public class PrintingProject extends IdEntity {
     /**
      * 学校机构ID
      */
     private Long orgId;
+    /**
+     * 学校机构名称(冗余字段)
+     */
+    @Column(length = 50)
+    private String orgName;
     /**
      * 考试ID
      */
     private Long examId;
     /**
-     * 考试名称
+     * 考试名称(冗余字段)
      */
     @Column(length = 50)
     private String examName;
-    /**
-     * 学校机构名称
-     */
-    @Column(length = 50)
-    private String orgName;
     /**
      * 供应商ID(表ecs_core_org的ID)
      */
@@ -96,6 +95,14 @@ public class PrintingProject extends IdEntity {
         this.orgId = orgId;
     }
 
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
     public Long getExamId() {
         return examId;
     }
@@ -112,14 +119,6 @@ public class PrintingProject extends IdEntity {
         this.examName = examName;
     }
 
-    public String getOrgName() {
-        return orgName;
-    }
-
-    public void setOrgName(String orgName) {
-        this.orgName = orgName;
-    }
-
     public Long getSupplierId() {
         return supplierId;
     }

+ 1 - 2
examcloud-core-print-dao/src/main/resources/db-schema.sql

@@ -97,8 +97,7 @@ CREATE TABLE ec_prt_project (
   supplier_id        bigint(20)          DEFAULT NULL,
   supplier_name      varchar(50)         DEFAULT NULL,
   PRIMARY KEY (id),
-  KEY INDEX_PRT_PROJECT_01 (org_id),
-  KEY INDEX_PRT_PROJECT_02 (exam_id)
+  UNIQUE KEY INDEX_PRT_PROJECT_01 (org_id, exam_id)
 ) ENGINE = InnoDB DEFAULT CHARSET = utf8;
 
 

+ 9 - 12
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/PrintingProjectStatisticController.java

@@ -10,18 +10,15 @@ 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.PrintingProjectStatisticService;
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectInfo;
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectQuery;
+import cn.com.qmth.examcloud.core.print.service.bean.ProjectStatisticInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
 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 java.util.List;
-
 import static cn.com.qmth.examcloud.core.print.common.Result.success;
 
 /**
@@ -37,16 +34,16 @@ public class PrintingProjectStatisticController extends ControllerSupport {
     @Autowired
     private PrintingProjectStatisticService printingProjectStatisticService;
 
-    @PostMapping("/list")
-    @ApiOperation(value = "获取印刷项目统计列表")
-    public List<PrintingProjectInfo> list(@RequestBody PrintingProjectQuery query) {
-        return printingProjectStatisticService.getPrintingProjectStatisticList(query);
+    @PostMapping("/{orgId}/{examId}")
+    @ApiOperation(value = "获取某个印刷项目的统计信息")
+    public ProjectStatisticInfo list(@PathVariable Long orgId, @PathVariable Long examId) {
+        return printingProjectStatisticService.getPrintingProjectStatistic(orgId, examId);
     }
 
     @PostMapping("/init")
-    @ApiOperation(value = "执行印刷项目统计")
-    public Result statistic() {
-        printingProjectStatisticService.statistic();
+    @ApiOperation(value = "初始印刷项目的统计信息")
+    public Result init() {
+        printingProjectStatisticService.initPrintingProjectStatistics();
         return success();
     }
 

+ 14 - 5
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/PrintingProjectStatisticService.java

@@ -7,10 +7,9 @@
 
 package cn.com.qmth.examcloud.core.print.service;
 
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectInfo;
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectQuery;
+import cn.com.qmth.examcloud.core.print.service.bean.ProjectStatisticInfo;
 
-import java.util.List;
+import javax.validation.constraints.NotNull;
 
 /**
  * @author: fengdesheng
@@ -18,8 +17,18 @@ import java.util.List;
  */
 public interface PrintingProjectStatisticService {
 
-    List<PrintingProjectInfo> getPrintingProjectStatisticList(PrintingProjectQuery query);
+    /**
+     * 获取某个印刷项目的统计信息
+     *
+     * @param orgId
+     * @param examId
+     * @return
+     */
+    ProjectStatisticInfo getPrintingProjectStatistic(@NotNull Long orgId, @NotNull Long examId);
 
-    void statistic();
+    /**
+     * 初始印刷项目的统计信息
+     */
+    void initPrintingProjectStatistics();
 
 }

+ 239 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/ProjectStatisticInfo.java

@@ -0,0 +1,239 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-10-30 11:15:44.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean;
+
+import java.io.Serializable;
+
+/**
+ * 印刷项目的统计信息
+ *
+ * @author: fengdesheng
+ * @since: 2018/10/30
+ */
+public class ProjectStatisticInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 印刷项目ID
+     */
+    private Long projectId;
+    /**
+     * 考试ID
+     */
+    private Long examId;
+    /**
+     * 考试名称
+     */
+    private String examName;
+    /**
+     * 学校机构ID
+     */
+    private Long orgId;
+    /**
+     * 学校机构名称
+     */
+    private String orgName;
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
+    /**
+     * 供应商名称
+     */
+    private String supplierName;
+    /**
+     * 项目经理ID
+     */
+    private Long pmId;
+    /**
+     * 项目经理名称
+     */
+    private String pmName;
+    /**
+     * 人科次
+     */
+    private Integer totalExamStudent;
+    /**
+     * 课程数量
+     */
+    private Integer totalCourse;
+    /**
+     * 试卷数量
+     */
+    private Integer totalPaper;
+    /**
+     * 试卷袋数
+     */
+    private Integer totalPkg;
+    /**
+     * 常规 印刷数量A3
+     */
+    private Integer normalA3;
+    /**
+     * 常规 印刷数量A4
+     */
+    private Integer normalA4;
+    /**
+     * 备份 印刷数量A4
+     */
+    private Integer backupA3;
+    /**
+     * 备份 印刷数量A4
+     */
+    private Integer backupA4;
+
+    /**
+     * 合计 印刷数量A3
+     */
+    public Integer getTotalA3() {
+        return getNormalA3() + getBackupA3();
+    }
+
+    /**
+     * 合计 印刷数量A4
+     */
+    public Integer getTotalA4() {
+        return getNormalA4() + getBackupA4();
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Long projectId) {
+        this.projectId = projectId;
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public Long getPmId() {
+        return pmId;
+    }
+
+    public void setPmId(Long pmId) {
+        this.pmId = pmId;
+    }
+
+    public String getPmName() {
+        return pmName;
+    }
+
+    public void setPmName(String pmName) {
+        this.pmName = pmName;
+    }
+
+    public Integer getTotalExamStudent() {
+        return totalExamStudent != null ? totalExamStudent : 0;
+    }
+
+    public void setTotalExamStudent(Integer totalExamStudent) {
+        this.totalExamStudent = totalExamStudent;
+    }
+
+    public Integer getTotalCourse() {
+        return totalCourse != null ? totalCourse : 0;
+    }
+
+    public void setTotalCourse(Integer totalCourse) {
+        this.totalCourse = totalCourse;
+    }
+
+    public Integer getTotalPaper() {
+        return totalPaper != null ? totalPaper : 0;
+    }
+
+    public void setTotalPaper(Integer totalPaper) {
+        this.totalPaper = totalPaper;
+    }
+
+    public Integer getNormalA3() {
+        return normalA3 != null ? normalA3 : 0;
+    }
+
+    public void setNormalA3(Integer normalA3) {
+        this.normalA3 = normalA3;
+    }
+
+    public Integer getNormalA4() {
+        return normalA4 != null ? normalA4 : 0;
+    }
+
+    public void setNormalA4(Integer normalA4) {
+        this.normalA4 = normalA4;
+    }
+
+    public Integer getBackupA3() {
+        return backupA3 != null ? backupA3 : 0;
+    }
+
+    public void setBackupA3(Integer backupA3) {
+        this.backupA3 = backupA3;
+    }
+
+    public Integer getBackupA4() {
+        return backupA4 != null ? backupA4 : 0;
+    }
+
+    public void setBackupA4(Integer backupA4) {
+        this.backupA4 = backupA4;
+    }
+
+    public Integer getTotalPkg() {
+        return totalPkg != null ? totalPkg : 0;
+    }
+
+    public void setTotalPkg(Integer totalPkg) {
+        this.totalPkg = totalPkg;
+    }
+
+}

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

@@ -10,13 +10,10 @@ package cn.com.qmth.examcloud.core.print.service.impl;
 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.PrintingProjectStatisticService;
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectInfo;
-import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectQuery;
+import cn.com.qmth.examcloud.core.print.service.bean.ProjectStatisticInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-
 /**
  * @author: fengdesheng
  * @since: 2018/10/26
@@ -29,14 +26,13 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
     private CourseStatisticService courseStatisticService;
 
     @Override
-    public List<PrintingProjectInfo> getPrintingProjectStatisticList(PrintingProjectQuery query) {
-        //todo
+    public ProjectStatisticInfo getPrintingProjectStatistic(Long orgId, Long examId) {
         return null;
     }
 
     @Override
-    public void statistic() {
-        //todo
+    public void initPrintingProjectStatistics() {
+
     }
 
 }

+ 40 - 0
examcloud-core-print-starter/src/test/java/cn/com/qmth/examcloud/core/print/test/ProjectStatisticServiceTest.java

@@ -0,0 +1,40 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-10-30 11:06:53.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.test;
+
+import cn.com.qmth.examcloud.core.print.PrintApplication;
+import cn.com.qmth.examcloud.core.print.service.PrintingProjectStatisticService;
+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 ProjectStatisticServiceTest {
+    @Autowired
+    private PrintingProjectStatisticService printingProjectStatisticService;
+
+    @Test
+    public void getPrintingProjectStatisticTest() throws Exception {
+        Long orgId = 1L;
+        Long examId = 1L;
+        printingProjectStatisticService.getPrintingProjectStatistic(orgId, examId);
+    }
+
+    @Test
+    public void initPrintingProjectStatisticsTest() throws Exception {
+        printingProjectStatisticService.initPrintingProjectStatistics();
+    }
+
+}