xiatian 7 ماه پیش
والد
کامیت
761b011a04

+ 393 - 387
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/impl/ProjectServiceImpl.java

@@ -56,391 +56,397 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 
 @Service
 @Service
 public class ProjectServiceImpl implements ProjectService {
 public class ProjectServiceImpl implements ProjectService {
-	@Autowired
-	private ExamOrgReportService examOrgReportService;
-	@Autowired
-	private ExamCourseDataReportService examCourseDataReportService;
-	@Autowired
-	private ExamCloudService examCloudService;
-	@Autowired
-	private ProjectRepo projectRepo;
-	@Autowired
-	private ReportsComputeCloudService reportsComputeCloudService;
-
-	@Transactional
-	@Override
-	public Long addProject(AddProjectReq req, Long rootOrgId) {
-		Date now = new Date();
-		ProjectEntity pe = new ProjectEntity();
-		BeanUtils.copyProperties(req, pe);
-		pe.setCreationTime(now);
-		pe.setUpdateTime(now);
-		pe.setRootOrgId(rootOrgId);
-		pe.setEnable(true);
-		pe.setReportStatus(ReportStatus.NONE);
-		pe.setExamIds(StringUtils.join(req.getExamIds().toArray(), ","));
-		if (pe.getDataOrigin().equals(DataOrigin.SYNC)) {
-			pe.setSampleCount(req.getExamIds().size());
-		}
-		projectRepo.save(pe);
-		return pe.getId();
-	}
-
-	@Transactional
-	@Override
-	public void updateProject(UpdateProjectReq req, Long rootOrgId) {
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, req.getId(), ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000001", "项目不存在");
-		}
-		if (!rootOrgId.equals(pe.getRootOrgId())) {
-			throw new StatusException("1000002", "RootOrgId不一致");
-		}
-		pe.setName(req.getName());
-		pe.setRemarks(req.getRemarks());
-		projectRepo.save(pe);
-	}
-
-	@Transactional
-	@Override
-	public void updateEnable(String ids, Boolean enable, Long rootOrgId) {
-		List<Long> idList = Arrays.asList(ids.split(",")).stream().map(str -> Long.parseLong(str))
-				.collect(Collectors.toList());
-		projectRepo.updateEnable(idList, rootOrgId, enable);
-	}
-
-	private String toSqlSearchPattern(String column) {
-		if (StringUtils.isBlank(column)) {
-			return "%";
-		} else {
-			column = column.trim().replaceAll("\\s", "%");
-			column = "%" + column + "%";
-			return column;
-		}
-	}
-
-	@Override
-	public PageInfo<ProjectBean> queryPage(QueryProjectPageReq req, Integer pageNo, Integer pageSize, Long rootOrgId) {
-		Long id = req.getId();
-		String name = req.getName();
-		AnalyseType analyseType = req.getAnalyseType();
-		DataOrigin dataOrigin = req.getDataOrigin();
-		Specification<ProjectEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
-
-			if (null != req.getEnable()) {
-				predicates.add(cb.equal(root.get("enable"), req.getEnable()));
-			}
-			if (null != id) {
-				predicates.add(cb.equal(root.get("id"), id));
-			}
-			if (null != analyseType) {
-				predicates.add(cb.equal(root.get("analyseType"), analyseType));
-			}
-			if (null != dataOrigin) {
-				predicates.add(cb.equal(root.get("dataOrigin"), dataOrigin));
-			}
-			if (StringUtils.isNotEmpty(name)) {
-				predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize, Sort.by(Direction.DESC, "id"));
-
-		Page<ProjectEntity> projects = projectRepo.findAll(specification, pageRequest);
-
-		List<ProjectBean> ret = Lists.newArrayList();
-
-		for (ProjectEntity cur : projects) {
-			ProjectBean bean = new ProjectBean();
-			BeanUtils.copyProperties(cur, bean);
-			bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
-			bean.setDataOriginName(bean.getDataOrigin().getDesc());
-			bean.setReportStatusName(bean.getReportStatus().getDesc());
-			if (StringUtils.isNotBlank(cur.getExamIds())) {
-				List<Long> temList = Arrays.asList(cur.getExamIds().split(",")).stream().map(str -> Long.parseLong(str))
-						.collect(Collectors.toList());
-				bean.setExamIds(temList);
-			}
-			if (StringUtils.isNotBlank(cur.getPartitionDetails())) {
-				List<Double> temList = Arrays.asList(cur.getPartitionDetails().split(",")).stream()
-						.map(str -> Double.parseDouble(str)).collect(Collectors.toList());
-				bean.setPartitionDetails(temList);
-			}
-			ret.add(bean);
-		}
-		return PageUtils.toPageInfo(projects, ret);
-	}
-
-	@Transactional
-	@Override
-	public void updateProjectStatus(UpdateProjectStatusReq req) {
-		Long id = req.getProjectId();
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000003", "项目不存在");
-		}
-		if (req.getStatus() == 2) {
-			pe.setReportStatus(ReportStatus.COMPUTING);
-		} else if (req.getStatus() == 3) {
-			pe.setReportStatus(ReportStatus.SUCCESS);
-		} else if (req.getStatus() == 4) {
-			pe.setReportStatus(ReportStatus.FAIL);
-		} else if (req.getStatus() == 5) {
-			pe.setReportStatus(ReportStatus.STOP);
-		} else {
-			throw new StatusException("1000004", "无效的Status");
-		}
-		projectRepo.save(pe);
-	}
-
-	@Override
-	public ProjectInfoBean getProjectInfoBean(GetProjectInfoBeanReq req) {
-		if (req.getProjectId() == null) {
-			throw new StatusException("1000005", "项目id不能为空");
-		}
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, req.getProjectId(), ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000006", "项目不存在");
-		}
-		ProjectInfoBean bean = new ProjectInfoBean();
-		BeanUtils.copyProperties(pe, bean);
-		bean.setAnalyseType(pe.getAnalyseType().name());
-		bean.setDataOrigin(pe.getDataOrigin().name());
-		bean.setReportStatus(pe.getReportStatus().name());
-		List<Double> partitionDetails = Arrays.asList(pe.getPartitionDetails().split(",")).stream()
-				.map(str -> Double.parseDouble(str)).collect(Collectors.toList());
-		bean.setPartitionDetails(partitionDetails);
-		return bean;
-	}
-
-	@Transactional
-	@Override
-	public void addReportsCompute(Long id, Long rootOrgId) {
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000021", "项目不存在");
-		}
-		if (!rootOrgId.equals(pe.getRootOrgId())) {
-			throw new StatusException("1000022", "非法操作");
-		}
-		if (!pe.getEnable()) {
-			throw new StatusException("1000023", "项目已禁用");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
-			throw new StatusException("1000024", "项目已处于待计算状态");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
-			throw new StatusException("1000025", "项目已处于计算状态");
-		}
-		if (pe.getPassScore() == null || pe.getTotalScore() == null || pe.getPartitionDetails() == null) {
-			throw new StatusException("1000026", "项目未设定及格分及分数段");
-		}
-		pe.setReportStatus(ReportStatus.WAITCOMPUTE);
-		projectRepo.saveAndFlush(pe);
-		AddReportsComputeReq req = new AddReportsComputeReq();
-		req.setProjectId(id);
-		req.setRootOrgId(rootOrgId);
-		reportsComputeCloudService.addReportsCompute(req);
-	}
-
-	@Transactional
-	@Override
-	public void updateScore(UpdateProjectScoreReq req, Long rootOrgId) {
-		Long id = req.getId();
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000031", "项目不存在");
-		}
-		if (!rootOrgId.equals(pe.getRootOrgId())) {
-			throw new StatusException("1000032", "非法操作");
-		}
-		if (!pe.getEnable()) {
-			throw new StatusException("1000033", "项目已禁用");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
-			throw new StatusException("1000034", "项目已处于待计算状态");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
-			throw new StatusException("1000035", "项目已处于计算状态");
-		}
-		Double passScore = req.getPassScore();
-		Double totalScore = req.getTotalScore();
-		if (passScore <= 0) {
-			throw new StatusException("1000036", "及格分数必须大于0");
-		}
-		if (totalScore <= 0) {
-			throw new StatusException("1000037", "满分分数必须大于0");
-		}
-		if (passScore > totalScore) {
-			throw new StatusException("1000038", "及格分数不能大于满分分数");
-		}
-		List<Double> scores = req.getPartitionDetails();
-		Set<Double> set = new HashSet<Double>();
-		for (Double d : scores) {
-			set.add(d);
-		}
-		if (set.size() != scores.size()) {
-			throw new StatusException("1000039", "分段分数不能相同");
-		}
-		Collections.sort(scores);
-		if (scores.get(0) <= 0) {
-			throw new StatusException("1000040", "第一个分段分数必须大于0");
-		}
-		if (scores.get(scores.size() - 1) >= totalScore) {
-			throw new StatusException("1000041", "最后一个分段分数必须小于满分分数");
-		}
-		pe.setUpdateTime(new Date());
-		pe.setPassScore(passScore);
-		pe.setTotalScore(totalScore);
-		pe.setPartitionCount(scores.size()+1);
-		pe.setPartitionDetails(StringUtils.join(scores.toArray(), ","));
-		if (!ReportStatus.NONE.equals(pe.getReportStatus())) {
-			pe.setReportStatus(ReportStatus.WAITCOMPUTE);
-		}
-		projectRepo.saveAndFlush(pe);
-		if (!ReportStatus.NONE.equals(pe.getReportStatus())) {
-			AddReportsComputeReq areq = new AddReportsComputeReq();
-			areq.setProjectId(id);
-			areq.setRootOrgId(rootOrgId);
-			reportsComputeCloudService.addReportsCompute(areq);
-		}
-	}
-
-	@Override
-	public ProjectEntity findProjectById(Long projectId) {
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, projectId, ProjectEntity.class);
-		return pe;
-	}
-
-	@Transactional
-	@Override
-	public void updateProjectCourseOrgCount(UpdateProjectCourseOrgCountReq req) {
-		projectRepo.updateProjectCourseOrgCount(req.getProjectId(), req.getCourseCount(), req.getOrgCount());
-	}
-
-	@Override
-	public List<ExamBean> queryAllExam(Long rootOrgId) {
-		Date now = new Date();
-		List<ExamBean> exams = new ArrayList<ExamBean>();
-		// 从考务获取启用的考试列表集合信息
-		GetExamListReq getExamListReq = new GetExamListReq();
-		getExamListReq.setEnable(true);// 启用的考试列表
-		getExamListReq.setRootOrgId(rootOrgId);
-		for (;;) {
-			GetExamListResp getExamListResp = examCloudService.getExamList(getExamListReq);
-			if (getExamListResp.getExamList() == null || getExamListResp.getExamList().size() == 0) {
-				break;
-			} else {
-				exams.addAll(getExamListResp.getExamList());
-				getExamListReq.setStart(getExamListResp.getNext());
-			}
-		}
-		// 按一定条件过滤考试集合
-		exams = exams.stream().filter(exam -> {
-			if (!exam.getExamType().equals(ExamType.ONLINE.toString())) {
-				return false;
-			}
-			if (now.before(exam.getEndTime())) {
-				return false;
-			}
-			return true;
-		}).collect(Collectors.toList());
-		return exams;
-	}
-
-	@Transactional
-	@Override
-	public void delProject(Long id, Long rootOrgId) {
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000041", "项目不存在");
-		}
-		if (!rootOrgId.equals(pe.getRootOrgId())) {
-			throw new StatusException("1000042", "非法操作");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
-			throw new StatusException("1000044", "不能删除待计算的项目");
-		}
-		if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
-			throw new StatusException("1000045", "不能删除计算中的项目");
-		}
-		examOrgReportService.deleteByProject(id, rootOrgId);
-		examCourseDataReportService.deleteByProject(id, rootOrgId);
-		projectRepo.deleteByIdAndRootOrgId(id, rootOrgId);
-	}
-
-	@Transactional
-	@Override
-	public void updateProjectStatusByIds(UpdateProjectStatusByIdsReq req) {
-		List<Long> cids = req.getComputingProjectIds();
-		List<Long> sids = req.getStopingProjectIds();
-		if(cids!=null&&cids.size()!=0) {
-			for (Long id : cids) {
-				ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-				if (pe == null) {
-					throw new StatusException("1000051", "项目不存在");
-				}
-				pe.setReportStatus(ReportStatus.WAITCOMPUTE);
-				projectRepo.save(pe);
-			}
-		}
-		if(sids!=null&&sids.size()!=0) {
-			for (Long id : sids) {
-				ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-				if (pe == null) {
-					throw new StatusException("1000052", "项目不存在");
-				}
-				pe.setReportStatus(ReportStatus.STOP);
-				projectRepo.save(pe);
-			}
-		}
-	}
-
-	@Override
-	public ProjectBean getProject(Long id, Long rootOrgId) {
-		ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
-		if (pe == null) {
-			throw new StatusException("1000061", "项目不存在");
-		}
-		if (!pe.getRootOrgId().equals(rootOrgId)) {
-			throw new StatusException("1000062", "非法操作");
-		}
-		ProjectBean bean = new ProjectBean();
-		BeanUtils.copyProperties(pe, bean);
-		bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
-		bean.setDataOriginName(bean.getDataOrigin().getDesc());
-		bean.setReportStatusName(bean.getReportStatus().getDesc());
-		if (StringUtils.isNotBlank(pe.getExamIds())) {
-			List<Long> temList = Arrays.asList(pe.getExamIds().split(",")).stream().map(str -> Long.parseLong(str))
-					.collect(Collectors.toList());
-			bean.setExamIds(temList);
-		}
-		if (StringUtils.isNotBlank(pe.getPartitionDetails())) {
-			List<Double> temList = Arrays.asList(pe.getPartitionDetails().split(",")).stream()
-					.map(str -> Double.parseDouble(str)).collect(Collectors.toList());
-			bean.setPartitionDetails(temList);
-		}
-		return bean;
-	}
-
-	@Override
-	public List<ProjectBean> getProjectList(List<Long> ids, Long rootOrgId) {
-		List<ProjectBean> ret=new ArrayList<ProjectBean>();
-		List<ProjectEntity> list=projectRepo.getByIds(ids, rootOrgId);
-		if(list!=null) {
-			for(ProjectEntity pe:list) {
-				ProjectBean bean = new ProjectBean();
-				BeanUtils.copyProperties(pe, bean);
-				bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
-				bean.setDataOriginName(bean.getDataOrigin().getDesc());
-				bean.setReportStatusName(bean.getReportStatus().getDesc());
-				ret.add(bean);
-			}
-		}
-		return ret;
-	}
+
+    @Autowired
+    private ExamOrgReportService examOrgReportService;
+
+    @Autowired
+    private ExamCourseDataReportService examCourseDataReportService;
+
+    @Autowired
+    private ExamCloudService examCloudService;
+
+    @Autowired
+    private ProjectRepo projectRepo;
+
+    @Autowired
+    private ReportsComputeCloudService reportsComputeCloudService;
+
+    @Transactional
+    @Override
+    public Long addProject(AddProjectReq req, Long rootOrgId) {
+        Date now = new Date();
+        ProjectEntity pe = new ProjectEntity();
+        BeanUtils.copyProperties(req, pe);
+        pe.setCreationTime(now);
+        pe.setUpdateTime(now);
+        pe.setRootOrgId(rootOrgId);
+        pe.setEnable(true);
+        pe.setReportStatus(ReportStatus.NONE);
+        pe.setExamIds(StringUtils.join(req.getExamIds().toArray(), ","));
+        if (pe.getDataOrigin().equals(DataOrigin.SYNC)) {
+            pe.setSampleCount(req.getExamIds().size());
+        }
+        projectRepo.save(pe);
+        return pe.getId();
+    }
+
+    @Transactional
+    @Override
+    public void updateProject(UpdateProjectReq req, Long rootOrgId) {
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, req.getId(), ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000001", "项目不存在");
+        }
+        if (!rootOrgId.equals(pe.getRootOrgId())) {
+            throw new StatusException("1000002", "RootOrgId不一致");
+        }
+        pe.setName(req.getName());
+        pe.setRemarks(req.getRemarks());
+        projectRepo.save(pe);
+    }
+
+    @Transactional
+    @Override
+    public void updateEnable(String ids, Boolean enable, Long rootOrgId) {
+        List<Long> idList = Arrays.asList(ids.split(",")).stream().map(str -> Long.parseLong(str))
+                .collect(Collectors.toList());
+        projectRepo.updateEnable(idList, rootOrgId, enable);
+    }
+
+    private String toSqlSearchPattern(String column) {
+        if (StringUtils.isBlank(column)) {
+            return "%";
+        } else {
+            column = column.trim().replaceAll("\\s", "%");
+            column = "%" + column + "%";
+            return column;
+        }
+    }
+
+    @Override
+    public PageInfo<ProjectBean> queryPage(QueryProjectPageReq req, Integer pageNo, Integer pageSize, Long rootOrgId) {
+        Long id = req.getId();
+        String name = req.getName();
+        AnalyseType analyseType = req.getAnalyseType();
+        DataOrigin dataOrigin = req.getDataOrigin();
+        Specification<ProjectEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+
+            if (null != req.getEnable()) {
+                predicates.add(cb.equal(root.get("enable"), req.getEnable()));
+            }
+            if (null != id) {
+                predicates.add(cb.equal(root.get("id"), id));
+            }
+            if (null != analyseType) {
+                predicates.add(cb.equal(root.get("analyseType"), analyseType));
+            }
+            if (null != dataOrigin) {
+                predicates.add(cb.equal(root.get("dataOrigin"), dataOrigin));
+            }
+            if (StringUtils.isNotEmpty(name)) {
+                predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
+            }
+
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize, Sort.by(Direction.DESC, "id"));
+
+        Page<ProjectEntity> projects = projectRepo.findAll(specification, pageRequest);
+
+        List<ProjectBean> ret = Lists.newArrayList();
+
+        for (ProjectEntity cur : projects) {
+            ProjectBean bean = new ProjectBean();
+            BeanUtils.copyProperties(cur, bean);
+            bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
+            bean.setDataOriginName(bean.getDataOrigin().getDesc());
+            bean.setReportStatusName(bean.getReportStatus().getDesc());
+            if (StringUtils.isNotBlank(cur.getExamIds())) {
+                List<Long> temList = Arrays.asList(cur.getExamIds().split(",")).stream().map(str -> Long.parseLong(str))
+                        .collect(Collectors.toList());
+                bean.setExamIds(temList);
+            }
+            if (StringUtils.isNotBlank(cur.getPartitionDetails())) {
+                List<Double> temList = Arrays.asList(cur.getPartitionDetails().split(",")).stream()
+                        .map(str -> Double.parseDouble(str)).collect(Collectors.toList());
+                bean.setPartitionDetails(temList);
+            }
+            ret.add(bean);
+        }
+        return PageUtils.toPageInfo(projects, ret);
+    }
+
+    @Transactional
+    @Override
+    public void updateProjectStatus(UpdateProjectStatusReq req) {
+        Long id = req.getProjectId();
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000003", "项目不存在");
+        }
+        if (req.getStatus() == 2) {
+            pe.setReportStatus(ReportStatus.COMPUTING);
+        } else if (req.getStatus() == 3) {
+            pe.setReportStatus(ReportStatus.SUCCESS);
+        } else if (req.getStatus() == 4) {
+            pe.setReportStatus(ReportStatus.FAIL);
+        } else if (req.getStatus() == 5) {
+            pe.setReportStatus(ReportStatus.STOP);
+        } else {
+            throw new StatusException("1000004", "无效的Status");
+        }
+        projectRepo.save(pe);
+    }
+
+    @Override
+    public ProjectInfoBean getProjectInfoBean(GetProjectInfoBeanReq req) {
+        if (req.getProjectId() == null) {
+            throw new StatusException("1000005", "项目id不能为空");
+        }
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, req.getProjectId(), ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000006", "项目不存在");
+        }
+        ProjectInfoBean bean = new ProjectInfoBean();
+        BeanUtils.copyProperties(pe, bean);
+        bean.setAnalyseType(pe.getAnalyseType().name());
+        bean.setDataOrigin(pe.getDataOrigin().name());
+        bean.setReportStatus(pe.getReportStatus().name());
+        List<Double> partitionDetails = Arrays.asList(pe.getPartitionDetails().split(",")).stream()
+                .map(str -> Double.parseDouble(str)).collect(Collectors.toList());
+        bean.setPartitionDetails(partitionDetails);
+        return bean;
+    }
+
+    @Transactional
+    @Override
+    public void addReportsCompute(Long id, Long rootOrgId) {
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000021", "项目不存在");
+        }
+        if (!rootOrgId.equals(pe.getRootOrgId())) {
+            throw new StatusException("1000022", "非法操作");
+        }
+        if (!pe.getEnable()) {
+            throw new StatusException("1000023", "项目已禁用");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
+            throw new StatusException("1000024", "项目已处于待计算状态");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
+            throw new StatusException("1000025", "项目已处于计算状态");
+        }
+        if (pe.getPassScore() == null || pe.getTotalScore() == null || pe.getPartitionDetails() == null) {
+            throw new StatusException("1000026", "项目未设定及格分及分数段");
+        }
+        pe.setReportStatus(ReportStatus.WAITCOMPUTE);
+        projectRepo.saveAndFlush(pe);
+        AddReportsComputeReq req = new AddReportsComputeReq();
+        req.setProjectId(id);
+        req.setRootOrgId(rootOrgId);
+        reportsComputeCloudService.addReportsCompute(req);
+    }
+
+    @Transactional
+    @Override
+    public void updateScore(UpdateProjectScoreReq req, Long rootOrgId) {
+        Long id = req.getId();
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000031", "项目不存在");
+        }
+        if (!rootOrgId.equals(pe.getRootOrgId())) {
+            throw new StatusException("1000032", "非法操作");
+        }
+        if (!pe.getEnable()) {
+            throw new StatusException("1000033", "项目已禁用");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
+            throw new StatusException("1000034", "项目已处于待计算状态");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
+            throw new StatusException("1000035", "项目已处于计算状态");
+        }
+        Double passScore = req.getPassScore();
+        Double totalScore = req.getTotalScore();
+        if (passScore <= 0) {
+            throw new StatusException("1000036", "及格分数必须大于0");
+        }
+        if (totalScore <= 0) {
+            throw new StatusException("1000037", "满分分数必须大于0");
+        }
+        if (passScore > totalScore) {
+            throw new StatusException("1000038", "及格分数不能大于满分分数");
+        }
+        List<Double> scores = req.getPartitionDetails();
+        Set<Double> set = new HashSet<Double>();
+        for (Double d : scores) {
+            set.add(d);
+        }
+        if (set.size() != scores.size()) {
+            throw new StatusException("1000039", "分段分数不能相同");
+        }
+        Collections.sort(scores);
+        if (scores.get(0) <= 0) {
+            throw new StatusException("1000040", "第一个分段分数必须大于0");
+        }
+        if (scores.get(scores.size() - 1) >= totalScore) {
+            throw new StatusException("1000041", "最后一个分段分数必须小于满分分数");
+        }
+        pe.setUpdateTime(new Date());
+        pe.setPassScore(passScore);
+        pe.setTotalScore(totalScore);
+        pe.setPartitionCount(scores.size() + 1);
+        pe.setPartitionDetails(StringUtils.join(scores.toArray(), ","));
+        if (!ReportStatus.NONE.equals(pe.getReportStatus())) {
+            pe.setReportStatus(ReportStatus.WAITCOMPUTE);
+        }
+        projectRepo.saveAndFlush(pe);
+        if (!ReportStatus.NONE.equals(pe.getReportStatus())) {
+            AddReportsComputeReq areq = new AddReportsComputeReq();
+            areq.setProjectId(id);
+            areq.setRootOrgId(rootOrgId);
+            reportsComputeCloudService.addReportsCompute(areq);
+        }
+    }
+
+    @Override
+    public ProjectEntity findProjectById(Long projectId) {
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, projectId, ProjectEntity.class);
+        return pe;
+    }
+
+    @Transactional
+    @Override
+    public void updateProjectCourseOrgCount(UpdateProjectCourseOrgCountReq req) {
+        projectRepo.updateProjectCourseOrgCount(req.getProjectId(), req.getCourseCount(), req.getOrgCount());
+    }
+
+    @Override
+    public List<ExamBean> queryAllExam(Long rootOrgId) {
+        Date now = new Date();
+        List<ExamBean> exams = new ArrayList<ExamBean>();
+        // 从考务获取启用的考试列表集合信息
+        GetExamListReq getExamListReq = new GetExamListReq();
+        getExamListReq.setEnable(true);// 启用的考试列表
+        getExamListReq.setRootOrgId(rootOrgId);
+        getExamListReq.setArchived(false);
+        for (;;) {
+            GetExamListResp getExamListResp = examCloudService.getExamList(getExamListReq);
+            if (getExamListResp.getExamList() == null || getExamListResp.getExamList().size() == 0) {
+                break;
+            } else {
+                exams.addAll(getExamListResp.getExamList());
+                getExamListReq.setStart(getExamListResp.getNext());
+            }
+        }
+        // 按一定条件过滤考试集合
+        exams = exams.stream().filter(exam -> {
+            if (!exam.getExamType().equals(ExamType.ONLINE.toString())) {
+                return false;
+            }
+            if (now.before(exam.getEndTime())) {
+                return false;
+            }
+            return true;
+        }).collect(Collectors.toList());
+        return exams;
+    }
+
+    @Transactional
+    @Override
+    public void delProject(Long id, Long rootOrgId) {
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000041", "项目不存在");
+        }
+        if (!rootOrgId.equals(pe.getRootOrgId())) {
+            throw new StatusException("1000042", "非法操作");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
+            throw new StatusException("1000044", "不能删除待计算的项目");
+        }
+        if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
+            throw new StatusException("1000045", "不能删除计算中的项目");
+        }
+        examOrgReportService.deleteByProject(id, rootOrgId);
+        examCourseDataReportService.deleteByProject(id, rootOrgId);
+        projectRepo.deleteByIdAndRootOrgId(id, rootOrgId);
+    }
+
+    @Transactional
+    @Override
+    public void updateProjectStatusByIds(UpdateProjectStatusByIdsReq req) {
+        List<Long> cids = req.getComputingProjectIds();
+        List<Long> sids = req.getStopingProjectIds();
+        if (cids != null && cids.size() != 0) {
+            for (Long id : cids) {
+                ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+                if (pe == null) {
+                    throw new StatusException("1000051", "项目不存在");
+                }
+                pe.setReportStatus(ReportStatus.WAITCOMPUTE);
+                projectRepo.save(pe);
+            }
+        }
+        if (sids != null && sids.size() != 0) {
+            for (Long id : sids) {
+                ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+                if (pe == null) {
+                    throw new StatusException("1000052", "项目不存在");
+                }
+                pe.setReportStatus(ReportStatus.STOP);
+                projectRepo.save(pe);
+            }
+        }
+    }
+
+    @Override
+    public ProjectBean getProject(Long id, Long rootOrgId) {
+        ProjectEntity pe = GlobalHelper.getEntity(projectRepo, id, ProjectEntity.class);
+        if (pe == null) {
+            throw new StatusException("1000061", "项目不存在");
+        }
+        if (!pe.getRootOrgId().equals(rootOrgId)) {
+            throw new StatusException("1000062", "非法操作");
+        }
+        ProjectBean bean = new ProjectBean();
+        BeanUtils.copyProperties(pe, bean);
+        bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
+        bean.setDataOriginName(bean.getDataOrigin().getDesc());
+        bean.setReportStatusName(bean.getReportStatus().getDesc());
+        if (StringUtils.isNotBlank(pe.getExamIds())) {
+            List<Long> temList = Arrays.asList(pe.getExamIds().split(",")).stream().map(str -> Long.parseLong(str))
+                    .collect(Collectors.toList());
+            bean.setExamIds(temList);
+        }
+        if (StringUtils.isNotBlank(pe.getPartitionDetails())) {
+            List<Double> temList = Arrays.asList(pe.getPartitionDetails().split(",")).stream()
+                    .map(str -> Double.parseDouble(str)).collect(Collectors.toList());
+            bean.setPartitionDetails(temList);
+        }
+        return bean;
+    }
+
+    @Override
+    public List<ProjectBean> getProjectList(List<Long> ids, Long rootOrgId) {
+        List<ProjectBean> ret = new ArrayList<ProjectBean>();
+        List<ProjectEntity> list = projectRepo.getByIds(ids, rootOrgId);
+        if (list != null) {
+            for (ProjectEntity pe : list) {
+                ProjectBean bean = new ProjectBean();
+                BeanUtils.copyProperties(pe, bean);
+                bean.setAnalyseTypeName(bean.getAnalyseType().getDesc());
+                bean.setDataOriginName(bean.getDataOrigin().getDesc());
+                bean.setReportStatusName(bean.getReportStatus().getDesc());
+                ret.add(bean);
+            }
+        }
+        return ret;
+    }
 }
 }