wangwei 7 tahun lalu
induk
melakukan
cb0039689b

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

@@ -2,12 +2,18 @@ package cn.com.qmth.examcloud.core.examwork.api.provider;
 
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.BeanCopierUtil;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
@@ -29,31 +35,54 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 			ExamStudentCloudService {
 
 	@Autowired
-	private ExamStudentService examStudentService;
+	ExamStudentService examStudentService;
 
 	@Autowired
-	private ExamStudentRepo examStudentRepo;
+	ExamStudentRepo examStudentRepo;
+
+	@Autowired
+	OrgCloudService orgCloudService;
 
 	@Override
-	public void saveExamStudent(SaveExamStudentReq examStudentReq) {
+	public void saveExamStudent(SaveExamStudentReq req) {
+
+		Long rootOrgId = req.getRootOrgId();
+		GetOrgReq getOrgReq = new GetOrgReq();
+		getOrgReq.setOrgId(rootOrgId);
+		GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
+		OrgBean rootOrg = getOrgResp.getOrg();
+		if (!rootOrg.getParentId().equals(0L)) {
+			throw new StatusException("E-100001", "rootOrgId is wrong");
+		}
+
+		String studentCode = req.getStudentCode();
+		String identityNumber = req.getIdentityNumber();
+
+		if (StringUtils.isBlank(studentCode)) {
+			throw new StatusException("E-100002", "studentCode is null");
+		}
+
+		if (StringUtils.isBlank(identityNumber)) {
+			throw new StatusException("E-100003", "identityNumber is null");
+		}
+
 		ExamStudentDTO examStudentDto = new ExamStudentDTO();
-		examStudentDto.setExamId(examStudentReq.getExamId());
-		examStudentDto.setCourseCode(examStudentReq.getCourseCode());
-		examStudentDto.setIdentityNumber(examStudentReq.getIdentityNumber());
+		examStudentDto.setExamId(req.getExamId());
+		examStudentDto.setCourseCode(req.getCourseCode());
+		examStudentDto.setIdentityNumber(req.getIdentityNumber());
 		List<ExamStudent> examStudents = examStudentService.getAllExamStudent(examStudentDto);
 		if (examStudents != null && examStudents.size() > 0) {
 			ExamStudent examStudentOld = examStudents.get(0);
 			// 更新相关的姓名、学习中心、专业
-			examStudentOld.setName(examStudentReq.getStudentName());
-			examStudentOld.setOrgId(examStudentReq.getOrgId());
-			examStudentOld.setOrgCode(examStudentReq.getOrgCode());
-			examStudentOld.setOrgName(examStudentReq.getOrgName());
-			examStudentOld.setRootOrgId(examStudentReq.getRootOrgId());
-			examStudentOld.setSpecialtyName(examStudentReq.getSpecialtyName());
+			// examStudentOld.setName(examStudentReq.getStudentName());
+			// examStudentOld.setOrgId(examStudentReq.getOrgId());
+			// examStudentOld.setOrgCode(examStudentReq.getOrgCode());
+			// examStudentOld.setOrgName(examStudentReq.getOrgName());
+			// examStudentOld.setRootOrgId(examStudentReq.getRootOrgId());
+			// examStudentOld.setSpecialtyName(examStudentReq.getSpecialtyName());
 			examStudentRepo.save(examStudentOld);
 		} else {
-			ExamStudent examStudent = BeanCopierUtil.copyProperties(examStudentReq,
-					ExamStudent.class);
+			ExamStudent examStudent = BeanCopierUtil.copyProperties(req, ExamStudent.class);
 			examStudent.setFinished(false);
 			examStudentRepo.save(examStudent);
 		}

+ 24 - 135
examcloud-core-examwork-api/src/main/java/cn/com/qmth/examcloud/examwork/api/request/SaveExamStudentReq.java

@@ -3,90 +3,67 @@ package cn.com.qmth.examcloud.examwork.api.request;
 import cn.com.qmth.examcloud.commons.web.cloud.api.BaseRequest;
 
 public class SaveExamStudentReq extends BaseRequest {
-	
+
 	private static final long serialVersionUID = -8455805881947392754L;
+
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
 	/**
 	 * 考试ID
 	 */
 	private Long examId;
+
 	/**
 	 * 考试名称
 	 */
 	private String examName;
+
 	/**
 	 * 学生姓名
 	 */
 	private String studentName;
+
 	/**
 	 * 学生学号
 	 */
 	private String studentCode;
+
 	/**
 	 * 学生身份证号
 	 */
 	private String identityNumber;
+
 	/**
 	 * 考试课程名称
 	 */
 	private String courseName;
+
 	/**
 	 * 考试课程code
 	 */
 	private String courseCode;
+
 	/**
 	 * 考试课程level
 	 */
 	private String courseLevel;
+
 	/**
 	 * 试卷类型
 	 */
 	private String paperType;
-	/**
-	 * 采集人
-	 */
-	private String infoCollector;
-	/**
-	 * 专业名称
-	 */
-	private String specialtyName;
-	/**
-	 * 所属机构code
-	 */
-	private String orgCode;
-	/**
-	 * 所属机构名称
-	 */
-	private String orgName;
-	/**
-	 * 性别
-	 */
-	private String gender;
-	/**
-	 * 年级
-	 */
-	private String grade;
-	/**
-	 * 是否为重修
-	 */
-	private Boolean repair;
-	/**
-	 * 是否毕业
-	 */
-	private Boolean graduated;
-	/**
-	 * 备注
-	 */
-	private String remark;
-	
-	/**
-	 * 机构ID
-	 */
-	private Long orgId;
-	/**
-	 * 顶级机构id 
-	 */
-	private Long rootOrgId;
-	
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
 	public Long getExamId() {
 		return examId;
 	}
@@ -159,92 +136,4 @@ public class SaveExamStudentReq extends BaseRequest {
 		this.paperType = paperType;
 	}
 
-	public String getInfoCollector() {
-		return infoCollector;
-	}
-
-	public void setInfoCollector(String infoCollector) {
-		this.infoCollector = infoCollector;
-	}
-
-	public String getSpecialtyName() {
-		return specialtyName;
-	}
-
-	public void setSpecialtyName(String specialtyName) {
-		this.specialtyName = specialtyName;
-	}
-
-	public String getOrgCode() {
-		return orgCode;
-	}
-
-	public void setOrgCode(String orgCode) {
-		this.orgCode = orgCode;
-	}
-
-	public String getOrgName() {
-		return orgName;
-	}
-
-	public void setOrgName(String orgName) {
-		this.orgName = orgName;
-	}
-
-	public String getGender() {
-		return gender;
-	}
-
-	public void setGender(String gender) {
-		this.gender = gender;
-	}
-
-	public String getGrade() {
-		return grade;
-	}
-
-	public void setGrade(String grade) {
-		this.grade = grade;
-	}
-
-	public Boolean getRepair() {
-		return repair;
-	}
-
-	public void setRepair(Boolean repair) {
-		this.repair = repair;
-	}
-
-	public Boolean getGraduated() {
-		return graduated;
-	}
-
-	public void setGraduated(Boolean graduated) {
-		this.graduated = graduated;
-	}
-
-	public String getRemark() {
-		return remark;
-	}
-
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-	public Long getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-	
 }

+ 139 - 0
examcloud-core-examwork-api/src/main/java/cn/com/qmth/examcloud/examwork/api/response/SaveExamStudentResp.java

@@ -0,0 +1,139 @@
+package cn.com.qmth.examcloud.examwork.api.response;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.BaseResponse;
+
+public class SaveExamStudentResp extends BaseResponse {
+
+	private static final long serialVersionUID = 5003024673163742249L;
+
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 考试ID
+	 */
+	private Long examId;
+
+	/**
+	 * 考试名称
+	 */
+	private String examName;
+
+	/**
+	 * 学生姓名
+	 */
+	private String studentName;
+
+	/**
+	 * 学生学号
+	 */
+	private String studentCode;
+
+	/**
+	 * 学生身份证号
+	 */
+	private String identityNumber;
+
+	/**
+	 * 考试课程名称
+	 */
+	private String courseName;
+
+	/**
+	 * 考试课程code
+	 */
+	private String courseCode;
+
+	/**
+	 * 考试课程level
+	 */
+	private String courseLevel;
+
+	/**
+	 * 试卷类型
+	 */
+	private String paperType;
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public String getExamName() {
+		return examName;
+	}
+
+	public void setExamName(String examName) {
+		this.examName = examName;
+	}
+
+	public String getStudentName() {
+		return studentName;
+	}
+
+	public void setStudentName(String studentName) {
+		this.studentName = studentName;
+	}
+
+	public String getStudentCode() {
+		return studentCode;
+	}
+
+	public void setStudentCode(String studentCode) {
+		this.studentCode = studentCode;
+	}
+
+	public String getIdentityNumber() {
+		return identityNumber;
+	}
+
+	public void setIdentityNumber(String identityNumber) {
+		this.identityNumber = identityNumber;
+	}
+
+	public String getCourseName() {
+		return courseName;
+	}
+
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
+
+	public String getCourseCode() {
+		return courseCode;
+	}
+
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+
+	public String getCourseLevel() {
+		return courseLevel;
+	}
+
+	public void setCourseLevel(String courseLevel) {
+		this.courseLevel = courseLevel;
+	}
+
+	public String getPaperType() {
+		return paperType;
+	}
+
+	public void setPaperType(String paperType) {
+		this.paperType = paperType;
+	}
+
+}

+ 7 - 0
examcloud-core-examwork-service/pom.xml

@@ -25,6 +25,13 @@
 			<artifactId>data-sync-rabbit</artifactId>
 			<version>1.0-SNAPSHOT</version>
 		</dependency>
+
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.core.basic</groupId>
+			<artifactId>examcloud-core-basic-api-client</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+
 	</dependencies>
 
 </project>