Bläddra i källkod

merge from examcloud-R

deason 5 år sedan
förälder
incheckning
52381cd3c3

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

@@ -1,5 +1,37 @@
 package cn.com.qmth.examcloud.core.examwork.api.controller;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.persistence.criteria.Predicate;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.common.collect.Lists;
+
 import cn.com.qmth.examcloud.api.commons.enums.CourseLevel;
 import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
@@ -27,30 +59,9 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
 import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckExamIsStartedReq;
 import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckExamIsStartedResp;
-import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import com.google.common.collect.Lists;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-import javax.persistence.criteria.Predicate;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * 考生服务API Created by songyue on 17/1/13.
@@ -141,40 +152,44 @@ public class ExamStudentController extends ControllerSupport {
      */
     @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) {
+    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.isNotBlank(studentCode)) {
-                predicates.add(cb.like(root.get("studentCode"), toSqlRightLike(studentCode)));
+            if (StringUtils.isNotEmpty(studentCode)) {
+                predicates.add(cb.like(root.get("studentCode"), toSqlSearchPattern(studentCode)));
             }
             if (null != courseId) {
                 predicates.add(cb.equal(root.get("courseId"), courseId));
@@ -191,22 +206,21 @@ public class ExamStudentController extends ControllerSupport {
             if (!StringUtils.isEmpty(examSite)) {
                 predicates.add(cb.like(root.get("examSite"), toSqlSearchPattern(examSite)));
             }
-
-            if (StringUtils.isNotBlank(identityNumber)) {
-                final Boolean queryLike = (identityNumberLike == null) ? true : identityNumberLike;
-                if (queryLike) {
-                    predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(identityNumber)));
+            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)));
+                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()]));

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

@@ -1,5 +1,27 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.criteria.Predicate;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.transaction.annotation.Transactional;
+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 com.google.common.collect.Lists;
+
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
@@ -25,30 +47,21 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean4Reset;
-import cn.com.qmth.examcloud.examwork.api.request.*;
-import cn.com.qmth.examcloud.examwork.api.response.*;
+import cn.com.qmth.examcloud.examwork.api.request.CopyExamStudentsReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPageReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.ResetExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.UpdateExamStudentStatusReq;
+import cn.com.qmth.examcloud.examwork.api.response.CopyExamStudentsResp;
+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.ResetExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.UpdateExamStudentStatusResp;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import com.google.common.collect.Lists;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.transaction.annotation.Transactional;
-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 javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * {@link StatusException} 状态码范围:088XXX<br>
@@ -60,547 +73,548 @@ import java.util.List;
 @RestController
 @RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
 public class ExamStudentCloudServiceProvider extends ControllerSupport
