|
@@ -1,18 +1,26 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.qmth.themis.business.base.BasePage;
|
|
|
+import com.qmth.themis.business.bean.backend.ExamViewCountListBean;
|
|
|
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
import com.qmth.themis.business.dao.TEExamStudentMapper;
|
|
|
import com.qmth.themis.business.dao.TOeExamRecordMapper;
|
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
+import com.qmth.themis.business.service.TEExamService;
|
|
|
import com.qmth.themis.business.service.TIeReportService;
|
|
|
|
|
|
@Service
|
|
@@ -26,6 +34,9 @@ public class TIeReportServiceImpl implements TIeReportService {
|
|
|
|
|
|
@Resource
|
|
|
TEExamActivityService examActivityService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamService examService;
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> examView(Long examId, Long examActivityId, String roomCode, String courseCode,
|
|
@@ -86,5 +97,66 @@ public class TIeReportServiceImpl implements TIeReportService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BasePage examViewCount(Long examId, Long examActivityId, String roomCode, String courseCode, String name,
|
|
|
+ String identity, int pageNumber, int pageSize) {
|
|
|
+ //应考人数
|
|
|
+ IPage<ExamViewCountListBean> total = examStudentMapper.getTotalCountInfo(new Page<>(pageNumber, pageSize),examId, examActivityId, roomCode, courseCode);
|
|
|
+ List<ExamViewCountListBean> data=total.getRecords();
|
|
|
+ BasePage basePage = new BasePage(total.getRecords(), total.getCurrent(), total.getSize(), total.getTotal());
|
|
|
+ if(data==null||data.size()==0) {
|
|
|
+ return basePage;
|
|
|
+ }
|
|
|
+ List<Long> activityIds=data.stream().map(e -> e.getExamActivityId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //实考
|
|
|
+ List<Map<String,Object>> doneCountByDay=examStudentMapper.getDoneCountByActivityIds(examId, activityIds);
|
|
|
+ Map<String,Long> doneMap=new HashMap<String,Long>();
|
|
|
+ for(Map<String,Object> map:doneCountByDay) {
|
|
|
+ Long acId=(Long)map.get("activityId");
|
|
|
+ String roomcode=(String)map.get("roomCode");
|
|
|
+ Long count=(Long)map.get("cc");
|
|
|
+ doneMap.put(acId+"-"+roomcode, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ //缺考
|
|
|
+ List<Long> absentActivityIds=new ArrayList<>();
|
|
|
+ Date now = new Date();
|
|
|
+ for(Long acid:activityIds) {
|
|
|
+ ExamActivityCacheBean ac=examActivityService.getExamActivityCacheBean(acid);
|
|
|
+ Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
+ if (now.getTime() > end) {//场次开考时间结束,未开考的都是缺考
|
|
|
+ absentActivityIds.add(acid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Long> absentMap=new HashMap<String,Long>();
|
|
|
+ if(absentActivityIds.size()>0) {
|
|
|
+ List<Map<String,Object>> absentCountByDay=examStudentMapper.getAbsentCountByActivityIds(examId, absentActivityIds);
|
|
|
+ for(Map<String,Object> map:absentCountByDay) {
|
|
|
+ Long acId=(Long)map.get("activityId");
|
|
|
+ String roomcode=(String)map.get("roomCode");
|
|
|
+ Long count=(Long)map.get("cc");
|
|
|
+ absentMap.put(acId+"-"+roomcode, count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExamCacheBean exam=examService.getExamCacheBean(examId);
|
|
|
+ for(ExamViewCountListBean b:data) {
|
|
|
+ Long done=doneMap.get(b.getExamActivityId()+"-"+b.getRoomCode());
|
|
|
+ if(done==null) {
|
|
|
+ done=0L;
|
|
|
+ }
|
|
|
+ Long absent=absentMap.get(b.getExamActivityId()+"-"+b.getRoomCode());
|
|
|
+ if(absent==null) {
|
|
|
+ absent=0L;
|
|
|
+ }
|
|
|
+ b.setActualExamTotal(done);
|
|
|
+ b.setDeficiencyExamTotal(absent);
|
|
|
+ b.setExamName(exam.getName());
|
|
|
+ }
|
|
|
+ basePage = new BasePage(total.getRecords(), total.getCurrent(), total.getSize(), total.getTotal());
|
|
|
+ return basePage;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|