wangwei 6 years ago
parent
commit
023a1bb768

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

@@ -208,7 +208,7 @@ public class ExamStudentController extends ControllerSupport {
 			if (null != withStarted && withStarted) {
 				CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
 				checkExamIsStartedReq.setExamId(exam.getId());
-				checkExamIsStartedReq.setCourseCode(courseBean.getCode());
+				checkExamIsStartedReq.setCourseId(courseBean.getId());
 				checkExamIsStartedReq.setStudentId(studentBean.getId());
 				checkExamIsStartedReq.setExamId(exam.getId());
 				try {

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

@@ -1,6 +1,5 @@
 package cn.com.qmth.examcloud.core.examwork.service.impl;
 
-import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
@@ -31,6 +30,9 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
+import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
+import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckExamIsStartedReq;
+import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckExamIsStartedResp;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncExamStudentReq;
 
@@ -69,6 +71,19 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	@Autowired
 	DataSyncCloudService dataSyncCloudService;
 
+	@Autowired
+	ExamRecordCloudService examRecordCloudService;
+
+	private boolean isStarted(Long examId, Long StudentId, Long courseId) {
+		CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
+		checkExamIsStartedReq.setExamId(examId);
+		checkExamIsStartedReq.setCourseId(courseId);
+		checkExamIsStartedReq.setStudentId(StudentId);
+		CheckExamIsStartedResp checkExamIsStartedResp = examRecordCloudService
+				.checkExamIsStarted(checkExamIsStartedReq);
+		return checkExamIsStartedResp.getIsStarted();
+	}
+
 	/**
 	 * 方法注释
 	 *
@@ -80,7 +95,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		List<ExamStudentEntity> examStudents = examStudentRepo.findByIdIn(ids);
 		for (ExamStudentEntity examStudent : examStudents) {
 			// 网考判断
-			if (System.currentTimeMillis() > 0) {
+			if (isStarted(examStudent.getExamId(), null, null)) {
 				throw new StatusException("E-150112", examStudent.getName() + "已开始考试,不能删除");
 			}
 			examStudentRepo.delete(examStudent);
@@ -114,7 +129,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	public void deleteExamStudentsByExamId(Long examId) {
 		ExamEntity exam = examRepo.findOne(examId);
 		// 已经开考
-		if (exam.getBeginTime().before(new Date())) {
+		if (isStarted(exam.getId(), null, null)) {
 			throw new StatusException("E-150113", "该考试已开始,不能删除");
 		}
 		examStudentRepo.deleteByExamId(examId);