WANG 5 years ago
parent
commit
9cfc0bbaeb

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

@@ -224,6 +224,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 			ExamStudentInfo one = new ExamStudentInfo();
 			one.setExamId(examId2);
 			one.setRootOrgId(es.getRootOrgId());
+			one.setEnable(es.getEnable());
 
 			one.setCourseId(es.getCourseId());
 			one.setCourseCode(es.getCourseCode());
@@ -476,6 +477,8 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 		ExamStudentEntity saved = examStudentRepo.save(es);
 
+		examStudentService.syncExamStudent(saved.getId());
+
 		UpdateExamStudentStatusResp resp = new UpdateExamStudentStatusResp();
 		resp.setExamStudentId(saved.getId());
 		return resp;
@@ -526,7 +529,14 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 		GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
 		StudentBean studentBean = gsResp.getStudentInfo();
 
-		examStudentRepo.updateExamStudnetDisabled(examId, studentBean.getId());
+		List<ExamStudentEntity> presentExamStudentList = examStudentRepo
+				.findByExamIdAndStudentId(examId, studentBean.getId());
+
+		for (ExamStudentEntity cur : presentExamStudentList) {
+			cur.setEnable(false);
+			examStudentRepo.save(cur);
+			examStudentService.syncExamStudent(cur.getId());
+		}
 
 		List<ExamStudentBean4Reset> examStudentList = req.getExamStudentList();
 		List<ExamStudentBean> savedExamStudentList = Lists.newArrayList();

+ 1 - 3
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -80,8 +80,6 @@ public interface ExamStudentRepo
 			@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);
+	List<ExamStudentEntity> findByExamIdAndStudentId(Long examId, Long studentId);
 
 }

+ 2 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/ExamStudentService.java

@@ -19,4 +19,6 @@ public interface ExamStudentService {
 
 	public void deleteExamStudentsByStudentIds(List<Long> studentIds);
 
+	public void syncExamStudent(Long studentId);
+
 }

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

@@ -13,9 +13,11 @@ import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
 import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
 import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
 import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
@@ -393,4 +395,60 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
 		return ret;
 	}
+
+	@Override
+	public void syncExamStudent(Long studentId) {
+
+		ExamStudentEntity saved = GlobalHelper.getPresentEntity(examStudentRepo, studentId,
+				ExamStudentEntity.class);
+
+		GetCourseReq gcReq = new GetCourseReq();
+		gcReq.setRootOrgId(saved.getRootOrgId());
+		gcReq.setCode(saved.getCourseCode());
+		gcReq.setId(saved.getCourseId());
+		GetCourseResp gcResp = courseCloudService.getCourse(gcReq);
+		CourseBean courseBean = gcResp.getCourseBean();
+
+		GetStudentReq getStudentReq = new GetStudentReq();
+		getStudentReq.setRootOrgId(saved.getRootOrgId());
+		getStudentReq.setIdentityNumber(saved.getIdentityNumber());
+		GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
+		StudentBean studentInfo = getStudentResp.getStudentInfo();
+
+		ExamEntity exam = GlobalHelper.getEntity(examRepo, saved.getExamId(), ExamEntity.class);
+
+		// 同步操作
+		SyncExamStudentReq req = new SyncExamStudentReq();
+		req.setSyncType("update");
+		req.setId(saved.getId());
+
+		req.setEnable(saved.getEnable());
+
+		req.setCourseId(courseBean.getId());
+		req.setCourseCode(courseBean.getCode());
+		req.setCourseLevel(courseBean.getLevel());
+		req.setCourseName(courseBean.getName());
+
+		req.setExamId(exam.getId());
+		req.setExamName(exam.getName());
+
+		req.setRootOrgId(saved.getRootOrgId());
+		req.setStudentId(saved.getId());
+		req.setStudentName(saved.getName());
+		req.setIdentityNumber(saved.getIdentityNumber());
+		req.setStudentCode(saved.getStudentCode());
+		req.setOrgId(saved.getOrgId());
+		req.setOrgName(studentInfo.getOrgName());
+		req.setOrgCode(saved.getOrgCode());
+
+		req.setGrade(saved.getGrade());
+		req.setSpecialtyName(saved.getSpecialtyName());
+		req.setPaperType(saved.getPaperType());
+		req.setRemark(saved.getRemark());
+		req.setInfoCollector(saved.getInfoCollector());
+		req.setExamSite(saved.getExamSite());
+
+		dataSyncCloudService.syncExamStudent(req);
+	}
+
 }