|
@@ -1,13 +1,25 @@
|
|
|
package cn.com.qmth.examcloud.core.reports.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
|
+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.reports.base.bean.ExamStudentCountBean;
|
|
|
import cn.com.qmth.examcloud.core.reports.base.util.online.ActiveDataUtil;
|
|
|
import cn.com.qmth.examcloud.core.reports.base.util.online.OnlineCount;
|
|
|
import cn.com.qmth.examcloud.core.reports.dao.ExamStudentCountRepo;
|
|
@@ -20,7 +32,8 @@ public class ExamStudentCountServiceImpl implements ExamStudentCountService {
|
|
|
private ExamStudentCountRepo examStudentCountRepo;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ExamStatisticsCloudService examStatisticsCloudService;
|
|
|
|
|
|
@Override
|
|
|
public Long getOnlineCount(Long rootOrgId, Long orgId, Long examId) {
|
|
@@ -64,4 +77,55 @@ public class ExamStudentCountServiceImpl implements ExamStudentCountService {
|
|
|
e.setOnlineCount(oc.getOnlineCount());
|
|
|
examStudentCountRepo.save(e);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<ExamStudentCountBean> queryPage(Long rootOrgId, Integer pageNo, Integer pageSize) {
|
|
|
+ GetExamCompletionStatisticsReq req=new GetExamCompletionStatisticsReq();
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
+ req.setPageNo(pageNo);
|
|
|
+ req.setPageSize(pageSize);
|
|
|
+ GetExamCompletionStatisticsResp rep=examStatisticsCloudService.getExamCompletionStatistics(req);
|
|
|
+ PageInfo<ExamCompletionBean> pi=rep.getPagedExamCompletionList();
|
|
|
+ PageInfo<ExamStudentCountBean> ret=new PageInfo<ExamStudentCountBean>();
|
|
|
+ ret.setIndex(pi.getIndex());
|
|
|
+ ret.setLimit(pi.getLimit());
|
|
|
+ ret.setPages(pi.getPages());
|
|
|
+ ret.setSize(pi.getSize());
|
|
|
+ ret.setTotal(pi.getTotal());
|
|
|
+ if(pi.getList()==null||pi.getList().size()==0) {
|
|
|
+ ret.setList(Lists.newArrayList());
|
|
|
+ }else {
|
|
|
+ List<ExamStudentCountBean> li=new ArrayList<ExamStudentCountBean>();
|
|
|
+ for(ExamCompletionBean cb:pi.getList()) {
|
|
|
+ ExamStudentCountBean sc=new ExamStudentCountBean();
|
|
|
+ sc.setCompleteCount(cb.getCompleteNum());
|
|
|
+ sc.setCompleteRatio(cb.getCompletePercent());
|
|
|
+ sc.setExamEndDate(cb.getEndTime());
|
|
|
+ sc.setExamName(cb.getExamName());
|
|
|
+ sc.setExamStartDate(cb.getStartTime());
|
|
|
+ sc.setExamType(cb.getExamType());
|
|
|
+ sc.setTotalCount(cb.getPlanNum());
|
|
|
+ li.add(sc);
|
|
|
+ }
|
|
|
+ fillOnExamCount(li,rootOrgId);
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ private void fillOnExamCount(List<ExamStudentCountBean> ret,Long rootOrgId) {
|
|
|
+ if (CollectionUtils.isEmpty(ret)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> temList = ret.stream().map(str -> str.getExamId()).collect(Collectors.toList());
|
|
|
+ List<ExamStudentCountEntity> sl = examStudentCountRepo.getByExamIdsRootOrgId(temList, rootOrgId);
|
|
|
+ if (CollectionUtils.isEmpty(sl)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, Integer> map = sl.stream().collect(Collectors.toMap(ExamStudentCountEntity::getExamId,
|
|
|
+ account -> account.getOnlineCount(), (key1, key2) -> key2));
|
|
|
+ for(ExamStudentCountBean b:ret) {
|
|
|
+ if(map.get(b.getExamId())!=null) {
|
|
|
+ b.setOnlineCount(map.get(b.getExamId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|