WANG 6 年之前
父节点
当前提交
b9636f0383

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

@@ -1,657 +1,660 @@
-package cn.com.qmth.examcloud.core.examwork.api.provider;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.criteria.Predicate;
-
-import org.apache.commons.collections.CollectionUtils;
-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.base.exception.StatusException;
-import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
-import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnumManager;
-import cn.com.qmth.examcloud.commons.web.enums.DataExecutionStatus;
-import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
-import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgSettingsRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgSettingsEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
-import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamServiceImpl;
-import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamPaperTypeRelation;
-import cn.com.qmth.examcloud.examwork.api.request.CountExamStudentReq;
-import cn.com.qmth.examcloud.examwork.api.request.GetExamCourseListReq;
-import cn.com.qmth.examcloud.examwork.api.request.GetExamCoursePaperTypeListReq;
-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.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;
-import cn.com.qmth.examcloud.examwork.api.request.SetExamPropertyReq;
-import cn.com.qmth.examcloud.examwork.api.request.UnlockExamStudentsReq;
-import cn.com.qmth.examcloud.examwork.api.response.CountExamStudentResp;
-import cn.com.qmth.examcloud.examwork.api.response.GetExamCourseListResp;
-import cn.com.qmth.examcloud.examwork.api.response.GetExamCoursePaperTypeListResp;
-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.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;
-import cn.com.qmth.examcloud.examwork.api.response.SetExamPropertyResp;
-import cn.com.qmth.examcloud.examwork.api.response.UnlockExamStudentsResp;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 考试云服务
- *
- * @author WANGWEI
- * @date 2018年11月23日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Transactional
-@RestController
-@RequestMapping("${$rmp.cloud.examwork}" + "exam")
-public class ExamCloudServiceProvider extends ControllerSupport implements ExamCloudService {
-
-	private static final long serialVersionUID = 6850508158980856785L;
-
-	@Autowired
-	private ExamServiceImpl examService;
-
-	@Autowired
-	ExamOrgSettingsRepo examOrgSettingsRepo;
-
-	@Autowired
-	ExamRepo examRepo;
-
-	@Autowired
-	ExamStudentRepo examStudentRepo;
-
-	@Autowired
-	ExamPropertyRepo examPropertyRepo;
-
-	@Autowired
-	ExamCourseRelationRepo examCourseRelationRepo;
-
-	@Autowired
-	ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
-
-	@ApiOperation(value = "保存考试批次", notes = "保存")
-	@PostMapping("saveExam")
-	@Override
-	public SaveExamResp saveExam(@RequestBody SaveExamReq req) {
-		ExamInfo examInfo = new ExamInfo();
-
-		examInfo.setBeginTime(req.getBeginTime());
-		examInfo.setDuration(req.getDuration());
-		examInfo.setEnable(true);
-		examInfo.setEndTime(req.getEndTime());
-		examInfo.setExamTimes(req.getExamTimes());
-
-		ExamType et = null;
-		try {
-			et = ExamType.valueOf(req.getExamType());
-		} catch (Exception e) {
-			throw new StatusException("E-001004", "考试类型错误");
-		}
-
-		examInfo.setExamType(et);
-		examInfo.setId(req.getId());
-		examInfo.setName(req.getName());
-		examInfo.setRemark(req.getRemark());
-		examInfo.setRootOrgId(req.getRootOrgId());
-
-		Map<String, String> properties = req.getProperties();
-		examInfo.setProperties(properties);
-
-		ExamEntity saved = examService.saveExam(examInfo, DataExecutionStatus.CREATION_OR_UPDATE);
-
-		SaveExamResp resp = new SaveExamResp();
-		resp.setExamId(saved.getId());
-		return resp;
-	}
-
-	@ApiOperation(value = "查询考试")
-	@PostMapping("getExam")
-	@Override
-	public GetExamResp getExam(@RequestBody GetExamReq req) {
-		Long id = req.getId();
-		Long rootOrgId = req.getRootOrgId();
-		String name = req.getName();
-		if (null == id && StringUtils.isBlank(name)) {
-			throw new StatusException("E-002002", "id,name不能都为空");
-		}
-		if (null != id && StringUtils.isNotBlank(name)) {
-			throw new StatusException("E-002003", "id,name不能都不为空");
-		}
-		ExamEntity exam = null;
-
-		if (null != id) {
-			exam = examRepo.findOne(id);
-		} else if (StringUtils.isNotBlank(name)) {
-			if (null == rootOrgId) {
-				throw new StatusException("E-002004", "rootOrgId is null");
-			}
-			exam = examService.findExamByNameAndRootOrgId(name, rootOrgId);
-		}
-
-		if (null == exam) {
-			throw new StatusException("E-002005", "考试不存在");
-		}
-		GetExamResp examResp = new GetExamResp();
-		examResp.setId(exam.getId());
-		ExamBean bean = new ExamBean();
-		examResp.setExamBean(bean);
-
-		bean.setId(exam.getId());
-		bean.setBeginTime(exam.getBeginTime());
-		bean.setDuration(exam.getDuration());
-		bean.setEnable(exam.getEnable());
-		bean.setEndTime(exam.getEndTime());
-		bean.setExamTimes(exam.getExamTimes());
-		bean.setExamType(exam.getExamType().name());
-		bean.setName(exam.getName());
-		bean.setRemark(exam.getRemark());
-		bean.setRootOrgId(exam.getRootOrgId());
-
-		Long orgId = req.getOrgId();
-		if (null != orgId) {
-			ExamOrgSettingsEntity examOrgEntity = examOrgSettingsRepo
-					.findByExamIdAndOrgId(exam.getId(), orgId);
-
-			bean.setBeginTime(examOrgEntity.getBeginTime());
-			bean.setEndTime(examOrgEntity.getEndTime());
-		}
-
-		return examResp;
-	}
-
-	@ApiOperation(value = "设置考试属性")
-	@PostMapping("setExamProperty")
-	@Override
-	public SetExamPropertyResp setExamProperty(@RequestBody SetExamPropertyReq req) {
-		Long examId = req.getExamId();
-		String key = req.getKey();
-		String value = req.getValue();
-
-		DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
-		DynamicEnum de = manager.getByName(key);
-
-		ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(examId, de.getId());
-		if (null == entity) {
-			entity = new ExamPropertyEntity();
-			entity.setExamId(examId);
-			entity.setKeyId(de.getId());
-		}
-		entity.setValue(value);
-
-		ExamPropertyEntity saved = examPropertyRepo.save(entity);
-
-		SetExamPropertyResp resp = new SetExamPropertyResp();
-		resp.setPropertyId(saved.getId());
-		return resp;
-	}
-
-	@ApiOperation(value = "查询考试属性")
-	@PostMapping("getExamProperty")
-	@Override
-	public GetExamPropertyResp getExamProperty(@RequestBody GetExamPropertyReq req) {
-		Long examId = req.getExamId();
-		Long orgId = req.getOrgId();
-		String key = req.getKey();
-
-		String value = examService.getOrgProperty(examId, orgId, key);
-
-		GetExamPropertyResp resp = new GetExamPropertyResp();
-		resp.setValue(value);
-		return resp;
-	}
-
-	@ApiOperation(value = "查询正在考试的考试集合")
-	@PostMapping("getOngoingExamList")
-	@Override
-	public GetOngoingExamListResp getOngoingExamList(@RequestBody GetOngoingExamListReq req) {
-
-		Long rootOrgId = req.getRootOrgId();
-		String examType = req.getExamType();
-
-		ExamType et = null;
-		if (StringUtils.isNotBlank(examType)) {
-			try {
-				et = ExamType.valueOf(examType);
-			} catch (Exception e) {
-				throw new StatusException("E-002005", "examType is wrong");
-			}
-		}
-
-		final ExamType type = et;
-
-		Specification<ExamEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
-			// predicates.add(cb.lessThan(root.get("beginTime"), new Date()));
-			predicates.add(cb.greaterThan(root.get("endTime"), new Date()));
-			if (null != type) {
-				predicates.add(cb.equal(root.get("examType"), type));
-			}
-
-			Boolean enable = req.getExamEnable();
-			if (null == enable) {
-				enable = true;
-			}
-			predicates.add(cb.equal(root.get("enable"), enable));
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		PageRequest pageRequest = new PageRequest(0, 100, new Sort(Direction.ASC, "beginTime"));
-
-		Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
-
-		Iterator<ExamEntity> iterator = page.iterator();
-
-		List<ExamBean> list = Lists.newArrayList();
-
-		while (iterator.hasNext()) {
-			ExamEntity exam = iterator.next();
-			ExamBean bean = new ExamBean();
-			list.add(bean);
-
-			bean.setId(exam.getId());
-			bean.setBeginTime(exam.getBeginTime());
-			bean.setDuration(exam.getDuration());
-			bean.setEnable(exam.getEnable());
-			bean.setEndTime(exam.getEndTime());
-			bean.setExamTimes(exam.getExamTimes());
-			bean.setExamType(exam.getExamType().name());
-			bean.setName(exam.getName());
-			bean.setRemark(exam.getRemark());
-			bean.setRootOrgId(exam.getRootOrgId());
-		}
-		GetOngoingExamListResp resp = new GetOngoingExamListResp();
-		resp.setExamList(list);
-		return resp;
-	}
-
-	@ApiOperation(value = "锁定考试")
-	@PostMapping("lockExamStudents")
-	@Override
-	public LockExamStudentsResp lockExamStudents(@RequestBody LockExamStudentsReq req) {
-
-		List<Long> examIdList = req.getExamIdList();
-
-		if (CollectionUtils.isEmpty(examIdList)) {
-			throw new StatusException("E-002003", "examIdList is empty");
-		}
-		for (Long examId : examIdList) {
-			if (null == examId) {
-				throw new StatusException("E-002001", "examId is null");
-			}
-			ExamEntity exam = examRepo.findOne(examId);
-			if (null == exam) {
-				throw new StatusException("E-002002", "ExamEntity is null");
-			}
-			exam.setExamStudentLocked(true);
-			examRepo.save(exam);
-		}
-
-		LockExamStudentsResp resp = new LockExamStudentsResp();
-		resp.setExamIdList(examIdList);
-		return resp;
-	}
-
-	@ApiOperation(value = "解锁考试")
-	@PostMapping("unlockExamStudents")
-	@Override
-	public UnlockExamStudentsResp unlockExamStudents(@RequestBody UnlockExamStudentsReq req) {
-
-		List<Long> examIdList = req.getExamIdList();
-
-		if (CollectionUtils.isEmpty(examIdList)) {
-			throw new StatusException("E-002003", "examIdList is empty");
-		}
-
-		for (Long examId : examIdList) {
-			if (null == examId) {
-				throw new StatusException("E-002001", "examId is null");
-			}
-			ExamEntity exam = examRepo.findOne(examId);
-			if (null == exam) {
-				throw new StatusException("E-002002", "ExamEntity is null");
-			}
-			exam.setExamStudentLocked(false);
-			examRepo.save(exam);
-		}
-
-		UnlockExamStudentsResp resp = new UnlockExamStudentsResp();
-		resp.setExamIdList(examIdList);
-		return resp;
-	}
-
-	@ApiOperation(value = "查询考试集合")
-	@PostMapping("getExamList")
-	@Override
-	public GetExamListResp getExamList(@RequestBody GetExamListReq req) {
-
-		Long rootOrgId = req.getRootOrgId();
-		Boolean enable = req.getEnable();
-		List<String> examTypeList = req.getExamTypeList();
-
-		List<ExamType> examTypes = Lists.newArrayList();
-		if (CollectionUtils.isNotEmpty(examTypeList)) {
-			for (String cur : examTypeList) {
-				examTypes.add(ExamType.valueOf(cur));
-			}
-		}
-
-		final long start = null == req.getStart() ? 1 : req.getStart();
-
-		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "id");
-
-		Specification<ExamEntity> 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));
-
-			if (null != enable) {
-				predicates.add(cb.equal(root.get("enable"), enable));
-			}
-			if (CollectionUtils.isNotEmpty(examTypes)) {
-				if (1 == examTypeList.size()) {
-					predicates.add(cb.equal(root.get("examType"), examTypes.get(0)));
-				} else {
-					predicates.add(root.get("examType").in(examTypes));
-				}
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		Page<ExamEntity> page = examRepo.findAll(specification, pageable);
-
-		Iterator<ExamEntity> iterator = page.iterator();
-
-		List<ExamBean> list = Lists.newArrayList();
-		long next = start;
-		while (iterator.hasNext()) {
-			ExamEntity cur = iterator.next();
-			ExamBean bean = new ExamBean();
-			list.add(bean);
-
-			bean.setId(cur.getId());
-			bean.setBeginTime(cur.getBeginTime());
-			bean.setDuration(cur.getDuration());
-			bean.setEnable(cur.getEnable());
-			bean.setEndTime(cur.getEndTime());
-			bean.setExamTimes(cur.getExamTimes());
-			bean.setExamType(cur.getExamType().name());
-			bean.setName(cur.getName());
-			bean.setRemark(cur.getRemark());
-			bean.setRootOrgId(cur.getRootOrgId());
-
-			next = cur.getId();
-		}
-
-		GetExamListResp resp = new GetExamListResp();
-		if (next != start) {
-			next++;
-		}
-		resp.setNext(next);
-		resp.setExamList(list);
-		return resp;
-	}
-
-	@ApiOperation(value = "查询考试的课程集合")
-	@PostMapping("getExamCourseList")
-	@Override
-	public GetExamCourseListResp getExamCourseList(@RequestBody GetExamCourseListReq req) {
-		Long examId = req.getExamId();
-
-		final long start = null == req.getStart() ? 1 : req.getStart();
-
-		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "courseId");
-
-		Specification<ExamCourseRelationEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("examId"), examId));
-
-			predicates.add(cb.greaterThanOrEqualTo(root.get("courseId"), start));
-
-			if (null != req.getCourseEnable()) {
-				predicates.add(cb.equal(root.get("courseEnable"), req.getCourseEnable()));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification,
-				pageable);
-
-		Iterator<ExamCourseRelationEntity> iterator = page.iterator();
-
-		List<ExamCourseRelationBean> list = Lists.newArrayList();
-		long next = start;
-		while (iterator.hasNext()) {
-			ExamCourseRelationEntity e = iterator.next();
-			ExamCourseRelationBean b = new ExamCourseRelationBean();
-			b.setCourseCode(e.getCourseCode());
-			b.setCourseId(e.getCourseId());
-			b.setCourseLevel(e.getCourseLevel());
-			b.setCourseName(e.getCourseName());
-			b.setExamId(examId);
-			b.setCourseEnable(e.getCourseEnable());
-
-			next = e.getCourseId();
-			list.add(b);
-		}
-
-		GetExamCourseListResp resp = new GetExamCourseListResp();
-		if (next != start) {
-			next++;
-		}
-		resp.setNext(next);
-		resp.setRelationList(list);
-
-		return resp;
-	}
-
-	@ApiOperation(value = "查询考试课程的试卷类型集")
-	@PostMapping("getExamCoursePaperTypeList")
-	@Override
-	public GetExamCoursePaperTypeListResp getExamCoursePaperTypeList(
-			@RequestBody GetExamCoursePaperTypeListReq req) {
-
-		Long examId = req.getExamId();
-
-		final long start = null == req.getStart() ? 1 : req.getStart();
-
-		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "courseId");
-
-		Specification<ExamPaperTypeRelationEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			predicates.add(cb.equal(root.get("examId"), examId));
-
-			predicates.add(cb.greaterThanOrEqualTo(root.get("courseId"), start));
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		Page<ExamPaperTypeRelationEntity> page = examPaperTypeRelationRepo.findAll(specification,
-				pageable);
-
-		Iterator<ExamPaperTypeRelationEntity> iterator = page.iterator();
-
-		List<ExamPaperTypeRelation> list = Lists.newArrayList();
-		long next = start;
-		while (iterator.hasNext()) {
-			ExamPaperTypeRelationEntity e = iterator.next();
-			ExamPaperTypeRelation b = new ExamPaperTypeRelation();
-			b.setCourseId(e.getCourseId());
-			b.setExamId(e.getExamId());
-			b.setPaperType(e.getPaperType());
-
-			next = e.getCourseId();
-			list.add(b);
-		}
-
-		GetExamCoursePaperTypeListResp resp = new GetExamCoursePaperTypeListResp();
-		if (next != start) {
-			next++;
-		}
-		resp.setNext(next);
-		resp.setRelationList(list);
-
-		return resp;
-	}
-
-	@ApiOperation(value = "统计考生数量")
-	@PostMapping("countExamStudent")
-	@Override
-	public CountExamStudentResp countExamStudent(@RequestBody CountExamStudentReq req) {
-
-		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-
-			if (null != req.getExamId()) {
-				predicates.add(cb.equal(root.get("examId"), req.getExamId()));
-			}
-			if (null != req.getCourseId()) {
-				predicates.add(cb.equal(root.get("courseId"), req.getCourseId()));
-			}
-			if (StringUtils.isNotEmpty(req.getPaperType())) {
-				predicates.add(cb.equal(root.get("paperType"), req.getPaperType()));
-			}
-			if (StringUtils.isNotEmpty(req.getExamSite())) {
-				predicates.add(cb.equal(root.get("examSite"), req.getExamSite()));
-			}
-			if (null != req.getOrgId()) {
-				predicates.add(cb.equal(root.get("orgId"), req.getOrgId()));
-			}
-			if (null != req.getExt1()) {
-				predicates.add(cb.equal(root.get("ext1"), req.getExt1()));
-			}
-			if (null != req.getExt2()) {
-				predicates.add(cb.equal(root.get("ext2"), req.getExt2()));
-			}
-			if (null != req.getExt3()) {
-				predicates.add(cb.equal(root.get("ext3"), req.getExt3()));
-			}
-			if (null != req.getExt4()) {
-				predicates.add(cb.equal(root.get("ext4"), req.getExt4()));
-			}
-			if (null != req.getExt5()) {
-				predicates.add(cb.equal(root.get("ext5"), req.getExt5()));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		long count = examStudentRepo.count(specification);
-		CountExamStudentResp resp = new CountExamStudentResp();
-		resp.setCount(count);
-		return resp;
-	}
-
-	@ApiOperation(value = "获取考试机构列表")
-	@PostMapping("getExamOrgList")
-	@Override
-	public GetExamOrgListResp getExamOrgList(@RequestBody GetExamOrgListReq req) {
-
-		long start = null == req.getStart() ? 1 : req.getStart();
-		Long examId = req.getExamId();
-		long next = start;
-
-		List<Long> bigIntegerList = examStudentRepo.queryOrgIdList(examId, start);
-		List<Long> orgIdList = Lists.newArrayList();
-		for (Object bigInteger : bigIntegerList) {
-			orgIdList.add(Long.parseLong(String.valueOf(bigInteger)));
-		}
-		if (CollectionUtils.isNotEmpty(orgIdList)) {
-			next = orgIdList.get(orgIdList.size() - 1);
-			next++;
-		}
-
-		GetExamOrgListResp resp = new GetExamOrgListResp();
-		resp.setNext(next);
-		resp.setOrgIdList(orgIdList);
-
-		return resp;
-	}
-
-	@ApiOperation(value = " 获取考生属性值集合")
-	@PostMapping("getExamStudentPropertyValueList")
-	@Override
-	public GetExamStudentPropertyValueListResp getExamStudentPropertyValueList(
-			@RequestBody GetExamStudentPropertyValueListReq req) {
-
-		Long examId = req.getExamId();
-		String start = null == req.getStart() ? "" : req.getStart();
-
-		List<String> valueList = null;
-		String name = req.getPropertyName();
-
-		if (StringUtils.isBlank(name)) {
-			throw new StatusException("E-003005", "propertyName is blank");
-		}
-
-		if (name.equals("examSite")) {
-			valueList = examStudentRepo.queryExamSiteList(examId, start);
-		} else if (name.equals("ext1")) {
-			valueList = examStudentRepo.queryExt1List(examId, start);
-		} else if (name.equals("ext2")) {
-			valueList = examStudentRepo.queryExt2List(examId, start);
-		} else if (name.equals("ext3")) {
-			valueList = examStudentRepo.queryExt3List(examId, start);
-		} else if (name.equals("ext4")) {
-			valueList = examStudentRepo.queryExt4List(examId, start);
-		} else if (name.equals("ext5")) {
-			valueList = examStudentRepo.queryExt5List(examId, start);
-		} else {
-			throw new StatusException("E-003006", "propertyName is wrong");
-		}
-
-		GetExamStudentPropertyValueListResp resp = new GetExamStudentPropertyValueListResp();
-		resp.setValueList(valueList);
-
-		return resp;
-	}
-
-}
+package cn.com.qmth.examcloud.core.examwork.api.provider;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.criteria.Predicate;
+
+import org.apache.commons.collections.CollectionUtils;
+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.base.exception.StatusException;
+import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
+import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnumManager;
+import cn.com.qmth.examcloud.commons.web.enums.DataExecutionStatus;
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgSettingsRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgSettingsEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
+import cn.com.qmth.examcloud.core.examwork.service.impl.ExamServiceImpl;
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamPaperTypeRelation;
+import cn.com.qmth.examcloud.examwork.api.request.CountExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamCourseListReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamCoursePaperTypeListReq;
+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.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;
+import cn.com.qmth.examcloud.examwork.api.request.SetExamPropertyReq;
+import cn.com.qmth.examcloud.examwork.api.request.UnlockExamStudentsReq;
+import cn.com.qmth.examcloud.examwork.api.response.CountExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamCourseListResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamCoursePaperTypeListResp;
+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.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;
+import cn.com.qmth.examcloud.examwork.api.response.SetExamPropertyResp;
+import cn.com.qmth.examcloud.examwork.api.response.UnlockExamStudentsResp;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 考试云服务
+ *
+ * @author WANGWEI
+ * @date 2018年11月23日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@Transactional
+@RestController
+@RequestMapping("${$rmp.cloud.examwork}" + "exam")
+public class ExamCloudServiceProvider extends ControllerSupport implements ExamCloudService {
+
+	private static final long serialVersionUID = 6850508158980856785L;
+
+	@Autowired
+	private ExamServiceImpl examService;
+
+	@Autowired
+	ExamOrgSettingsRepo examOrgSettingsRepo;
+
+	@Autowired
+	ExamRepo examRepo;
+
+	@Autowired
+	ExamStudentRepo examStudentRepo;
+
+	@Autowired
+	ExamPropertyRepo examPropertyRepo;
+
+	@Autowired
+	ExamCourseRelationRepo examCourseRelationRepo;
+
+	@Autowired
+	ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
+
+	@ApiOperation(value = "保存考试批次", notes = "保存")
+	@PostMapping("saveExam")
+	@Override
+	public SaveExamResp saveExam(@RequestBody SaveExamReq req) {
+		ExamInfo examInfo = new ExamInfo();
+
+		examInfo.setBeginTime(req.getBeginTime());
+		examInfo.setDuration(req.getDuration());
+		examInfo.setEnable(true);
+		examInfo.setEndTime(req.getEndTime());
+		examInfo.setExamTimes(req.getExamTimes());
+
+		ExamType et = null;
+		try {
+			et = ExamType.valueOf(req.getExamType());
+		} catch (Exception e) {
+			throw new StatusException("E-001004", "考试类型错误");
+		}
+
+		examInfo.setExamType(et);
+		examInfo.setId(req.getId());
+		examInfo.setName(req.getName());
+		examInfo.setRemark(req.getRemark());
+		examInfo.setRootOrgId(req.getRootOrgId());
+
+		Map<String, String> properties = req.getProperties();
+		examInfo.setProperties(properties);
+
+		ExamEntity saved = examService.saveExam(examInfo, DataExecutionStatus.CREATION_OR_UPDATE);
+
+		SaveExamResp resp = new SaveExamResp();
+		resp.setExamId(saved.getId());
+		return resp;
+	}
+
+	@ApiOperation(value = "查询考试")
+	@PostMapping("getExam")
+	@Override
+	public GetExamResp getExam(@RequestBody GetExamReq req) {
+		Long id = req.getId();
+		Long rootOrgId = req.getRootOrgId();
+		String name = req.getName();
+		if (null == id && StringUtils.isBlank(name)) {
+			throw new StatusException("E-002002", "id,name不能都为空");
+		}
+		if (null != id && StringUtils.isNotBlank(name)) {
+			throw new StatusException("E-002003", "id,name不能都不为空");
+		}
+		ExamEntity exam = null;
+
+		if (null != id) {
+			exam = examRepo.findOne(id);
+		} else if (StringUtils.isNotBlank(name)) {
+			if (null == rootOrgId) {
+				throw new StatusException("E-002004", "rootOrgId is null");
+			}
+			exam = examService.findExamByNameAndRootOrgId(name, rootOrgId);
+		}
+
+		if (null == exam) {
+			throw new StatusException("E-002005", "考试不存在");
+		}
+		GetExamResp examResp = new GetExamResp();
+		examResp.setId(exam.getId());
+		ExamBean bean = new ExamBean();
+		examResp.setExamBean(bean);
+
+		bean.setId(exam.getId());
+		bean.setBeginTime(exam.getBeginTime());
+		bean.setDuration(exam.getDuration());
+		bean.setEnable(exam.getEnable());
+		bean.setEndTime(exam.getEndTime());
+		bean.setExamTimes(exam.getExamTimes());
+		bean.setExamType(exam.getExamType().name());
+		bean.setName(exam.getName());
+		bean.setRemark(exam.getRemark());
+		bean.setRootOrgId(exam.getRootOrgId());
+
+		Long orgId = req.getOrgId();
+		if (null != orgId) {
+			ExamOrgSettingsEntity examOrgEntity = examOrgSettingsRepo
+					.findByExamIdAndOrgId(exam.getId(), orgId);
+			if (null != examOrgEntity.getBeginTime()) {
+				bean.setBeginTime(examOrgEntity.getBeginTime());
+			}
+			if (null != examOrgEntity.getEndTime()) {
+				bean.setEndTime(examOrgEntity.getEndTime());
+			}
+		}
+
+		return examResp;
+	}
+
+	@ApiOperation(value = "设置考试属性")
+	@PostMapping("setExamProperty")
+	@Override
+	public SetExamPropertyResp setExamProperty(@RequestBody SetExamPropertyReq req) {
+		Long examId = req.getExamId();
+		String key = req.getKey();
+		String value = req.getValue();
+
+		DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
+		DynamicEnum de = manager.getByName(key);
+
+		ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(examId, de.getId());
+		if (null == entity) {
+			entity = new ExamPropertyEntity();
+			entity.setExamId(examId);
+			entity.setKeyId(de.getId());
+		}
+		entity.setValue(value);
+
+		ExamPropertyEntity saved = examPropertyRepo.save(entity);
+
+		SetExamPropertyResp resp = new SetExamPropertyResp();
+		resp.setPropertyId(saved.getId());
+		return resp;
+	}
+
+	@ApiOperation(value = "查询考试属性")
+	@PostMapping("getExamProperty")
+	@Override
+	public GetExamPropertyResp getExamProperty(@RequestBody GetExamPropertyReq req) {
+		Long examId = req.getExamId();
+		Long orgId = req.getOrgId();
+		String key = req.getKey();
+
+		String value = examService.getOrgProperty(examId, orgId, key);
+
+		GetExamPropertyResp resp = new GetExamPropertyResp();
+		resp.setValue(value);
+		return resp;
+	}
+
+	@ApiOperation(value = "查询正在考试的考试集合")
+	@PostMapping("getOngoingExamList")
+	@Override
+	public GetOngoingExamListResp getOngoingExamList(@RequestBody GetOngoingExamListReq req) {
+
+		Long rootOrgId = req.getRootOrgId();
+		String examType = req.getExamType();
+
+		ExamType et = null;
+		if (StringUtils.isNotBlank(examType)) {
+			try {
+				et = ExamType.valueOf(examType);
+			} catch (Exception e) {
+				throw new StatusException("E-002005", "examType is wrong");
+			}
+		}
+
+		final ExamType type = et;
+
+		Specification<ExamEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+			// predicates.add(cb.lessThan(root.get("beginTime"), new Date()));
+			predicates.add(cb.greaterThan(root.get("endTime"), new Date()));
+			if (null != type) {
+				predicates.add(cb.equal(root.get("examType"), type));
+			}
+
+			Boolean enable = req.getExamEnable();
+			if (null == enable) {
+				enable = true;
+			}
+			predicates.add(cb.equal(root.get("enable"), enable));
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		PageRequest pageRequest = new PageRequest(0, 100, new Sort(Direction.ASC, "beginTime"));
+
+		Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
+
+		Iterator<ExamEntity> iterator = page.iterator();
+
+		List<ExamBean> list = Lists.newArrayList();
+
+		while (iterator.hasNext()) {
+			ExamEntity exam = iterator.next();
+			ExamBean bean = new ExamBean();
+			list.add(bean);
+
+			bean.setId(exam.getId());
+			bean.setBeginTime(exam.getBeginTime());
+			bean.setDuration(exam.getDuration());
+			bean.setEnable(exam.getEnable());
+			bean.setEndTime(exam.getEndTime());
+			bean.setExamTimes(exam.getExamTimes());
+			bean.setExamType(exam.getExamType().name());
+			bean.setName(exam.getName());
+			bean.setRemark(exam.getRemark());
+			bean.setRootOrgId(exam.getRootOrgId());
+		}
+		GetOngoingExamListResp resp = new GetOngoingExamListResp();
+		resp.setExamList(list);
+		return resp;
+	}
+
+	@ApiOperation(value = "锁定考试")
+	@PostMapping("lockExamStudents")
+	@Override
+	public LockExamStudentsResp lockExamStudents(@RequestBody LockExamStudentsReq req) {
+
+		List<Long> examIdList = req.getExamIdList();
+
+		if (CollectionUtils.isEmpty(examIdList)) {
+			throw new StatusException("E-002003", "examIdList is empty");
+		}
+		for (Long examId : examIdList) {
+			if (null == examId) {
+				throw new StatusException("E-002001", "examId is null");
+			}
+			ExamEntity exam = examRepo.findOne(examId);
+			if (null == exam) {
+				throw new StatusException("E-002002", "ExamEntity is null");
+			}
+			exam.setExamStudentLocked(true);
+			examRepo.save(exam);
+		}
+
+		LockExamStudentsResp resp = new LockExamStudentsResp();
+		resp.setExamIdList(examIdList);
+		return resp;
+	}
+
+	@ApiOperation(value = "解锁考试")
+	@PostMapping("unlockExamStudents")
+	@Override
+	public UnlockExamStudentsResp unlockExamStudents(@RequestBody UnlockExamStudentsReq req) {
+
+		List<Long> examIdList = req.getExamIdList();
+
+		if (CollectionUtils.isEmpty(examIdList)) {
+			throw new StatusException("E-002003", "examIdList is empty");
+		}
+
+		for (Long examId : examIdList) {
+			if (null == examId) {
+				throw new StatusException("E-002001", "examId is null");
+			}
+			ExamEntity exam = examRepo.findOne(examId);
+			if (null == exam) {
+				throw new StatusException("E-002002", "ExamEntity is null");
+			}
+			exam.setExamStudentLocked(false);
+			examRepo.save(exam);
+		}
+
+		UnlockExamStudentsResp resp = new UnlockExamStudentsResp();
+		resp.setExamIdList(examIdList);
+		return resp;
+	}
+
+	@ApiOperation(value = "查询考试集合")
+	@PostMapping("getExamList")
+	@Override
+	public GetExamListResp getExamList(@RequestBody GetExamListReq req) {
+
+		Long rootOrgId = req.getRootOrgId();
+		Boolean enable = req.getEnable();
+		List<String> examTypeList = req.getExamTypeList();
+
+		List<ExamType> examTypes = Lists.newArrayList();
+		if (CollectionUtils.isNotEmpty(examTypeList)) {
+			for (String cur : examTypeList) {
+				examTypes.add(ExamType.valueOf(cur));
+			}
+		}
+
+		final long start = null == req.getStart() ? 1 : req.getStart();
+
+		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "id");
+
+		Specification<ExamEntity> 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));
+
+			if (null != enable) {
+				predicates.add(cb.equal(root.get("enable"), enable));
+			}
+			if (CollectionUtils.isNotEmpty(examTypes)) {
+				if (1 == examTypeList.size()) {
+					predicates.add(cb.equal(root.get("examType"), examTypes.get(0)));
+				} else {
+					predicates.add(root.get("examType").in(examTypes));
+				}
+			}
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		Page<ExamEntity> page = examRepo.findAll(specification, pageable);
+
+		Iterator<ExamEntity> iterator = page.iterator();
+
+		List<ExamBean> list = Lists.newArrayList();
+		long next = start;
+		while (iterator.hasNext()) {
+			ExamEntity cur = iterator.next();
+			ExamBean bean = new ExamBean();
+			list.add(bean);
+
+			bean.setId(cur.getId());
+			bean.setBeginTime(cur.getBeginTime());
+			bean.setDuration(cur.getDuration());
+			bean.setEnable(cur.getEnable());
+			bean.setEndTime(cur.getEndTime());
+			bean.setExamTimes(cur.getExamTimes());
+			bean.setExamType(cur.getExamType().name());
+			bean.setName(cur.getName());
+			bean.setRemark(cur.getRemark());
+			bean.setRootOrgId(cur.getRootOrgId());
+
+			next = cur.getId();
+		}
+
+		GetExamListResp resp = new GetExamListResp();
+		if (next != start) {
+			next++;
+		}
+		resp.setNext(next);
+		resp.setExamList(list);
+		return resp;
+	}
+
+	@ApiOperation(value = "查询考试的课程集合")
+	@PostMapping("getExamCourseList")
+	@Override
+	public GetExamCourseListResp getExamCourseList(@RequestBody GetExamCourseListReq req) {
+		Long examId = req.getExamId();
+
+		final long start = null == req.getStart() ? 1 : req.getStart();
+
+		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "courseId");
+
+		Specification<ExamCourseRelationEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("examId"), examId));
+
+			predicates.add(cb.greaterThanOrEqualTo(root.get("courseId"), start));
+
+			if (null != req.getCourseEnable()) {
+				predicates.add(cb.equal(root.get("courseEnable"), req.getCourseEnable()));
+			}
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification,
+				pageable);
+
+		Iterator<ExamCourseRelationEntity> iterator = page.iterator();
+
+		List<ExamCourseRelationBean> list = Lists.newArrayList();
+		long next = start;
+		while (iterator.hasNext()) {
+			ExamCourseRelationEntity e = iterator.next();
+			ExamCourseRelationBean b = new ExamCourseRelationBean();
+			b.setCourseCode(e.getCourseCode());
+			b.setCourseId(e.getCourseId());
+			b.setCourseLevel(e.getCourseLevel());
+			b.setCourseName(e.getCourseName());
+			b.setExamId(examId);
+			b.setCourseEnable(e.getCourseEnable());
+
+			next = e.getCourseId();
+			list.add(b);
+		}
+
+		GetExamCourseListResp resp = new GetExamCourseListResp();
+		if (next != start) {
+			next++;
+		}
+		resp.setNext(next);
+		resp.setRelationList(list);
+
+		return resp;
+	}
+
+	@ApiOperation(value = "查询考试课程的试卷类型集")
+	@PostMapping("getExamCoursePaperTypeList")
+	@Override
+	public GetExamCoursePaperTypeListResp getExamCoursePaperTypeList(
+			@RequestBody GetExamCoursePaperTypeListReq req) {
+
+		Long examId = req.getExamId();
+
+		final long start = null == req.getStart() ? 1 : req.getStart();
+
+		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "courseId");
+
+		Specification<ExamPaperTypeRelationEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			predicates.add(cb.equal(root.get("examId"), examId));
+
+			predicates.add(cb.greaterThanOrEqualTo(root.get("courseId"), start));
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		Page<ExamPaperTypeRelationEntity> page = examPaperTypeRelationRepo.findAll(specification,
+				pageable);
+
+		Iterator<ExamPaperTypeRelationEntity> iterator = page.iterator();
+
+		List<ExamPaperTypeRelation> list = Lists.newArrayList();
+		long next = start;
+		while (iterator.hasNext()) {
+			ExamPaperTypeRelationEntity e = iterator.next();
+			ExamPaperTypeRelation b = new ExamPaperTypeRelation();
+			b.setCourseId(e.getCourseId());
+			b.setExamId(e.getExamId());
+			b.setPaperType(e.getPaperType());
+
+			next = e.getCourseId();
+			list.add(b);
+		}
+
+		GetExamCoursePaperTypeListResp resp = new GetExamCoursePaperTypeListResp();
+		if (next != start) {
+			next++;
+		}
+		resp.setNext(next);
+		resp.setRelationList(list);
+
+		return resp;
+	}
+
+	@ApiOperation(value = "统计考生数量")
+	@PostMapping("countExamStudent")
+	@Override
+	public CountExamStudentResp countExamStudent(@RequestBody CountExamStudentReq req) {
+
+		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+
+			if (null != req.getExamId()) {
+				predicates.add(cb.equal(root.get("examId"), req.getExamId()));
+			}
+			if (null != req.getCourseId()) {
+				predicates.add(cb.equal(root.get("courseId"), req.getCourseId()));
+			}
+			if (StringUtils.isNotEmpty(req.getPaperType())) {
+				predicates.add(cb.equal(root.get("paperType"), req.getPaperType()));
+			}
+			if (StringUtils.isNotEmpty(req.getExamSite())) {
+				predicates.add(cb.equal(root.get("examSite"), req.getExamSite()));
+			}
+			if (null != req.getOrgId()) {
+				predicates.add(cb.equal(root.get("orgId"), req.getOrgId()));
+			}
+			if (null != req.getExt1()) {
+				predicates.add(cb.equal(root.get("ext1"), req.getExt1()));
+			}
+			if (null != req.getExt2()) {
+				predicates.add(cb.equal(root.get("ext2"), req.getExt2()));
+			}
+			if (null != req.getExt3()) {
+				predicates.add(cb.equal(root.get("ext3"), req.getExt3()));
+			}
+			if (null != req.getExt4()) {
+				predicates.add(cb.equal(root.get("ext4"), req.getExt4()));
+			}
+			if (null != req.getExt5()) {
+				predicates.add(cb.equal(root.get("ext5"), req.getExt5()));
+			}
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
+		long count = examStudentRepo.count(specification);
+		CountExamStudentResp resp = new CountExamStudentResp();
+		resp.setCount(count);
+		return resp;
+	}
+
+	@ApiOperation(value = "获取考试机构列表")
+	@PostMapping("getExamOrgList")
+	@Override
+	public GetExamOrgListResp getExamOrgList(@RequestBody GetExamOrgListReq req) {
+
+		long start = null == req.getStart() ? 1 : req.getStart();
+		Long examId = req.getExamId();
+		long next = start;
+
+		List<Long> bigIntegerList = examStudentRepo.queryOrgIdList(examId, start);
+		List<Long> orgIdList = Lists.newArrayList();
+		for (Object bigInteger : bigIntegerList) {
+			orgIdList.add(Long.parseLong(String.valueOf(bigInteger)));
+		}
+		if (CollectionUtils.isNotEmpty(orgIdList)) {
+			next = orgIdList.get(orgIdList.size() - 1);
+			next++;
+		}
+
+		GetExamOrgListResp resp = new GetExamOrgListResp();
+		resp.setNext(next);
+		resp.setOrgIdList(orgIdList);
+
+		return resp;
+	}
+
+	@ApiOperation(value = " 获取考生属性值集合")
+	@PostMapping("getExamStudentPropertyValueList")
+	@Override
+	public GetExamStudentPropertyValueListResp getExamStudentPropertyValueList(
+			@RequestBody GetExamStudentPropertyValueListReq req) {
+
+		Long examId = req.getExamId();
+		String start = null == req.getStart() ? "" : req.getStart();
+
+		List<String> valueList = null;
+		String name = req.getPropertyName();
+
+		if (StringUtils.isBlank(name)) {
+			throw new StatusException("E-003005", "propertyName is blank");
+		}
+
+		if (name.equals("examSite")) {
+			valueList = examStudentRepo.queryExamSiteList(examId, start);
+		} else if (name.equals("ext1")) {
+			valueList = examStudentRepo.queryExt1List(examId, start);
+		} else if (name.equals("ext2")) {
+			valueList = examStudentRepo.queryExt2List(examId, start);
+		} else if (name.equals("ext3")) {
+			valueList = examStudentRepo.queryExt3List(examId, start);
+		} else if (name.equals("ext4")) {
+			valueList = examStudentRepo.queryExt4List(examId, start);
+		} else if (name.equals("ext5")) {
+			valueList = examStudentRepo.queryExt5List(examId, start);
+		} else {
+			throw new StatusException("E-003006", "propertyName is wrong");
+		}
+
+		GetExamStudentPropertyValueListResp resp = new GetExamStudentPropertyValueListResp();
+		resp.setValueList(valueList);
+
+		return resp;
+	}
+
+}