Przeglądaj źródła

阅卷接口添加批次号的查询条件和返回值

lideyin 5 lat temu
rodzic
commit
c36a96c8a6

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

@@ -40,143 +40,146 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 /**
- * 
- * @author  	chenken
- * @date    	2018年9月27日 上午11:01:23
- * @company 	QMTH
+ * @author chenken
+ * @date 2018年9月27日 上午11:01:23
+ * @company QMTH
  * @description 阅卷相关接口
  */
 @Api(tags = "阅卷获取信息相关接口")
 @RestController
 @RequestMapping("${$rmp.cloud.oe}/examRecordForMarking")
-public class ExamRecordForMarkingCloudServiceProvider extends ControllerSupport implements ExamRecordForMarkingCloudService{
-	
-	private static final long serialVersionUID = -8343697288418890873L;
-	
-	@Autowired
-	private ExamRecordForMarkingService examRecordForMarkingService;
-	@Autowired
-	private ExamStudentRepo examStudentRepo;
-
-	@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());
-		List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
-		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());
-			examRecordForMarkingBean.setOfflineFileName(entity.getOfflineFileName());
-			examRecordForMarkingBean.setOfflineFileUrl(entity.getOfflineFileUrl());
-			examRecordForMarkingBeanList.add(examRecordForMarkingBean);
-		}
-		resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
-		return resp;
-	}
-
-	@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.queryValidExamRecordInfo(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) {
+public class ExamRecordForMarkingCloudServiceProvider extends ControllerSupport implements ExamRecordForMarkingCloudService {
+
+    private static final long serialVersionUID = -8343697288418890873L;
+
+    @Autowired
+    private ExamRecordForMarkingService examRecordForMarkingService;
+    @Autowired
+    private ExamStudentRepo examStudentRepo;
+
+    @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<ExamRecordForMarkingBean>();
+        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());
+            examRecordForMarkingBean.setOfflineFileName(entity.getOfflineFileName());
+            examRecordForMarkingBean.setOfflineFileUrl(entity.getOfflineFileUrl());
+            examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
+            examRecordForMarkingBeanList.add(examRecordForMarkingBean);
+        }
+        resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+        return resp;
+    }
+
+    @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.queryValidExamRecordInfo(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");
+        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());
+            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);
+            }
         }
-		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);
-			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;
-	}
+        resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
+        return resp;
+    }
 
 }

+ 7 - 6
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamRecordForMarkingService.java

@@ -1,9 +1,9 @@
 package cn.com.qmth.examcloud.core.oe.admin.service;
 
-import java.util.List;
-
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordForMarkingEntity;
 
+import java.util.List;
+
 /**
  * 
  * @author  	chenken
@@ -16,18 +16,19 @@ public interface ExamRecordForMarkingService {
 	/**
 	 * 获取 有效考试记录
 	 */
-	public List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId,Long courseId);
+	List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId, Long courseId);
 	
 	/**
 	 * 根据条件查询阅卷需要的信息
 	 * @param id
 	 * @param examId
-	 * @param courseCode
+	 * @param courseId
+	 * @param batchNum
 	 * @return
 	 */
-	public List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id,Long examId,Long courseId);
+	List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id, Long examId, Long courseId,String batchNum);
 
 	List<ExamRecordForMarkingEntity> queryValidExamRecordInfoByStuIds(Long examId, Long courseId,
-			List<Long> examStudentIds);
+			List<Long> examStudentIds,String batchNum);
 	
 }

+ 197 - 181
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordForMarkingServiceImpl.java

