瀏覽代碼

报表页面

xiatian 5 年之前
父節點
當前提交
b2a8e53ec6

+ 11 - 1
examcloud-core-reports-api-provider/src/main/java/cn/com/qmth/examcloud/core/reports/api/provider/ProjectCloudServiceProvider.java

@@ -10,9 +10,11 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.reports.api.ProjectCloudService;
 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.api.response.GetProjectInfoBeanResp;
 import cn.com.qmth.examcloud.core.reports.api.response.UpdateProjectCourseOrgCountResp;
+import cn.com.qmth.examcloud.core.reports.api.response.UpdateProjectStatusByIdsResp;
 import cn.com.qmth.examcloud.core.reports.api.response.UpdateProjectStatusResp;
 import cn.com.qmth.examcloud.core.reports.service.ProjectService;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
@@ -32,7 +34,7 @@ public class ProjectCloudServiceProvider extends ControllerSupport implements Pr
 	@Autowired
 	private ProjectService projectService;
 
-	@ApiOperation(value = "批量保存")
+	@ApiOperation(value = "修改状态")
     @PostMapping("/updateStatus")
 	@Override
 	public UpdateProjectStatusResp updateProjectStatus(@RequestBody UpdateProjectStatusReq req) {
@@ -63,4 +65,12 @@ public class ProjectCloudServiceProvider extends ControllerSupport implements Pr
 		return new UpdateProjectCourseOrgCountResp();
 	}
 
+	@ApiOperation(value = "批量修改状态")
+    @PostMapping("/updateStatusByIds")
+	@Override
+	public UpdateProjectStatusByIdsResp updateProjectStatusByIds(@RequestBody UpdateProjectStatusByIdsReq req) {
+		projectService.updateProjectStatusByIds(req);
+		return new UpdateProjectStatusByIdsResp();
+	}
+
 }

+ 11 - 1
examcloud-core-reports-base/src/main/java/cn/com/qmth/examcloud/core/reports/base/bean/QueryProjectPageReq.java

@@ -32,7 +32,9 @@ public class QueryProjectPageReq implements JsonSerializable {
     @ApiModelProperty(value = "数据来源")
 	@Enumerated(EnumType.STRING)
 	private DataOrigin dataOrigin;
-
+    // 启用禁用
+    @ApiModelProperty(value = "启用禁用")
+	private Boolean enable;
 	public Long getId() {
 		return id;
 	}
@@ -65,5 +67,13 @@ public class QueryProjectPageReq implements JsonSerializable {
 		this.dataOrigin = dataOrigin;
 	}
 
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
 	
 }

+ 7 - 7
examcloud-core-reports-base/src/main/java/cn/com/qmth/examcloud/core/reports/base/bean/UpdateProjectScoreReq.java

@@ -25,7 +25,7 @@ public class UpdateProjectScoreReq implements JsonSerializable {
 	private Double passScore;
 	@NotEmpty(message = "项目分段分数不能为空")
 	@ApiModelProperty(value = "项目分段分数")
-	private List<Double> scores;
+	private List<Double> partitionDetails;
 	public Long getId() {
 		return id;
 	}
@@ -38,18 +38,18 @@ public class UpdateProjectScoreReq implements JsonSerializable {
 	public void setTotalScore(Double totalScore) {
 		this.totalScore = totalScore;
 	}
-	public List<Double> getScores() {
-		return scores;
-	}
-	public void setScores(List<Double> scores) {
-		this.scores = scores;
-	}
 	public Double getPassScore() {
 		return passScore;
 	}
 	public void setPassScore(Double passScore) {
 		this.passScore = passScore;
 	}
+	public List<Double> getPartitionDetails() {
+		return partitionDetails;
+	}
+	public void setPartitionDetails(List<Double> partitionDetails) {
+		this.partitionDetails = partitionDetails;
+	}
 	
 	
 

+ 2 - 0
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/ProjectService.java

@@ -6,6 +6,7 @@ import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
 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;
@@ -28,4 +29,5 @@ public interface ProjectService {
 	public ProjectEntity findProjectById(Long projectId);
 	public void updateProjectCourseOrgCount(UpdateProjectCourseOrgCountReq req);
 	public List<ExamBean> queryAllExam(Long rootOrgId);
+	public void updateProjectStatusByIds(UpdateProjectStatusByIdsReq req) ;
 }

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

@@ -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);
+			}
+		}
 	}
 }