|
@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.reports.service.impl;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
|
+import java.util.Date;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
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.bean.ProjectInfoBean;
|
|
@@ -39,7 +41,13 @@ import cn.com.qmth.examcloud.core.reports.base.enums.DataOrigin;
|
|
import cn.com.qmth.examcloud.core.reports.base.enums.ReportStatus;
|
|
import cn.com.qmth.examcloud.core.reports.base.enums.ReportStatus;
|
|
import cn.com.qmth.examcloud.core.reports.dao.ProjectRepo;
|
|
import cn.com.qmth.examcloud.core.reports.dao.ProjectRepo;
|
|
import cn.com.qmth.examcloud.core.reports.dao.entity.ProjectEntity;
|
|
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;
|
|
import cn.com.qmth.examcloud.core.reports.service.ProjectService;
|
|
import cn.com.qmth.examcloud.core.reports.service.ProjectService;
|
|
|
|
+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.GetExamListReq;
|
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamListResp;
|
|
import cn.com.qmth.examcloud.task.api.ReportsComputeCloudService;
|
|
import cn.com.qmth.examcloud.task.api.ReportsComputeCloudService;
|
|
import cn.com.qmth.examcloud.task.api.request.AddReportsComputeReq;
|
|
import cn.com.qmth.examcloud.task.api.request.AddReportsComputeReq;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
@@ -47,18 +55,30 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
@Service
|
|
@Service
|
|
public class ProjectServiceImpl implements ProjectService {
|
|
public class ProjectServiceImpl implements ProjectService {
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private ExamOrgReportService examOrgReportService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamCourseDataReportService examCourseDataReportService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamCloudService examCloudService;
|
|
|
|
+ @Autowired
|
|
private ProjectRepo projectRepo;
|
|
private ProjectRepo projectRepo;
|
|
@Autowired
|
|
@Autowired
|
|
private ReportsComputeCloudService reportsComputeCloudService;
|
|
private ReportsComputeCloudService reportsComputeCloudService;
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public Long addProject(AddProjectReq req, Long rootOrgId) {
|
|
public Long addProject(AddProjectReq req, Long rootOrgId) {
|
|
|
|
+ Date now=new Date();
|
|
ProjectEntity pe = new ProjectEntity();
|
|
ProjectEntity pe = new ProjectEntity();
|
|
BeanUtils.copyProperties(req, pe);
|
|
BeanUtils.copyProperties(req, pe);
|
|
|
|
+ pe.setCreationTime(now);
|
|
|
|
+ pe.setUpdateTime(now);
|
|
pe.setRootOrgId(rootOrgId);
|
|
pe.setRootOrgId(rootOrgId);
|
|
pe.setEnable(true);
|
|
pe.setEnable(true);
|
|
pe.setReportStatus(ReportStatus.NONE);
|
|
pe.setReportStatus(ReportStatus.NONE);
|
|
pe.setExamIds(StringUtils.join(req.getExamIds().toArray(), ","));
|
|
pe.setExamIds(StringUtils.join(req.getExamIds().toArray(), ","));
|
|
|
|
+ if(pe.getDataOrigin().equals(DataOrigin.SYNC)) {
|
|
|
|
+ pe.setSampleCount(req.getExamIds().size());
|
|
|
|
+ }
|
|
projectRepo.save(pe);
|
|
projectRepo.save(pe);
|
|
return pe.getId();
|
|
return pe.getId();
|
|
}
|
|
}
|
|
@@ -263,6 +283,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
if(scores.get(scores.size()-1)>=totalScore) {
|
|
if(scores.get(scores.size()-1)>=totalScore) {
|
|
throw new StatusException("1000041", "最后一个分段分数必须小于满分分数");
|
|
throw new StatusException("1000041", "最后一个分段分数必须小于满分分数");
|
|
}
|
|
}
|
|
|
|
+ pe.setUpdateTime(new Date());
|
|
pe.setPassScore(passScore);
|
|
pe.setPassScore(passScore);
|
|
pe.setTotalScore(totalScore);
|
|
pe.setTotalScore(totalScore);
|
|
pe.setPartitionCount(scores.size());
|
|
pe.setPartitionCount(scores.size());
|
|
@@ -285,4 +306,54 @@ public class ProjectServiceImpl implements ProjectService {
|
|
public void updateProjectCourseOrgCount(UpdateProjectCourseOrgCountReq req) {
|
|
public void updateProjectCourseOrgCount(UpdateProjectCourseOrgCountReq req) {
|
|
projectRepo.updateProjectCourseOrgCount(req.getProjectId(), req.getCourseCount(), req.getOrgCount());
|
|
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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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);
|
|
|
|
+ }
|
|
}
|
|
}
|