|
@@ -30,6 +30,7 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.bean.ProjectInfoBean;
|
|
|
import cn.com.qmth.examcloud.core.reports.api.request.GetProjectInfoBeanReq;
|
|
|
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.base.bean.AddProjectReq;
|
|
|
import cn.com.qmth.examcloud.core.reports.base.bean.ProjectBean;
|
|
@@ -55,19 +56,20 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
@Service
|
|
|
public class ProjectServiceImpl implements ProjectService {
|
|
|
@Autowired
|
|
|
- private ExamOrgReportService examOrgReportService;
|
|
|
+ private ExamOrgReportService examOrgReportService;
|
|
|
@Autowired
|
|
|
- private ExamCourseDataReportService examCourseDataReportService;
|
|
|
+ private ExamCourseDataReportService examCourseDataReportService;
|
|
|
@Autowired
|
|
|
- private ExamCloudService examCloudService;
|
|
|
+ private ExamCloudService examCloudService;
|
|
|
@Autowired
|
|
|
private ProjectRepo projectRepo;
|
|
|
@Autowired
|
|
|
private ReportsComputeCloudService reportsComputeCloudService;
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Long addProject(AddProjectReq req, Long rootOrgId) {
|
|
|
- Date now=new Date();
|
|
|
+ Date now = new Date();
|
|
|
ProjectEntity pe = new ProjectEntity();
|
|
|
BeanUtils.copyProperties(req, pe);
|
|
|
pe.setCreationTime(now);
|
|
@@ -76,7 +78,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
pe.setEnable(true);
|
|
|
pe.setReportStatus(ReportStatus.NONE);
|
|
|
pe.setExamIds(StringUtils.join(req.getExamIds().toArray(), ","));
|
|
|
- if(pe.getDataOrigin().equals(DataOrigin.SYNC)) {
|
|
|
+ if (pe.getDataOrigin().equals(DataOrigin.SYNC)) {
|
|
|
pe.setSampleCount(req.getExamIds().size());
|
|
|
}
|
|
|
projectRepo.save(pe);
|
|
@@ -126,6 +128,9 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
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));
|
|
|
}
|
|
@@ -177,15 +182,15 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
if (pe == null) {
|
|
|
throw new StatusException("1000003", "项目不存在");
|
|
|
}
|
|
|
- if(req.getStatus()==2) {
|
|
|
+ if (req.getStatus() == 2) {
|
|
|
pe.setReportStatus(ReportStatus.COMPUTING);
|
|
|
- }else if(req.getStatus()==3) {
|
|
|
+ } else if (req.getStatus() == 3) {
|
|
|
pe.setReportStatus(ReportStatus.SUCCESS);
|
|
|
- }else if(req.getStatus()==4) {
|
|
|
+ } else if (req.getStatus() == 4) {
|
|
|
pe.setReportStatus(ReportStatus.FAIL);
|
|
|
- }else if(req.getStatus()==5) {
|
|
|
+ } else if (req.getStatus() == 5) {
|
|
|
pe.setReportStatus(ReportStatus.STOP);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new StatusException("1000004", "无效的Status");
|
|
|
}
|
|
|
projectRepo.save(pe);
|
|
@@ -200,13 +205,13 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
if (pe == null) {
|
|
|
throw new StatusException("1000006", "项目不存在");
|
|
|
}
|
|
|
- ProjectInfoBean bean=new ProjectInfoBean();
|
|
|
+ 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());
|
|
|
+ List<Double> partitionDetails = Arrays.asList(pe.getPartitionDetails().split(",")).stream()
|
|
|
+ .map(str -> Double.parseDouble(str)).collect(Collectors.toList());
|
|
|
bean.setPartitionDetails(partitionDetails);
|
|
|
return bean;
|
|
|
}
|
|
@@ -214,73 +219,77 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void addReportsCompute(Long id, Long rootOrgId) {
|
|
|
- ProjectEntity pe = GlobalHelper.getEntity(projectRepo,id, ProjectEntity.class);
|
|
|
+ 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()) {
|
|
|
+ if (!pe.getEnable()) {
|
|
|
throw new StatusException("1000023", "项目已禁用");
|
|
|
}
|
|
|
- if(pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
|
|
|
+ if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
|
|
|
throw new StatusException("1000024", "项目已处于待计算状态");
|
|
|
}
|
|
|
- if(pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
|
|
|
+ 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();
|
|
|
+ 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);
|
|
|
+ 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()) {
|
|
|
+ if (!pe.getEnable()) {
|
|
|
throw new StatusException("1000033", "项目已禁用");
|
|
|
}
|
|
|
- if(pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
|
|
|
+ if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
|
|
|
throw new StatusException("1000034", "项目已处于待计算状态");
|
|
|
}
|
|
|
- if(pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
|
|
|
+ if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
|
|
|
throw new StatusException("1000035", "项目已处于计算状态");
|
|
|
}
|
|
|
- Double passScore=req.getPassScore();
|
|
|
- Double totalScore=req.getTotalScore();
|
|
|
- if(passScore<=0) {
|
|
|
+ Double passScore = req.getPassScore();
|
|
|
+ Double totalScore = req.getTotalScore();
|
|
|
+ if (passScore <= 0) {
|
|
|
throw new StatusException("1000036", "及格分数必须大于0");
|
|
|
}
|
|
|
- if(totalScore<=0) {
|
|
|
+ if (totalScore <= 0) {
|
|
|
throw new StatusException("1000037", "满分分数必须大于0");
|
|
|
}
|
|
|
- if(passScore>totalScore) {
|
|
|
+ if (passScore > totalScore) {
|
|
|
throw new StatusException("1000038", "及格分数不能大于满分分数");
|
|
|
}
|
|
|
- List<Double> scores=req.getScores();
|
|
|
- Set<Double> set=new HashSet<Double>();
|
|
|
- for(Double d:scores) {
|
|
|
+ List<Double> scores = req.getPartitionDetails();
|
|
|
+ Set<Double> set = new HashSet<Double>();
|
|
|
+ for (Double d : scores) {
|
|
|
set.add(d);
|
|
|
}
|
|
|
- if(set.size()!=scores.size()) {
|
|
|
+ if (set.size() != scores.size()) {
|
|
|
throw new StatusException("1000039", "分段分数不能相同");
|
|
|
}
|
|
|
Collections.sort(scores);
|
|
|
- if(scores.get(0)<=0) {
|
|
|
+ if (scores.get(0) <= 0) {
|
|
|
throw new StatusException("1000040", "第一个分段分数必须大于0");
|
|
|
}
|
|
|
- if(scores.get(scores.size()-1)>=totalScore) {
|
|
|
+ if (scores.get(scores.size() - 1) >= totalScore) {
|
|
|
throw new StatusException("1000041", "最后一个分段分数必须小于满分分数");
|
|
|
}
|
|
|
pe.setUpdateTime(new Date());
|
|
@@ -288,13 +297,18 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
pe.setTotalScore(totalScore);
|
|
|
pe.setPartitionCount(scores.size());
|
|
|
pe.setPartitionDetails(StringUtils.join(scores.toArray(), ","));
|
|
|
- pe.setReportStatus(ReportStatus.WAITCOMPUTE);
|
|
|
+ if (!ReportStatus.NONE.equals(pe.getReportStatus())) {
|
|
|
+ pe.setReportStatus(ReportStatus.WAITCOMPUTE);
|
|
|
+ }
|
|
|
projectRepo.saveAndFlush(pe);
|
|
|
- AddReportsComputeReq areq=new AddReportsComputeReq();
|
|
|
- areq.setProjectId(id);
|
|
|
- areq.setRootOrgId(rootOrgId);
|
|
|
- reportsComputeCloudService.addReportsCompute(areq);
|
|
|
+ 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);
|
|
@@ -306,54 +320,82 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
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.PRACTICE.toString())) {//练习不创建
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(now.before(exam.getEndTime())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- return exams;
|
|
|
+ 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);
|
|
|
+ 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)) {
|
|
|
+ if (pe.getReportStatus().equals(ReportStatus.WAITCOMPUTE)) {
|
|
|
throw new StatusException("1000044", "不能删除待计算的项目");
|
|
|
}
|
|
|
- if(pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
|
|
|
+ if (pe.getReportStatus().equals(ReportStatus.COMPUTING)) {
|
|
|
throw new StatusException("1000045", "不能删除计算中的项目");
|
|
|
}
|
|
|
examOrgReportService.deleteByProject(id, rootOrgId);
|
|
|
examCourseDataReportService.deleteByProject(id, rootOrgId);
|
|
|
- projectRepo.deleteByIdAndRootOrgId(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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|