|
@@ -1,16 +1,20 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.controller;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.base.utils.excel.ExportUtils;
|
|
|
+import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamStatisticService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.ExamStatisticInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.OverviewInfo;
|
|
|
+import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.web.support.Naked;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
@@ -21,6 +25,9 @@ public class ExamStatisticController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
private ExamStatisticService examStatisticService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SystemProperties systemConfig;
|
|
|
+
|
|
|
@PostMapping("/overview")
|
|
|
@ApiOperation(value = "统计概况")
|
|
|
public OverviewInfo overview(@RequestParam Long examId, @RequestParam Long courseId) {
|
|
@@ -33,12 +40,29 @@ public class ExamStatisticController extends ControllerSupport {
|
|
|
return examStatisticService.overviewForOrg(examId, courseId);
|
|
|
}
|
|
|
|
|
|
+ @Naked
|
|
|
@GetMapping("/overview/for/org/export")
|
|
|
@ApiOperation(value = "统计概况(学习中心)导出Excel")
|
|
|
- public void overviewForOrgExport(@RequestParam Long examId, @RequestParam Long courseId
|
|
|
- , HttpServletResponse response) throws Exception {
|
|
|
+ public void overviewForOrgExport(@RequestParam Long examId, @RequestParam Long courseId) throws Exception {
|
|
|
List<ExamStatisticInfo> list = examStatisticService.overviewForOrg(examId, courseId);
|
|
|
- ExportUtils.exportEXCEL("学习中心统计", ExamStatisticInfo.class, list, response);
|
|
|
+
|
|
|
+ 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()});
|
|
|
+ }
|
|
|
+
|
|
|
+ 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},
|
|
|
+ lines, new File(filePath));
|
|
|
+
|
|
|
+ exportFile("学习中心统计.xlsx", file);
|
|
|
+ FileUtils.deleteQuietly(file);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|