WANG 6 years ago
parent
commit
698e6de36b

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

@@ -27,23 +27,14 @@ import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
-import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
-import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
-import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
-import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
-import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationPK;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
@@ -58,7 +49,6 @@ import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentPageResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
 import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
-import cn.com.qmth.examcloud.task.api.request.SyncExamStudentReq;
 import io.swagger.annotations.ApiOperation;
 
 /**
@@ -71,7 +61,9 @@ import io.swagger.annotations.ApiOperation;
 @Transactional
 @RestController
 @RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
-public class ExamStudentCloudServiceProvider extends ControllerSupport implements ExamStudentCloudService {
+public class ExamStudentCloudServiceProvider extends ControllerSupport
+		implements
+			ExamStudentCloudService {
 
 	private static final long serialVersionUID = -89062090947597841L;
 
@@ -122,7 +114,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport implement
 		info.setExamSite(req.getExamSite());
 		info.setSpecialtyName(req.getSpecialtyName());
 		info.setRemark(req.getRemark());
-		
+
 		info.setExt1(req.getExt1());
 		info.setExt2(req.getExt2());
 		info.setExt3(req.getExt3());
@@ -211,13 +203,12 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport implement
 		while (iterator.hasNext()) {
 			ExamStudentEntity es = iterator.next();
 
-			ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2, es.getStudentId(),
-					es.getCourseId());
+			ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
+					es.getStudentId(), es.getCourseId());
 
 			if (null == finded) {
-				ExamStudentEntity one = new ExamStudentEntity();
+				ExamStudentInfo one = new ExamStudentInfo();
 				one.setExamId(examId2);
-				one.setEnable(es.getEnable());
 				one.setRootOrgId(es.getRootOrgId());
 
 				one.setCourseId(es.getCourseId());
@@ -228,7 +219,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport implement
 				one.setOrgId(es.getOrgId());
 				one.setOrgCode(es.getOrgCode());
 
-				one.setName(es.getName());
+				one.setStudentName(es.getName());
 				one.setStudentCode(es.getStudentCode());
 				one.setStudentId(es.getStudentId());
 				one.setIdentityNumber(es.getIdentityNumber());
@@ -240,76 +231,13 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport implement
 				one.setSpecialtyName(es.getSpecialtyName());
 				one.setInfoCollector(es.getInfoCollector());
 
-				ExamStudentEntity saved = examStudentRepo.save(one);
-
-				ExamCourseRelationEntity ecR = examCourseRelationRepo
-						.findOne(new ExamCourseRelationPK(saved.getExamId(), saved.getCourseId()));
-
-				ExamCourseRelationEntity relation = new ExamCourseRelationEntity();
-				relation.setExamId(saved.getExamId());
-				relation.setCourseId(saved.getCourseId());
-				relation.setCourseLevel(saved.getCourseLevel());
-				relation.setCourseCode(saved.getCourseCode());
-				relation.setCourseName(saved.getCourseName());
-
-				if (null != ecR) {
-					relation.setCourseEnable(ecR.getCourseEnable());
-				} else {
-					GetCourseReq getCourseReq = new GetCourseReq();
-					getCourseReq.setRootOrgId(saved.getRootOrgId());
-					getCourseReq.setId(saved.getCourseId());
-					getCourseReq.setCode(saved.getCourseCode());
-					GetCourseResp getCourseResp = courseCloudService.getCourse(getCourseReq);
-					CourseBean courseBean = getCourseResp.getCourseBean();
-					relation.setCourseName(courseBean.getName());
-					relation.setCourseEnable(courseBean.getEnable());
-				}
-
-				examCourseRelationRepo.save(relation);
-
-				ExamPaperTypeRelationEntity pt = new ExamPaperTypeRelationEntity();
-				pt.setCourseId(saved.getCourseId());
-				pt.setExamId(saved.getExamId());
-				pt.setPaperType(saved.getPaperType());
-				examPaperTypeRelationRepo.save(pt);
-
-				GetStudentReq getStudentReq = new GetStudentReq();
-				getStudentReq.setRootOrgId(rootOrgId);
-				getStudentReq.setIdentityNumber(saved.getIdentityNumber());
-				GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
-
-				StudentBean studentInfo = getStudentResp.getStudentInfo();
-
-				// 同步操作
-				SyncExamStudentReq sync = new SyncExamStudentReq();
-				sync.setSyncType("update");
-				sync.setId(saved.getId());
-
-				sync.setCourseId(saved.getCourseId());
-				sync.setCourseCode(saved.getCourseCode());
-				sync.setCourseLevel(saved.getCourseLevel());
-				sync.setCourseName(saved.getCourseName());
-
-				sync.setExamId(saved.getExamId());
-				sync.setExamName(exam2.getName());
-
-				sync.setRootOrgId(saved.getRootOrgId());
-				sync.setStudentId(studentInfo.getId());
-				sync.setStudentName(studentInfo.getName());
-				sync.setIdentityNumber(saved.getIdentityNumber());
-				sync.setStudentCode(saved.getStudentCode());
-				sync.setOrgId(studentInfo.getOrgId());
-				sync.setOrgName(studentInfo.getOrgName());
-				sync.setOrgCode(studentInfo.getOrgCode());
-
-				sync.setPaperType(saved.getPaperType());
-				sync.setRemark(saved.getRemark());
-				sync.setInfoCollector(saved.getInfoCollector());
-				sync.setExamSite(saved.getExamSite());
-				sync.setGrade(saved.getGrade());
-				sync.setSpecialtyName(saved.getSpecialtyName());
-				dataSyncCloudService.syncExamStudent(sync);
+				one.setExt1(es.getExt1());
+				one.setExt2(es.getExt2());
+				one.setExt3(es.getExt3());
+				one.setExt4(es.getExt4());
+				one.setExt5(es.getExt5());
 
+				ExamStudentInfo saved = examStudentService.saveExamStudent(one);
 				examStudentIds.add(saved.getId());
 			}
 
@@ -412,19 +340,23 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport implement
 				predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
 			}
 			if (StringUtils.isNotEmpty(identityNumber)) {
-				predicates.add(cb.like(root.get("identityNumber"), toSqlSearchPattern(identityNumber)));
+				predicates.add(
+						cb.like(root.get("identityNumber"), toSqlSearchPattern(identityNumber)));
 			}
 			if (StringUtils.isNotEmpty(specialtyName)) {
-				predicates.add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
+				predicates
+						.add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
 			}
 			if (StringUtils.isNotEmpty(infoCollector)) {
-				predicates.add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
+				predicates
+						.add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
 			}
 
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(curPage, pageSize, new Sort(Direction.DESC, "updateTime"));
+		PageRequest pageRequest = new PageRequest(curPage, pageSize,
+				new Sort(Direction.DESC, "updateTime"));
 
 		Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);