瀏覽代碼

提交代码

chenken 7 年之前
父節點
當前提交
ee6118983c

+ 47 - 0
examcloud-exchange-outer-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/ExamStudentProvider.java

@@ -0,0 +1,47 @@
+package cn.com.qmth.examcloud.exchange.outer.api.provider;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.common.support.ControllerSupport;
+import cn.com.qmth.examcloud.common.support.exception.StatusException;
+import cn.com.qmth.examcloud.exchange.outer.api.request.ExamStudentAllInfoReq;
+import cn.com.qmth.examcloud.exchange.outer.service.ExamStudentService;
+
+/**
+ * 
+ * @author  	chenken
+ * @date    	2018年5月4日 下午2:08:45
+ * @company 	QMTH
+ * @description ExamStudentProvider.java
+ */
+@RestController
+@RequestMapping("${outer.url.prefix}/examStudents")
+public class ExamStudentProvider  extends ControllerSupport{
+	
+	@Autowired
+	ExamStudentService examStudentService;
+	
+	@ApiOperation(value = "保存考生信息", notes = "保存考生信息")
+	@PostMapping
+	public Map<String,String> saveExamStudents(@RequestBody List<ExamStudentAllInfoReq> examStudentInfoList){
+		Map<String,String> returnMap = new HashMap<String,String>();
+		try{
+			examStudentService.saveExamStudents(examStudentInfoList);
+			returnMap.put("successMsg", "执行成功");
+		}catch(StatusException e){
+			throw e;
+		}
+		return returnMap;
+	}
+	
+}

+ 5 - 0
examcloud-exchange-outer-api/pom.xml

@@ -19,5 +19,10 @@
 			<artifactId>examcloud-core-examwork-api-client</artifactId>
 			<version>${examcloud.version}</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>

+ 213 - 0
examcloud-exchange-outer-api/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/request/ExamStudentAllInfoReq.java

@@ -0,0 +1,213 @@
+package cn.com.qmth.examcloud.exchange.outer.api.request;
+
+import cn.com.qmth.examcloud.common.support.BaseRequest;
+
+public class ExamStudentAllInfoReq extends BaseRequest {
+	
+	private static final long serialVersionUID = -8455805881947392754L;
+	/**
+	 * 考试名称
+	 */
+	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;
+
+	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;
+	}
+
+	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;
+	}
+	
+}

+ 18 - 0
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/ExamStudentService.java

@@ -0,0 +1,18 @@
+package cn.com.qmth.examcloud.exchange.outer.service;
+
+import java.util.List;
+
+import cn.com.qmth.examcloud.exchange.outer.api.request.ExamStudentAllInfoReq;
+
+public interface ExamStudentService {
+
+	/**
+	 * 1.保存机构
+	 * 2.保存课程
+	 * 3.保存学生
+	 * 4.保存考生
+	 * @param examStudentReqList
+	 */
+	public void saveExamStudents(List<ExamStudentAllInfoReq> examStudentReqList);
+	
+}

+ 105 - 0
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/impl/ExamStudentServiceImpl.java

