Browse Source

update api

deason 1 year ago
parent
commit
622292b097

+ 31 - 14
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamStatisticController.java

@@ -55,22 +55,30 @@ public class ExamStatisticController extends ControllerSupport {
     @GetMapping("/overview/for/course/export")
     @ApiOperation(value = "统计概况(课程)导出Excel")
     public void overviewForCourseExport(@RequestParam Long examId, @RequestParam(required = false) Long courseId) throws Exception {
-        List<ExamStatisticInfo> list = examStatisticService.overviewForCourse(examId, courseId);
+        ExamStatisticInfo examOverview = examStatisticService.overviewForExam(examId);
+
+        List<ExamStatisticInfo> list = new ArrayList<>();
+        if (examOverview.getExamId() != null) {
+            list.add(examOverview);
+            list.addAll(examStatisticService.overviewForCourse(examId, courseId));
+        }
 
         List<Object[]> lines = new ArrayList<>();
         for (ExamStatisticInfo info : list) {
-            lines.add(new Object[]{info.getCourseName(), info.getCourseCode(), info.getAllCount(), info.getFinishCount()
-                    , info.getUnFinishCount(), info.getUnFinishRate(), info.getPassScoreCount()
-                    , info.getPassScoreRate(), info.getGoodScoreCount(), info.getGoodScoreRate(),
+            lines.add(new Object[]{info.getExamId(), info.getExamName(), info.getCourseName(), info.getCourseCode(),
+                    info.getAllCount(), info.getFinishCount(), info.getUnFinishCount(), info.getUnFinishRate(),
+                    info.getPassScoreCount(), info.getPassScoreRate(), info.getGoodScoreCount(), info.getGoodScoreRate(),
                     info.getIllegalityCount(), info.getIllegalityRate()});
         }
 
         String filePath = systemConfig.getTempDataDir() + File.separator + System.currentTimeMillis() + ".xlsx";
         File file = new File(filePath);
 
-        ExcelWriter.write(new String[]{"课程名称", "课程代码", "应考人数", "实考人数", "缺考人数", "缺考率", "及格人数", "及格率", "优秀人数", "优秀率", "违纪人数", "违纪率"},
-                new Class[]{String.class, String.class, Integer.class, Integer.class, Integer.class, Double.class,
-                        Integer.class, Double.class, Integer.class, Double.class, Integer.class, Double.class},
+        ExcelWriter.write(new String[]{"考试ID", "考试名称", "课程名称", "课程代码", "应考人数", "实考人数", "缺考人数", "缺考率",
+                        "及格人数", "及格率", "优秀人数", "优秀率", "违纪人数", "违纪率"},
+                new Class[]{Long.class, String.class, String.class, String.class, Integer.class, Integer.class,
+                        Integer.class, Double.class, Integer.class, Double.class, Integer.class, Double.class,
+                        Integer.class, Double.class},
                 lines, new File(filePath));
 
         exportFile("课程统计.xlsx", file);
@@ -81,21 +89,30 @@ public class ExamStatisticController extends ControllerSupport {
     @GetMapping("/overview/for/org/export")
     @ApiOperation(value = "统计概况(学习中心)导出Excel")
     public void overviewForOrgExport(@RequestParam Long examId, @RequestParam(required = false) Long orgId) throws Exception {
-        List<ExamStatisticInfo> list = examStatisticService.overviewForOrg(examId, orgId);
+        ExamStatisticInfo examOverview = examStatisticService.overviewForExam(examId);
+
+        List<ExamStatisticInfo> list = new ArrayList<>();
+        if (examOverview.getExamId() != null) {
+            list.add(examOverview);
+            list.addAll(examStatisticService.overviewForOrg(examId, orgId));
+        }
 
         List<Object[]> lines = new ArrayList<>();
         for (ExamStatisticInfo info : list) {
-            lines.add(new Object[]{info.getOrgName(), info.getAllCount(), info.getFinishCount()
-                    , info.getUnFinishCount(), info.getUnFinishRate(), info.getPassScoreCount()
-                    , info.getPassScoreRate(), info.getGoodScoreCount(), info.getGoodScoreRate()});
+            lines.add(new Object[]{info.getExamId(), info.getExamName(), info.getOrgName(),
+                    info.getAllCount(), info.getFinishCount(), info.getUnFinishCount(), info.getUnFinishRate(),
+                    info.getPassScoreCount(), info.getPassScoreRate(), info.getGoodScoreCount(), info.getGoodScoreRate(),
+                    info.getIllegalityCount(), info.getIllegalityRate()});
         }
 
         String filePath = systemConfig.getTempDataDir() + File.separator + System.currentTimeMillis() + ".xlsx";
         File file = new File(filePath);
 
-        ExcelWriter.write(new String[]{"学习中心", "应考人数", "实考人数", "缺考人数", "缺考率", "及格人数", "及格率", "优秀人数", "优秀率", "违纪人数", "违纪率"},
-                new Class[]{String.class, Integer.class, Integer.class, Integer.class, Double.class,
-                        Integer.class, Double.class, Integer.class, Double.class, Integer.class, Double.class},
+        ExcelWriter.write(new String[]{"考试ID", "考试名称", "学习中心", "应考人数", "实考人数", "缺考人数", "缺考率",
+                        "及格人数", "及格率", "优秀人数", "优秀率", "违纪人数", "违纪率"},
+                new Class[]{Long.class, String.class, String.class, Integer.class, Integer.class, Integer.class,
+                        Double.class, Integer.class, Double.class, Integer.class, Double.class,
+                        Integer.class, Double.class},
                 lines, new File(filePath));
 
         exportFile("学习中心统计.xlsx", file);

+ 10 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/statistic/ExamStatisticInfo.java

@@ -8,6 +8,8 @@ public class ExamStatisticInfo implements JsonSerializable {
 
     private Long examId;
 
+    private String examName;
+
     private Long courseId;
 
     private String courseCode;
@@ -89,6 +91,14 @@ public class ExamStatisticInfo implements JsonSerializable {
         this.examId = examId;
     }
 
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
     public Long getCourseId() {
         return courseId;
     }