wangwei %!s(int64=6) %!d(string=hai) anos
pai
achega
d99e3a966c

+ 2 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamCourseRelationRepo.java

@@ -22,4 +22,6 @@ public interface ExamCourseRelationRepo
 
 	void deleteByExamId(Long examId);
 
+	void deleteByExamIdAndCourseId(Long examId, Long courseId);
+
 }

+ 2 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamPaperTypeRelationRepo.java

@@ -19,4 +19,6 @@ public interface ExamPaperTypeRelationRepo
 
 	void deleteByExamId(Long examId);
 
+	void deleteByExamIdAndCourseIdAndPageType(Long examId, Long courseId, String pageType);
+
 }

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

@@ -35,4 +35,8 @@ public interface ExamStudentRepo
 	@Query("update ExamStudentEntity s set s.courseName = ?1, s.courseLevel  = ?2  where s.rootOrgId = ?3 and s.courseId=?4")
 	void updateCourse(String courseName, String courseLevel, Long rootOrgId, Long courseId);
 
+	int countByExamIdAndCourseIdAndPaperType(Long examId, Long courseId, String paperType);
+
+	int countByExamIdAndCourseId(Long examId, Long courseId);
+
 }

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

@@ -98,12 +98,28 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	@Override
 	public void deleteExamStudentsByStudentIds(List<Long> ids) {
 		List<ExamStudentEntity> examStudents = examStudentRepo.findByIdIn(ids);
+
 		for (ExamStudentEntity examStudent : examStudents) {
 			// 网考判断
 			if (isStarted(examStudent.getExamId(), null, null)) {
 				throw new StatusException("E-150112", examStudent.getName() + "已开始考试,不能删除");
 			}
 			examStudentRepo.delete(examStudent);
+
+			int countCourseId = examStudentRepo.countByExamIdAndCourseId(examStudent.getExamId(),
+					examStudent.getCourseId());
+			if (1 > countCourseId) {
+				examCourseRelationRepo.deleteByExamIdAndCourseId(examStudent.getExamId(),
+						examStudent.getCourseId());
+			}
+
+			int countPaperType = examStudentRepo.countByExamIdAndCourseIdAndPaperType(
+					examStudent.getExamId(), examStudent.getCourseId(), examStudent.getPaperType());
+			if (1 > countPaperType) {
+				examPaperTypeRelationRepo.deleteByExamIdAndCourseIdAndPageType(
+						examStudent.getExamId(), examStudent.getCourseId(),
+						examStudent.getPaperType());
+			}
 		}
 
 		for (ExamStudentEntity cur : examStudents) {