|
@@ -11,12 +11,22 @@ import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
import javax.transaction.Transactional;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+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 com.google.common.collect.Lists;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
@@ -43,16 +53,18 @@ import cn.com.qmth.examcloud.core.reports.api.request.GetProjectInfoBeanReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.request.SaveExamCourseDataReportListReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.request.SaveExamOrgReportListReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.request.UpdateProjectCourseOrgCountReq;
|
|
|
+import cn.com.qmth.examcloud.core.reports.api.request.UpdateProjectStatusByIdsReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.request.UpdateProjectStatusReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.response.GetProjectInfoBeanResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamsByIdListReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamsByIdListResp;
|
|
|
+import cn.com.qmth.examcloud.task.base.bean.ReportsComputeBean;
|
|
|
+import cn.com.qmth.examcloud.task.base.enums.ReportsComputeStatus;
|
|
|
import cn.com.qmth.examcloud.task.base.util.BatchGetDataUtil;
|
|
|
import cn.com.qmth.examcloud.task.dao.ReportsComputeRepo;
|
|
|
import cn.com.qmth.examcloud.task.dao.entity.ReportsComputeEntity;
|
|
|
-import cn.com.qmth.examcloud.task.dao.enums.ReportsComputeStatus;
|
|
|
import cn.com.qmth.examcloud.task.service.ReportsComputeService;
|
|
|
import cn.com.qmth.examcloud.task.service.dto.TopicScoreDto;
|
|
|
import cn.com.qmth.examcloud.task.service.exception.ReportsComputeStopException;
|
|
@@ -92,8 +104,22 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void initReportsCompute() {
|
|
|
- reportsComputeRepo.initComputingJob();
|
|
|
- reportsComputeRepo.initStopingJob();
|
|
|
+ List<ReportsComputeEntity> cs = reportsComputeRepo.findByStatus(ReportsComputeStatus.COMPUTING);
|
|
|
+ UpdateProjectStatusByIdsReq req = new UpdateProjectStatusByIdsReq();
|
|
|
+ if (cs != null && cs.size() > 0) {
|
|
|
+ reportsComputeRepo.initComputingJob();
|
|
|
+ List<Long> cids = cs.stream().map(c -> c.getProjectId()).collect(Collectors.toList());
|
|
|
+ req.setComputingProjectIds(cids);
|
|
|
+ }
|
|
|
+ List<ReportsComputeEntity> ss = reportsComputeRepo.findByStatus(ReportsComputeStatus.STOPING);
|
|
|
+ if (ss != null && ss.size() > 0) {
|
|
|
+ reportsComputeRepo.initStopingJob();
|
|
|
+ List<Long> sids = ss.stream().map(c -> c.getProjectId()).collect(Collectors.toList());
|
|
|
+ req.setStopingProjectIds(sids);
|
|
|
+ }
|
|
|
+ if(req.getComputingProjectIds()!=null||req.getStopingProjectIds()!=null) {
|
|
|
+ projectCloudService.updateProjectStatusByIds(req);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -203,7 +229,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
bean.setCdi(getPercentage(bean.getStd(), bean.getAvgScore()));
|
|
|
bean.setAvgScore(getTwoDecimal(bean.getAvgScore()));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 判断任务终止
|
|
|
checkIsStoping(et.getId());
|
|
|
// 计算basePaperId对应的难度系数
|
|
@@ -252,9 +278,9 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
SaveExamCourseDataReportListReq req2 = new SaveExamCourseDataReportListReq();
|
|
|
req2.setBeans(new ArrayList<ExamCourseDataReportBean>(examCourseDataReport.values()));
|
|
|
examCourseDataReportCloudService.saveExamCourseDataReportList(req2);
|
|
|
-
|
|
|
- //保存项目课程数量、中心数量
|
|
|
- UpdateProjectCourseOrgCountReq req=new UpdateProjectCourseOrgCountReq();
|
|
|
+
|
|
|
+ // 保存项目课程数量、中心数量
|
|
|
+ UpdateProjectCourseOrgCountReq req = new UpdateProjectCourseOrgCountReq();
|
|
|
req.setProjectId(pro.getId());
|
|
|
req.setOrgCount(ordIds.size());
|
|
|
req.setCourseCount(courseIds.size());
|
|
@@ -341,39 +367,40 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
|
|
|
private Double avgDifficultyDegree(String dataKey, Map<String, Set<String>> basePapers,
|
|
|
Map<String, Double> basePapersDegree) {
|
|
|
- //考试课程对应的basePapers
|
|
|
+ // 考试课程对应的basePapers
|
|
|
Set<String> set = basePapers.get(dataKey);
|
|
|
- if (set == null||set.size()==0) {
|
|
|
+ if (set == null || set.size() == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
double total = 0.0;
|
|
|
- //算平均难度时剔除没有难度系数的试卷
|
|
|
- int nullCount=0;
|
|
|
+ // 算平均难度时剔除没有难度系数的试卷
|
|
|
+ int nullCount = 0;
|
|
|
for (String s : set) {
|
|
|
- Double td=basePapersDegree.get(s);
|
|
|
- if(td==null) {
|
|
|
+ Double td = basePapersDegree.get(s);
|
|
|
+ if (td == null) {
|
|
|
nullCount++;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
total = total + basePapersDegree.get(s);
|
|
|
}
|
|
|
}
|
|
|
- if(nullCount==set.size()) {
|
|
|
+ if (nullCount == set.size()) {
|
|
|
return null;
|
|
|
}
|
|
|
- return getTwoDecimal(total / (set.size()-nullCount));
|
|
|
+ return getTwoDecimal(total / (set.size() - nullCount));
|
|
|
}
|
|
|
|
|
|
private Double difficultyDegree(Map<String, TopicScoreDto> map) {
|
|
|
- //剔除整张卷子没有小题答题的
|
|
|
- if(map==null||map.size()==0) {
|
|
|
+ // 剔除整张卷子没有小题答题的
|
|
|
+ if (map == null || map.size() == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
double totalAvg = 0.0;
|
|
|
double totalFull = 0.0;
|
|
|
for (String k : map.keySet()) {
|
|
|
TopicScoreDto dto = map.get(k);
|
|
|
- if(dto.getTotal()==0) {
|
|
|
- throw new StatusException("100001", "小题满分不能为0 QuestionId:"+dto.getQuestionId()+" QuestionOrder:"+dto.getQuestionOrder());
|
|
|
+ if (dto.getTotal() == 0) {
|
|
|
+ throw new StatusException("100001",
|
|
|
+ "小题满分不能为0 QuestionId:" + dto.getQuestionId() + " QuestionOrder:" + dto.getQuestionOrder());
|
|
|
}
|
|
|
totalAvg = totalAvg + dto.getAvg();
|
|
|
totalFull = totalFull + dto.getTotal();
|
|
@@ -457,8 +484,8 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
bean.setParticipantCount(bean.getParticipantCount() + 1);
|
|
|
}
|
|
|
// 及格人数
|
|
|
- if (!st.getAbsent() && st.getScore()==null) {
|
|
|
- throw new StatusException("10030","未缺考的考生分数不能为空 ExamStudentId:"+st.getExamStudentId());
|
|
|
+ if (!st.getAbsent() && st.getScore() == null) {
|
|
|
+ throw new StatusException("10030", "未缺考的考生分数不能为空 ExamStudentId:" + st.getExamStudentId());
|
|
|
}
|
|
|
if (!st.getAbsent() && st.getScore() >= pro.getPassScore()) {
|
|
|
bean.setPassCount(bean.getPassCount() + 1);
|
|
@@ -593,10 +620,10 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
}
|
|
|
// 考生小题得分详情
|
|
|
List<ExamStudentScoreDataBean> scoreDetails = st.getScoreDetails();
|
|
|
- if(scoreDetails==null||scoreDetails.size()==0) {
|
|
|
- throw new StatusException("10040","考生小题得分详情不能为空 ExamStudentId:"+st.getExamStudentId());
|
|
|
+ if (scoreDetails == null || scoreDetails.size() == 0) {
|
|
|
+ throw new StatusException("10040", "考生小题得分详情不能为空 ExamStudentId:" + st.getExamStudentId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 计算每个小题的平均分
|
|
|
for (ExamStudentScoreDataBean b : scoreDetails) {
|
|
|
if (b.getScore() != null) {
|
|
@@ -714,6 +741,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
public int getTodoDataCount() {
|
|
|
return reportsComputeRepo.getTodoDataCount();
|
|
|
}
|
|
|
+
|
|
|
private Double getPercentage(Double a, Double b) {
|
|
|
if (b == 0) {
|
|
|
return null;
|
|
@@ -722,6 +750,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
return tem;
|
|
|
}
|
|
|
+
|
|
|
private Double getTwoDecimal(Double b) {
|
|
|
if (b == null) {
|
|
|
return b;
|
|
@@ -730,4 +759,30 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
return tem;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<ReportsComputeBean> queryPage(Long projectId, Integer pageNo, Integer pageSize, Long rootOrgId) {
|
|
|
+ Specification<ReportsComputeEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+
|
|
|
+ predicates.add(cb.equal(root.get("projectId"), projectId));
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize, new Sort(Direction.DESC, "id"));
|
|
|
+
|
|
|
+ Page<ReportsComputeEntity> projects = reportsComputeRepo.findAll(specification, pageRequest);
|
|
|
+
|
|
|
+ List<ReportsComputeBean> ret = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (ReportsComputeEntity cur : projects) {
|
|
|
+ ReportsComputeBean bean = new ReportsComputeBean();
|
|
|
+ BeanUtils.copyProperties(cur, bean);
|
|
|
+ bean.setStatusName(bean.getStatus().getDesc());
|
|
|
+ ret.add(bean);
|
|
|
+ }
|
|
|
+ return new PageInfo<ReportsComputeBean>(projects, ret);
|
|
|
+ }
|
|
|
}
|