WANG 6 tahun lalu
induk
melakukan
d69efe8ff4

+ 26 - 47
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -57,7 +57,7 @@ import cn.com.qmth.examcloud.examwork.api.request.GetExamListReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamOrgListReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamPropertyReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
-import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentExtListReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPropertyValueListReq;
 import cn.com.qmth.examcloud.examwork.api.request.GetOngoingExamListReq;
 import cn.com.qmth.examcloud.examwork.api.request.LockExamStudentsReq;
 import cn.com.qmth.examcloud.examwork.api.request.SaveExamReq;
@@ -70,7 +70,7 @@ import cn.com.qmth.examcloud.examwork.api.response.GetExamListResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamOrgListResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamPropertyResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
-import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentExtListResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentPropertyValueListResp;
 import cn.com.qmth.examcloud.examwork.api.response.GetOngoingExamListResp;
 import cn.com.qmth.examcloud.examwork.api.response.LockExamStudentsResp;
 import cn.com.qmth.examcloud.examwork.api.response.SaveExamResp;
@@ -581,49 +581,15 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	public GetExamOrgListResp getExamOrgList(@RequestBody GetExamOrgListReq req) {
 
 		long start = null == req.getStart() ? 1 : req.getStart();
-		long next = start;
-
-		List<Long> orgIdList = Lists.newArrayList();
-
-		while (true) {
-
-			final long s = next;
-			Pageable pageable = new PageRequest(0, 200, Sort.Direction.ASC, "orgId");
-
-			Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-				List<Predicate> predicates = new ArrayList<>();
-
-				if (null != req.getExamId()) {
-					predicates.add(cb.equal(root.get("examId"), req.getExamId()));
-				}
-
-				predicates.add(cb.greaterThanOrEqualTo(root.get("orgId"), s));
-
-				return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-			};
-
-			Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
-
-			Iterator<ExamStudentEntity> iterator = page.iterator();
-
-			boolean has = false;
-			while (iterator.hasNext()) {
-				ExamStudentEntity e = iterator.next();
-				has = true;
-
-				next = e.getOrgId();
-				if (!orgIdList.contains(next)) {
-					orgIdList.add(next);
-				}
-			}
-
-			if (!has) {
-				break;
-			} else {
-				next++;
-			}
+		Long examId = req.getExamId();
+		Long next = start;
 
+		List<Long> orgIdList = examStudentRepo.queryOrgIdList(examId, start);
+		if (CollectionUtils.isNotEmpty(orgIdList)) {
+			next = orgIdList.get(orgIdList.size() - 1);
+			next++;
 		}
+
 		GetExamOrgListResp resp = new GetExamOrgListResp();
 		resp.setNext(next);
 		resp.setOrgIdList(orgIdList);
@@ -632,11 +598,24 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	}
 
 	@ApiOperation(value = "获取考生ext集合")
-	@PostMapping("getExamStudentExtList")
+	@PostMapping("getExamStudentPropertyValueList")
 	@Override
-	public GetExamStudentExtListResp getExamStudentExtList(
-			@RequestBody GetExamStudentExtListReq req) {
-		return null;
+	public GetExamStudentPropertyValueListResp getExamStudentPropertyValueList(
+			@RequestBody GetExamStudentPropertyValueListReq req) {
+
+		String start = null == req.getStart() ? "" : req.getStart();
+		String next = start;
+
+		List<String> extList = Lists.newArrayList();
+
+		// examStudentRepo.getClass().getMethod("queryExt" + extIndex + "List",
+		// String.class);
+
+		GetExamStudentPropertyValueListResp resp = new GetExamStudentPropertyValueListResp();
+		resp.setNext(next);
+		resp.setValueList(extList);
+
+		return resp;
 	}
 
 }

+ 18 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -40,4 +40,22 @@ public interface ExamStudentRepo
 
 	List<ExamStudentEntity> findTop2ByExamIdAndCourseId(Long examId, Long courseId);
 
+	@Query(value = "select distinct org_id from ec_e_exam_student t where t.org_id>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<Long> queryOrgIdList(Long examId, Long start);
+
+	@Query(value = "select distinct ext1 from ec_e_exam_student t where t.ext1>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<String> queryExt1List(Long examId, Long start);
+
+	@Query(value = "select distinct ext2 from ec_e_exam_student t where t.ext2>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<String> queryExt2List(Long examId, Long start);
+
+	@Query(value = "select distinct ext3 from ec_e_exam_student t where t.ext3>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<String> queryExt3List(Long examId, Long start);
+
+	@Query(value = "select distinct ext4 from ec_e_exam_student t where t.ext4>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<String> queryExt4List(Long examId, Long start);
+
+	@Query(value = "select distinct ext5 from ec_e_exam_student t where t.ext5>?2 and t.exam_id=?1 order by org_id limit 500", nativeQuery = true)
+	List<String> queryExt5List(Long examId, Long start);
+
 }