xiatian 1 kuukausi sitten
vanhempi
commit
14462b770f

+ 338 - 310
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/ExamRecordForMarkingCloudServiceProvider.java

@@ -10,7 +10,6 @@ import java.util.stream.Collectors;
 
 import javax.persistence.criteria.Predicate;
 
-import cn.com.qmth.examcloud.support.fss.FssHelper;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +55,7 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordForMarkingEntity
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordQuestionsService;
+import cn.com.qmth.examcloud.support.fss.FssHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
@@ -71,314 +71,342 @@ import io.swagger.annotations.ApiOperation;
 @RestController
 @RequestMapping("${$rmp.cloud.oe}/examRecordForMarking")
 public class ExamRecordForMarkingCloudServiceProvider extends ControllerSupport
-		implements ExamRecordForMarkingCloudService {
-
-	private static final long serialVersionUID = -8343697288418890873L;
-	@Autowired
-	private JdbcTemplate jdbcTemplate;
-	@Autowired
-	private ExamRecordForMarkingService examRecordForMarkingService;
-
-	@Autowired
-	private ExamStudentRepo examStudentRepo;
-
-	@Autowired
-	private ExamRecordDataRepo examRecordDataRepo;
-
-	@Autowired
-	private ExamRecordForMarkingRepo examRecordForMarkingRepo;
-
-	@Autowired
-	private ExamRecordQuestionsService examRecordQuestionsService;
-
-	@Autowired
-	private ExamRecordFileAnswerRepo examRecordFileAnswerRepo;
-
-	@Override
-	@ApiOperation(value = "根据条件查询阅卷需要的信息")
-	@PostMapping("/findExamRecordForMarkingInfo")
-	public FindExamRecordForMarkingInfoResp findExamRecordForMarkingInfo(
-			@RequestBody FindExamRecordForMarkingInfoReq req) {
-		Long id = req.getId();
-		Long examId = req.getExamId();
-		FindExamRecordForMarkingInfoResp resp = new FindExamRecordForMarkingInfoResp();
-		if (id == null && examId == null) {
-			return resp;
-		}
-
-		List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
-				.findExamRecordForMarkingInfo(id, examId, req.getCourseId(), req.getBatchNum());
-		List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<>();
-		for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
-			ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
-			examRecordForMarkingBean.setId(entity.getId());
-			examRecordForMarkingBean.setExamId(entity.getExamId());
-			examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
-			examRecordForMarkingBean.setPaperType(entity.getPaperType());
-			examRecordForMarkingBean.setCourseId(entity.getCourseId());
-
-			if (entity.getExamRecordDataId() == null) {
-				throw new StatusException("500101", "阅卷信息错误,考试记录ID存在空值!");
-			}
-
-			long examRecordDataId = entity.getExamRecordDataId();
-			List<ExamRecordFileAnswerEntity> fileAnswerList = examRecordFileAnswerRepo
-					.findByExamRecordDataId(examRecordDataId);
-			if (fileAnswerList != null) {
-				examRecordForMarkingBean.setOfflineFiles(getOfflineFilesFrom(fileAnswerList));
-			}
-
-			examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
-			examRecordForMarkingBeanList.add(examRecordForMarkingBean);
-		}
-
-		resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
-		return resp;
-	}
-
-	private List<ExamRecordFileAnswerBean> getOfflineFilesFrom(List<ExamRecordFileAnswerEntity> fileAnswerList) {
-		List<ExamRecordFileAnswerBean> resultList = new ArrayList<>();
-		for (ExamRecordFileAnswerEntity entity : fileAnswerList) {
-			ExamRecordFileAnswerBean bean = new ExamRecordFileAnswerBean();
-			bean.setId(entity.getId());
-			bean.setExamRecordDataId(entity.getExamRecordDataId());
-
-			bean.setOfflineFileUrl(FssHelper.finalFileUrl(entity.getFileUrl()));
-
-			bean.setOfflineFileName(entity.getFileName());
-			bean.setOriginalFileName(entity.getOriginalFileName());
-			bean.setFileType(entity.getFileType());
-			bean.setSuffix(entity.getSuffix());
-			bean.setProperties(entity.getProperties());
-			resultList.add(bean);
-		}
-
-		return resultList;
-	}
-
-	@Override
-	@ApiOperation(value = "查询有效成绩")
-	@PostMapping("/queryValidExamRecordInfo")
-	public QueryValidExamRecordInfoResp queryValidExamRecordInfo(@RequestBody QueryValidExamRecordInfoReq req) {
-		Check.isNull(req.getExamId(), "examId不能为空");
-		Check.isNull(req.getCourseId(), "courseId不能为空");
-		List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
-				.queryValidExamRecordList(req.getExamId(), req.getCourseId());
-
-		QueryValidExamRecordInfoResp resp = new QueryValidExamRecordInfoResp();
-		List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
-		for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
-			ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
-			examRecordForMarkingBean.setId(entity.getId());
-			examRecordForMarkingBean.setExamId(entity.getExamId());
-			examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
-			examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
-			examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
-			examRecordForMarkingBean.setPaperType(entity.getPaperType());
-			examRecordForMarkingBean.setCourseId(entity.getCourseId());
-			examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
-			examRecordForMarkingBeanList.add(examRecordForMarkingBean);
-		}
-		resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
-		return resp;
-	}
-
-	@Override
-	@ApiOperation(value = "分页查询有效成绩")
-	@PostMapping("/queryValidExamRecordInfoPage")
-	public QueryValidExamRecordInfoPageResp queryValidExamRecordInfoPage(
-			@RequestBody QueryValidExamRecordInfoPageReq req) {
-		Check.isNull(req.getExamId(), "examId不能为空");
-		Check.isNull(req.getCourseId(), "courseId不能为空");
-		Check.isNull(req.getStart(), "start不能为空");
-		Check.isNull(req.getSize(), "size不能为空");
-		if (req.getStart().longValue() <= 0) {
-			throw new StatusException(OE_CODE_400, "start必须大于0");
-		}
-		if (req.getSize().longValue() <= 0) {
-			throw new StatusException(OE_CODE_400, "size必须大于0");
-		}
-		Long courseId = req.getCourseId();
-		Long examId = req.getExamId();
-		Long size = req.getSize();
-		Long start = req.getStart();
-		// 分页获取考生id
-		Pageable pageable = PageRequest.of(0, size.intValue(), Sort.Direction.ASC, "id");
-
-		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("examId"), examId));
-			predicates.add(cb.equal(root.get("courseId"), courseId));
-			predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
-
-		Iterator<ExamStudentEntity> iterator = page.iterator();
-
-		List<Long> stuIdList = Lists.newArrayList();
-		Long next = start;
-		while (iterator.hasNext()) {
-			ExamStudentEntity e = iterator.next();
-			next = e.getId();
-			stuIdList.add(e.getExamStudentId());
-		}
-
-		QueryValidExamRecordInfoPageResp resp = new QueryValidExamRecordInfoPageResp();
-		if (!next.equals(start)) {
-			next++;
-		}
-		resp.setNext(next);
-		// 根据分页获取的考生id获取需要阅卷的试卷
-		List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
-		if (stuIdList.size() > 0) {
-			List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
-					.queryValidExamRecordInfoByStuIds(examId, courseId, stuIdList, req.getBatchNum());
-
-			if (CollectionUtils.isEmpty(examRecordForMarkingList)) {
-				resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
-				return resp;
-			}
-
-			for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
-				ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
-				examRecordForMarkingBean.setId(entity.getId());
-				examRecordForMarkingBean.setExamId(entity.getExamId());
-				examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
-				examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
-				examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
-				examRecordForMarkingBean.setPaperType(entity.getPaperType());
-				examRecordForMarkingBean.setCourseId(entity.getCourseId());
-				examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
-				examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
-				examRecordForMarkingBeanList.add(examRecordForMarkingBean);
-			}
-			fillTatolScoreAndOtherInfo(examRecordForMarkingBeanList);
-		}
-		resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
-		return resp;
-	}
-
-	private void fillTatolScoreAndOtherInfo(List<ExamRecordForMarkingBean> list) {
-		RowMapper<ExamRecordDataTotalScoreVo> rowMapper = new BeanPropertyRowMapper<>(ExamRecordDataTotalScoreVo.class);
-		StringBuilder sb = new StringBuilder(
-				"select t.id,t.paper_score totalScore,random_paper randomPaper from ec_oe_exam_record_data t where t.id in (");
-		List<Long> ids = list.stream().map(e -> e.getExamRecordDataId()).collect(Collectors.toList());
-		sb.append(StringUtils.join(ids, ","));
-		sb.append(")");
-		List<ExamRecordDataTotalScoreVo> dtos = jdbcTemplate.query(sb.toString(), rowMapper);
-		Map<Long, ExamRecordDataTotalScoreVo> totalScores = dtos.stream().collect(Collectors.toMap(e -> e.getId(), e -> e));
-		for(ExamRecordForMarkingBean b:list) {
-			b.setTotalScore(totalScores.get(b.getExamRecordDataId()).getTotalScore());
-			b.setRandomPaper(totalScores.get(b.getExamRecordDataId()).getRandomPaper());
-		}
-	}
-
-	/**
-	 * 获取单个考试记录信息
-	 *
-	 * @param req
-	 * @return
-	 */
-	@Override
-	@PostMapping("/getSingleExamRecordData")
-	public GetSingleExamRecordDataResp getSingleExamRecordData(@RequestBody GetSingleExamRecordDataReq req) {
-		Check.isNull(req.getId(), "id不能为空");
-		ExamRecordDataEntity entity = GlobalHelper.getEntity(examRecordDataRepo, req.getId(),
-				ExamRecordDataEntity.class);
-		if (entity == null) {
-			return new GetSingleExamRecordDataResp();
-		}
-
-		return copyGetSingleExamRecordDataRespFrom(entity);
-	}
-
-	private GetSingleExamRecordDataResp copyGetSingleExamRecordDataRespFrom(ExamRecordDataEntity entity) {
-		GetSingleExamRecordDataResp resp = new GetSingleExamRecordDataResp();
-
-		ExamRecordDataBean data = new ExamRecordDataBean();
-		data.setId(entity.getId());
-		data.setExamId(entity.getExamId());
-		data.setExamType(entity.getExamType() == null ? null : entity.getExamType().toString());
-		data.setExamStudentId(entity.getExamStudentId());
-		data.setStudentId(entity.getStudentId());
-		data.setStudentCode(entity.getStudentCode());
-		data.setStudentName(entity.getStudentName());
-		data.setIdentityNumber(entity.getIdentityNumber());
-		data.setCourseId(entity.getCourseId());
-		data.setCourseLevel(entity.getCourseLevel());
-		data.setOrgId(entity.getOrgId());
-		data.setRootOrgId(entity.getRootOrgId());
-		data.setBasePaperId(entity.getBasePaperId());
-		data.setPaperType(entity.getPaperType());
-		data.setPaperStructId(entity.getPaperStructId());
-		data.setInfoCollector(entity.getInfoCollector());
-		data.setExamRecordQuestionsId(entity.getExamRecordQuestionsId());
-		data.setExamRecordStatus(entity.getExamRecordStatus() == null ? null : entity.getExamRecordStatus().toString());
-		data.setStartTime(entity.getStartTime());
-		data.setEndTime(entity.getEndTime());
-		data.setCleanTime(entity.getCleanTime());
-		data.setWarn(entity.getIsWarn());
-		data.setAudit(entity.getIsAudit());
-		data.setIllegality(entity.getIsIllegality());
-		data.setUsedExamTime(entity.getUsedExamTime());
-		data.setExamOrder(entity.getExamOrder());
-		data.setReexamine(entity.getIsReexamine());
-		data.setContinued(entity.getIsContinued());
-		data.setAllObjectivePaper(entity.getIsAllObjectivePaper());
-		data.setContinuedCount(entity.getContinuedCount());
-		data.setExceed(entity.getIsExceed());
-		data.setFaceSuccessCount(entity.getFaceSuccessCount());
-		data.setFaceFailedCount(entity.getFaceFailedCount());
-		data.setFaceStrangerCount(entity.getFaceStrangerCount());
-		data.setFaceTotalCount(entity.getFaceTotalCount());
-		data.setFaceSuccessPercent(entity.getFaceSuccessPercent());
-		data.setFaceVerifyResult(entity.getFaceVerifyResult() == null ? null : entity.getFaceVerifyResult().toString());
-		data.setBaiduFaceLivenessSuccessPercent(entity.getBaiduFaceLivenessSuccessPercent());
-		data.setFaceLandmarkVal(entity.getFaceLandmarkVal());
-		data.setRandomPaper(entity.getRandomPaper());
-		data.setPaperScore(entity.getPaperScore());
-
-		resp.setData(data);
-		return resp;
-	}
-
-	@Override
-	@PostMapping("/updateExamRecordForMarkingBatchNum")
-	public void updateExamRecordForMarkingBatchNum(@RequestBody UpdateExamRecordForMarkingBatchNumReq req) {
-		if (req.getIdList() == null || req.getIdList().isEmpty()) {
-			throw new StatusException("222001", "阅卷原始数据表id不允许为空");
-		}
-		if (req.getIdList().size() > 100) {
-			throw new StatusException("222002", "阅卷原始数据表id集合最大不得超过100条");
-		}
-		if (StringUtils.isBlank(req.getBatchNum())) {
-			throw new StatusException("222003", "批次号不允许为空");
-		}
-		examRecordForMarkingRepo.updateBatchNum(req.getIdList(), req.getBatchNum());
-	}
-
-	@Override
-	@PostMapping("/saveExamRecordForMarking")
-	public void saveExamRecordForMarking(@RequestBody SaveExamRecordForMarkingReq req) {
-		ExamRecordForMarkingEntity examRecordForMarkingExists = examRecordForMarkingRepo
-				.findByExamRecordDataId(req.getExamRecordDataId());
-		if (examRecordForMarkingExists != null) {
-			return;
-		}
-		ExamRecordForMarkingEntity examRecordForMarking = new ExamRecordForMarkingEntity();
-		examRecordForMarking.setExamId(req.getExamId());
-		examRecordForMarking.setExamRecordDataId(req.getExamRecordDataId());
-		examRecordForMarking.setExamStudentId(req.getExamStudentId());
-		examRecordForMarking.setBasePaperId(req.getBasePaperId());
-		examRecordForMarking.setPaperType(req.getPaperType());
-		examRecordForMarking.setCourseId(req.getCourseId());
-		examRecordForMarking.setObjectiveScore(req.getObjectiveScore());
-		int subjectiveAnswerLength = examRecordQuestionsService
-				.calculationSubjectiveAnswerLength(req.getExamRecordDataId());
-		examRecordForMarking.setSubjectiveAnswerLength(subjectiveAnswerLength);
-		examRecordForMarkingRepo.save(examRecordForMarking);
-	}
+        implements ExamRecordForMarkingCloudService {
+
+    private static final long serialVersionUID = -8343697288418890873L;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private ExamRecordForMarkingService examRecordForMarkingService;
+
+    @Autowired
+    private ExamStudentRepo examStudentRepo;
+
+    @Autowired
+    private ExamRecordDataRepo examRecordDataRepo;
+
+    @Autowired
+    private ExamRecordForMarkingRepo examRecordForMarkingRepo;
+
+    @Autowired
+    private ExamRecordQuestionsService examRecordQuestionsService;
+
+    @Autowired
+    private ExamRecordFileAnswerRepo examRecordFileAnswerRepo;
+
+    @Override
+    @ApiOperation(value = "根据条件查询阅卷需要的信息")
+    @PostMapping("/findExamRecordForMarkingInfo")
+    public FindExamRecordForMarkingInfoResp findExamRecordForMarkingInfo(
+            @RequestBody FindExamRecordForMarkingInfoReq req) {
+        Long id = req.getId();
+        Long examId = req.getExamId();
+        FindExamRecordForMarkingInfoResp resp = new FindExamRecordForMarkingInfoResp();
+        if (id == null && examId == null) {
+            return resp;
+        }
+
+        List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
+                .findExamRecordForMarkingInfo(id, examId, req.getCourseId(), req.getBatchNum());
+        List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<>();
+        for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
+            ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
+            examRecordForMarkingBean.setId(entity.getId());
+            examRecordForMarkingBean.setExamId(entity.getExamId());
+            examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
+            examRecordForMarkingBean.setPaperType(entity.getPaperType());
+            examRecordForMarkingBean.setCourseId(entity.getCourseId());
+
+            if (entity.getExamRecordDataId() == null) {
+                throw new StatusException("500101", "阅卷信息错误,考试记录ID存在空值!");
+            }
+
+            long examRecordDataId = entity.getExamRecordDataId();
+            List<ExamRecordFileAnswerEntity> fileAnswerList = examRecordFileAnswerRepo
+                    .findByExamRecordDataId(examRecordDataId);
+            if (fileAnswerList != null) {
+                examRecordForMarkingBean.setOfflineFiles(getOfflineFilesFrom(fileAnswerList));
+            }
+
+            examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
+            examRecordForMarkingBeanList.add(examRecordForMarkingBean);
+        }
+
+        resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+        return resp;
+    }
+
+    private List<ExamRecordFileAnswerBean> getOfflineFilesFrom(List<ExamRecordFileAnswerEntity> fileAnswerList) {
+        List<ExamRecordFileAnswerBean> resultList = new ArrayList<>();
+        for (ExamRecordFileAnswerEntity entity : fileAnswerList) {
+            ExamRecordFileAnswerBean bean = new ExamRecordFileAnswerBean();
+            bean.setId(entity.getId());
+            bean.setExamRecordDataId(entity.getExamRecordDataId());
+
+            bean.setOfflineFileUrl(FssHelper.finalFileUrl(entity.getFileUrl()));
+
+            bean.setOfflineFileName(entity.getFileName());
+            bean.setOriginalFileName(entity.getOriginalFileName());
+            bean.setFileType(entity.getFileType());
+            bean.setSuffix(entity.getSuffix());
+            bean.setProperties(entity.getProperties());
+            resultList.add(bean);
+        }
+
+        return resultList;
+    }
+
+    @Override
+    @ApiOperation(value = "查询有效成绩")
+    @PostMapping("/queryValidExamRecordInfo")
+    public QueryValidExamRecordInfoResp queryValidExamRecordInfo(@RequestBody QueryValidExamRecordInfoReq req) {
+        Check.isNull(req.getExamId(), "examId不能为空");
+        Check.isNull(req.getCourseId(), "courseId不能为空");
+        List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
+                .queryValidExamRecordList(req.getExamId(), req.getCourseId());
+
+        QueryValidExamRecordInfoResp resp = new QueryValidExamRecordInfoResp();
+        List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
+        for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
+            ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
+            examRecordForMarkingBean.setId(entity.getId());
+            examRecordForMarkingBean.setExamId(entity.getExamId());
+            examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
+            examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
+            examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
+            examRecordForMarkingBean.setPaperType(entity.getPaperType());
+            examRecordForMarkingBean.setCourseId(entity.getCourseId());
+            examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
+            examRecordForMarkingBeanList.add(examRecordForMarkingBean);
+        }
+        resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+        return resp;
+    }
+
+    @Override
+    @ApiOperation(value = "分页查询有效成绩")
+    @PostMapping("/queryValidExamRecordInfoPage")
+    public QueryValidExamRecordInfoPageResp queryValidExamRecordInfoPage(
+            @RequestBody QueryValidExamRecordInfoPageReq req) {
+        Check.isNull(req.getExamId(), "examId不能为空");
+        Check.isNull(req.getCourseId(), "courseId不能为空");
+        Check.isNull(req.getStart(), "start不能为空");
+        Check.isNull(req.getSize(), "size不能为空");
+        if (req.getStart().longValue() <= 0) {
+            throw new StatusException(OE_CODE_400, "start必须大于0");
+        }
+        if (req.getSize().longValue() <= 0) {
+            throw new StatusException(OE_CODE_400, "size必须大于0");
+        }
+        Long courseId = req.getCourseId();
+        Long examId = req.getExamId();
+        Long size = req.getSize();
+        Long start = req.getStart();
+        // 分页获取考生id
+        Pageable pageable = PageRequest.of(0, size.intValue(), Sort.Direction.ASC, "id");
+
+        Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(cb.equal(root.get("examId"), examId));
+            predicates.add(cb.equal(root.get("courseId"), courseId));
+            predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
+
+        Iterator<ExamStudentEntity> iterator = page.iterator();
+
+        List<Long> stuIdList = Lists.newArrayList();
+        Long next = start;
+        while (iterator.hasNext()) {
+            ExamStudentEntity e = iterator.next();
+            next = e.getId();
+            stuIdList.add(e.getExamStudentId());
+        }
+
+        QueryValidExamRecordInfoPageResp resp = new QueryValidExamRecordInfoPageResp();
+        if (!next.equals(start)) {
+            next++;
+        }
+        resp.setNext(next);
+        // 根据分页获取的考生id获取需要阅卷的试卷
+        List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
+        if (stuIdList.size() > 0) {
+            List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
+                    .queryValidExamRecordInfoByStuIds(examId, courseId, stuIdList, req.getBatchNum());
+
+            if (CollectionUtils.isEmpty(examRecordForMarkingList)) {
+                resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+                return resp;
+            }
+
+            for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
+                ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
+                examRecordForMarkingBean.setId(entity.getId());
+                examRecordForMarkingBean.setExamId(entity.getExamId());
+                examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
+                examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
+                examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
+                examRecordForMarkingBean.setPaperType(entity.getPaperType());
+                examRecordForMarkingBean.setCourseId(entity.getCourseId());
+                examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
+                examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
+                examRecordForMarkingBeanList.add(examRecordForMarkingBean);
+            }
+            fillTatolScoreAndOtherInfo(examRecordForMarkingBeanList);
+        }
+        resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+        return resp;
+    }
+
+    private void fillTatolScoreAndOtherInfo(List<ExamRecordForMarkingBean> list) {
+        RowMapper<ExamRecordDataTotalScoreVo> rowMapper = new BeanPropertyRowMapper<>(ExamRecordDataTotalScoreVo.class);
+        StringBuilder sb = new StringBuilder(
+                "select t.id,t.paper_score totalScore,random_paper randomPaper from ec_oe_exam_record_data t where t.id in (");
+        List<Long> ids = list.stream().map(e -> e.getExamRecordDataId()).collect(Collectors.toList());
+        sb.append(StringUtils.join(ids, ","));
+        sb.append(")");
+        List<ExamRecordDataTotalScoreVo> dtos = jdbcTemplate.query(sb.toString(), rowMapper);
+        Map<Long, ExamRecordDataTotalScoreVo> totalScores = dtos.stream()
+                .collect(Collectors.toMap(e -> e.getId(), e -> e));
+        for (ExamRecordForMarkingBean b : list) {
+            b.setTotalScore(totalScores.get(b.getExamRecordDataId()).getTotalScore());
+            b.setRandomPaper(totalScores.get(b.getExamRecordDataId()).getRandomPaper());
+        }
+    }
+
+    /**
+     * 获取单个考试记录信息
+     *
+     * @param req
+     * @return
+     */
+    @Override
+    @PostMapping("/getSingleExamRecordData")
+    public GetSingleExamRecordDataResp getSingleExamRecordData(@RequestBody GetSingleExamRecordDataReq req) {
+        Check.isNull(req.getId(), "id不能为空");
+        ExamRecordDataEntity entity = GlobalHelper.getEntity(examRecordDataRepo, req.getId(),
+                ExamRecordDataEntity.class);
+        if (entity == null) {
+            return new GetSingleExamRecordDataResp();
+        }
+
+        return copyGetSingleExamRecordDataRespFrom(entity);
+    }
+
+    private GetSingleExamRecordDataResp copyGetSingleExamRecordDataRespFrom(ExamRecordDataEntity entity) {
+        GetSingleExamRecordDataResp resp = new GetSingleExamRecordDataResp();
+
+        ExamRecordDataBean data = new ExamRecordDataBean();
+        data.setId(entity.getId());
+        data.setExamId(entity.getExamId());
+        data.setExamType(entity.getExamType() == null ? null : entity.getExamType().toString());
+        data.setExamStudentId(entity.getExamStudentId());
+        data.setStudentId(entity.getStudentId());
+        data.setStudentCode(entity.getStudentCode());
+        data.setStudentName(entity.getStudentName());
+        data.setIdentityNumber(entity.getIdentityNumber());
+        data.setCourseId(entity.getCourseId());
+        data.setCourseLevel(entity.getCourseLevel());
+        data.setOrgId(entity.getOrgId());
+        data.setRootOrgId(entity.getRootOrgId());
+        data.setBasePaperId(entity.getBasePaperId());
+        data.setPaperType(entity.getPaperType());
+        data.setPaperStructId(entity.getPaperStructId());
+        data.setInfoCollector(entity.getInfoCollector());
+        data.setExamRecordQuestionsId(entity.getExamRecordQuestionsId());
+        data.setExamRecordStatus(entity.getExamRecordStatus() == null ? null : entity.getExamRecordStatus().toString());
+        data.setStartTime(entity.getStartTime());
+        data.setEndTime(entity.getEndTime());
+        data.setCleanTime(entity.getCleanTime());
+        data.setWarn(entity.getIsWarn());
+        data.setAudit(entity.getIsAudit());
+        data.setIllegality(entity.getIsIllegality());
+        data.setUsedExamTime(entity.getUsedExamTime());
+        data.setExamOrder(entity.getExamOrder());
+        data.setReexamine(entity.getIsReexamine());
+        data.setContinued(entity.getIsContinued());
+        data.setAllObjectivePaper(entity.getIsAllObjectivePaper());
+        data.setContinuedCount(entity.getContinuedCount());
+        data.setExceed(entity.getIsExceed());
+        data.setFaceSuccessCount(entity.getFaceSuccessCount());
+        data.setFaceFailedCount(entity.getFaceFailedCount());
+        data.setFaceStrangerCount(entity.getFaceStrangerCount());
+        data.setFaceTotalCount(entity.getFaceTotalCount());
+        data.setFaceSuccessPercent(entity.getFaceSuccessPercent());
+        data.setFaceVerifyResult(entity.getFaceVerifyResult() == null ? null : entity.getFaceVerifyResult().toString());
+        data.setBaiduFaceLivenessSuccessPercent(entity.getBaiduFaceLivenessSuccessPercent());
+        data.setFaceLandmarkVal(entity.getFaceLandmarkVal());
+        data.setRandomPaper(entity.getRandomPaper());
+        data.setPaperScore(entity.getPaperScore());
+
+        resp.setData(data);
+        return resp;
+    }
+
+    @Override
+    @PostMapping("/updateExamRecordForMarkingBatchNum")
+    public void updateExamRecordForMarkingBatchNum(@RequestBody UpdateExamRecordForMarkingBatchNumReq req) {
+        if (req.getIdList() == null || req.getIdList().isEmpty()) {
+            throw new StatusException("222001", "阅卷原始数据表id不允许为空");
+        }
+        if (req.getIdList().size() > 100) {
+            throw new StatusException("222002", "阅卷原始数据表id集合最大不得超过100条");
+        }
+        if (StringUtils.isBlank(req.getBatchNum())) {
+            throw new StatusException("222003", "批次号不允许为空");
+        }
+        examRecordForMarkingRepo.updateBatchNum(req.getIdList(), req.getBatchNum());
+    }
+
+    @Override
+    @PostMapping("/saveExamRecordForMarking")
+    public void saveExamRecordForMarking(@RequestBody SaveExamRecordForMarkingReq req) {
+        ExamRecordForMarkingEntity examRecordForMarkingExists = examRecordForMarkingRepo
+                .findByExamRecordDataId(req.getExamRecordDataId());
+        if (examRecordForMarkingExists != null) {
+            return;
+        }
+        ExamRecordForMarkingEntity examRecordForMarking = new ExamRecordForMarkingEntity();
+        examRecordForMarking.setExamId(req.getExamId());
+        examRecordForMarking.setExamRecordDataId(req.getExamRecordDataId());
+        examRecordForMarking.setExamStudentId(req.getExamStudentId());
+        examRecordForMarking.setBasePaperId(req.getBasePaperId());
+        examRecordForMarking.setPaperType(req.getPaperType());
+        examRecordForMarking.setCourseId(req.getCourseId());
+        examRecordForMarking.setObjectiveScore(req.getObjectiveScore());
+        int subjectiveAnswerLength = examRecordQuestionsService
+                .calculationSubjectiveAnswerLength(req.getExamRecordDataId());
+        examRecordForMarking.setSubjectiveAnswerLength(subjectiveAnswerLength);
+        examRecordForMarkingRepo.save(examRecordForMarking);
+    }
+
+    // @ApiOperation(value = "根据条件查询阅卷需要的basepaperId")
+    // @Override
+    // @PostMapping("/findBasePaperForMarkWork")
+    // public FindBasePaperForMarkWorkResp findBasePaperForMarkWork(@RequestBody
+    // FindBasePaperForMarkWorkReq req) {
+    // Long id = req.getId();
+    // Long examId = req.getExamId();
+    // FindBasePaperForMarkWorkResp resp = new FindBasePaperForMarkWorkResp();
+    // if (id == null && examId == null) {
+    // return resp;
+    // }
+    //
+    // List<ExamRecordForMarkingEntity> examRecordForMarkingList =
+    // examRecordForMarkingService
+    // .findExamRecordForMarkingInfo(id, examId, req.getCourseId(),
+    // req.getBatchNum());
+    // Set<String> set = new HashSet<>();
+    // for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
+    // set.add(entity.getBasePaperId());
+    // }
+    //
+    // resp.setBasePaperIds(set);
+    // return resp;
+    // }
 
 }