-        implements
-        ExamStudentCloudService {
-
-    private static final long serialVersionUID = -89062090947597841L;
-
-    @Autowired
-    ExamRepo examRepo;
-
-    @Autowired
-    ExamService examService;
-
-    @Autowired
-    OrgCloudService orgCloudService;
-
-    @Autowired
-    ExamStudentService examStudentService;
-
-    @Autowired
-    StudentCloudService studentCloudService;
-
-    @Autowired
-    ExamStudentRepo examStudentRepo;
-
-    @Autowired
-    CourseCloudService courseCloudService;
-
-    @Autowired
-    ExamCourseRelationRepo examCourseRelationRepo;
-
-    @Autowired
-    ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
-
-    @ApiOperation(value = "保存考生")
-    @PostMapping("saveExamStudent")
-    @Transactional
-    @Override
-    public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
-        trim(req);
-
-        ExamStudentInfo info = new ExamStudentInfo();
-        info.setCourseCode(req.getCourseCode());
-        info.setCourseName(req.getCourseName());
-        info.setCourseLevel(req.getCourseLevel());
-        info.setCourseId(req.getCourseId());
-        info.setRootOrgId(req.getRootOrgId());
-        info.setExamId(req.getExamId());
-        info.setExamName(req.getExamName());
-        info.setExamCode(req.getExamCode());
-        info.setIdentityNumber(req.getIdentityNumber());
-        info.setPaperType(req.getPaperType());
-        info.setStudentCode(req.getStudentCode());
-        info.setStudentName(req.getStudentName());
-        info.setInfoCollector(req.getInfoCollector());
-        info.setGrade(req.getGrade());
-        info.setExamSite(req.getExamSite());
-        info.setSpecialtyName(req.getSpecialtyName());
-        info.setRemark(req.getRemark());
-
-        info.setSpecialBeginTime(req.getSpecialBeginTime());
-        info.setSpecialEndTime(req.getSpecialEndTime());
-
-        info.setExt1(req.getExt1());
-        info.setExt2(req.getExt2());
-        info.setExt3(req.getExt3());
-        info.setExt4(req.getExt4());
-        info.setExt5(req.getExt5());
-
-        ExamStudentInfo saved = examStudentService.saveExamStudent(info);
-
-        SaveExamStudentResp resp = new SaveExamStudentResp();
-
-        ExamStudentBean examStudentBean = new ExamStudentBean();
-        examStudentBean.setId(saved.getId());
-        examStudentBean.setCourseCode(saved.getCourseCode());
-        examStudentBean.setCourseLevel(saved.getCourseLevel());
-        examStudentBean.setCourseName(saved.getCourseName());
-        examStudentBean.setExamId(saved.getExamId());
-        examStudentBean.setExamName(saved.getExamName());
-        examStudentBean.setIdentityNumber(saved.getIdentityNumber());
-        examStudentBean.setStudentCode(saved.getStudentCode());
-        examStudentBean.setPaperType(saved.getPaperType());
-        examStudentBean.setRootOrgId(saved.getRootOrgId());
-        examStudentBean.setStudentName(saved.getStudentName());
-        examStudentBean.setGrade(saved.getGrade());
-        examStudentBean.setCourseId(saved.getCourseId());
-        examStudentBean.setInfoCollector(saved.getInfoCollector());
-        examStudentBean.setExamSite(saved.getExamSite());
-        examStudentBean.setOrgId(saved.getOrgId());
-        examStudentBean.setOrgCode(saved.getOrgCode());
-        examStudentBean.setOrgName(saved.getOrgName());
-
-        resp.setExamStudentBean(examStudentBean);
-
-        return resp;
-    }
-
-    @ApiOperation(value = "复制考生")
-    @PostMapping("copyExamStudents")
-    @Transactional
-    @Override
-    public CopyExamStudentsResp copyExamStudents(@RequestBody CopyExamStudentsReq req) {
-
-        Long examId1 = req.getExamId1();
-        Long examId2 = req.getExamId2();
-
-        if (null == examId1) {
-            throw new StatusException("210001", "examId1 is null");
-        }
-        if (null == examId2) {
-            throw new StatusException("210002", "examId2 is null");
-        }
-
-        ExamEntity exam1 = GlobalHelper.getEntity(examRepo, examId1, ExamEntity.class);
-        ExamEntity exam2 = GlobalHelper.getEntity(examRepo, examId2, ExamEntity.class);
-        if (null == exam1) {
-            throw new StatusException("210003", "ExamEntity is null");
-        }
-        if (null == exam2) {
-            throw new StatusException("210004", "ExamEntity is null");
-        }
-
-        if (!exam1.getRootOrgId().equals(exam2.getRootOrgId())) {
-            throw new StatusException("210005", "examId1 and examId2  is not matched");
-        }
-
-        final Long rootOrgId = exam1.getRootOrgId();
-
-        final long start = null == req.getStart() ? 1 : req.getStart();
-
-        Pageable pageable = PageRequest.of(0, 10, Sort.Direction.ASC, "id");
-
-        Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
-            predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
-            predicates.add(cb.equal(root.get("examId"), examId1));
-
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-
-        Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
-
-        Iterator<ExamStudentEntity> iterator = page.iterator();
-
-        List<Long> examStudentIds = Lists.newArrayList();
-
-        long next = start;
-        boolean has = false;
-        while (iterator.hasNext()) {
-            ExamStudentEntity es = iterator.next();
-
-            ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
-                    es.getStudentId(), es.getCourseId());
-
-            if (null != finded) {
-                continue;
-            }
-
-            ExamStudentInfo one = new ExamStudentInfo();
-            one.setExamId(examId2);
-            one.setRootOrgId(es.getRootOrgId());
-            one.setEnable(es.getEnable());
-
-            one.setCourseId(es.getCourseId());
-            one.setCourseCode(es.getCourseCode());
-            one.setCourseLevel(es.getCourseLevel());
-            one.setCourseName(es.getCourseName());
-
-            one.setOrgId(es.getOrgId());
-            one.setOrgCode(es.getOrgCode());
-
-            one.setStudentName(es.getName());
-            one.setStudentCode(es.getStudentCode());
-            one.setStudentId(es.getStudentId());
-            one.setIdentityNumber(es.getIdentityNumber());
-
-            one.setExamSite(es.getExamSite());
-            one.setGrade(es.getGrade());
-            one.setPaperType(es.getPaperType());
-            one.setRemark(es.getRemark());
-            one.setSpecialtyName(es.getSpecialtyName());
-            one.setInfoCollector(es.getInfoCollector());
-
-            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());
-
-            next = es.getId();
-            has = true;
-        }
-
-        if (has) {
-            next++;
-        }
-
-        CopyExamStudentsResp resp = new CopyExamStudentsResp();
-        resp.setNext(next);
-        resp.setExamStudentIds(examStudentIds);
-
-        return resp;
-    }
-
-    @ApiOperation(value = "获取考生")
-    @PostMapping("getExamStudent")
-    @Override
-    public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
-        Long examStudentId = req.getExamStudentId();
-
-        ExamStudentEntity saved = GlobalHelper.getEntity(examStudentRepo, examStudentId,
-                ExamStudentEntity.class);
-
-        ExamStudentBean examStudentBean = new ExamStudentBean();
-        examStudentBean.setId(saved.getId());
-        examStudentBean.setCourseCode(saved.getCourseCode());
-        examStudentBean.setCourseLevel(saved.getCourseLevel());
-        examStudentBean.setCourseName(saved.getCourseName());
-        examStudentBean.setExamId(saved.getExamId());
-        examStudentBean.setIdentityNumber(saved.getIdentityNumber());
-        examStudentBean.setStudentCode(saved.getStudentCode());
-        examStudentBean.setPaperType(saved.getPaperType());
-        examStudentBean.setRootOrgId(saved.getRootOrgId());
-        examStudentBean.setGrade(saved.getGrade());
-        examStudentBean.setCourseId(saved.getCourseId());
-        examStudentBean.setInfoCollector(saved.getInfoCollector());
-        examStudentBean.setExamSite(saved.getExamSite());
-        examStudentBean.setOrgId(saved.getOrgId());
-        examStudentBean.setOrgCode(saved.getOrgCode());
-        examStudentBean.setStudentName(saved.getName());
-        examStudentBean.setSpecialtyName(saved.getSpecialtyName());
-
-        examStudentBean.setExt1(saved.getExt1());
-        examStudentBean.setExt2(saved.getExt2());
-        examStudentBean.setExt3(saved.getExt3());
-        examStudentBean.setExt4(saved.getExt4());
-        examStudentBean.setExt5(saved.getExt5());
-
-        GetExamStudentResp resp = new GetExamStudentResp();
-        resp.setExamStudentBean(examStudentBean);
-        return resp;
-    }
-
-    @ApiOperation(value = " 分页查询考生")
-    @PostMapping("getExamStudentPage")
-    @Override
-    public GetExamStudentPageResp getExamStudentPage(@RequestBody GetExamStudentPageReq req) {
-        Long rootOrgId = req.getRootOrgId();
-        String courseCode = req.getCourseCode();
-        String courseLevel = req.getCourseLevel();
-        String courseName = req.getCourseName();
-        Integer curPage = req.getCurPage();
-        Long examId = req.getExamId();
-        String examSite = req.getExamSite();
-        String identityNumber = req.getIdentityNumber();
-        String infoCollector = req.getInfoCollector();
-        Long orgId = req.getOrgId();
-        String specialtyName = req.getSpecialtyName();
-        String studentCode = req.getStudentCode();
-        String studentName = req.getStudentName();
-        Integer pageSize = req.getPageSize();
-
-        if (null == rootOrgId) {
-            throw new StatusException("210005", "rootOrgId is null");
-        }
-
-        Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
-
-            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.isNotBlank(studentCode)) {
-                predicates.add(cb.like(root.get("studentCode"), toSqlRightLike(studentCode)));
-            }
-            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.isNotBlank(identityNumber)) {
-                predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(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<ExamStudentBean> list = 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();
-
-            ExamStudentBean bean = new ExamStudentBean();
-            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.setCourseCode(cur.getCourseCode());
-            bean.setCourseName(cur.getCourseName());
-            bean.setInfoCollector(cur.getInfoCollector());
-            bean.setOrgId(cur.getOrgId());
-            bean.setOrgCode(org.getCode());
-            bean.setOrgName(org.getName());
-            bean.setPaperType(cur.getPaperType());
-            bean.setGrade(cur.getGrade());
-            bean.setSpecialtyName(cur.getSpecialtyName());
-            bean.setExamSite(cur.getExamSite());
-
-            list.add(bean);
-        }
-
-        GetExamStudentPageResp resp = new GetExamStudentPageResp();
-        resp.setList(list);
-        resp.setTotal(examStudents.getTotalElements());
-
-        return resp;
-    }
-
-    @ApiOperation(value = "更新考生状态")
-    @PostMapping("updateExamStudentStatus")
-    @Transactional
-    @Override
-    public UpdateExamStudentStatusResp updateExamStudentStatus(
-            @RequestBody UpdateExamStudentStatusReq req) {
-        Long rootOrgId = req.getRootOrgId();
-        Long examId = req.getExamId();
-        String examCode = req.getExamCode();
-        String examName = req.getExamName();
-        Long studentId = req.getStudentId();
-        String identityNumber = req.getIdentityNumber();
-        Long courseId = req.getCourseId();
-        String courseCode = req.getCourseCode();
-        Boolean enable = req.getEnable();
-
-        if (null == rootOrgId) {
-            throw new StatusException("088001", "rootOrgId is null");
-        }
-
-        ExamEntity examEntity = null;
-        if (null != examId) {
-            examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
-            GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
-        } else if (StringUtils.isNotBlank(examCode)) {
-            examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
-            if (null == examEntity) {
-                throw new StatusException("088002", "exam is not present");
-            }
-        } else if (StringUtils.isNotBlank(examName)) {
-            examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
-            if (null == examEntity) {
-                throw new StatusException("088003", "exam is not present");
-            }
-        } else {
-            throw new StatusException("088079", "examId,examCode,examName cannot be all empty");
-        }
-
-        if (null == courseId && StringUtils.isBlank(courseCode)) {
-            throw new StatusException("088003", "courseId & courseCode cannot be all null");
-        }
-        GetCourseReq gcR = new GetCourseReq();
-        gcR.setRootOrgId(rootOrgId);
-        gcR.setId(courseId);
-        gcR.setCode(courseCode);
-        GetCourseResp gcResp = courseCloudService.getCourse(gcR);
-        CourseBean courseBean = gcResp.getCourseBean();
-
-        GetStudentReq gsReq = new GetStudentReq();
-        gsReq.setRootOrgId(rootOrgId);
-        gsReq.setIdentityNumber(identityNumber);
-        gsReq.setStudentId(studentId);
-
-        GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
-        StudentBean studentBean = gsResp.getStudentInfo();
-
-        ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(
-                examEntity.getId(), studentBean.getId(), courseBean.getId());
-
-        es.setEnable(enable);
-
-        ExamStudentEntity saved = examStudentRepo.save(es);
-
-        examStudentService.syncExamStudent(saved.getId());
-
-        UpdateExamStudentStatusResp resp = new UpdateExamStudentStatusResp();
-        resp.setExamStudentId(saved.getId());
-        return resp;
-    }
-
-    @ApiOperation(value = "重置考生")
-    @PostMapping("resetExamStudent")
-    @Transactional
-    @Override
-    public ResetExamStudentResp resetExamStudent(@RequestBody ResetExamStudentReq req) {
-
-        Long rootOrgId = req.getRootOrgId();
-        Long examId = req.getExamId();
-        String examCode = req.getExamCode();
-        String examName = req.getExamName();
-        Long studentId = req.getStudentId();
-        String identityNumber = req.getIdentityNumber();
-        String studentName = req.getStudentName();
-        String studentCode = req.getStudentCode();
-
-        if (null == rootOrgId) {
-            throw new StatusException("088001", "rootOrgId is null");
-        }
-
-        ExamEntity examEntity = null;
-        if (null != examId) {
-            examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
-            GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
-        } else if (StringUtils.isNotBlank(examCode)) {
-            examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
-            if (null == examEntity) {
-                throw new StatusException("088002", "exam is not present");
-            }
-        } else if (StringUtils.isNotBlank(examName)) {
-            examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
-            if (null == examEntity) {
-                throw new StatusException("088003", "exam is not present");
-            }
-        } else {
-            throw new StatusException("088075", "examId,examCode,examName cannot be all empty");
-        }
-
-        GetStudentReq gsReq = new GetStudentReq();
-        gsReq.setRootOrgId(rootOrgId);
-        gsReq.setIdentityNumber(identityNumber);
-        gsReq.setStudentId(studentId);
-        gsReq.setStudentCode(studentCode);
-
-        GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
-        StudentBean studentBean = gsResp.getStudentInfo();
-
-        List<ExamStudentEntity> presentExamStudentList = examStudentRepo
-                .findByExamIdAndStudentId(examId, studentBean.getId());
-
-        for (ExamStudentEntity cur : presentExamStudentList) {
-            cur.setEnable(false);
-            examStudentRepo.save(cur);
-            examStudentService.syncExamStudent(cur.getId());
-        }
-
-        List<ExamStudentBean4Reset> examStudentList = req.getExamStudentList();
-        List<ExamStudentBean> savedExamStudentList = Lists.newArrayList();
-
-        for (ExamStudentBean4Reset cur : examStudentList) {
-
-            ExamStudentInfo info = new ExamStudentInfo();
-            info.setCourseCode(cur.getCourseCode());
-            info.setCourseName(cur.getCourseName());
-            info.setCourseLevel(cur.getCourseLevel());
-            info.setCourseId(cur.getCourseId());
-            info.setRootOrgId(req.getRootOrgId());
-            info.setExamId(req.getExamId());
-            info.setExamCode(req.getExamCode());
-            info.setExamName(examEntity.getName());
-            info.setIdentityNumber(identityNumber);
-            info.setPaperType(cur.getPaperType());
-            info.setStudentCode(studentCode);
-            info.setStudentName(studentName);
-            info.setInfoCollector(cur.getInfoCollector());
-            info.setGrade(cur.getGrade());
-            info.setExamSite(cur.getExamSite());
-            info.setSpecialtyName(cur.getSpecialtyName());
-            info.setRemark(cur.getRemark());
-            info.setEnable(true);
-
-            info.setExt1(cur.getExt1());
-            info.setExt2(cur.getExt2());
-            info.setExt3(cur.getExt3());
-            info.setExt4(cur.getExt4());
-            info.setExt5(cur.getExt5());
-
-            ExamStudentInfo saved = examStudentService.saveExamStudent(info);
-
-            ExamStudentBean examStudentBean = new ExamStudentBean();
-            examStudentBean.setId(saved.getId());
-            examStudentBean.setCourseCode(saved.getCourseCode());
-            examStudentBean.setCourseLevel(saved.getCourseLevel());
-            examStudentBean.setCourseName(saved.getCourseName());
-            examStudentBean.setExamId(saved.getExamId());
-            examStudentBean.setExamName(saved.getExamName());
-            examStudentBean.setIdentityNumber(saved.getIdentityNumber());
-            examStudentBean.setStudentCode(saved.getStudentCode());
-            examStudentBean.setPaperType(saved.getPaperType());
-            examStudentBean.setRootOrgId(saved.getRootOrgId());
-            examStudentBean.setStudentName(saved.getStudentName());
-            examStudentBean.setGrade(saved.getGrade());
-            examStudentBean.setCourseId(saved.getCourseId());
-            examStudentBean.setInfoCollector(saved.getInfoCollector());
-            examStudentBean.setExamSite(saved.getExamSite());
-            examStudentBean.setOrgId(saved.getOrgId());
-            examStudentBean.setOrgCode(saved.getOrgCode());
-            examStudentBean.setOrgName(saved.getOrgName());
-
-            savedExamStudentList.add(examStudentBean);
-        }
-
-        ResetExamStudentResp resp = new ResetExamStudentResp();
-        resp.setExamStudentList(savedExamStudentList);
-        return resp;
-    }
+		implements
+			ExamStudentCloudService {
+
+	private static final long serialVersionUID = -89062090947597841L;
+
+	@Autowired
+	ExamRepo examRepo;
+
+	@Autowired
+	ExamService examService;
+
+	@Autowired
+	OrgCloudService orgCloudService;
+
+	@Autowired
+	ExamStudentService examStudentService;
+
+	@Autowired
+	StudentCloudService studentCloudService;
+
+	@Autowired
+	ExamStudentRepo examStudentRepo;
+
+	@Autowired
+	CourseCloudService courseCloudService;
+
+	@Autowired
+	ExamCourseRelationRepo examCourseRelationRepo;
+
+	@Autowired
+	ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
+
+	@ApiOperation(value = "保存考生")
+	@PostMapping("saveExamStudent")
+	@Transactional
+	@Override
+	public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
+		trim(req);
+
+		ExamStudentInfo info = new ExamStudentInfo();
+		info.setCourseCode(req.getCourseCode());
+		info.setCourseName(req.getCourseName());
+		info.setCourseLevel(req.getCourseLevel());
+		info.setCourseId(req.getCourseId());
+		info.setRootOrgId(req.getRootOrgId());
+		info.setExamId(req.getExamId());
+		info.setExamName(req.getExamName());
+		info.setExamCode(req.getExamCode());
+		info.setIdentityNumber(req.getIdentityNumber());
+		info.setPaperType(req.getPaperType());
+		info.setStudentCode(req.getStudentCode());
+		info.setStudentName(req.getStudentName());
+		info.setInfoCollector(req.getInfoCollector());
+		info.setGrade(req.getGrade());
+		info.setExamSite(req.getExamSite());
+		info.setSpecialtyName(req.getSpecialtyName());
+		info.setRemark(req.getRemark());
+
+		info.setSpecialBeginTime(req.getSpecialBeginTime());
+		info.setSpecialEndTime(req.getSpecialEndTime());
+
+		info.setExt1(req.getExt1());
+		info.setExt2(req.getExt2());
+		info.setExt3(req.getExt3());
+		info.setExt4(req.getExt4());
+		info.setExt5(req.getExt5());
+
+		ExamStudentInfo saved = examStudentService.saveExamStudent(info);
+
+		SaveExamStudentResp resp = new SaveExamStudentResp();
+
+		ExamStudentBean examStudentBean = new ExamStudentBean();
+		examStudentBean.setId(saved.getId());
+		examStudentBean.setCourseCode(saved.getCourseCode());
+		examStudentBean.setCourseLevel(saved.getCourseLevel());
+		examStudentBean.setCourseName(saved.getCourseName());
+		examStudentBean.setExamId(saved.getExamId());
+		examStudentBean.setExamName(saved.getExamName());
+		examStudentBean.setIdentityNumber(saved.getIdentityNumber());
+		examStudentBean.setStudentCode(saved.getStudentCode());
+		examStudentBean.setPaperType(saved.getPaperType());
+		examStudentBean.setRootOrgId(saved.getRootOrgId());
+		examStudentBean.setStudentName(saved.getStudentName());
+		examStudentBean.setGrade(saved.getGrade());
+		examStudentBean.setCourseId(saved.getCourseId());
+		examStudentBean.setInfoCollector(saved.getInfoCollector());
+		examStudentBean.setExamSite(saved.getExamSite());
+		examStudentBean.setOrgId(saved.getOrgId());
+		examStudentBean.setOrgCode(saved.getOrgCode());
+		examStudentBean.setOrgName(saved.getOrgName());
+
+		resp.setExamStudentBean(examStudentBean);
+
+		return resp;
+	}
+
+	@ApiOperation(value = "复制考生")
+	@PostMapping("copyExamStudents")
+	@Transactional
+	@Override
+	public CopyExamStudentsResp copyExamStudents(@RequestBody CopyExamStudentsReq req) {
+
+		Long examId1 = req.getExamId1();
+		Long examId2 = req.getExamId2();
+
+		if (null == examId1) {
+			throw new StatusException("210001", "examId1 is null");
+		}
+		if (null == examId2) {
+			throw new StatusException("210002", "examId2 is null");
+		}
+
+		ExamEntity exam1 = GlobalHelper.getEntity(examRepo, examId1, ExamEntity.class);
+		ExamEntity exam2 = GlobalHelper.getEntity(examRepo, examId2, ExamEntity.class);
+		if (null == exam1) {
+			throw new StatusException("210003", "ExamEntity is null");
+		}
+		if (null == exam2) {
+			throw new StatusException("210004", "ExamEntity is null");
+		}
+
+		if (!exam1.getRootOrgId().equals(exam2.getRootOrgId())) {
+			throw new StatusException("210005", "examId1 and examId2  is not matched");
+		}
+
+		final Long rootOrgId = exam1.getRootOrgId();
+
+		final long start = null == req.getStart() ? 1 : req.getStart();
+
+		Pageable pageable = PageRequest.of(0, 10, Sort.Direction.ASC, "id");
+
+		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+			predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
+			predicates.add(cb.equal(root.get("examId"), examId1));
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
+
+		Iterator<ExamStudentEntity> iterator = page.iterator();
+
+		List<Long> examStudentIds = Lists.newArrayList();
+
+		long next = start;
+		boolean has = false;
+		while (iterator.hasNext()) {
+			ExamStudentEntity es = iterator.next();
+
+			ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
+					es.getStudentId(), es.getCourseId());
+
+			if (null != finded) {
+				continue;
+			}
+
+			ExamStudentInfo one = new ExamStudentInfo();
+			one.setExamId(examId2);
+			one.setRootOrgId(es.getRootOrgId());
+			one.setEnable(es.getEnable());
+
+			one.setCourseId(es.getCourseId());
+			one.setCourseCode(es.getCourseCode());
+			one.setCourseLevel(es.getCourseLevel());
+			one.setCourseName(es.getCourseName());
+
+			one.setOrgId(es.getOrgId());
+			one.setOrgCode(es.getOrgCode());
+
+			one.setStudentName(es.getName());
+			one.setStudentCode(es.getStudentCode());
+			one.setStudentId(es.getStudentId());
+			one.setIdentityNumber(es.getIdentityNumber());
+
+			one.setExamSite(es.getExamSite());
+			one.setGrade(es.getGrade());
+			one.setPaperType(es.getPaperType());
+			one.setRemark(es.getRemark());
+			one.setSpecialtyName(es.getSpecialtyName());
+			one.setInfoCollector(es.getInfoCollector());
+
+			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());
+
+			next = es.getId();
+			has = true;
+		}
+
+		if (has) {
+			next++;
+		}
+
+		CopyExamStudentsResp resp = new CopyExamStudentsResp();
+		resp.setNext(next);
+		resp.setExamStudentIds(examStudentIds);
+
+		return resp;
+	}
+
+	@ApiOperation(value = "获取考生")
+	@PostMapping("getExamStudent")
+	@Override
+	public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
+		Long examStudentId = req.getExamStudentId();
+
+		ExamStudentEntity saved = GlobalHelper.getEntity(examStudentRepo, examStudentId,
+				ExamStudentEntity.class);
+
+		ExamStudentBean examStudentBean = new ExamStudentBean();
+		examStudentBean.setId(saved.getId());
+		examStudentBean.setCourseCode(saved.getCourseCode());
+		examStudentBean.setCourseLevel(saved.getCourseLevel());
+		examStudentBean.setCourseName(saved.getCourseName());
+		examStudentBean.setExamId(saved.getExamId());
+		examStudentBean.setIdentityNumber(saved.getIdentityNumber());
+		examStudentBean.setStudentCode(saved.getStudentCode());
+		examStudentBean.setPaperType(saved.getPaperType());
+		examStudentBean.setRootOrgId(saved.getRootOrgId());
+		examStudentBean.setGrade(saved.getGrade());
+		examStudentBean.setCourseId(saved.getCourseId());
+		examStudentBean.setInfoCollector(saved.getInfoCollector());
+		examStudentBean.setExamSite(saved.getExamSite());
+		examStudentBean.setOrgId(saved.getOrgId());
+		examStudentBean.setOrgCode(saved.getOrgCode());
+		examStudentBean.setStudentName(saved.getName());
+		examStudentBean.setSpecialtyName(saved.getSpecialtyName());
+
+		examStudentBean.setExt1(saved.getExt1());
+		examStudentBean.setExt2(saved.getExt2());
+		examStudentBean.setExt3(saved.getExt3());
+		examStudentBean.setExt4(saved.getExt4());
+		examStudentBean.setExt5(saved.getExt5());
+
+		GetExamStudentResp resp = new GetExamStudentResp();
+		resp.setExamStudentBean(examStudentBean);
+		return resp;
+	}
+
+	@ApiOperation(value = " 分页查询考生")
+	@PostMapping("getExamStudentPage")
+	@Override
+	public GetExamStudentPageResp getExamStudentPage(@RequestBody GetExamStudentPageReq req) {
+		Long rootOrgId = req.getRootOrgId();
+		String courseCode = req.getCourseCode();
+		String courseLevel = req.getCourseLevel();
+		String courseName = req.getCourseName();
+		Integer curPage = req.getCurPage();
+		Long examId = req.getExamId();
+		String examSite = req.getExamSite();
+		String identityNumber = req.getIdentityNumber();
+		String infoCollector = req.getInfoCollector();
+		Long orgId = req.getOrgId();
+		String specialtyName = req.getSpecialtyName();
+		String studentCode = req.getStudentCode();
+		String studentName = req.getStudentName();
+		Integer pageSize = req.getPageSize();
+
+		if (null == rootOrgId) {
+			throw new StatusException("210005", "rootOrgId is null");
+		}
+
+		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+
+			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 (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)) {
+				predicates.add(
+						cb.like(root.get("identityNumber"), toSqlSearchPattern(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<ExamStudentBean> list = 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();
+
+			ExamStudentBean bean = new ExamStudentBean();
+			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.setCourseCode(cur.getCourseCode());
+			bean.setCourseName(cur.getCourseName());
+			bean.setInfoCollector(cur.getInfoCollector());
+			bean.setOrgId(cur.getOrgId());
+			bean.setOrgCode(org.getCode());
+			bean.setOrgName(org.getName());
+			bean.setPaperType(cur.getPaperType());
+			bean.setGrade(cur.getGrade());
+			bean.setSpecialtyName(cur.getSpecialtyName());
+			bean.setExamSite(cur.getExamSite());
+
+			list.add(bean);
+		}
+
+		GetExamStudentPageResp resp = new GetExamStudentPageResp();
+		resp.setList(list);
+		resp.setTotal(examStudents.getTotalElements());
+
+		return resp;
+	}
+
+	@ApiOperation(value = "更新考生状态")
+	@PostMapping("updateExamStudentStatus")
+	@Transactional
+	@Override
+	public UpdateExamStudentStatusResp updateExamStudentStatus(
+			@RequestBody UpdateExamStudentStatusReq req) {
+		Long rootOrgId = req.getRootOrgId();
+		Long examId = req.getExamId();
+		String examCode = req.getExamCode();
+		String examName = req.getExamName();
+		Long studentId = req.getStudentId();
+		String identityNumber = req.getIdentityNumber();
+		Long courseId = req.getCourseId();
+		String courseCode = req.getCourseCode();
+		Boolean enable = req.getEnable();
+
+		if (null == rootOrgId) {
+			throw new StatusException("088001", "rootOrgId is null");
+		}
+
+		ExamEntity examEntity = null;
+		if (null != examId) {
+			examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
+			GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
+		} else if (StringUtils.isNotBlank(examCode)) {
+			examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088002", "exam is not present");
+			}
+		} else if (StringUtils.isNotBlank(examName)) {
+			examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088003", "exam is not present");
+			}
+		} else {
+			throw new StatusException("088079", "examId,examCode,examName cannot be all empty");
+		}
+
+		if (null == courseId && StringUtils.isBlank(courseCode)) {
+			throw new StatusException("088003", "courseId & courseCode cannot be all null");
+		}
+		GetCourseReq gcR = new GetCourseReq();
+		gcR.setRootOrgId(rootOrgId);
+		gcR.setId(courseId);
+		gcR.setCode(courseCode);
+		GetCourseResp gcResp = courseCloudService.getCourse(gcR);
+		CourseBean courseBean = gcResp.getCourseBean();
+
+		GetStudentReq gsReq = new GetStudentReq();
+		gsReq.setRootOrgId(rootOrgId);
+		gsReq.setIdentityNumber(identityNumber);
+		gsReq.setStudentId(studentId);
+
+		GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
+		StudentBean studentBean = gsResp.getStudentInfo();
+
+		ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(
+				examEntity.getId(), studentBean.getId(), courseBean.getId());
+
+		es.setEnable(enable);
+
+		ExamStudentEntity saved = examStudentRepo.save(es);
+
+		examStudentService.syncExamStudent(saved.getId());
+
+		UpdateExamStudentStatusResp resp = new UpdateExamStudentStatusResp();
+		resp.setExamStudentId(saved.getId());
+		return resp;
+	}
+
+	@ApiOperation(value = "重置考生")
+	@PostMapping("resetExamStudent")
+	@Transactional
+	@Override
+	public ResetExamStudentResp resetExamStudent(@RequestBody ResetExamStudentReq req) {
+
+		Long rootOrgId = req.getRootOrgId();
+		Long examId = req.getExamId();
+		String examCode = req.getExamCode();
+		String examName = req.getExamName();
+		Long studentId = req.getStudentId();
+		String identityNumber = req.getIdentityNumber();
+		String studentName = req.getStudentName();
+		String studentCode = req.getStudentCode();
+
+		if (null == rootOrgId) {
+			throw new StatusException("088001", "rootOrgId is null");
+		}
+
+		ExamEntity examEntity = null;
+		if (null != examId) {
+			examEntity = GlobalHelper.getPresentEntity(examRepo, examId, ExamEntity.class);
+			GlobalHelper.uniformRootOrg(examEntity.getRootOrgId(), rootOrgId);
+		} else if (StringUtils.isNotBlank(examCode)) {
+			examEntity = examRepo.findByCodeAndRootOrgId(examCode, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088002", "exam is not present");
+			}
+		} else if (StringUtils.isNotBlank(examName)) {
+			examEntity = examRepo.findByNameAndRootOrgId(examName, rootOrgId);
+			if (null == examEntity) {
+				throw new StatusException("088003", "exam is not present");
+			}
+		} else {
+			throw new StatusException("088075", "examId,examCode,examName cannot be all empty");
+		}
+
+		GetStudentReq gsReq = new GetStudentReq();
+		gsReq.setRootOrgId(rootOrgId);
+		gsReq.setIdentityNumber(identityNumber);
+		gsReq.setStudentId(studentId);
+		gsReq.setStudentCode(studentCode);
+
+		GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
+		StudentBean studentBean = gsResp.getStudentInfo();
+
+		List<ExamStudentEntity> presentExamStudentList = examStudentRepo
+				.findByExamIdAndStudentId(examId, studentBean.getId());
+
+		for (ExamStudentEntity cur : presentExamStudentList) {
+			cur.setEnable(false);
+			examStudentRepo.save(cur);
+			examStudentService.syncExamStudent(cur.getId());
+		}
+
+		List<ExamStudentBean4Reset> examStudentList = req.getExamStudentList();
+		List<ExamStudentBean> savedExamStudentList = Lists.newArrayList();
+
+		for (ExamStudentBean4Reset cur : examStudentList) {
+
+			ExamStudentInfo info = new ExamStudentInfo();
+			info.setCourseCode(cur.getCourseCode());
+			info.setCourseName(cur.getCourseName());
+			info.setCourseLevel(cur.getCourseLevel());
+			info.setCourseId(cur.getCourseId());
+			info.setRootOrgId(req.getRootOrgId());
+			info.setExamId(req.getExamId());
+			info.setExamCode(req.getExamCode());
+			info.setExamName(examEntity.getName());
+			info.setIdentityNumber(identityNumber);
+			info.setPaperType(cur.getPaperType());
+			info.setStudentCode(studentCode);
+			info.setStudentName(studentName);
+			info.setInfoCollector(cur.getInfoCollector());
+			info.setGrade(cur.getGrade());
+			info.setExamSite(cur.getExamSite());
+			info.setSpecialtyName(cur.getSpecialtyName());
+			info.setRemark(cur.getRemark());
+			info.setEnable(true);
+
+			info.setExt1(cur.getExt1());
+			info.setExt2(cur.getExt2());
+			info.setExt3(cur.getExt3());
+			info.setExt4(cur.getExt4());
+			info.setExt5(cur.getExt5());
+
+			ExamStudentInfo saved = examStudentService.saveExamStudent(info);
+
+			ExamStudentBean examStudentBean = new ExamStudentBean();
+			examStudentBean.setId(saved.getId());
+			examStudentBean.setCourseCode(saved.getCourseCode());
+			examStudentBean.setCourseLevel(saved.getCourseLevel());
+			examStudentBean.setCourseName(saved.getCourseName());
+			examStudentBean.setExamId(saved.getExamId());
+			examStudentBean.setExamName(saved.getExamName());
+			examStudentBean.setIdentityNumber(saved.getIdentityNumber());
+			examStudentBean.setStudentCode(saved.getStudentCode());
+			examStudentBean.setPaperType(saved.getPaperType());
+			examStudentBean.setRootOrgId(saved.getRootOrgId());
+			examStudentBean.setStudentName(saved.getStudentName());
+			examStudentBean.setGrade(saved.getGrade());
+			examStudentBean.setCourseId(saved.getCourseId());
+			examStudentBean.setInfoCollector(saved.getInfoCollector());
+			examStudentBean.setExamSite(saved.getExamSite());
+			examStudentBean.setOrgId(saved.getOrgId());
+			examStudentBean.setOrgCode(saved.getOrgCode());
+			examStudentBean.setOrgName(saved.getOrgName());
+
+			savedExamStudentList.add(examStudentBean);
+		}
+
+		ResetExamStudentResp resp = new ResetExamStudentResp();
+		resp.setExamStudentList(savedExamStudentList);
+		return resp;
+	}
 
 }