Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

lideyin 5 anni fa
parent
commit
fdd048ff20

+ 2 - 1
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -928,7 +928,8 @@ public class ExamController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime");
+		Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime",
+				"id");
 		Page<ExamSpecialSettingsEntity> page = examSpecialSettingsRepo.findAll(specification,
 				pageable);
 

+ 111 - 3
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamStudentCloudServiceProvider.java

@@ -45,6 +45,7 @@ import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean4Reset;
 import cn.com.qmth.examcloud.examwork.api.request.CopyExamStudentsReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPageReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
@@ -421,6 +422,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 		Long rootOrgId = req.getRootOrgId();
 		Long examId = req.getExamId();
 		String examCode = req.getExamCode();
+		String examName = req.getExamName();
 		Long studentId = req.getStudentId();
 		String identityNumber = req.getIdentityNumber();
 		Long courseId = req.getCourseId();
@@ -435,11 +437,18 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 		if (null != examId) {
 			examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
 			GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
-		} else if (StringUtils.isNotBlank(courseCode)) {
+		} else if (StringUtils.isNotBlank(examCode)) {
 			examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
 			if (null == examEntity) {
 				throw new StatusException("088002", "exam is not present");
 			}
+		} else if (StringUtils.isNotBlank(examName)) {
+			examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088003", "exam is not present");
+			}
+		} else {
+			throw new StatusException("088079", "examId,examCode,examName cannot be all empty");
 		}
 
 		if (null == courseId && StringUtils.isBlank(courseCode)) {
@@ -460,8 +469,8 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 		GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
 		StudentBean studentBean = gsResp.getStudentInfo();
 
-		ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId,
-				studentBean.getId(), courseBean.getId());
+		ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(
+				examEntity.getId(), studentBean.getId(), courseBean.getId());
 
 		es.setEnable(enable);
 
@@ -477,7 +486,106 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 	@Override
 	public ResetExamStudentResp resetExamStudent(@RequestBody ResetExamStudentReq req) {
 
+		Long rootOrgId = req.getRootOrgId();
+		Long examId = req.getExamId();
+		String examCode = req.getExamCode();
+		String examName = req.getExamName();
+		Long studentId = req.getStudentId();
+		String identityNumber = req.getIdentityNumber();
+		String studentName = req.getStudentName();
+		String studentCode = req.getStudentCode();
+
+		if (null == rootOrgId) {
+			throw new StatusException("088001", "rootOrgId is null");
+		}
+
+		ExamEntity examEntity = null;
+		if (null != examId) {
+			examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
+			GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
+		} else if (StringUtils.isNotBlank(examCode)) {
+			examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088002", "exam is not present");
+			}
+		} else if (StringUtils.isNotBlank(examName)) {
+			examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088003", "exam is not present");
+			}
+		} else {
+			throw new StatusException("088075", "examId,examCode,examName cannot be all empty");
+		}
+
+		GetStudentReq gsReq = new GetStudentReq();
+		gsReq.setRootOrgId(rootOrgId);
+		gsReq.setIdentityNumber(identityNumber);
+		gsReq.setStudentId(studentId);
+		gsReq.setStudentCode(studentCode);
+
+		GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
+		StudentBean studentBean = gsResp.getStudentInfo();
+
+		examStudentRepo.updateExamStudnetDisabled(examId, studentBean.getId());
+
+		List<ExamStudentBean4Reset> examStudentList = req.getExamStudentList();
+		List<ExamStudentBean> savedExamStudentList = Lists.newArrayList();
+
+		for (ExamStudentBean4Reset cur : examStudentList) {
+
+			ExamStudentInfo info = new ExamStudentInfo();
+			info.setCourseCode(cur.getCourseCode());
+			info.setCourseName(cur.getCourseName());
+			info.setCourseLevel(cur.getCourseLevel());
+			info.setCourseId(cur.getCourseId());
+			info.setRootOrgId(req.getRootOrgId());
+			info.setExamId(req.getExamId());
+			info.setExamCode(req.getExamCode());
+			info.setExamName(examEntity.getName());
+			info.setIdentityNumber(identityNumber);
+			info.setPaperType(cur.getPaperType());
+			info.setStudentCode(studentCode);
+			info.setStudentName(studentName);
+			info.setInfoCollector(cur.getInfoCollector());
+			info.setGrade(cur.getGrade());
+			info.setExamSite(cur.getExamSite());
+			info.setSpecialtyName(cur.getSpecialtyName());
+			info.setRemark(cur.getRemark());
+			info.setEnable(true);
+
+			info.setExt1(cur.getExt1());
+			info.setExt2(cur.getExt2());
+			info.setExt3(cur.getExt3());
+			info.setExt4(cur.getExt4());
+			info.setExt5(cur.getExt5());
+
+			ExamStudentInfo saved = examStudentService.saveExamStudent(info);
+
+			ExamStudentBean examStudentBean = new ExamStudentBean();
+			examStudentBean.setId(saved.getId());
+			examStudentBean.setCourseCode(saved.getCourseCode());
+			examStudentBean.setCourseLevel(saved.getCourseLevel());
+			examStudentBean.setCourseName(saved.getCourseName());
+			examStudentBean.setExamId(saved.getExamId());
+			examStudentBean.setExamName(saved.getExamName());
+			examStudentBean.setIdentityNumber(saved.getIdentityNumber());
+			examStudentBean.setStudentCode(saved.getStudentCode());
+			examStudentBean.setPaperType(saved.getPaperType());
+			examStudentBean.setRootOrgId(saved.getRootOrgId());
+			examStudentBean.setStudentName(saved.getStudentName());
+			examStudentBean.setGrade(saved.getGrade());
+			examStudentBean.setCourseId(saved.getCourseId());
+			examStudentBean.setInfoCollector(saved.getInfoCollector());
+			examStudentBean.setExamSite(saved.getExamSite());
+			examStudentBean.setOrgId(saved.getOrgId());
+			examStudentBean.setOrgCode(saved.getOrgCode());
+			examStudentBean.setOrgName(saved.getOrgName());
+
+			savedExamStudentList.add(examStudentBean);
+		}
+
 		ResetExamStudentResp resp = new ResetExamStudentResp();