@@ -10,6 +10,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
@@ -27,191 +28,206 @@ import cn.com.qmth.examcloud.examwork.api.response.GetExamPropertyResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
 
 /**
- * 
- * @author  	chenken
- * @date    	2018年9月19日 下午3:20:29
- * @company 	QMTH
+ * @author chenken
+ * @date 2018年9月19日 下午3:20:29
+ * @company QMTH
  * @description ExamRecordForMarkingServiceImpl.java
  */
 @Service("examRecordForMarkingService")
 public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingService {
-	
-	@Autowired
-	private ExamRecordForMarkingRepo examRecordForMarkingRepo;
-	
-	@Autowired
-	private ExamCloudService examCloudService;
-	
-	@Autowired
+
+    @Autowired
+    private ExamRecordForMarkingRepo examRecordForMarkingRepo;
+
+    @Autowired
+    private ExamCloudService examCloudService;
+
+    @Autowired
     private JdbcTemplate jdbcTemplate;
-	@Override
-	public List<ExamRecordForMarkingEntity> queryValidExamRecordInfoByStuIds(Long examId,Long courseId,List<Long> examStudentIds) {
-		GetExamReq getExamReq = new GetExamReq();
-		getExamReq.setId(examId);
-		GetExamResp getExamResp = examCloudService.getExam(getExamReq);
-		ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
-		
-		List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
-		if(examType == ExamType.OFFLINE){
-			return examRecordForMarkingList;
-		}else if(examType == ExamType.ONLINE){
-			GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
-			getExamPropertyReq.setExamId(examId);
-			getExamPropertyReq.setKey("MARKING_TYPE");
-			GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
-			
-			String markingType = getExamPropertyResp.getValue();
-			if(markingType.equals(MarkingType.ALL.name())){
-				return examRecordForMarkingList;
-			}else if(markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())){
-				return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
-			}else if(markingType.equals(MarkingType.LAST_SUBMIT.name())){
-				return queryStudentPapersByLastSubmit(examRecordForMarkingList);
-			}
-		}
-		return null;
-	}
-	@Override
-	public List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId,Long courseId) {
-		GetExamReq getExamReq = new GetExamReq();
-		getExamReq.setId(examId);
-		GetExamResp getExamResp = examCloudService.getExam(getExamReq);
-		ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
-		
-		List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseId(examId, courseId);
-		if(examType == ExamType.OFFLINE){
-			return examRecordForMarkingList;
-		}else if(examType == ExamType.ONLINE){
-			GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
-			getExamPropertyReq.setExamId(examId);
-			getExamPropertyReq.setKey("MARKING_TYPE");
-			GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
-			
-			String markingType = getExamPropertyResp.getValue();
-			if(markingType.equals(MarkingType.ALL.name())){
-				return examRecordForMarkingList;
-			}else if(markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())){
-				return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
-			}else if(markingType.equals(MarkingType.LAST_SUBMIT.name())){
-				return queryStudentPapersByLastSubmit(examRecordForMarkingList);
-			}
-		}
-		return null;
-	}
-
-	/**
-	 * 最后一次提交
-	 * @param examRecordForMarkingList
-	 * @return
-	 */
-	private List<ExamRecordForMarkingEntity> queryStudentPapersByLastSubmit(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
-		Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
-		Iterator<Entry<Long,List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
-		List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
-		while (iterator.hasNext()) {
-			Entry<Long,List<ExamRecordForMarkingEntity>> entry = iterator.next();
-			List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
-			List<ExamRecordForMarkingEntity> listSortByExamRecordDataId = examRecordForMarkingList.stream().sorted((p1,p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId())).collect(Collectors.toList());
-			finalExamRecordForMarkingEntityList.add(listSortByExamRecordDataId.get(0));
-		}
-		/**
-		 * 解决下面的问题:
-		 *  当一个课程下设置两套试卷一套有主观题,一套没有主观题时,考试完成后给阅卷端传试卷时会传错,例如:
-		 *	考试批次设置为取最后一次考试成绩;
-		 *	在调卷规则中给课程A设置了两份试卷A1和A2,A1试卷中有主观题,A2试卷没有主观题;
-		 *	考生AA在考试时,第一次抽取到了A1试卷,第二次抽取到了A2试卷;
-		 *	考试完成后考生AA应该没有试卷传给阅卷端,但实际上系统将A1试卷传给了阅卷端
-		 */
-		//todo
-		return finalExamRecordForMarkingEntityList;
-	}
-	
-	/**
-	 * 客观分最高
-	 * @param examRecordForMarkingList
-	 * @return
-	 */
-	private List<ExamRecordForMarkingEntity> queryStudentPapersByObjectScoreMax(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
-		Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
-		Iterator<Entry<Long,List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
-		List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
-		while (iterator.hasNext()) {
-			Entry<Long,List<ExamRecordForMarkingEntity>> entry = iterator.next();
-			List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
-			//得出该考生的最高客观分
-			double maxObjectiveScore = examRecordForMarkingList.stream().sorted((p1,p2) -> p2.getObjectiveScore().compareTo(p1.getObjectiveScore()))
-			.limit(1).findFirst().get().getObjectiveScore();
-			//过滤出最高分集合
-			List<ExamRecordForMarkingEntity> examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
-				return score.getObjectiveScore() == maxObjectiveScore;
-			}).collect(Collectors.toList());
-			//如果最高客观分的有多个,继续按主观题答案长度过滤
-			if(examRecordForMarkingByFilterList.size()>1){
-				int maxAnswerLength = examRecordForMarkingByFilterList.stream().sorted((p1,p2) -> p2.getSubjectiveAnswerLength()-p1.getSubjectiveAnswerLength())
-				.limit(1).findFirst().get().getSubjectiveAnswerLength();
-				examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
-					return score.getSubjectiveAnswerLength() == maxAnswerLength;
-				}).collect(Collectors.toList());
-				//如果主观题答案最长长度一样的还有多个,继续按时间(考试记录ID)过滤出最新的那条
-				if(examRecordForMarkingByFilterList.size()>1){
-					examRecordForMarkingByFilterList = examRecordForMarkingByFilterList.stream().sorted((p1,p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId()))
-					.limit(1)
-					.collect(Collectors.toList());
-				}
-			}
-			finalExamRecordForMarkingEntityList.add(examRecordForMarkingByFilterList.get(0));
-		}
-		return finalExamRecordForMarkingEntityList;
-	}
-	
-	private Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentId(List<ExamRecordForMarkingEntity> examRecordForMarkingList){
-		Map<Long,List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = new HashMap<Long,List<ExamRecordForMarkingEntity>>();
-		for(ExamRecordForMarkingEntity examRecordForMarkingEntity:examRecordForMarkingList){
-			Long examStudentId = examRecordForMarkingEntity.getExamStudentId();
-			List<ExamRecordForMarkingEntity> value = null;
-			if(groupByExamStudentIdMap.containsKey(examStudentId)){
-				value = groupByExamStudentIdMap.get(examStudentId);
-			}else{
-				value = new ArrayList<ExamRecordForMarkingEntity>();
-			}
-			value.add(examRecordForMarkingEntity);
-			groupByExamStudentIdMap.put(examStudentId, value);
-		}
-		return groupByExamStudentIdMap;
-	}
-
-	@Override
-	public List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id,Long examId,Long courseId) {
-		if(id == null && examId == null){
-			return null;
-		}
-		StringBuffer sql = new StringBuffer();
-		sql.append("select id,exam_id,base_paper_id,paper_type,course_id,offline_file_name,offline_file_url "+
-					 " from ec_oe_exam_record_4_marking where 1=1 ");
-		if(id != null){
-			sql.append(" and id = "+id);
-		}
-		if(examId != null){
-			sql.append(" and exam_id = "+examId);
-		}
-		if(courseId != null){
-			sql.append(" and course_id = '"+courseId+"'");
-		}
-		sql.append(" group by base_paper_id");
-		return jdbcTemplate.query(sql.toString(), new RowMapper<ExamRecordForMarkingEntity>(){
-			@Override
-			public ExamRecordForMarkingEntity mapRow(ResultSet rs, int arg1) throws SQLException {
-				ExamRecordForMarkingEntity entity = new ExamRecordForMarkingEntity();
-				entity.setId(rs.getLong("id"));
-				entity.setExamId(rs.getLong("exam_id"));
-				entity.setBasePaperId(rs.getString("base_paper_id"));
-				entity.setPaperType(rs.getString("paper_type"));
-				entity.setCourseId(rs.getLong("course_id"));
-				entity.setOfflineFileName(rs.getString("offline_file_name"));
-				entity.setOfflineFileUrl(rs.getString("offline_file_url"));
-				return entity;
-			}
-		});
-	}
+
+    @Override
+    public List<ExamRecordForMarkingEntity> queryValidExamRecordInfoByStuIds(
+            Long examId, Long courseId, List<Long> examStudentIds, String batchNum) {
+        GetExamReq getExamReq = new GetExamReq();
+        getExamReq.setId(examId);
+        GetExamResp getExamResp = examCloudService.getExam(getExamReq);
+        ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
+
+        List<ExamRecordForMarkingEntity> examRecordForMarkingList;
+        if (StringUtils.isEmpty(batchNum)){
+            examRecordForMarkingList =
+                    examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
+        }else {
+            examRecordForMarkingList =
+                    examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIdsAndBatchNum(examId, courseId, examStudentIds,batchNum);
+        }
+        if (examType == ExamType.OFFLINE) {
+            return examRecordForMarkingList;
+        } else if (examType == ExamType.ONLINE) {
+            GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
+            getExamPropertyReq.setExamId(examId);
+            getExamPropertyReq.setKey("MARKING_TYPE");
+            GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
+
+            String markingType = getExamPropertyResp.getValue();
+            if (markingType.equals(MarkingType.ALL.name())) {
+                return examRecordForMarkingList;
+            } else if (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
+                return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
+            } else if (markingType.equals(MarkingType.LAST_SUBMIT.name())) {
+                return queryStudentPapersByLastSubmit(examRecordForMarkingList);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public List<ExamRecordForMarkingEntity> queryValidExamRecordInfo(Long examId, Long courseId) {
+        GetExamReq getExamReq = new GetExamReq();
+        getExamReq.setId(examId);
+        GetExamResp getExamResp = examCloudService.getExam(getExamReq);
+        ExamType examType = ExamType.strToEnum(getExamResp.getExamBean().getExamType());
+
+        List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseId(examId, courseId);
+        if (examType == ExamType.OFFLINE) {
+            return examRecordForMarkingList;
+        } else if (examType == ExamType.ONLINE) {
+            GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
+            getExamPropertyReq.setExamId(examId);
+            getExamPropertyReq.setKey("MARKING_TYPE");
+            GetExamPropertyResp getExamPropertyResp = examCloudService.getExamProperty(getExamPropertyReq);
+
+            String markingType = getExamPropertyResp.getValue();
+            if (markingType.equals(MarkingType.ALL.name())) {
+                return examRecordForMarkingList;
+            } else if (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
+                return queryStudentPapersByObjectScoreMax(examRecordForMarkingList);
+            } else if (markingType.equals(MarkingType.LAST_SUBMIT.name())) {
+                return queryStudentPapersByLastSubmit(examRecordForMarkingList);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 最后一次提交
+     *
+     * @param examRecordForMarkingAllList
+     * @return
+     */
+    private List<ExamRecordForMarkingEntity> queryStudentPapersByLastSubmit(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
+        Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
+        Iterator<Entry<Long, List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
+        List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
+        while (iterator.hasNext()) {
+            Entry<Long, List<ExamRecordForMarkingEntity>> entry = iterator.next();
+            List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
+            List<ExamRecordForMarkingEntity> listSortByExamRecordDataId = examRecordForMarkingList.stream().sorted((p1, p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId())).collect(Collectors.toList());
+            finalExamRecordForMarkingEntityList.add(listSortByExamRecordDataId.get(0));
+        }
+        /**
+         * 解决下面的问题:
+         *  当一个课程下设置两套试卷一套有主观题,一套没有主观题时,考试完成后给阅卷端传试卷时会传错,例如:
+         *	考试批次设置为取最后一次考试成绩;
+         *	在调卷规则中给课程A设置了两份试卷A1和A2,A1试卷中有主观题,A2试卷没有主观题;
+         *	考生AA在考试时,第一次抽取到了A1试卷,第二次抽取到了A2试卷;
+         *	考试完成后考生AA应该没有试卷传给阅卷端,但实际上系统将A1试卷传给了阅卷端
+         */
+        //todo
+        return finalExamRecordForMarkingEntityList;
+    }
+
+    /**
+     * 客观分最高
+     *
+     * @param examRecordForMarkingList
+     * @return
+     */
+    private List<ExamRecordForMarkingEntity> queryStudentPapersByObjectScoreMax(List<ExamRecordForMarkingEntity> examRecordForMarkingAllList) {
+        Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = groupByExamStudentId(examRecordForMarkingAllList);
+        Iterator<Entry<Long, List<ExamRecordForMarkingEntity>>> iterator = groupByExamStudentIdMap.entrySet().iterator();
+        List<ExamRecordForMarkingEntity> finalExamRecordForMarkingEntityList = new ArrayList<ExamRecordForMarkingEntity>();
+        while (iterator.hasNext()) {
+            Entry<Long, List<ExamRecordForMarkingEntity>> entry = iterator.next();
+            List<ExamRecordForMarkingEntity> examRecordForMarkingList = entry.getValue();
+            //得出该考生的最高客观分
+            double maxObjectiveScore = examRecordForMarkingList.stream().sorted((p1, p2) -> p2.getObjectiveScore().compareTo(p1.getObjectiveScore()))
+                    .limit(1).findFirst().get().getObjectiveScore();
+            //过滤出最高分集合
+            List<ExamRecordForMarkingEntity> examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
+                return score.getObjectiveScore() == maxObjectiveScore;
+            }).collect(Collectors.toList());
+            //如果最高客观分的有多个,继续按主观题答案长度过滤
+            if (examRecordForMarkingByFilterList.size() > 1) {
+                int maxAnswerLength = examRecordForMarkingByFilterList.stream().sorted((p1, p2) -> p2.getSubjectiveAnswerLength() - p1.getSubjectiveAnswerLength())
+                        .limit(1).findFirst().get().getSubjectiveAnswerLength();
+                examRecordForMarkingByFilterList = examRecordForMarkingList.stream().filter(score -> {
+                    return score.getSubjectiveAnswerLength() == maxAnswerLength;
+                }).collect(Collectors.toList());
+                //如果主观题答案最长长度一样的还有多个,继续按时间(考试记录ID)过滤出最新的那条
+                if (examRecordForMarkingByFilterList.size() > 1) {
+                    examRecordForMarkingByFilterList = examRecordForMarkingByFilterList.stream().sorted((p1, p2) -> p2.getExamRecordDataId().compareTo(p1.getExamRecordDataId()))
+                            .limit(1)
+                            .collect(Collectors.toList());
+                }
+            }
+            finalExamRecordForMarkingEntityList.add(examRecordForMarkingByFilterList.get(0));
+        }
+        return finalExamRecordForMarkingEntityList;
+    }
+
+    private Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentId(List<ExamRecordForMarkingEntity> examRecordForMarkingList) {
+        Map<Long, List<ExamRecordForMarkingEntity>> groupByExamStudentIdMap = new HashMap<Long, List<ExamRecordForMarkingEntity>>();
+        for (ExamRecordForMarkingEntity examRecordForMarkingEntity : examRecordForMarkingList) {
+            Long examStudentId = examRecordForMarkingEntity.getExamStudentId();
+            List<ExamRecordForMarkingEntity> value = null;
+            if (groupByExamStudentIdMap.containsKey(examStudentId)) {
+                value = groupByExamStudentIdMap.get(examStudentId);
+            } else {
+                value = new ArrayList<ExamRecordForMarkingEntity>();
+            }
+            value.add(examRecordForMarkingEntity);
+            groupByExamStudentIdMap.put(examStudentId, value);
+        }
+        return groupByExamStudentIdMap;
+    }
+
+    @Override
+    public List<ExamRecordForMarkingEntity> findExamRecordForMarkingInfo(Long id, Long examId, Long courseId, String batchNum) {
+        if (id == null && examId == null) {
+            return null;
+        }
+        StringBuffer sql = new StringBuffer();
+        sql.append("select id,exam_id,base_paper_id,paper_type,course_id,offline_file_name,offline_file_url " +
+                " from ec_oe_exam_record_4_marking where 1=1 ");
+        if (id != null) {
+            sql.append(" and id = " + id);
+        }
+        if (examId != null) {
+            sql.append(" and exam_id = " + examId);
+        }
+        if (courseId != null) {
+            sql.append(" and course_id = '" + courseId + "'");
+        }
+        if (StringUtils.isNotEmpty(batchNum)) {
+            sql.append(" and (batch_num is null or batch_num != '" + batchNum + "')");
+        }
+        sql.append(" group by base_paper_id");
+        return jdbcTemplate.query(sql.toString(), new RowMapper<ExamRecordForMarkingEntity>() {
+            @Override
+            public ExamRecordForMarkingEntity mapRow(ResultSet rs, int arg1) throws SQLException {
+                ExamRecordForMarkingEntity entity = new ExamRecordForMarkingEntity();
+                entity.setId(rs.getLong("id"));
+                entity.setExamId(rs.getLong("exam_id"));
+                entity.setBasePaperId(rs.getString("base_paper_id"));
+                entity.setPaperType(rs.getString("paper_type"));
+                entity.setCourseId(rs.getLong("course_id"));
+                entity.setOfflineFileName(rs.getString("offline_file_name"));
+                entity.setOfflineFileUrl(rs.getString("offline_file_url"));
+                entity.setBatchNum(rs.getString("batch_num"));
+                return entity;
+            }
+        });
+    }
 
 }