|
@@ -1,151 +0,0 @@
|
|
|
-package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.ExamStatisticsCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamCompletionBean;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.request.GetExamCompletionStatisticsReq;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.response.GetExamCompletionStatisticsResp;
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamStudentEntity;
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamStudentRepo;
|
|
|
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * @Description 考试统计类
|
|
|
- * @Author lideyin
|
|
|
- * @Date 2019/9/27 11:32
|
|
|
- * @Version 1.0
|
|
|
- */
|
|
|
-@Api(tags = "考试统计类")
|
|
|
-@RestController
|
|
|
-@RequestMapping("${$rmp.cloud.oe}/examStatistics")
|
|
|
-public class ExamStatisticsCloudServiceProvider extends ControllerSupport implements ExamStatisticsCloudService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamStudentRepo examStudentRepo;
|
|
|
-
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "获取考试完成情况统计信息")
|
|
|
- @PostMapping("/getExamCompletionStatistics")
|
|
|
- public GetExamCompletionStatisticsResp getExamCompletionStatistics(@RequestBody GetExamCompletionStatisticsReq req) {
|
|
|
- if (req.getPageNo()==null){
|
|
|
- throw new StatusException("100001","当前页码不允许为空");
|
|
|
- }
|
|
|
- if (req.getPageSize()==null){
|
|
|
- throw new StatusException("100002","每页条数不允许为空");
|
|
|
- }
|
|
|
- if (req.getRootOrgId()==null){
|
|
|
- throw new StatusException("100003","学校id不允许为空");
|
|
|
- }
|
|
|
- GetExamCompletionStatisticsResp resp = new GetExamCompletionStatisticsResp();
|
|
|
- PageInfo<ExamCompletionBeanW> examCompletionInfo = null;//TODO 调王伟接口获取
|
|
|
- PageInfo<ExamCompletionBean> pagedList = getPageInfoFrom(examCompletionInfo);
|
|
|
- resp.setPagedExamCompletionList(pagedList);
|
|
|
- List<ExamCompletionBean> list = pagedList.getList();
|
|
|
- for (ExamCompletionBean b : list) {
|
|
|
-
|
|
|
- List<ExamStudentEntity> examStudentList = examStudentRepo.findByExamId(b.getExamId());
|
|
|
- long completeCount = 0;
|
|
|
- long planCount = 0;
|
|
|
- long percent = 0;
|
|
|
- if (examCompletionInfo != null && !examStudentList.isEmpty()) {
|
|
|
- completeCount = examStudentList.stream().filter(p -> p.getFinished()).count();
|
|
|
- planCount = examStudentList.size();
|
|
|
- percent = completeCount * 100 / planCount;
|
|
|
- }
|
|
|
-
|
|
|
- b.setPlanNum(planCount);
|
|
|
- b.setCompleteNum(completeCount);
|
|
|
- b.setCompletePercent(percent);
|
|
|
- }
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- private PageInfo<ExamCompletionBean> getPageInfoFrom(PageInfo<ExamCompletionBeanW> examCompletionInfo) {
|
|
|
- PageInfo<ExamCompletionBean> resultPageInfo = new PageInfo<>();
|
|
|
- resultPageInfo.setTotal(examCompletionInfo.getTotal());
|
|
|
- resultPageInfo.setIndex(examCompletionInfo.getIndex());
|
|
|
- resultPageInfo.setLimit(examCompletionInfo.getLimit());
|
|
|
- resultPageInfo.setPages(examCompletionInfo.getPages());
|
|
|
- resultPageInfo.setSize(examCompletionInfo.getSize());
|
|
|
- List<ExamCompletionBean> resultList = new ArrayList<>();
|
|
|
- List<ExamCompletionBeanW> list = examCompletionInfo.getList();
|
|
|
- if (list != null && !list.isEmpty()) {
|
|
|
- for (ExamCompletionBeanW ni : list) {
|
|
|
- ExamCompletionBean bean = new ExamCompletionBean();
|
|
|
- bean.setExamId(ni.getExamId());
|
|
|
- bean.setExamName(ni.getExamName());
|
|
|
- bean.setExamType(ni.getExamType());
|
|
|
- bean.setStartTime(ni.getStartTime());
|
|
|
- bean.setEndTime(ni.getEndTime());
|
|
|
- resultList.add(bean);
|
|
|
- }
|
|
|
- }
|
|
|
- resultPageInfo.setList(resultList);
|
|
|
- return resultPageInfo;
|
|
|
- }
|
|
|
-
|
|
|
- //TODO 临时用一下
|
|
|
- private class ExamCompletionBeanW {
|
|
|
- //考试id
|
|
|
- private Long examId;
|
|
|
- //考试名称
|
|
|
- private String examName;
|
|
|
- //考试类型
|
|
|
- private String examType;
|
|
|
- //考试开始时间
|
|
|
- private String startTime;
|
|
|
- //考试结束时间
|
|
|
- private String endTime;
|
|
|
-
|
|
|
- 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 String getExamType() {
|
|
|
- return examType;
|
|
|
- }
|
|
|
-
|
|
|
- public void setExamType(String examType) {
|
|
|
- this.examType = examType;
|
|
|
- }
|
|
|
-
|
|
|
- public String getStartTime() {
|
|
|
- return startTime;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStartTime(String startTime) {
|
|
|
- this.startTime = startTime;
|
|
|
- }
|
|
|
-
|
|
|
- public String getEndTime() {
|
|
|
- return endTime;
|
|
|
- }
|
|
|
-
|
|
|
- public void setEndTime(String endTime) {
|
|
|
- this.endTime = endTime;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|