|
@@ -577,42 +577,52 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
@PostMapping("getExamOrgList")
|
|
@PostMapping("getExamOrgList")
|
|
@Override
|
|
@Override
|
|
public GetExamOrgListResp getExamOrgList(@RequestBody GetExamOrgListReq req) {
|
|
public GetExamOrgListResp getExamOrgList(@RequestBody GetExamOrgListReq req) {
|
|
- final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
|
|
|
|
|
- Pageable pageable = new PageRequest(0, 200, Sort.Direction.ASC, "orgId");
|
|
|
|
|
|
+ long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
|
+ long next = start;
|
|
|
|
|
|
- Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
|
|
|
+ List<Long> orgIdList = Lists.newArrayList();
|
|
|
|
|
|
- if (null != req.getExamId()) {
|
|
|
|
- predicates.add(cb.equal(root.get("examId"), req.getExamId()));
|
|
|
|
- }
|
|
|
|
|
|
+ while (true) {
|
|
|
|
|
|
- predicates.add(cb.greaterThanOrEqualTo(root.get("orgId"), start));
|
|
|
|
|
|
+ final long s = next;
|
|
|
|
+ Pageable pageable = new PageRequest(0, 200, Sort.Direction.ASC, "orgId");
|
|
|
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
- };
|
|
|
|
|
|
+ Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
|
|
|
- Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
|
|
|
|
|
|
+ if (null != req.getExamId()) {
|
|
|
|
+ predicates.add(cb.equal(root.get("examId"), req.getExamId()));
|
|
|
|
+ }
|
|
|
|
|
|
- Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
|
|
|
+ predicates.add(cb.greaterThanOrEqualTo(root.get("orgId"), s));
|
|
|
|
|
|
- List<Long> orgIdList = Lists.newArrayList();
|
|
|
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
+ };
|
|
|
|
|
|
- long next = start;
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- ExamStudentEntity e = iterator.next();
|
|
|
|
|
|
+ Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
|
|
|
|
+
|
|
|
|
+ Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
|
|
|
- next = e.getOrgId();
|
|
|
|
- if (!orgIdList.contains(next)) {
|
|
|
|
- orgIdList.add(next);
|
|
|
|
|
|
+ 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++;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- GetExamOrgListResp resp = new GetExamOrgListResp();
|
|
|
|
- if (next != start) {
|
|
|
|
- next++;
|
|
|
|
}
|
|
}
|
|
|
|
+ GetExamOrgListResp resp = new GetExamOrgListResp();
|
|
resp.setNext(next);
|
|
resp.setNext(next);
|
|
resp.setOrgIdList(orgIdList);
|
|
resp.setOrgIdList(orgIdList);
|
|
|
|
|