宋悦 8 лет назад
Родитель
Сommit
f7e3acb958

+ 2 - 2
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -216,11 +216,11 @@ public class ExamStudentService {
 
 	public void checkExamStudent(ExamStudent examStudent){
 		if(examStudent.getId() != null){
-			if(examStudentRepo.checkExamStuById(examStudent.getRootOrgId(),examStudent.getIdentityNumber(),examStudent.getId()) > 0){
+			if(examStudentRepo.checkExamStuById(examStudent.getRootOrgId(),examStudent.getIdentityNumber(),examStudent.getCourseCode(),examStudent.getId()) > 0){
 				throw new RuntimeException("该考生已存在");
 			}
 		}else{
-			if(examStudentRepo.checkExamStu(examStudent.getRootOrgId(),examStudent.getIdentityNumber()) > 0){
+			if(examStudentRepo.checkExamStu(examStudent.getRootOrgId(),examStudent.getIdentityNumber(),examStudent.getCourseCode()) > 0){
 				throw new RuntimeException("该考生已存在");
 			}
 		}

+ 4 - 4
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/ExamStudentRepo.java

@@ -33,9 +33,9 @@ public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>, Query
     @Query("select s from ExamStudent s where s.exam.id = ?1 and s.courseCode = ?2 and (s.studentCode = ?3 or s.identityNumber = ?3)")
     ExamStudent findFirstByExamId(Long examId,String courseCode,String stuNumber);
 
-    @Query("select count(s) from ExamStudent s where s.rootOrgId=?1 and s.identityNumber = ?2 and s.id != ?3")
-    int checkExamStuById(Long rootOrgId,String identityNumber,Long id);
+    @Query("select count(s) from ExamStudent s where s.rootOrgId=?1 and s.identityNumber=?2 and s.courseCode=?3 and s.id <> ?4")
+    int checkExamStuById(Long rootOrgId,String identityNumber,String courseCode,Long id);
 
-    @Query("select count(s) from ExamStudent s where s.rootOrgId=?1 and s.identityNumber = ?2")
-    int checkExamStu(Long rootOrgId,String identityNumber);
+    @Query("select count(s) from ExamStudent s where s.rootOrgId=?1 and s.identityNumber=?2 and s.courseCode=?3")
+    int checkExamStu(Long rootOrgId,String identityNumber,String courseCode);
 }