+		resp.setExamStudentList(savedExamStudentList);
 		return resp;
 	}
 

+ 5 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -79,4 +79,9 @@ public interface ExamStudentRepo
 	List<Long> findByExamIdLimitStudentIdList(@Param("rootOrgId") Long rootOrgId,
 			@Param("examIds") List<Long> examIds, @Param("maxStudentId") Long maxStudentId,
 			@Param("rowNumber") int rowNumber);
+
+	@Modifying
+	@Query("update ExamStudentEntity s set s.enable = false where s.examId = ?1 and s.studentId = ?2")
+	void updateExamStudnetDisabled(Long examId, Long studentId);
+
 }

+ 26 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamStudentInfo.java

@@ -21,6 +21,11 @@ public class ExamStudentInfo {
 	 */
 	private Long examId;
 
+	/**
+	 * 考试编码
+	 */
+	private String examCode;
+
 	/**
 	 * 考试名称
 	 */
@@ -81,6 +86,11 @@ public class ExamStudentInfo {
 	 */
 	private String courseLevel;
 
+	/**
+	 * 是否可用
+	 */
+	private Boolean enable;
+
 	/**
 	 * 试卷类型
 	 */
@@ -160,6 +170,14 @@ public class ExamStudentInfo {
 		this.examId = examId;
 	}
 
+	public String getExamCode() {
+		return examCode;
+	}
+
+	public void setExamCode(String examCode) {
+		this.examCode = examCode;
+	}
+
 	public String getExamName() {
 		return examName;
 	}
@@ -344,4 +362,12 @@ public class ExamStudentInfo {
 		this.ext5 = ext5;
 	}
 
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
 }

+ 13 - 1
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -210,19 +210,25 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		ExamEntity exam = null;
 		Long examId = examStudentInfo.getExamId();
 		String examName = examStudentInfo.getExamName();
+		String examCode = examStudentInfo.getExamCode();
 
 		if (null != examId) {
 			exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
 			if (null == exam) {
 				throw new StatusException("100020", "examId is wrong");
 			}
+		} else if (StringUtils.isNotBlank(examCode)) {
+			exam = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
+			if (null == exam) {
+				throw new StatusException("1000050", "考试不存在");
+			}
 		} else if (StringUtils.isNotBlank(examName)) {
 			exam = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
 			if (null == exam) {
 				throw new StatusException("100005", "考试不存在");
 			}
 		} else {
-			throw new StatusException("100002", "examId & examName are both blank");
+			throw new StatusException("100002", "examId,examCode,examName cannot be all empty");
 		}
 
 		String identityNumber = examStudentInfo.getIdentityNumber();
@@ -306,6 +312,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		examStudent.setExt4(examStudentInfo.getExt4());
 		examStudent.setExt5(examStudentInfo.getExt5());
 
+		Boolean enable = examStudentInfo.getEnable();
+
+		if (null != enable) {
+			examStudent.setEnable(enable);
+		}
+
 		ExamStudentEntity saved = examStudentRepo.save(examStudent);
 
 		ExamCourseRelationEntity relation = new ExamCourseRelationEntity();