WANG 6 anni fa
parent
commit
7848eda09a

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

@@ -1,461 +1,464 @@
-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.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.ExamPropertyRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
-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.ExamPropertyEntity;
-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.request.GetExamCourseListReq;
-import cn.com.qmth.examcloud.examwork.api.request.GetExamListReq;
-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.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.GetExamCourseListResp;
-import cn.com.qmth.examcloud.examwork.api.response.GetExamListResp;
-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.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 chenken
- * @date 2018年5月3日 下午2:08:59
- * @company QMTH
- * @description ExamProvider.java
- */
-@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
-	ExamPropertyRepo examPropertyRepo;
-
-	@Autowired
-	ExamCourseRelationRepo examCourseRelationRepo;
-
-	@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);
-
-		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));
-			}
-
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-
-		PageRequest pageRequest = new PageRequest(0, 100, new Sort(Direction.DESC, "updateTime"));
-
-		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)) {
-				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));
-
-			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);
-
-			next = e.getCourseId();
-			list.add(b);
-		}
-
-		GetExamCourseListResp resp = new GetExamCourseListResp();
-		if (next != start) {
-			next++;
-		}
-		resp.setNext(next);
-		resp.setRelationList(list);
-
-		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.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.ExamPropertyRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+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.ExamPropertyEntity;
+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.request.GetExamCourseListReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamListReq;
+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.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.GetExamCourseListResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamListResp;
+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.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 chenken
+ * @date 2018年5月3日 下午2:08:59
+ * @company QMTH
+ * @description ExamProvider.java
+ */
+@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
+	ExamPropertyRepo examPropertyRepo;
+
+	@Autowired
+	ExamCourseRelationRepo examCourseRelationRepo;
+
+	@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);
+
+		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.DESC, "updateTime"));
+
+		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)) {
+				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));
+
+			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);
+
+			next = e.getCourseId();
+			list.add(b);
+		}
+
+		GetExamCourseListResp resp = new GetExamCourseListResp();
+		if (next != start) {
+			next++;
+		}
+		resp.setNext(next);
+		resp.setRelationList(list);
+
+		return resp;
+	}
+
+}