|
@@ -1,30 +1,53 @@
|
|
|
package cn.com.qmth.examcloud.core.reports.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import cn.com.qmth.examcloud.core.reports.api.bean.ExamOrgReportBean;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.ExamOrgMainTopTen;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.ExamOrgReportMainBean;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.ExamReportMainBean;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.PartitionDataBean;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.PartitionTopTen;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.util.excel.ExportUtils;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.util.excel.SheetData;
|
|
|
import cn.com.qmth.examcloud.core.reports.dao.ExamOrgReportRepo;
|
|
|
import cn.com.qmth.examcloud.core.reports.dao.entity.ExamOrgReportEntity;
|
|
|
+import cn.com.qmth.examcloud.core.reports.dao.entity.ProjectEntity;
|
|
|
import cn.com.qmth.examcloud.core.reports.service.ExamOrgReportService;
|
|
|
|
|
|
@Service
|
|
|
public class ExamOrgReportServiceImpl implements ExamOrgReportService {
|
|
|
+ private final static int asc=0;
|
|
|
+ private final static int desc=2;
|
|
|
@Autowired
|
|
|
private ExamOrgReportRepo examOrgReportRepo;
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void saveExamOrgReportList(List<ExamOrgReportBean> beans) {
|
|
|
- List<ExamOrgReportEntity> list=new ArrayList<ExamOrgReportEntity>();
|
|
|
- for(ExamOrgReportBean bean:beans) {
|
|
|
- ExamOrgReportEntity e=new ExamOrgReportEntity();
|
|
|
+ List<ExamOrgReportEntity> list = new ArrayList<ExamOrgReportEntity>();
|
|
|
+ for (ExamOrgReportBean bean : beans) {
|
|
|
+ ExamOrgReportEntity e = new ExamOrgReportEntity();
|
|
|
BeanUtils.copyProperties(bean, e);
|
|
|
e.setPartitionData(StringUtils.join(bean.getPartitionData().toArray(), ","));
|
|
|
list.add(e);
|
|
@@ -36,4 +59,597 @@ public class ExamOrgReportServiceImpl implements ExamOrgReportService {
|
|
|
public void deleteByProject(Long projectId, Long rootOrgId) {
|
|
|
examOrgReportRepo.deleteByProject(projectId, rootOrgId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamOrgReportMainBean> getExamOrgMainList(Long projectId, Long examId) {
|
|
|
+ Specification<ExamOrgReportEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("projectId"), projectId));
|
|
|
+ if (examId != null) {
|
|
|
+ predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
+ }
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Sort sort = new Sort(Direction.ASC, "id");
|
|
|
+ List<ExamOrgReportEntity> orgEntityList = examOrgReportRepo.findAll(specification, sort);
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>();
|
|
|
+ for (ExamOrgReportEntity e : orgEntityList) {
|
|
|
+ ret.add(of(e));
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ExamOrgReportMainBean of(ExamOrgReportEntity e) {
|
|
|
+ ExamOrgReportMainBean b = new ExamOrgReportMainBean();
|
|
|
+ BeanUtils.copyProperties(e, b);
|
|
|
+ b.setParticipantRatio(getPercentage(b.getParticipantCount(), b.getSignCount()));
|
|
|
+ b.setMissCount(e.getSignCount() - e.getParticipantCount());
|
|
|
+ b.setMissRatio(getPercentage(b.getMissCount(), b.getSignCount()));
|
|
|
+ b.setPassSignRatio(getPercentage(b.getPassCount(), b.getSignCount()));
|
|
|
+ b.setPassParticipantRatio(getPercentage(b.getPassCount(), b.getParticipantCount()));
|
|
|
+ List<Long> li = Arrays.asList(e.getPartitionData().split(",")).stream().map(str -> Long.parseLong(str))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<PartitionDataBean> partitionData = new ArrayList<PartitionDataBean>();
|
|
|
+ for (Long l : li) {
|
|
|
+ PartitionDataBean pb = new PartitionDataBean();
|
|
|
+ pb.setCount(l);
|
|
|
+ pb.setParticipantRatio(getPercentage(l, b.getParticipantCount()));
|
|
|
+ pb.setSignRatio(getPercentage(l, b.getSignCount()));
|
|
|
+ partitionData.add(pb);
|
|
|
+ }
|
|
|
+ b.setPartitionData(partitionData);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Double getPercentage(Long a, Long b) {
|
|
|
+ if (b == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Double da = Double.valueOf(a);
|
|
|
+ Double db = Double.valueOf(b);
|
|
|
+ BigDecimal bd = new BigDecimal(da * 100 / db);
|
|
|
+ Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ return tem;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamReportMainBean> getExamMainList(Long projectId, Long examId) {
|
|
|
+ Specification<ExamOrgReportEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("projectId"), projectId));
|
|
|
+ if (examId != null) {
|
|
|
+ predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
+ }
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Sort sort = new Sort(Direction.ASC, "id");
|
|
|
+ List<ExamOrgReportEntity> orgEntityList = examOrgReportRepo.findAll(specification, sort);
|
|
|
+ Map<Long, ExamReportMainBean> map = new LinkedHashMap<Long, ExamReportMainBean>();
|
|
|
+ for (ExamOrgReportEntity e : orgEntityList) {
|
|
|
+ ExamReportMainBean b = map.get(e.getExamId());
|
|
|
+ List<Long> li = Arrays.asList(e.getPartitionData().split(",")).stream().map(str -> Long.parseLong(str))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (b == null) {
|
|
|
+ b = new ExamReportMainBean();
|
|
|
+ b.setExamCode(e.getExamCode());
|
|
|
+ b.setExamId(e.getExamId());
|
|
|
+ b.setExamName(e.getExamName());
|
|
|
+ b.setRootOrgId(e.getRootOrgId());
|
|
|
+ b.setProjectId(e.getProjectId());
|
|
|
+ b.init(li.size());
|
|
|
+ map.put(e.getExamId(), b);
|
|
|
+ }
|
|
|
+ b.setSignCount(b.getSignCount() + e.getSignCount());
|
|
|
+ b.setParticipantCount(b.getParticipantCount() + e.getParticipantCount());
|
|
|
+ b.setPassCount(b.getPassCount() + e.getPassCount());
|
|
|
+ List<PartitionDataBean> partitionData = b.getPartitionData();
|
|
|
+ for (int i = 0; i < partitionData.size(); i++) {
|
|
|
+ PartitionDataBean pb = partitionData.get(i);
|
|
|
+ pb.setCount(pb.getCount() + li.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ExamReportMainBean> ret = new ArrayList<ExamReportMainBean>(map.values());
|
|
|
+ computExamReportRatio(ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void computExamReportRatio(List<ExamReportMainBean> ret) {
|
|
|
+ for (ExamReportMainBean b : ret) {
|
|
|
+ b.setParticipantRatio(getPercentage(b.getParticipantCount(), b.getSignCount()));
|
|
|
+ b.setMissCount(b.getSignCount() - b.getParticipantCount());
|
|
|
+ b.setMissRatio(getPercentage(b.getMissCount(), b.getSignCount()));
|
|
|
+ b.setPassSignRatio(getPercentage(b.getPassCount(), b.getSignCount()));
|
|
|
+ b.setPassParticipantRatio(getPercentage(b.getPassCount(), b.getParticipantCount()));
|
|
|
+ List<PartitionDataBean> partitionData = b.getPartitionData();
|
|
|
+ for (PartitionDataBean pb : partitionData) {
|
|
|
+ pb.setParticipantRatio(getPercentage(pb.getCount(), b.getParticipantCount()));
|
|
|
+ pb.setSignRatio(getPercentage(pb.getCount(), b.getSignCount()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExamOrgMainTopTen getExamOrgMainTop10(Long projectId, Long examId) {
|
|
|
+ ExamOrgMainTopTen ret = new ExamOrgMainTopTen();
|
|
|
+ List<ExamOrgReportMainBean> list = getExamOrgMainList(projectId, examId);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ ret.setParticipant(getParticipantSort(list,asc));
|
|
|
+ ret.setParticipantDesc(getParticipantSort(list,desc));
|
|
|
+ ret.setParticipantRatio(getParticipantRatioSort(list, asc));
|
|
|
+ ret.setParticipantRatioDesc(getParticipantRatioSort(list, desc));
|
|
|
+ ret.setMiss(getMissSort(list,asc));
|
|
|
+ ret.setMissDesc(getMissSort(list,desc));
|
|
|
+ ret.setMissRatio(getMissRatioSort(list, asc));
|
|
|
+ ret.setMissRatioDesc(getMissRatioSort(list, desc));
|
|
|
+ ret.setPass(getPassSort(list,asc));
|
|
|
+ ret.setPassDesc(getPassSort(list,desc));
|
|
|
+ ret.setPassSignRatio(getPassSignRatioSort(list, asc));
|
|
|
+ ret.setPassSignRatioDesc(getPassSignRatioSort(list, desc));
|
|
|
+ ret.setPassParticipantRatio(getPassParticipantRatioSort(list, asc));
|
|
|
+ ret.setPassParticipantRatioDesc(getPassParticipantRatioSort(list, desc));
|
|
|
+ ret.setPartition(getPartitionSort(list));
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getParticipantSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getParticipantCount() > o2.getParticipantCount()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getParticipantCount() < o2.getParticipantCount()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getParticipantRatioSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getParticipantRatio() > o2.getParticipantRatio()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getParticipantRatio() < o2.getParticipantRatio()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getMissSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getMissCount() > o2.getMissCount()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getMissCount() < o2.getMissCount()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamOrgReportMainBean> getMissRatioSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getMissRatio() > o2.getMissRatio()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getMissRatio() < o2.getMissRatio()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getPassSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getPassCount() > o2.getPassCount()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getPassCount() < o2.getPassCount()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamOrgReportMainBean> getPassSignRatioSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getPassSignRatio() > o2.getPassSignRatio()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getPassSignRatio() < o2.getPassSignRatio()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamOrgReportMainBean> getPassParticipantRatioSort(List<ExamOrgReportMainBean> list,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ if (o1.getPassParticipantRatio() > o2.getPassParticipantRatio()) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (o1.getPassParticipantRatio() < o2.getPassParticipantRatio()) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<PartitionTopTen> getPartitionSort(List<ExamOrgReportMainBean> list) {
|
|
|
+ List<PartitionTopTen> ret = new ArrayList<PartitionTopTen>();
|
|
|
+ int size = list.get(0).getPartitionData().size();
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ PartitionTopTen pt = new PartitionTopTen();
|
|
|
+ pt.setCountAsc(getPartitionCountSort(list, i,asc));
|
|
|
+ pt.setCountDesc(getPartitionCountSort(list, i,desc));
|
|
|
+ pt.setSignRatioAsc(getPartitionSignRatioSort(list, i, asc));
|
|
|
+ pt.setSignRatioDesc(getPartitionSignRatioSort(list, i, desc));
|
|
|
+ pt.setParticipantRatioAsc(getPartitionParticipantRatioSort(list, i, asc));
|
|
|
+ pt.setParticipantRatioDesc(getPartitionParticipantRatioSort(list, i, desc));
|
|
|
+ ret.add(pt);
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getPartitionCountSort(List<ExamOrgReportMainBean> list, int index,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ Long c1 = o1.getPartitionData().get(index).getCount();
|
|
|
+ Long c2 = o2.getPartitionData().get(index).getCount();
|
|
|
+ if (c1 > c2) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (c1 < c2) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamOrgReportMainBean> getPartitionSignRatioSort(List<ExamOrgReportMainBean> list, int index,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ Double c1 = o1.getPartitionData().get(index).getSignRatio();
|
|
|
+ Double c2 = o2.getPartitionData().get(index).getSignRatio();
|
|
|
+ if (c1 > c2) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (c1 < c2) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamOrgReportMainBean> getPartitionParticipantRatioSort(List<ExamOrgReportMainBean> list, int index,int ascOrDesc) {
|
|
|
+ List<ExamOrgReportMainBean> ret = new ArrayList<ExamOrgReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamOrgReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamOrgReportMainBean o1, ExamOrgReportMainBean o2) {
|
|
|
+ Double c1 = o1.getPartitionData().get(index).getParticipantRatio();
|
|
|
+ Double c2 = o2.getPartitionData().get(index).getParticipantRatio();
|
|
|
+ if (c1 > c2) {
|
|
|
+ return 1-ascOrDesc;
|
|
|
+ } else if (c1 < c2) {
|
|
|
+ return -1+ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void exportAll(ProjectEntity pe, Long examId, String items, HttpServletResponse response) {
|
|
|
+ Long projectId = pe.getId();
|
|
|
+ List<SheetData> sheets = new ArrayList<SheetData>();
|
|
|
+ List<String> examheader = new ArrayList<String>();
|
|
|
+ examheader.addAll(
|
|
|
+ Arrays.asList(new String[] { "考试名称", "报名人数", "实考人数","实考比例(%)", "缺考人数", "缺考率(%)", "及格人数", "及格报名人数占比(%)", "及格实考人数占比(%)" }));
|
|
|
+ int partitionCount = pe.getPartitionCount();
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ examheader.add("分段" + i + "人数");
|
|
|
+ examheader.add("分段" + i + "报名人数占比(%)");
|
|
|
+ examheader.add("分段" + i + "实考人数占比(%)");
|
|
|
+ }
|
|
|
+ List<String> header = new ArrayList<String>();
|
|
|
+ header.addAll(
|
|
|
+ Arrays.asList(new String[] { "考试名称","中心名称", "报名人数", "实考人数","实考比例(%)", "缺考人数", "缺考率(%)", "及格人数", "及格报名人数占比(%)", "及格实考人数占比(%)" }));
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ header.add("分段" + i + "人数");
|
|
|
+ header.add("分段" + i + "报名人数占比(%)");
|
|
|
+ header.add("分段" + i + "实考人数占比(%)");
|
|
|
+ }
|
|
|
+ List<ExamReportMainBean> list1 = getExamMainList(projectId, examId);
|
|
|
+ fillExamMainSheetdata(sheets,list1, examheader, partitionCount);
|
|
|
+ List<ExamOrgReportMainBean> list2 = getExamOrgMainList(projectId, examId);
|
|
|
+ fillExamOrgMainSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ if (StringUtils.isNotBlank(items)) {
|
|
|
+ String[] itemstr = items.split(",");
|
|
|
+ for (String it : itemstr) {
|
|
|
+ if ("1".equals(it)) {
|
|
|
+ fillParticipantSheetdata(sheets, list2, header,partitionCount);
|
|
|
+ } else if ("2".equals(it)) {
|
|
|
+ fillMissSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ } else if ("3".equals(it)) {
|
|
|
+ fillPassSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ } else if ("4".equals(it)) {
|
|
|
+ fillPassRatioSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ } else if ("5".equals(it)) {
|
|
|
+ fillPartitionSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ } else if ("6".equals(it)) {
|
|
|
+ fillPartitionRatioSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExportUtils.exportExcel("考试学习中心分析结果", sheets, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillExamMainSheetdata(List<SheetData> sheets,List<ExamReportMainBean> list,List<String> header, int partitionCount) {
|
|
|
+ SheetData sheet = new SheetData();
|
|
|
+ sheet.setHeader(header);
|
|
|
+ sheet.setName("考试总体数值分析");
|
|
|
+ List<Object[]> data = new ArrayList<Object[]>();
|
|
|
+ for (ExamReportMainBean b : list) {
|
|
|
+ Object[] ob = new Object[header.size()];
|
|
|
+ ob[0] = b.getExamName();
|
|
|
+ ob[1] = b.getSignCount();
|
|
|
+ ob[2] = b.getParticipantCount();
|
|
|
+ ob[3] = b.getParticipantRatio();
|
|
|
+ ob[4] = b.getMissCount();
|
|
|
+ ob[5] = b.getMissRatio();
|
|
|
+ ob[6] = b.getPassCount();
|
|
|
+ ob[7] = b.getPassSignRatio();
|
|
|
+ ob[8] = b.getPassParticipantRatio();
|
|
|
+ for (int i = 0; i < partitionCount; i++) {
|
|
|
+ ob[9 + i*3] = b.getPartitionData().get(i).getCount();
|
|
|
+ ob[9 + i*3 + 1] = b.getPartitionData().get(i).getSignRatio();
|
|
|
+ ob[9 + i*3 + 2] = b.getPartitionData().get(i).getParticipantRatio();
|
|
|
+ }
|
|
|
+ data.add(ob);
|
|
|
+ }
|
|
|
+ sheet.setData(data);
|
|
|
+ sheets.add(sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillExamOrgMainSheetdata(List<SheetData> sheets,List<ExamOrgReportMainBean> list, List<String> header, int partitionCount) {
|
|
|
+ SheetData sheet = new SheetData();
|
|
|
+ sheet.setHeader(header);
|
|
|
+ sheet.setName("考试学习中心数值分析");
|
|
|
+ fillSheetData(sheets,sheet, list, header.size(), partitionCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillSheetData(List<SheetData> sheets,SheetData sheet, List<ExamOrgReportMainBean> list, int headerSize, int partitionCount) {
|
|
|
+ List<Object[]> data = new ArrayList<Object[]>();
|
|
|
+ for (ExamOrgReportMainBean b : list) {
|
|
|
+ Object[] ob = new Object[headerSize];
|
|
|
+ ob[0] = b.getExamName();
|
|
|
+ ob[1] = b.getOrgName();
|
|
|
+ ob[2] = b.getSignCount();
|
|
|
+ ob[3] = b.getParticipantCount();
|
|
|
+ ob[4] = b.getParticipantRatio();
|
|
|
+ ob[5] = b.getMissCount();
|
|
|
+ ob[6] = b.getMissRatio();
|
|
|
+ ob[7] = b.getPassCount();
|
|
|
+ ob[8] = b.getPassSignRatio();
|
|
|
+ ob[9] = b.getPassParticipantRatio();
|
|
|
+ for (int i = 0; i < partitionCount; i++) {
|
|
|
+ ob[10 + i*3] = b.getPartitionData().get(i).getCount();
|
|
|
+ ob[10 + i*3 + 1] = b.getPartitionData().get(i).getSignRatio();
|
|
|
+ ob[10 + i*3 + 2] = b.getPartitionData().get(i).getParticipantRatio();
|
|
|
+ }
|
|
|
+ data.add(ob);
|
|
|
+ }
|
|
|
+ sheet.setData(data);
|
|
|
+ sheets.add(sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillParticipantSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header, int partitionCount) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("实考人数前十");
|
|
|
+ fillSheetData(sheets,sheet1, getParticipantSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet2 = new SheetData();
|
|
|
+ sheet2.setHeader(header);
|
|
|
+ sheet2.setName("实考人数后十");
|
|
|
+ fillSheetData(sheets,sheet2, getParticipantSort(list,asc), header.size(), partitionCount);
|
|
|
+ SheetData sheet3 = new SheetData();
|
|
|
+ sheet3.setHeader(header);
|
|
|
+ sheet3.setName("实考比例前十");
|
|
|
+ fillSheetData(sheets,sheet3, getParticipantRatioSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet4 = new SheetData();
|
|
|
+ sheet4.setHeader(header);
|
|
|
+ sheet4.setName("实考比例后十");
|
|
|
+ fillSheetData(sheets,sheet4, getParticipantRatioSort(list,asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ private void fillMissSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header,int partitionCount) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("缺考人数前十");
|
|
|
+ fillSheetData(sheets,sheet1, getMissSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet2 = new SheetData();
|
|
|
+ sheet2.setHeader(header);
|
|
|
+ sheet2.setName("缺考人数后十");
|
|
|
+ fillSheetData(sheets,sheet2, getMissSort(list,asc), header.size(), partitionCount);
|
|
|
+ SheetData sheet3 = new SheetData();
|
|
|
+ sheet3.setHeader(header);
|
|
|
+ sheet3.setName("缺考比例前十");
|
|
|
+ fillSheetData(sheets,sheet3, getMissRatioSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet4 = new SheetData();
|
|
|
+ sheet4.setHeader(header);
|
|
|
+ sheet4.setName("缺考比例后十");
|
|
|
+ fillSheetData(sheets,sheet4, getMissRatioSort(list,asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ private void fillPassSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header,int partitionCount) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("及格人数前十");
|
|
|
+ fillSheetData(sheets,sheet1, getPassSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet2 = new SheetData();
|
|
|
+ sheet2.setHeader(header);
|
|
|
+ sheet2.setName("及格人数后十");
|
|
|
+ fillSheetData(sheets,sheet2, getPassSort(list,asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ private void fillPassRatioSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header, int partitionCount) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("及格报名人数比例前十");
|
|
|
+ fillSheetData(sheets,sheet1, getPassSignRatioSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet2 = new SheetData();
|
|
|
+ sheet2.setHeader(header);
|
|
|
+ sheet2.setName("及格报名人数比例后十");
|
|
|
+ fillSheetData(sheets,sheet2, getPassSignRatioSort(list,asc), header.size(), partitionCount);
|
|
|
+ SheetData sheet3 = new SheetData();
|
|
|
+ sheet3.setHeader(header);
|
|
|
+ sheet3.setName("及格实考人数比例前十");
|
|
|
+ fillSheetData(sheets,sheet3, getPassParticipantRatioSort(list,desc), header.size(), partitionCount);
|
|
|
+ SheetData sheet4 = new SheetData();
|
|
|
+ sheet4.setHeader(header);
|
|
|
+ sheet4.setName("及格实考人数比例后十");
|
|
|
+ fillSheetData(sheets,sheet4, getPassParticipantRatioSort(list,asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ private void fillPartitionSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header, int partitionCount) {
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "人数前十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionCountSort(list, i-1, desc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "人数后十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionCountSort(list, i-1, asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void fillPartitionRatioSheetdata(List<SheetData> sheets, List<ExamOrgReportMainBean> list, List<String> header, int partitionCount) {
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "报名人数比例前十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionSignRatioSort(list, i-1, desc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "报名人数比例后十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionSignRatioSort(list, i-1, asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "实考人数比例前十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionParticipantRatioSort(list, i-1, desc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= partitionCount; i++) {
|
|
|
+ SheetData sheet1 = new SheetData();
|
|
|
+ sheet1.setHeader(header);
|
|
|
+ sheet1.setName("分段" + i + "实考人数比例后十");
|
|
|
+ fillSheetData(sheets, sheet1, getPartitionParticipantRatioSort(list, i-1, asc), header.size(), partitionCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|