|
@@ -1,30 +1,54 @@
|
|
|
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.List;
|
|
|
+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.ExamCourseDataReportBean;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.ExamCourseMainTopTen;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.bean.ExamCourseReportMainBean;
|
|
|
+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.ExamCourseDataReportRepo;
|
|
|
import cn.com.qmth.examcloud.core.reports.dao.entity.ExamCourseDataReportEntity;
|
|
|
+import cn.com.qmth.examcloud.core.reports.dao.entity.ProjectEntity;
|
|
|
import cn.com.qmth.examcloud.core.reports.service.ExamCourseDataReportService;
|
|
|
+import cn.com.qmth.examcloud.core.reports.service.ExamOrgReportService;
|
|
|
|
|
|
@Service
|
|
|
public class ExamCourseDataReportServiceImpl implements ExamCourseDataReportService {
|
|
|
+ private final static int asc = 0;
|
|
|
+ private final static int desc = 2;
|
|
|
@Autowired
|
|
|
private ExamCourseDataReportRepo examCourseDataReportRepo;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ExamOrgReportService examOrgReportService;
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void saveExamCourseDataReportList(List<ExamCourseDataReportBean> beans) {
|
|
|
- List<ExamCourseDataReportEntity> list=new ArrayList<ExamCourseDataReportEntity>();
|
|
|
- for(ExamCourseDataReportBean bean:beans) {
|
|
|
- ExamCourseDataReportEntity e=new ExamCourseDataReportEntity();
|
|
|
+ List<ExamCourseDataReportEntity> list = new ArrayList<ExamCourseDataReportEntity>();
|
|
|
+ for (ExamCourseDataReportBean bean : beans) {
|
|
|
+ ExamCourseDataReportEntity e = new ExamCourseDataReportEntity();
|
|
|
BeanUtils.copyProperties(bean, e);
|
|
|
e.setPartitionData(StringUtils.join(bean.getPartitionData().toArray(), ","));
|
|
|
list.add(e);
|
|
@@ -37,5 +61,472 @@ public class ExamCourseDataReportServiceImpl implements ExamCourseDataReportServ
|
|
|
examCourseDataReportRepo.deleteByProject(projectId, rootOrgId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ExamCourseReportMainBean> getExamCourseMainList(Long projectId, Long examId) {
|
|
|
+ Specification<ExamCourseDataReportEntity> 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<ExamCourseDataReportEntity> entityList = examCourseDataReportRepo.findAll(specification, sort);
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>();
|
|
|
+ for (ExamCourseDataReportEntity e : entityList) {
|
|
|
+ ret.add(of(e));
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ExamCourseReportMainBean of(ExamCourseDataReportEntity e) {
|
|
|
+ ExamCourseReportMainBean b = new ExamCourseReportMainBean();
|
|
|
+ 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 ExamCourseMainTopTen getExamOrgMainTop10(Long projectId, Long examId) {
|
|
|
+ ExamCourseMainTopTen ret = new ExamCourseMainTopTen();
|
|
|
+ List<ExamCourseReportMainBean> list = getExamCourseMainList(projectId, examId);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ ret.setDifficultyDegree(getDifficultyDegreeSort(list, asc));
|
|
|
+ ret.setDifficultyDegreeDesc(getDifficultyDegreeSort(list, desc));
|
|
|
+ ret.setStd(getStdSort(list, asc));
|
|
|
+ ret.setStdDesc(getStdSort(list, desc));
|
|
|
+ ret.setCdi(getCdiSort(list, asc));
|
|
|
+ ret.setCdiDesc(getCdiSort(list, desc));
|
|
|
+ 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<ExamCourseReportMainBean> getParticipantSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getParticipantRatioSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getMissSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getMissRatioSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getPassSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getPassSignRatioSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getPassParticipantRatioSort(List<ExamCourseReportMainBean> list,
|
|
|
+ int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean>> getPartitionSort(List<ExamCourseReportMainBean> list) {
|
|
|
+ List<PartitionTopTen<ExamCourseReportMainBean>> ret = new ArrayList<PartitionTopTen<ExamCourseReportMainBean>>();
|
|
|
+ int size = list.get(0).getPartitionData().size();
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ PartitionTopTen<ExamCourseReportMainBean> pt = new PartitionTopTen<ExamCourseReportMainBean>();
|
|
|
+ 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<ExamCourseReportMainBean> getPartitionCountSort(List<ExamCourseReportMainBean> list, int index,
|
|
|
+ int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getPartitionSignRatioSort(List<ExamCourseReportMainBean> list, int index,
|
|
|
+ int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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<ExamCourseReportMainBean> getPartitionParticipantRatioSort(List<ExamCourseReportMainBean> list,
|
|
|
+ int index, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamCourseReportMainBean> getDifficultyDegreeSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean o2) {
|
|
|
+ if (o1.getAvgDifficultyDegree() > o2.getAvgDifficultyDegree()) {
|
|
|
+ return 1 - ascOrDesc;
|
|
|
+ } else if (o1.getAvgDifficultyDegree() < o2.getAvgDifficultyDegree()) {
|
|
|
+ return -1 + ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamCourseReportMainBean> getStdSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean o2) {
|
|
|
+ if (o1.getStd() > o2.getStd()) {
|
|
|
+ return 1 - ascOrDesc;
|
|
|
+ } else if (o1.getStd() < o2.getStd()) {
|
|
|
+ return -1 + ascOrDesc;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ if (ret.size() > 10) {
|
|
|
+ return ret.subList(0, 10);
|
|
|
+ } else {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private List<ExamCourseReportMainBean> getCdiSort(List<ExamCourseReportMainBean> list, int ascOrDesc) {
|
|
|
+ List<ExamCourseReportMainBean> ret = new ArrayList<ExamCourseReportMainBean>(list);
|
|
|
+ Collections.sort(ret, new Comparator<ExamCourseReportMainBean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(ExamCourseReportMainBean o1, ExamCourseReportMainBean o2) {
|
|
|
+ if (o1.getCdi() > o2.getCdi()) {
|
|
|
+ return 1 - ascOrDesc;
|
|
|
+ } else if (o1.getCdi() < o2.getCdi()) {
|
|
|
+ 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, 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 = examOrgReportService.getExamMainList(projectId, examId);
|
|
|
+ examOrgReportService.fillExamMainSheetdata(sheets,list1, examheader, partitionCount);
|
|
|
+ List<ExamCourseReportMainBean> list2 = getExamCourseMainList(projectId, examId);
|
|
|
+ fillExamCourseMainSheetdata(sheets, list2, header, partitionCount);
|
|
|
+ ExportUtils.exportExcel("考试课程分析结果", sheets, response);
|
|
|
+ }
|
|
|
+ private void fillExamCourseMainSheetdata(List<SheetData> sheets,List<ExamCourseReportMainBean> 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<ExamCourseReportMainBean> list, int headerSize, int partitionCount) {
|
|
|
+ List<Object[]> data = new ArrayList<Object[]>();
|
|
|
+ for (ExamCourseReportMainBean b : list) {
|
|
|
+ Object[] ob = new Object[headerSize];
|
|
|
+ ob[0] = b.getExamName();
|
|
|
+ ob[1] = b.getCourseName();
|
|
|
+ ob[2] = b.getTotalScore();
|
|
|
+ ob[3] = b.getMaxScore();
|
|
|
+ ob[4] = b.getMinScore();
|
|
|
+ ob[5] = b.getAvgScore();
|
|
|
+ ob[6] = b.getStd();
|
|
|
+ ob[7] = b.getAvgDifficultyDegree();
|
|
|
+ ob[8] = b.getCdi();
|
|
|
+ ob[9] = b.getSignCount();
|
|
|
+ ob[10] = b.getParticipantCount();
|
|
|
+ ob[11] = b.getFullCount();
|
|
|
+ ob[12] = b.getZeroCount();
|
|
|
+ ob[13] = b.getPassCount();
|
|
|
+ ob[14] = b.getPassParticipantRatio();
|
|
|
+ for (int i = 0; i < partitionCount; i++) {
|
|
|
+ ob[15 + i*3] = b.getPartitionData().get(i).getCount();
|
|
|
+ ob[15 + i*3 + 1] = b.getPartitionData().get(i).getSignRatio();
|
|
|
+ ob[15 + i*3 + 2] = b.getPartitionData().get(i).getParticipantRatio();
|
|
|
+ }
|
|
|
+ data.add(ob);
|
|
|
+ }
|
|
|
+ sheet.setData(data);
|
|
|
+ sheets.add(sheet);
|
|
|
+ }
|
|
|
}
|