|
@@ -17,16 +17,8 @@ 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;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamStageRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStageEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.*;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.*;
|
|
|
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;
|
|
@@ -36,6 +28,7 @@ import cn.com.qmth.examcloud.support.Constants;
|
|
|
import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
|
import cn.com.qmth.examcloud.task.api.request.SyncExamStudentReq;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Example;
|
|
@@ -53,8 +46,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
@Autowired
|
|
|
ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamStageRepo examStageRepo;
|
|
|
+
|
|
|
@Autowired
|
|
|
ExamRepo examRepo;
|
|
|
|
|
@@ -109,6 +104,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void deleteExamStudentsByStudentIds(List<Long> ids) {
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
List<ExamStudentEntity> examStudents = examStudentRepo.findByIdIn(ids);
|
|
|
|
|
|
for (ExamStudentEntity examStudent : examStudents) {
|
|
@@ -116,39 +115,41 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
if (isStarted(examStudent.getExamId(), null, null)) {
|
|
|
throw new StatusException("150112", examStudent.getName() + "已开始考试,不能删除");
|
|
|
}
|
|
|
+
|
|
|
+ // 先删除网考模块考生
|
|
|
+ this.syncDeleteExamStudent(examStudent);
|
|
|
+
|
|
|
+ // 再删除考务模块考生
|
|
|
examStudentRepo.delete(examStudent);
|
|
|
|
|
|
- List<ExamStudentEntity> top2 = examStudentRepo.findTop2ByExamIdAndCourseId(
|
|
|
+ List<ExamStudentEntity> list1 = examStudentRepo.findTop2ByExamIdAndCourseId(
|
|
|
examStudent.getExamId(), examStudent.getCourseId());
|
|
|
- if (1 > top2.size()) {
|
|
|
+ if (list1.isEmpty()) {
|
|
|
examCourseRelationRepo.deleteByExamIdAndCourseId(examStudent.getExamId(), examStudent.getCourseId());
|
|
|
}
|
|
|
|
|
|
- top2 = examStudentRepo.findTop2ByExamIdAndCourseIdAndPaperType(examStudent.getExamId(),
|
|
|
- examStudent.getCourseId(), examStudent.getPaperType());
|
|
|
- if (1 > top2.size()) {
|
|
|
+ List<ExamStudentEntity> list2 = examStudentRepo.findTop2ByExamIdAndCourseIdAndPaperType(
|
|
|
+ examStudent.getExamId(), examStudent.getCourseId(), examStudent.getPaperType());
|
|
|
+ if (list2.isEmpty()) {
|
|
|
examPaperTypeRelationRepo.deleteByExamIdAndCourseIdAndPaperType(
|
|
|
- examStudent.getExamId(), examStudent.getCourseId(),
|
|
|
- examStudent.getPaperType());
|
|
|
+ examStudent.getExamId(), examStudent.getCourseId(), examStudent.getPaperType());
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- for (ExamStudentEntity cur : examStudents) {
|
|
|
- // 同步操作
|
|
|
- SyncExamStudentReq req = new SyncExamStudentReq();
|
|
|
- req.setSyncType("delete");
|
|
|
- req.setId(cur.getId());
|
|
|
- req.setCourseId(cur.getId());
|
|
|
- req.setCourseCode(cur.getCourseCode());
|
|
|
- req.setCourseName(cur.getCourseName());
|
|
|
- req.setExamId(cur.getId());
|
|
|
- req.setStudentId(cur.getStudentId());
|
|
|
- req.setStudentName(cur.getName());
|
|
|
- req.setIdentityNumber(cur.getIdentityNumber());
|
|
|
- req.setStudentCode(cur.getStudentCode());
|
|
|
- dataSyncCloudService.syncExamStudent(req);
|
|
|
- }
|
|
|
-
|
|
|
+ private void syncDeleteExamStudent(ExamStudentEntity examStudent) {
|
|
|
+ SyncExamStudentReq req = new SyncExamStudentReq();
|
|
|
+ req.setSyncType("delete");
|
|
|
+ req.setId(examStudent.getId());
|
|
|
+ req.setCourseId(examStudent.getId());
|
|
|
+ req.setCourseCode(examStudent.getCourseCode());
|
|
|
+ req.setCourseName(examStudent.getCourseName());
|
|
|
+ req.setExamId(examStudent.getId());
|
|
|
+ req.setStudentId(examStudent.getStudentId());
|
|
|
+ req.setStudentName(examStudent.getName());
|
|
|
+ req.setIdentityNumber(examStudent.getIdentityNumber());
|
|
|
+ req.setStudentCode(examStudent.getStudentCode());
|
|
|
+ dataSyncCloudService.syncExamStudent(req);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -160,6 +161,10 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
@Override
|
|
|
public void deleteExamStudentsByExamId(Long examId) {
|
|
|
ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
+ if (exam == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 已经开考
|
|
|
if (isStarted(exam.getId(), null, null)) {
|
|
|
throw new StatusException("150113", "该考试已开始,不能删除");
|
|
@@ -180,26 +185,27 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
deleteExamStudentsByStudentIds(IdList);
|
|
|
}
|
|
|
-
|
|
|
- private void disposeStage(Long examId,ExamStudentInfo info) {
|
|
|
- ExamStageEntity stage=null;
|
|
|
- if(info.getExamStageId()!=null) {
|
|
|
- stage= GlobalHelper.getEntity(examStageRepo, info.getExamStageId(), ExamStageEntity.class);
|
|
|
- if(stage==null) {
|
|
|
- throw new StatusException("examStageId 错误");
|
|
|
- }
|
|
|
- if(!examId.equals(stage.getExamId())) {
|
|
|
- throw new StatusException("examStageId 的场次的考试不一致");
|
|
|
- }
|
|
|
- info.setExamStageOrder(stage.getStageOrder());
|
|
|
- }else if(info.getExamStageOrder()!=null) {
|
|
|
- stage = examStageRepo.findByExamIdAndStageOrder(examId, info.getExamStageOrder());
|
|
|
- if(stage==null) {
|
|
|
- throw new StatusException("该场次号还未创建,场次号:"+info.getExamStageOrder());
|
|
|
+
|
|
|
+ private void disposeStage(Long examId, ExamStudentInfo info) {
|
|
|
+ ExamStageEntity stage = null;
|
|
|
+ if (info.getExamStageId() != null) {
|
|
|
+ stage = GlobalHelper.getEntity(examStageRepo, info.getExamStageId(), ExamStageEntity.class);
|
|
|
+ if (stage == null) {
|
|
|
+ throw new StatusException("examStageId 错误");
|
|
|
+ }
|
|
|
+ if (!examId.equals(stage.getExamId())) {
|
|
|
+ throw new StatusException("examStageId 的场次的考试不一致");
|
|
|
+ }
|
|
|
+ info.setExamStageOrder(stage.getStageOrder());
|
|
|
+ } else if (info.getExamStageOrder() != null) {
|
|
|
+ stage = examStageRepo.findByExamIdAndStageOrder(examId, info.getExamStageOrder());
|
|
|
+ if (stage == null) {
|
|
|
+ throw new StatusException("该场次号还未创建,场次号:" + info.getExamStageOrder());
|
|
|
}
|
|
|
info.setExamStageId(stage.getId());
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 实现
|
|
|
*
|
|
@@ -252,7 +258,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
} else {
|
|
|
throw new StatusException("100002", "examId,examCode,examName cannot be all empty");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
disposeStage(exam.getId(), examStudentInfo);
|
|
|
|
|
|
String identityNumber = examStudentInfo.getIdentityNumber();
|