deason 6 anni fa
parent
commit
36c97be9f6

+ 2 - 0
examcloud-core-print-dao/src/main/java/cn/com/qmth/examcloud/core/print/repository/ProjectStatisticRepository.java

@@ -15,4 +15,6 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface ProjectStatisticRepository extends JpaRepository<ProjectStatistic, Long>, JpaSpecificationExecutor<ProjectStatistic> {
 
+    ProjectStatistic getProjectStatisticByProjectId(Long projectId);
+
 }

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

@@ -34,7 +34,7 @@ public interface PrintingProjectService {
     /**
      * 获取某印刷项目的信息(By orgId & examId)
      */
-    PrintingProject getPrintingProjectByOrgExam(Long orgId, Long examId);
+    PrintingProject getPrintingProjectByOrgIdAndExamId(Long orgId, Long examId);
 
     /**
      * 更新印刷项目信息

+ 5 - 29
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/printingproject/ProjectStatisticInfo.java

@@ -25,18 +25,10 @@ public class ProjectStatisticInfo implements Serializable {
      * 考试ID
      */
     private Long examId;
-    /**
-     * 考试名称
-     */
-    private String examName;
     /**
      * 学校机构ID
      */
     private Long orgId;
-    /**
-     * 学校机构名称
-     */
-    private String orgName;
     /**
      * 供应商ID
      */
@@ -56,7 +48,7 @@ public class ProjectStatisticInfo implements Serializable {
     /**
      * 人科次
      */
-    private Integer totalExamStudent;
+    private Integer totalStudent;
     /**
      * 课程数量
      */
@@ -116,14 +108,6 @@ public class ProjectStatisticInfo implements Serializable {
         this.examId = examId;
     }
 
-    public String getExamName() {
-        return examName;
-    }
-
-    public void setExamName(String examName) {
-        this.examName = examName;
-    }
-
     public Long getOrgId() {
         return orgId;
     }
@@ -132,14 +116,6 @@ public class ProjectStatisticInfo implements Serializable {
         this.orgId = orgId;
     }
 
-    public String getOrgName() {
-        return orgName;
-    }
-
-    public void setOrgName(String orgName) {
-        this.orgName = orgName;
-    }
-
     public Long getSupplierId() {
         return supplierId;
     }
@@ -172,12 +148,12 @@ public class ProjectStatisticInfo implements Serializable {
         this.pmName = pmName;
     }
 
-    public Integer getTotalExamStudent() {
-        return totalExamStudent != null ? totalExamStudent : 0;
+    public Integer getTotalStudent() {
+        return totalStudent != null ? totalStudent : 0;
     }
 
-    public void setTotalExamStudent(Integer totalExamStudent) {
-        this.totalExamStudent = totalExamStudent;
+    public void setTotalStudent(Integer totalExamStudent) {
+        this.totalStudent = totalExamStudent;
     }
 
     public Integer getTotalCourse() {

+ 42 - 0
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/projectstatistic/PrintingStatisticConvert.java

@@ -0,0 +1,42 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-11-05 14:07:19.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.core.print.service.bean.projectstatistic;
+
+import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
+import cn.com.qmth.examcloud.core.print.entity.ProjectStatistic;
+import cn.com.qmth.examcloud.core.print.service.bean.printingproject.ProjectStatisticInfo;
+
+/**
+ * @author: fengdesheng
+ * @since: 2018/11/05
+ */
+public class PrintingStatisticConvert {
+
+    public static ProjectStatisticInfo of(PrintingProject project, ProjectStatistic statistic) {
+        ProjectStatisticInfo info = new ProjectStatisticInfo();
+        info.setProjectId(project.getId());
+        info.setOrgId(project.getOrgId());
+        info.setExamId(project.getExamId());
+        info.setPmId(project.getPmId());
+        info.setPmName(project.getPmName());
+        info.setSupplierId(project.getSupplierId());
+        info.setSupplierName(project.getSupplierName());
+        if (statistic != null) {
+            info.setTotalStudent(statistic.getTotalStudent());
+            info.setTotalCourse(statistic.getTotalCourse());
+            info.setTotalPaper(statistic.getTotalPaper());
+            info.setTotalPkg(statistic.getTotalPkg());
+            info.setNormalA3(statistic.getNormalA3());
+            info.setNormalA4(statistic.getNormalA4());
+            info.setBackupA3(statistic.getBackupA3());
+            info.setBackupA4(statistic.getBackupA4());
+        }
+        return info;
+    }
+
+}

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

@@ -89,7 +89,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
     }
 
     @Override
-    public PrintingProject getPrintingProjectByOrgExam(Long orgId, Long examId) {
+    public PrintingProject getPrintingProjectByOrgIdAndExamId(Long orgId, Long examId) {
         SearchBuilder searches = new SearchBuilder()
                 .eq("orgId", orgId)
                 .eq("examId", examId);

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

@@ -8,13 +8,15 @@
 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.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
+import cn.com.qmth.examcloud.core.print.entity.ProjectStatistic;
 import cn.com.qmth.examcloud.core.print.repository.ProjectStatisticRepository;
 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.printingproject.ProjectStatisticInfo;
-import org.springframework.beans.BeanUtils;
+import cn.com.qmth.examcloud.core.print.service.bean.projectstatistic.PrintingStatisticConvert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -35,15 +37,17 @@ public class PrintingProjectStatisticServiceImpl implements PrintingProjectStati
 
     @Override
     public ProjectStatisticInfo getPrintingProjectStatistic(Long orgId, Long examId) {
-        PrintingProject project = printingProjectService.getPrintingProjectByOrgExam(orgId, examId);
+        Check.isNull(orgId, "学校ID不能为空!");
+        Check.isNull(examId, "考试ID不能为空!");
+        PrintingProject project = printingProjectService.getPrintingProjectByOrgIdAndExamId(orgId, examId);
         if (project == null) {
-            throw new StatusException(PRT_CODE_500, "当前项目统计不存在!");
+            throw new StatusException(PRT_CODE_500, "当前项目不存在!");
         }
-        ProjectStatisticInfo info = new ProjectStatisticInfo();
-        BeanUtils.copyProperties(project, info);
-        info.setProjectId(project.getId());
-        //todo total
-        return info;
+        ProjectStatistic statistic = projectStatisticRepository.getProjectStatisticByProjectId(project.getId());
+        if (statistic == null) {
+            //throw new StatusException(PRT_CODE_500, "当前项目统计不存在!");
+        }
+        return PrintingStatisticConvert.of(project, statistic);
     }
 
     @Override