|
@@ -1,6 +1,7 @@
|
|
package cn.com.qmth.examcloud.core.reports.service.impl;
|
|
package cn.com.qmth.examcloud.core.reports.service.impl;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -26,7 +27,9 @@ import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsByIdListReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsByIdListResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsByIdListResp;
|
|
import cn.com.qmth.examcloud.core.reports.base.bean.StudentCountBean;
|
|
import cn.com.qmth.examcloud.core.reports.base.bean.StudentCountBean;
|
|
import cn.com.qmth.examcloud.core.reports.base.util.BatchGetDataUtil;
|
|
import cn.com.qmth.examcloud.core.reports.base.util.BatchGetDataUtil;
|
|
|
|
+import cn.com.qmth.examcloud.core.reports.dao.ExamStudentCountRepo;
|
|
import cn.com.qmth.examcloud.core.reports.dao.StudentTotalCountRepo;
|
|
import cn.com.qmth.examcloud.core.reports.dao.StudentTotalCountRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.reports.dao.entity.ExamStudentCountEntity;
|
|
import cn.com.qmth.examcloud.core.reports.dao.entity.StudentTotalCountEntity;
|
|
import cn.com.qmth.examcloud.core.reports.dao.entity.StudentTotalCountEntity;
|
|
import cn.com.qmth.examcloud.core.reports.service.StudentCountService;
|
|
import cn.com.qmth.examcloud.core.reports.service.StudentCountService;
|
|
import cn.com.qmth.examcloud.core.reports.service.StudentTotalCountService;
|
|
import cn.com.qmth.examcloud.core.reports.service.StudentTotalCountService;
|
|
@@ -36,6 +39,8 @@ public class StudentTotalCountServiceImpl implements StudentTotalCountService {
|
|
@Autowired
|
|
@Autowired
|
|
private StudentTotalCountRepo studentTotalCountRepo;
|
|
private StudentTotalCountRepo studentTotalCountRepo;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private ExamStudentCountRepo examStudentCountRepo;
|
|
|
|
+ @Autowired
|
|
private StudentCountService studentCountService;
|
|
private StudentCountService studentCountService;
|
|
@Autowired
|
|
@Autowired
|
|
private OrgCloudService orgCloudService;
|
|
private OrgCloudService orgCloudService;
|
|
@@ -72,9 +77,12 @@ public class StudentTotalCountServiceImpl implements StudentTotalCountService {
|
|
StudentCountBean bean = new StudentCountBean();
|
|
StudentCountBean bean = new StudentCountBean();
|
|
bean.setTotalCount(cur.getTotalCount());
|
|
bean.setTotalCount(cur.getTotalCount());
|
|
bean.setRootOrgId(cur.getRootOrgId());
|
|
bean.setRootOrgId(cur.getRootOrgId());
|
|
|
|
+ bean.setOnlineCount(0);
|
|
|
|
+ bean.setOnExamCount(0);
|
|
ret.add(bean);
|
|
ret.add(bean);
|
|
}
|
|
}
|
|
fillOnlineCount(ret);
|
|
fillOnlineCount(ret);
|
|
|
|
+ fillOnExamCount(ret);
|
|
fillRootOrgName(ret);
|
|
fillRootOrgName(ret);
|
|
return new PageInfo<StudentCountBean>(es, ret);
|
|
return new PageInfo<StudentCountBean>(es, ret);
|
|
}
|
|
}
|
|
@@ -91,10 +99,39 @@ public class StudentTotalCountServiceImpl implements StudentTotalCountService {
|
|
Map<Long, Integer> map = sl.stream().collect(Collectors.toMap(StudentCountBean::getRootOrgId,
|
|
Map<Long, Integer> map = sl.stream().collect(Collectors.toMap(StudentCountBean::getRootOrgId,
|
|
account -> account.getOnlineCount(), (key1, key2) -> key2));
|
|
account -> account.getOnlineCount(), (key1, key2) -> key2));
|
|
for(StudentCountBean b:ret) {
|
|
for(StudentCountBean b:ret) {
|
|
- b.setOnlineCount(map.get(b.getRootOrgId()));
|
|
|
|
|
|
+ if(map.get(b.getRootOrgId())!=null) {
|
|
|
|
+ b.setOnlineCount(map.get(b.getRootOrgId()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ private void fillOnExamCount(List<StudentCountBean> ret) {
|
|
|
|
+ if (CollectionUtils.isEmpty(ret)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<Long> temList = ret.stream().map(str -> str.getRootOrgId()).collect(Collectors.toList());
|
|
|
|
+ List<ExamStudentCountEntity> sl = examStudentCountRepo.getByRootOrgIds(temList);
|
|
|
|
+ if (CollectionUtils.isEmpty(sl)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<Long, Integer> map = groupByRootOrg(sl);
|
|
|
|
+ for(StudentCountBean b:ret) {
|
|
|
|
+ if(map.get(b.getRootOrgId())!=null) {
|
|
|
|
+ b.setOnExamCount(map.get(b.getRootOrgId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private Map<Long, Integer> groupByRootOrg(List<ExamStudentCountEntity> sl){
|
|
|
|
+ Map<Long, Integer> map=new HashMap<Long, Integer>();
|
|
|
|
+ for(ExamStudentCountEntity s:sl) {
|
|
|
|
+ Integer c=map.get(s.getRootOrgId());
|
|
|
|
+ if(c==null) {
|
|
|
|
+ map.put(s.getRootOrgId(), s.getOnlineCount());
|
|
|
|
+ }else {
|
|
|
|
+ map.put(s.getRootOrgId(), s.getOnlineCount()+c);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
private void fillRootOrgName(List<StudentCountBean> ret) {
|
|
private void fillRootOrgName(List<StudentCountBean> ret) {
|
|
if (CollectionUtils.isEmpty(ret)) {
|
|
if (CollectionUtils.isEmpty(ret)) {
|
|
return;
|
|
return;
|