lideyin преди 5 години
родител
ревизия
d89a18f9dc

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

@@ -70,438 +70,438 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping("${$rmp.ctr.examwork}/exam_student")
 public class ExamStudentController extends ControllerSupport {
 
-	@Autowired
-	ExamStudentRepo examStudentRepo;
-
-	@Autowired
-	ExamStudentService examStudentService;
-
-	@Autowired
-	ExamRepo examRepo;
-
-	@Autowired
-	StudentCloudService studentCloudService;
-
-	@Autowired
-	CourseCloudService courseCloudService;
-
-	@Autowired
-	OrgCloudService orgCloudService;
-
-	@Autowired
-	ExamRecordCloudService examRecordCloudService;
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @return
-	 */
-	@ApiOperation(value = "查询考生的专业集合")
-	@GetMapping("specialtyNameList")
-	public List<String> getSpecialtyNameListByStudentId() {
-		User accessUser = getAccessUser();
-		if (!accessUser.getUserType().equals(UserType.STUDENT)) {
-			throw new StatusException("005002", "用户类型错误");
-		}
-		List<String> querySpecialtyNameList = examStudentRepo
-				.querySpecialtyNameList(accessUser.getUserId());
-		querySpecialtyNameList.removeAll(Collections.singleton(null));
-		return querySpecialtyNameList;
-	}
-
-	@ApiOperation(value = "查询考生的专业集合")
-	@GetMapping("courseLevelList")
-	public List<String> getCourseLevelByStudentId() {
-		User accessUser = getAccessUser();
-		if (!accessUser.getUserType().equals(UserType.STUDENT)) {
-			throw new StatusException("005001", "用户类型错误");
-		}
-		List<String> courseLevelList = examStudentRepo.queryCourseLevelList(accessUser.getUserId());
-		List<String> ret = Lists.newArrayList();
-		for (String cur : courseLevelList) {
-			if (null != cur) {
-				CourseLevel courseLevel = CourseLevel.getCourseLevel(cur);
-				ret.add(courseLevel.getName());
-			}
-		}
-		return ret;
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param studentId
-	 * @return
-	 */
-	@ApiOperation(value = "查询学生的所有考试")
-	@GetMapping("byStudentId/{studentId}")
-	public List<ExamStudentEntity> getExamStudentListByStudentId(@PathVariable Long studentId) {
-
-		return examStudentRepo.findByStudentId(studentId);
-	}
-
-	/**
-	 * 重构
-	 *
-	 * @author WANGWEI
-	 * @param curPage
-	 * @param pageSize
-	 * @return
-	 */
-	@ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
-	@GetMapping("examStudentPage/{curPage}/{pageSize}")
-	public PageInfo<ExamStudentDomain> getExamStudentPage(@PathVariable Integer curPage,
-			@PathVariable Integer pageSize, @RequestParam(required = false) Long orgId,
-			@RequestParam(required = false) Long examId,
-			@RequestParam(required = false) String studentName,
-			@RequestParam(required = false) String studentCode,
-			@RequestParam(required = false) Long courseId,
-			@RequestParam(required = false) String courseCode,
-			@RequestParam(required = false) String courseLevel,
-			@RequestParam(required = false) String courseName,
-			@RequestParam(required = false) String examSite,
-			@RequestParam(required = false) String identityNumber,
-			@RequestParam(required = false) Boolean identityNumberLike,
-			@RequestParam(required = false) String specialtyName,
-			@RequestParam(required = false) String infoCollector,
-			@RequestParam(required = false) Boolean withStarted) {
-
-		User accessUser = getAccessUser();
-
-		final Boolean finalIdentityNumberLike = null == identityNumberLike
-				? true
-				: identityNumberLike;
-
-		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
-
-			if (null != orgId) {
-				predicates.add(cb.equal(root.get("orgId"), orgId));
-			}
-
-			if (null != examId) {
-				predicates.add(cb.equal(root.get("examId"), examId));
-			}
-			if (StringUtils.isNotEmpty(studentName)) {
-				predicates.add(cb.like(root.get("name"), toSqlSearchPattern(studentName)));
-			}
-			if (StringUtils.isNotEmpty(studentCode)) {
-				predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
-			}
-			if (null != courseId) {
-				predicates.add(cb.equal(root.get("courseId"), courseId));
-			}
-			if (StringUtils.isNotEmpty(courseCode)) {
-				predicates.add(cb.equal(root.get("courseCode"), courseCode));
-			}
-			if (StringUtils.isNotEmpty(courseLevel)) {
-				predicates.add(cb.equal(root.get("courseLevel"), courseLevel));
-			}
-			if (StringUtils.isNotEmpty(courseName)) {
-				predicates.add(cb.like(root.get("courseName"), toSqlSearchPattern(courseName)));
-			}
-			if (!StringUtils.isEmpty(examSite)) {
-				predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
-			}
-			if (StringUtils.isNotEmpty(identityNumber)) {
-				if (finalIdentityNumberLike) {
-					predicates.add(cb.like(root.get("identityNumber"),
-							toSqlSearchPattern(identityNumber)));
-				} else {
-					predicates.add(cb.equal(root.get("identityNumber"), identityNumber));
-				}
-			}
-			if (StringUtils.isNotEmpty(specialtyName)) {
-				predicates
-						.add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
-			}
-			if (StringUtils.isNotEmpty(infoCollector)) {
-				predicates
-						.add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
-				new Sort(Direction.DESC, "updateTime", "id"));
-
-		Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
-
-		List<ExamStudentDomain> ret = Lists.newArrayList();
-
-		for (ExamStudentEntity cur : examStudents) {
-			ExamEntity exam = GlobalHelper.getEntity(examRepo, cur.getExamId(), ExamEntity.class);
-
-			GetOrgReq getOrgReq = new GetOrgReq();
-			getOrgReq.setOrgId(cur.getOrgId());
-			GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
-			OrgBean org = getOrgResp.getOrg();
-
-			GetStudentReq getStudentReq = new GetStudentReq();
-			getStudentReq.setRootOrgId(accessUser.getRootOrgId());
-			getStudentReq.setIdentityNumber(cur.getIdentityNumber());
-			GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
-			StudentBean studentBean = getStudentResp.getStudentInfo();
-
-			Boolean started = null;
-			if (null != withStarted && withStarted) {
-				CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
-				checkExamIsStartedReq.setExamId(exam.getId());
-				checkExamIsStartedReq.setCourseId(cur.getCourseId());
-				checkExamIsStartedReq.setStudentId(studentBean.getId());
-				checkExamIsStartedReq.setExamId(exam.getId());
-				try {
-					CheckExamIsStartedResp checkExamIsStartedResp = examRecordCloudService
-							.checkExamIsStarted(checkExamIsStartedReq);
-					started = checkExamIsStartedResp.getIsStarted();
-				} catch (Exception e) {
-					log.error("fail to invoke remote method: checkExamIsStarted()", e);
-				}
-
-			}
-
-			ExamStudentDomain bean = new ExamStudentDomain();
-			bean.setRootOrgId(cur.getRootOrgId());
-			bean.setId(cur.getId());
-			bean.setExamId(exam.getId());
-			bean.setExamName(exam.getName());
-			bean.setStudentId(cur.getStudentId());
-			bean.setStudentName(cur.getName());
-			bean.setStudentCode(cur.getStudentCode());
-			bean.setIdentityNumber(IdentityNumberHelper.conceal(cur.getRootOrgId(), cur.getIdentityNumber()));
-			bean.setCourseId(cur.getCourseId());
-			bean.setCourseCode(cur.getCourseCode());
-			bean.setCourseName(cur.getCourseName());
-			bean.setCourseLevel(cur.getCourseLevel());
-			bean.setInfoCollector(cur.getInfoCollector());
-			bean.setOrgId(cur.getOrgId());
-			bean.setOrgCode(org.getCode());
-			bean.setOrgName(org.getName());
-			bean.setPaperType(cur.getPaperType());
-			bean.setPhone(studentBean.getPhoneNumber());
-			bean.setGrade(cur.getGrade());
-			bean.setSpecialtyName(cur.getSpecialtyName());
-			bean.setExamSite(cur.getExamSite());
-			bean.setExamType(exam.getExamType().name());
-			bean.setUpdateTime(cur.getUpdateTime());
-			bean.setEnable(cur.getEnable());
-			bean.setLocked(
-					null == exam.getExamStudentLocked() ? false : exam.getExamStudentLocked());
-			bean.setStarted(started);
-			bean.setPhotoPath(studentBean.getPhotoPath());
-
-			bean.setExt1(cur.getExt1());
-			bean.setExt2(cur.getExt2());
-			bean.setExt3(cur.getExt3());
-			bean.setExt4(cur.getExt4());
-			bean.setExt5(cur.getExt5());
-			ret.add(bean);
-		}
-		return new PageInfo<ExamStudentDomain>(examStudents, ret);
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
-	@GetMapping("{id}")
-	public ExamStudentEntity getExamStudentById(@PathVariable Long id) {
-		ExamStudentEntity es = GlobalHelper.getEntity(examStudentRepo, id, ExamStudentEntity.class);
-		if (null == es) {
-			throw new StatusException("520001", "考生不存在");
-		}
-		return es;
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param examStudent
-	 * @return
-	 */
-	@ApiOperation(value = "新增考试学生", notes = "新增")
-	@PostMapping()
-	@Transactional
-	public ExamStudentDomain addExamStudent(@RequestBody ExamStudentDomain examStudent) {
-		trim(examStudent);
-		Long rootOrgId = getRootOrgId();
-		examStudent.setRootOrgId(rootOrgId);
-		examStudent.setInfoCollector(examStudent.getInfoCollector());
-		return saveExamStudent(examStudent);
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param examStudent
-	 * @return
-	 */
-	@ApiOperation(value = "更新考试学生", notes = "更新")
-	@PutMapping()
-	@Transactional
-	public ExamStudentDomain updateExamStudent(@RequestBody ExamStudentDomain examStudent) {
-		trim(examStudent);
-		Long rootOrgId = getRootOrgId();
-		examStudent.setRootOrgId(rootOrgId);
-		examStudent.setInfoCollector(examStudent.getInfoCollector());
-		return saveExamStudent(examStudent);
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param examStudent
-	 * @return
-	 */
-	private ExamStudentDomain saveExamStudent(ExamStudentDomain examStudent) {
-		SaveStudentReq saveStudentReq = new SaveStudentReq();
-		saveStudentReq.setIdentityNumber(examStudent.getIdentityNumber().toUpperCase(Locale.US));
-		saveStudentReq.setName(examStudent.getStudentName());
-		saveStudentReq.setPhoneNumber(examStudent.getPhone());
-		saveStudentReq.setOrgId(examStudent.getOrgId());
-		saveStudentReq.setRemark(examStudent.getRemark());
-		saveStudentReq.setRootOrgId(examStudent.getRootOrgId());
-		if (StringUtils.isNotBlank(examStudent.getStudentCode())) {
-			List<String> studentCodeList = Lists.newArrayList();
-			studentCodeList.add(examStudent.getStudentCode());
-			saveStudentReq.setStudentCodeList(studentCodeList);
-		}
-		SaveStudentResp saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
-
-		Long studentId = saveStudentResp.getStudentId();
-
-		ExamStudentInfo info = new ExamStudentInfo();
-		info.setCourseId(examStudent.getCourseId());
-		info.setExamId(examStudent.getExamId());
-		info.setIdentityNumber(examStudent.getIdentityNumber());
-		info.setPaperType(examStudent.getPaperType());
-		info.setRootOrgId(examStudent.getRootOrgId());
-		info.setStudentCode(examStudent.getStudentCode());
-		info.setStudentName(examStudent.getStudentName());
-		info.setStudentId(studentId);
-		info.setInfoCollector(examStudent.getInfoCollector());
-		info.setGrade(examStudent.getGrade());
-		info.setExamSite(examStudent.getExamSite());
-		info.setSpecialtyName(examStudent.getSpecialtyName());
-		info.setRemark(examStudent.getRemark());
-
-		info.setExt1(examStudent.getExt1());
-		info.setExt2(examStudent.getExt2());
-		info.setExt3(examStudent.getExt3());
-		info.setExt4(examStudent.getExt4());
-		info.setExt5(examStudent.getExt5());
-
-		ExamStudentInfo savedExamStudent = examStudentService.saveExamStudent(info);
-
-		ExamStudentDomain ret = new ExamStudentDomain();
-		ret.setId(savedExamStudent.getId());
-		ret.setStudentId(studentId);
-		ret.setStudentCode(savedExamStudent.getStudentCode());
-		ret.setStudentName(savedExamStudent.getStudentName());
-		ret.setCourseCode(savedExamStudent.getCourseCode());
-		ret.setCourseName(savedExamStudent.getCourseName());
-		return ret;
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param ids
-	 * @return
-	 */
-	@ApiOperation(value = "按ID删除考试学生", notes = "删除")
-	@DeleteMapping("/{ids}")
-	@Transactional
-	public List<Long> deleteExamStudent(@PathVariable String ids) {
-		List<Long> idList = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-				.collect(Collectors.toList());
-		examStudentService.deleteExamStudentsByStudentIds(idList);
-		return idList;
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param examId
-	 * @return
-	 */
-	@ApiOperation(value = "按考试删除考试学生", notes = "按考试删除")
-	@DeleteMapping("exam/{examId}")
-	@Transactional
-	public Long deleteExamStudents(@PathVariable Long examId) {
-		examStudentService.deleteExamStudentsByExamId(examId);
-		return examId;
-	}
-
-	@ApiOperation(value = "下载导入模板", notes = "下载导入模板")
-	@GetMapping("/downloadTemplate")
-	public void downloadTemplate(HttpServletResponse response) {
-		String resoucePath = PathUtil.getResoucePath("templates/studentImportTemplate.xlsx");
-		exportFile("考生导入模板.xlsx", new File(resoucePath));
-	}
-
-	@ApiOperation(value = "启用考生")
-	@PutMapping("enable/{ids}")
-	@Transactional
-	public List<String> enableExamStudent(@PathVariable String ids) {
-		List<Long> examStuIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-				.collect(Collectors.toList());
-		List<String> ret = Lists.newArrayList();
-		for (Long cur : examStuIds) {
-			ExamStudentEntity s = GlobalHelper.getEntity(examStudentRepo, cur,
-					ExamStudentEntity.class);
-			s.setEnable(true);
-			examStudentRepo.save(s);
-			ret.add(s.getId() + ":" + s.getName());
-		}
-
-		for (Long cur : examStuIds) {
-			examStudentService.syncExamStudent(cur);
-		}
-
-		return ret;
-	}
-
-	/**
-	 * 方法注释
-	 *
-	 * @author WANGWEI
-	 * @param ids
-	 * @return
-	 */
-	@ApiOperation(value = "禁用考生")
-	@PutMapping("disable/{ids}")
-	@Transactional
-	public List<String> disableExamStudent(@PathVariable String ids) {
-		List<Long> examStuIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-				.collect(Collectors.toList());
-		List<String> ret = Lists.newArrayList();
-		for (Long cur : examStuIds) {
-			ExamStudentEntity s = GlobalHelper.getEntity(examStudentRepo, cur,
-					ExamStudentEntity.class);
-			s.setEnable(false);
-			examStudentRepo.save(s);
-			ret.add(s.getId() + ":" + s.getName());
-		}
-
-		for (Long cur : examStuIds) {
-			examStudentService.syncExamStudent(cur);
-		}
-
-		return ret;
-	}
+    @Autowired
+    ExamStudentRepo examStudentRepo;
+
+    @Autowired
+    ExamStudentService examStudentService;
+
+    @Autowired
+    ExamRepo examRepo;
+
+    @Autowired
+    StudentCloudService studentCloudService;
+
+    @Autowired
+    CourseCloudService courseCloudService;
+
+    @Autowired
+    OrgCloudService orgCloudService;
+
+    @Autowired
+    ExamRecordCloudService examRecordCloudService;
+
+    /**
+     * 方法注释
+     *
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "查询考生的专业集合")
+    @GetMapping("specialtyNameList")
+    public List<String> getSpecialtyNameListByStudentId() {
+        User accessUser = getAccessUser();
+        if (!accessUser.getUserType().equals(UserType.STUDENT)) {
+            throw new StatusException("005002", "用户类型错误");
+        }
+        List<String> querySpecialtyNameList = examStudentRepo
+                .querySpecialtyNameList(accessUser.getUserId());
+        querySpecialtyNameList.removeAll(Collections.singleton(null));
+        return querySpecialtyNameList;
+    }
+
+    @ApiOperation(value = "查询考生的专业集合")
+    @GetMapping("courseLevelList")
+    public List<String> getCourseLevelByStudentId() {
+        User accessUser = getAccessUser();
+        if (!accessUser.getUserType().equals(UserType.STUDENT)) {
+            throw new StatusException("005001", "用户类型错误");
+        }
+        List<String> courseLevelList = examStudentRepo.queryCourseLevelList(accessUser.getUserId());
+        List<String> ret = Lists.newArrayList();
+        for (String cur : courseLevelList) {
+            if (null != cur) {
+                CourseLevel courseLevel = CourseLevel.getCourseLevel(cur);
+                ret.add(courseLevel.getName());
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param studentId
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "查询学生的所有考试")
+    @GetMapping("byStudentId/{studentId}")
+    public List<ExamStudentEntity> getExamStudentListByStudentId(@PathVariable Long studentId) {
+
+        return examStudentRepo.findByStudentId(studentId);
+    }
+
+    /**
+     * 重构
+     *
+     * @param curPage
+     * @param pageSize
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
+    @GetMapping("examStudentPage/{curPage}/{pageSize}")
+    public PageInfo<ExamStudentDomain> getExamStudentPage(@PathVariable Integer curPage,
+                                                          @PathVariable Integer pageSize, @RequestParam(required = false) Long orgId,
+                                                          @RequestParam(required = false) Long examId,
+                                                          @RequestParam(required = false) String studentName,
+                                                          @RequestParam(required = false) String studentCode,
+                                                          @RequestParam(required = false) Long courseId,
+                                                          @RequestParam(required = false) String courseCode,
+                                                          @RequestParam(required = false) String courseLevel,
+                                                          @RequestParam(required = false) String courseName,
+                                                          @RequestParam(required = false) String examSite,
+                                                          @RequestParam(required = false) String identityNumber,
+                                                          @RequestParam(required = false) Boolean identityNumberLike,
+                                                          @RequestParam(required = false) String specialtyName,
+                                                          @RequestParam(required = false) String infoCollector,
+                                                          @RequestParam(required = false) Boolean withStarted) {
+
+        User accessUser = getAccessUser();
+
+        final Boolean finalIdentityNumberLike = null == identityNumberLike
+                ? true
+                : identityNumberLike;
+
+        Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
+
+            if (null != orgId) {
+                predicates.add(cb.equal(root.get("orgId"), orgId));
+            }
+
+            if (null != examId) {
+                predicates.add(cb.equal(root.get("examId"), examId));
+            }
+            if (StringUtils.isNotEmpty(studentName)) {
+                predicates.add(cb.like(root.get("name"), toSqlSearchPattern(studentName)));
+            }
+            if (StringUtils.isNotEmpty(studentCode)) {
+                predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
+            }
+            if (null != courseId) {
+                predicates.add(cb.equal(root.get("courseId"), courseId));
+            }
+            if (StringUtils.isNotEmpty(courseCode)) {
+                predicates.add(cb.equal(root.get("courseCode"), courseCode));
+            }
+            if (StringUtils.isNotEmpty(courseLevel)) {
+                predicates.add(cb.equal(root.get("courseLevel"), courseLevel));
+            }
+            if (StringUtils.isNotEmpty(courseName)) {
+                predicates.add(cb.like(root.get("courseName"), toSqlSearchPattern(courseName)));
+            }
+            if (!StringUtils.isEmpty(examSite)) {
+                predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
+            }
+            if (StringUtils.isNotEmpty(identityNumber)) {
+                if (finalIdentityNumberLike) {
+                    predicates.add(cb.like(root.get("identityNumber"),
+                            toSqlSearchPattern(identityNumber)));
+                } else {
+                    predicates.add(cb.equal(root.get("identityNumber"), identityNumber));
+                }
+            }
+            if (StringUtils.isNotEmpty(specialtyName)) {
+                predicates
+                        .add(cb.like(root.get("specialtyName"), toSqlSearchPattern(specialtyName)));
+            }
+            if (StringUtils.isNotEmpty(infoCollector)) {
+                predicates
+                        .add(cb.like(root.get("infoCollector"), toSqlSearchPattern(infoCollector)));
+            }
+
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        PageRequest pageRequest = PageRequest.of(curPage, pageSize,
+                new Sort(Direction.DESC, "updateTime", "id"));
+
+        Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
+
+        List<ExamStudentDomain> ret = Lists.newArrayList();
+
+        for (ExamStudentEntity cur : examStudents) {
+            ExamEntity exam = GlobalHelper.getEntity(examRepo, cur.getExamId(), ExamEntity.class);
+
+            GetOrgReq getOrgReq = new GetOrgReq();
+            getOrgReq.setOrgId(cur.getOrgId());
+            GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
+            OrgBean org = getOrgResp.getOrg();
+
+            GetStudentReq getStudentReq = new GetStudentReq();
+            getStudentReq.setRootOrgId(accessUser.getRootOrgId());
+            getStudentReq.setIdentityNumber(cur.getIdentityNumber());
+            GetStudentResp getStudentResp = studentCloudService.getStudent(getStudentReq);
+            StudentBean studentBean = getStudentResp.getStudentInfo();
+
+            Boolean started = null;
+            if (null != withStarted && withStarted) {
+                CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
+                checkExamIsStartedReq.setExamId(exam.getId());
+                checkExamIsStartedReq.setCourseId(cur.getCourseId());
+                checkExamIsStartedReq.setStudentId(studentBean.getId());
+                checkExamIsStartedReq.setExamId(exam.getId());
+                try {
+                    CheckExamIsStartedResp checkExamIsStartedResp = examRecordCloudService
+                            .checkExamIsStarted(checkExamIsStartedReq);
+                    started = checkExamIsStartedResp.getIsStarted();
+                } catch (Exception e) {
+                    log.error("fail to invoke remote method: checkExamIsStarted()", e);
+                }
+
+            }
+
+            ExamStudentDomain bean = new ExamStudentDomain();
+            bean.setRootOrgId(cur.getRootOrgId());
+            bean.setId(cur.getId());
+            bean.setExamId(exam.getId());
+            bean.setExamName(exam.getName());
+            bean.setStudentId(cur.getStudentId());
+            bean.setStudentName(cur.getName());
+            bean.setStudentCode(cur.getStudentCode());
+            bean.setIdentityNumber(cur.getIdentityNumber());
+            bean.setCourseId(cur.getCourseId());
+            bean.setCourseCode(cur.getCourseCode());
+            bean.setCourseName(cur.getCourseName());
+            bean.setCourseLevel(cur.getCourseLevel());
+            bean.setInfoCollector(cur.getInfoCollector());
+            bean.setOrgId(cur.getOrgId());
+            bean.setOrgCode(org.getCode());
+            bean.setOrgName(org.getName());
+            bean.setPaperType(cur.getPaperType());
+            bean.setPhone(studentBean.getPhoneNumber());
+            bean.setGrade(cur.getGrade());
+            bean.setSpecialtyName(cur.getSpecialtyName());
+            bean.setExamSite(cur.getExamSite());
+            bean.setExamType(exam.getExamType().name());
+            bean.setUpdateTime(cur.getUpdateTime());
+            bean.setEnable(cur.getEnable());
+            bean.setLocked(
+                    null == exam.getExamStudentLocked() ? false : exam.getExamStudentLocked());
+            bean.setStarted(started);
+            bean.setPhotoPath(studentBean.getPhotoPath());
+
+            bean.setExt1(cur.getExt1());
+            bean.setExt2(IdentityNumberHelper.conceal(cur.getRootOrgId(), cur.getIdentityNumber()));//特殊处理:把ext2当作隐私模式下的身份证号
+            bean.setExt3(cur.getExt3());
+            bean.setExt4(cur.getExt4());
+            bean.setExt5(cur.getExt5());
+            ret.add(bean);
+        }
+        return new PageInfo<ExamStudentDomain>(examStudents, ret);
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param id
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
+    @GetMapping("{id}")
+    public ExamStudentEntity getExamStudentById(@PathVariable Long id) {
+        ExamStudentEntity es = GlobalHelper.getEntity(examStudentRepo, id, ExamStudentEntity.class);
+        if (null == es) {
+            throw new StatusException("520001", "考生不存在");
+        }
+        return es;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param examStudent
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "新增考试学生", notes = "新增")
+    @PostMapping()
+    @Transactional
+    public ExamStudentDomain addExamStudent(@RequestBody ExamStudentDomain examStudent) {
+        trim(examStudent);
+        Long rootOrgId = getRootOrgId();
+        examStudent.setRootOrgId(rootOrgId);
+        examStudent.setInfoCollector(examStudent.getInfoCollector());
+        return saveExamStudent(examStudent);
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param examStudent
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "更新考试学生", notes = "更新")
+    @PutMapping()
+    @Transactional
+    public ExamStudentDomain updateExamStudent(@RequestBody ExamStudentDomain examStudent) {
+        trim(examStudent);
+        Long rootOrgId = getRootOrgId();
+        examStudent.setRootOrgId(rootOrgId);
+        examStudent.setInfoCollector(examStudent.getInfoCollector());
+        return saveExamStudent(examStudent);
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param examStudent
+     * @return
+     * @author WANGWEI
+     */
+    private ExamStudentDomain saveExamStudent(ExamStudentDomain examStudent) {
+        SaveStudentReq saveStudentReq = new SaveStudentReq();
+        saveStudentReq.setIdentityNumber(examStudent.getIdentityNumber().toUpperCase(Locale.US));
+        saveStudentReq.setName(examStudent.getStudentName());
+        saveStudentReq.setPhoneNumber(examStudent.getPhone());
+        saveStudentReq.setOrgId(examStudent.getOrgId());
+        saveStudentReq.setRemark(examStudent.getRemark());
+        saveStudentReq.setRootOrgId(examStudent.getRootOrgId());
+        if (StringUtils.isNotBlank(examStudent.getStudentCode())) {
+            List<String> studentCodeList = Lists.newArrayList();
+            studentCodeList.add(examStudent.getStudentCode());
+            saveStudentReq.setStudentCodeList(studentCodeList);
+        }
+        SaveStudentResp saveStudentResp = studentCloudService.saveStudent(saveStudentReq);
+
+        Long studentId = saveStudentResp.getStudentId();
+
+        ExamStudentInfo info = new ExamStudentInfo();
+        info.setCourseId(examStudent.getCourseId());
+        info.setExamId(examStudent.getExamId());
+        info.setIdentityNumber(examStudent.getIdentityNumber());
+        info.setPaperType(examStudent.getPaperType());
+        info.setRootOrgId(examStudent.getRootOrgId());
+        info.setStudentCode(examStudent.getStudentCode());
+        info.setStudentName(examStudent.getStudentName());
+        info.setStudentId(studentId);
+        info.setInfoCollector(examStudent.getInfoCollector());
+        info.setGrade(examStudent.getGrade());
+        info.setExamSite(examStudent.getExamSite());
+        info.setSpecialtyName(examStudent.getSpecialtyName());
+        info.setRemark(examStudent.getRemark());
+
+        info.setExt1(examStudent.getExt1());
+        info.setExt2(examStudent.getExt2());
+        info.setExt3(examStudent.getExt3());
+        info.setExt4(examStudent.getExt4());
+        info.setExt5(examStudent.getExt5());
+
+        ExamStudentInfo savedExamStudent = examStudentService.saveExamStudent(info);
+
+        ExamStudentDomain ret = new ExamStudentDomain();
+        ret.setId(savedExamStudent.getId());
+        ret.setStudentId(studentId);
+        ret.setStudentCode(savedExamStudent.getStudentCode());
+        ret.setStudentName(savedExamStudent.getStudentName());
+        ret.setCourseCode(savedExamStudent.getCourseCode());
+        ret.setCourseName(savedExamStudent.getCourseName());
+        return ret;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param ids
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "按ID删除考试学生", notes = "删除")
+    @DeleteMapping("/{ids}")
+    @Transactional
+    public List<Long> deleteExamStudent(@PathVariable String ids) {
+        List<Long> idList = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        examStudentService.deleteExamStudentsByStudentIds(idList);
+        return idList;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param examId
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "按考试删除考试学生", notes = "按考试删除")
+    @DeleteMapping("exam/{examId}")
+    @Transactional
+    public Long deleteExamStudents(@PathVariable Long examId) {
+        examStudentService.deleteExamStudentsByExamId(examId);
+        return examId;
+    }
+
+    @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
+    @GetMapping("/downloadTemplate")
+    public void downloadTemplate(HttpServletResponse response) {
+        String resoucePath = PathUtil.getResoucePath("templates/studentImportTemplate.xlsx");
+        exportFile("考生导入模板.xlsx", new File(resoucePath));
+    }
+
+    @ApiOperation(value = "启用考生")
+    @PutMapping("enable/{ids}")
+    @Transactional
+    public List<String> enableExamStudent(@PathVariable String ids) {
+        List<Long> examStuIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        List<String> ret = Lists.newArrayList();
+        for (Long cur : examStuIds) {
+            ExamStudentEntity s = GlobalHelper.getEntity(examStudentRepo, cur,
+                    ExamStudentEntity.class);
+            s.setEnable(true);
+            examStudentRepo.save(s);
+            ret.add(s.getId() + ":" + s.getName());
+        }
+
+        for (Long cur : examStuIds) {
+            examStudentService.syncExamStudent(cur);
+        }
+
+        return ret;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param ids
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "禁用考生")
+    @PutMapping("disable/{ids}")
+    @Transactional
+    public List<String> disableExamStudent(@PathVariable String ids) {
+        List<Long> examStuIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        List<String> ret = Lists.newArrayList();
+        for (Long cur : examStuIds) {
+            ExamStudentEntity s = GlobalHelper.getEntity(examStudentRepo, cur,
+                    ExamStudentEntity.class);
+            s.setEnable(false);
+            examStudentRepo.save(s);
+            ret.add(s.getId() + ":" + s.getName());
+        }
+
+        for (Long cur : examStuIds) {
+            examStudentService.syncExamStudent(cur);
+        }
+
+        return ret;
+    }
 
 }