@@ -0,0 +1,105 @@
+package cn.com.qmth.examcloud.exchange.outer.service.impl;
+
+import java.util.HashSet;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import cn.com.qmth.examcloud.common.support.exception.StatusException;
+import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
+import cn.com.qmth.examcloud.core.basic.api.client.CourseCloudServiceClient;
+import cn.com.qmth.examcloud.core.basic.api.client.OrgCloudServiceClient;
+import cn.com.qmth.examcloud.core.basic.api.client.StudentCloudServiceClient;
+import cn.com.qmth.examcloud.core.basic.api.request.CourseReq;
+import cn.com.qmth.examcloud.core.basic.api.request.OrgReq;
+import cn.com.qmth.examcloud.core.basic.api.request.StudentReq;
+import cn.com.qmth.examcloud.core.basic.api.response.OrgResp;
+import cn.com.qmth.examcloud.examwork.api.client.ExamCloudClient;
+import cn.com.qmth.examcloud.examwork.api.client.ExamStudentCloudClient;
+import cn.com.qmth.examcloud.examwork.api.request.ExamReq;
+import cn.com.qmth.examcloud.examwork.api.response.ExamResp;
+import cn.com.qmth.examcloud.exchange.outer.api.request.ExamStudentAllInfoReq;
+import cn.com.qmth.examcloud.exchange.outer.service.ExamStudentService;
+
+public class ExamStudentServiceImpl implements ExamStudentService {
+	
+	@Autowired
+	private ExamCloudClient examCloudClient;
+	
+	@Autowired
+	private ExamStudentCloudClient examStudentCloudClient;
+	
+	@Autowired
+	private OrgCloudServiceClient orgCloudServiceClient;
+
+	@Autowired
+	private CourseCloudServiceClient courseCloudServiceClient;
+	
+	@Autowired
+	private StudentCloudServiceClient studentCloudServiceClient;
+	
+	@Override
+	public void saveExamStudents(List<ExamStudentAllInfoReq> examStudentReqList) {
+		chechExamStudents(examStudentReqList);
+		Long rootOrgId = 109L;
+		ExamResp examResp = getExamResp(examStudentReqList,rootOrgId);
+		for(ExamStudentAllInfoReq examStudentAllInfoReq:examStudentReqList){
+			OrgResp orgResp = saveOrg(examStudentAllInfoReq,rootOrgId);
+			saveCourse(examStudentAllInfoReq,rootOrgId);
+			saveStudent(examStudentAllInfoReq,orgResp,rootOrgId);
+			
+		}
+	}
+
+	private void saveStudent(ExamStudentAllInfoReq examStudentAllInfoReq,OrgResp orgResp,Long rootOrgId) {
+		StudentReq studentReq = new StudentReq();
+		studentReq.setName(examStudentAllInfoReq.getStudentName());
+		studentReq.setStudentCode(examStudentAllInfoReq.getStudentCode());
+		studentReq.setOrgId(orgResp.getId());
+		studentReq.setRootOrgId(rootOrgId);
+		studentCloudServiceClient.saveStudent(studentReq);
+	}
+
+	private OrgResp saveOrg(ExamStudentAllInfoReq examStudentAllInfoReq,Long rootOrgId) {
+		OrgReq orgReq = new OrgReq();
+		orgReq.setRootOrgId(rootOrgId);
+		orgReq.setOrgCode(examStudentAllInfoReq.getOrgCode());
+		orgReq.setOrgName(examStudentAllInfoReq.getOrgName());
+		return orgCloudServiceClient.saveOrg(orgReq);
+	}
+	
+	private void saveCourse(ExamStudentAllInfoReq examStudentAllInfoReq,Long rootOrgId) {
+		CourseReq courseReq = new CourseReq();
+		courseReq.setOrgId(rootOrgId);
+		courseReq.setCourseName(examStudentAllInfoReq.getCourseName());
+		courseReq.setCourseCode(examStudentAllInfoReq.getCourseCode());
+		courseReq.setCourseLevel(examStudentAllInfoReq.getCourseLevel());
+		courseCloudServiceClient.saveCourse(courseReq);
+	}
+
+	private void chechExamStudents(List<ExamStudentAllInfoReq> examStudentReqList){
+		if(examStudentReqList==null||examStudentReqList.size()==0){
+			throw new StatusException("exchange-errorMsg","集合不能为空");
+		}
+		if(examStudentReqList.size()>1000){
+			throw new StatusException("exchange-errorMsg","单次集合长度不能大于1000");
+		}
+		HashSet<String> examNameSet = new HashSet<String>();
+		for(ExamStudentAllInfoReq examStudentAllInfoReq:examStudentReqList){
+			examNameSet.add(examStudentAllInfoReq.getExamName());
+		}
+		if(examNameSet.size()>1){
+			throw new StatusException("exchange-errorMsg","集合中不允许存在多个考试");
+		}
+	}
+	
+	private ExamResp getExamResp(List<ExamStudentAllInfoReq> examStudentReqList,Long rootOrgId){
+		ExamStudentAllInfoReq firstExamStudent = examStudentReqList.get(0);
+		
+		ExamReq examReq = new ExamReq();
+		examReq.setName(firstExamStudent.getExamName());
+		examReq.setRootOrgId(rootOrgId);
+		return examCloudClient.findExamByExamReq(examReq);
+	}
+	
+}