WANG %!s(int64=6) %!d(string=hai) anos
pai
achega
dca49b1d3c

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

@@ -374,7 +374,9 @@ public class ExamStudentController extends ControllerSupport {
 		saveStudentReq.setOrgId(examStudent.getOrgId());
 		saveStudentReq.setRemark(examStudent.getRemark());
 		saveStudentReq.setRootOrgId(examStudent.getRootOrgId());
-		saveStudentReq.setStudentCode(examStudent.getStudentCode());
+		List<String> studentCodeList = Lists.newArrayList();
+		studentCodeList.add(examStudent.getStudentCode());
+		saveStudentReq.setStudentCodeList(studentCodeList);
 
 		SaveStudentResp saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
 

+ 14 - 3
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/HandleSyncCloudServiceProvider.java

@@ -1,5 +1,8 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
+import java.util.List;
+
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -95,7 +98,7 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport
 	public SyncStudentResp syncStudent(@RequestBody SyncStudentReq req) {
 		String name = req.getName();
 		Long id = req.getId();
-		String studentCode = req.getStudentCode();
+		List<String> unboundStudentCodeList = req.getUnboundStudentCodeList();
 
 		if (StringUtils.isBlank(name)) {
 			throw new StatusException("100001", "name is null");
@@ -104,8 +107,16 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport
 			throw new StatusException("100002", "id is null");
 		}
 
-		examStudentRepo.updateStudent(name, studentCode, id);
-		return null;
+		examStudentRepo.updateStudentName(name, id);
+
+		if (CollectionUtils.isNotEmpty(unboundStudentCodeList)) {
+			for (String cur : unboundStudentCodeList) {
+				examStudentRepo.unboundStudentCode(cur, id);
+			}
+		}
+
+		SyncStudentResp resp = new SyncStudentResp();
+		return resp;
 	}
 
 	@ApiOperation(value = "同步考生")

+ 6 - 2
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -28,8 +28,12 @@ public interface ExamStudentRepo
 			Long courseId);
 
 	@Modifying
-	@Query("update ExamStudentEntity s set s.name = ?1, s.studentCode=?2 where s.studentId = ?3")
-	void updateStudent(String name, String studentCode, Long studentId);
+	@Query("update ExamStudentEntity s set s.studentCode=null where s.studentCode= ?1 and s.studentId = ?2")
+	void unboundStudentCode(String studentCode, Long studentId);
+
+	@Modifying
+	@Query("update ExamStudentEntity s set s.name = ?1 where s.studentId = ?2")
+	void updateStudentName(String name, Long studentId);
 
 	@Modifying
 	@Query("update ExamStudentEntity s set s.courseName = ?1, s.courseLevel  = ?2  where s.courseId = ?3")

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

@@ -190,6 +190,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	@Override
 	public ExamStudentInfo saveExamStudent(ExamStudentInfo examStudentInfo) {
 		String paperType = examStudentInfo.getPaperType();
+		String studentCode = examStudentInfo.getStudentCode();
+
 		if (StringUtils.isBlank(paperType)) {
 			paperType = "X";
 		} else if (!paperType.matches("[A-Z]")) {
@@ -235,6 +237,15 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
 		StudentBean studentInfo = getStudentResp.getStudentInfo();
 
+		if (StringUtils.isNotBlank(studentCode)) {
+			List<String> studentCodeList = studentInfo.getStudentCodeList();
+			if (!studentCodeList.contains(studentCode)) {
+				throw new StatusException("100063", "学号未绑定到身份证");
+			}
+		} else {
+			studentCode = null;
+		}
+
 		String courseCode = examStudentInfo.getCourseCode();
 		String courseName = examStudentInfo.getCourseName();
 		String courseLevel = examStudentInfo.getCourseLevel();
@@ -279,7 +290,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
 		examStudent.setExamId(exam.getId());
 		examStudent.setIdentityNumber(studentInfo.getIdentityNumber());
-		examStudent.setStudentCode(studentInfo.getStudentCode());
+		examStudent.setStudentCode(studentCode);
 		examStudent.setPaperType(paperType);
 		examStudent.setStudentId(studentInfo.getId());
 		examStudent.setOrgId(studentInfo.getOrgId());