wangwei il y a 6 ans
Parent
commit
8e8114c04b

+ 16 - 1
examcloud-exchange-outer-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/controller/sydx/StudentExamInfoController.java

@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
 import cn.com.qmth.examcloud.core.basic.api.request.SaveStudentReq;
+import cn.com.qmth.examcloud.core.basic.api.request.UnbindStudentCodeReq;
 import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentResp;
 import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
@@ -123,7 +124,21 @@ public class StudentExamInfoController extends ControllerSupport {
 			saveStudentReq.setRootOrgId(rootOrgId);
 			saveStudentReq.setStudentCode(cur.getStudentCode());
 
-			SaveStudentResp saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
+			SaveStudentResp saveStudentResp = null;
+			try {
+				saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
+			} catch (StatusException e) {
+				String code = e.getCode();
+				if (code.equals("B-160005") || code.equals("B-160008")) {
+					UnbindStudentCodeReq unbindStudentCodeReq = new UnbindStudentCodeReq();
+					unbindStudentCodeReq.setRootOrgId(rootOrgId);
+					unbindStudentCodeReq.setStudentCode(cur.getStudentCode());
+					studentCloudService.unbindStudentCode(unbindStudentCodeReq);
+					saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
+				} else {
+					throw e;
+				}
+			}
 
 			Long studentId = saveStudentResp.getStudentId();