|
@@ -56,763 +56,764 @@ import java.util.*;
|
|
@RequestMapping("${$rmp.cloud.examwork}" + "exam")
|
|
@RequestMapping("${$rmp.cloud.examwork}" + "exam")
|
|
public class ExamCloudServiceProvider extends ControllerSupport implements ExamCloudService {
|
|
public class ExamCloudServiceProvider extends ControllerSupport implements ExamCloudService {
|
|
|
|
|
|
- private static final long serialVersionUID = 6850508158980856785L;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- RedisClient redisClient;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamService examService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamSpecialSettingsRepo examSpecialSettingsRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamRepo examRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamStudentRepo examStudentRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamPropertyRepo examPropertyRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamCourseRelationRepo examCourseRelationRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- OnGoingExamService onGoingExamService;
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "保存考试批次", notes = "保存")
|
|
|
|
- @PostMapping("saveExam")
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public SaveExamResp saveExam(@RequestBody SaveExamReq req) {
|
|
|
|
- ExamInfo examInfo = new ExamInfo();
|
|
|
|
-
|
|
|
|
- examInfo.setBeginTime(req.getBeginTime());
|
|
|
|
- examInfo.setDuration(req.getDuration());
|
|
|
|
- examInfo.setEnable(req.getEnable());
|
|
|
|
- examInfo.setEndTime(req.getEndTime());
|
|
|
|
- examInfo.setExamTimes(req.getExamTimes());
|
|
|
|
-
|
|
|
|
- examInfo.setExamType(req.getExamType());
|
|
|
|
- examInfo.setCode(req.getCode());
|
|
|
|
- examInfo.setName(req.getName());
|
|
|
|
- examInfo.setRemark(req.getRemark());
|
|
|
|
- examInfo.setRootOrgId(req.getRootOrgId());
|
|
|
|
- examInfo.setExamLimit(req.getExamLimit());
|
|
|
|
-
|
|
|
|
- Map<String, String> properties = req.getProperties();
|
|
|
|
- examInfo.setProperties(properties);
|
|
|
|
-
|
|
|
|
- ExamEntity saved = examService.saveExam(examInfo, CURD.CREATION_OR_UPDATE);
|
|
|
|
-
|
|
|
|
- SaveExamResp resp = new SaveExamResp();
|
|
|
|
- resp.setExamId(saved.getId());
|
|
|
|
-
|
|
|
|
- ExamBean bean = new ExamBean();
|
|
|
|
- resp.setExamBean(bean);
|
|
|
|
-
|
|
|
|
- bean.setId(saved.getId());
|
|
|
|
- bean.setBeginTime(saved.getBeginTime());
|
|
|
|
- bean.setDuration(saved.getDuration());
|
|
|
|
- bean.setEnable(saved.getEnable());
|
|
|
|
- bean.setEndTime(saved.getEndTime());
|
|
|
|
- bean.setExamTimes(saved.getExamTimes());
|
|
|
|
- bean.setExamType(saved.getExamType().name());
|
|
|
|
- bean.setName(saved.getName());
|
|
|
|
- bean.setCode(saved.getCode());
|
|
|
|
- bean.setRemark(saved.getRemark());
|
|
|
|
- bean.setRootOrgId(saved.getRootOrgId());
|
|
|
|
- bean.setExamLimit(saved.getExamLimit());
|
|
|
|
-
|
|
|
|
- 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();
|
|
|
|
- String code = req.getCode();
|
|
|
|
-
|
|
|
|
- ExamEntity exam = null;
|
|
|
|
-
|
|
|
|
- if (null != id) {
|
|
|
|
- exam = GlobalHelper.getEntity(examRepo, id, ExamEntity.class);
|
|
|
|
- } else if (StringUtils.isNotBlank(name)) {
|
|
|
|
- if (null == rootOrgId) {
|
|
|
|
- throw new StatusException("002004", "rootOrgId is null");
|
|
|
|
- }
|
|
|
|
- exam = examRepo.findByNameAndRootOrgId(name, rootOrgId);
|
|
|
|
- } else if (StringUtils.isNotBlank(code)) {
|
|
|
|
- if (null == rootOrgId) {
|
|
|
|
- throw new StatusException("002003", "rootOrgId is null");
|
|
|
|
- }
|
|
|
|
- exam = examRepo.findByCodeAndRootOrgId(code, rootOrgId);
|
|
|
|
- } else {
|
|
|
|
- throw new StatusException("002002", "id,name,code are all null");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null == exam) {
|
|
|
|
- throw new StatusException("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.setCode(exam.getCode());
|
|
|
|
- bean.setRemark(exam.getRemark());
|
|
|
|
- bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
- bean.setExamLimit(exam.getExamLimit());
|
|
|
|
-
|
|
|
|
- return examResp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "设置考试属性")
|
|
|
|
- @PostMapping("setExamProperty")
|
|
|
|
- @Transactional
|
|
|
|
- @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.getExamOrgProperty(examId, orgId, key);
|
|
|
|
-
|
|
|
|
- GetExamPropertyResp resp = new GetExamPropertyResp();
|
|
|
|
- resp.setValue(value);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询考试属性集合")
|
|
|
|
- @PostMapping("getExamPropertyList")
|
|
|
|
- @Override
|
|
|
|
- public GetExamPropertyListResp getExamPropertyList(@RequestBody GetExamPropertyListReq req) {
|
|
|
|
-
|
|
|
|
- Long examId = req.getExamId();
|
|
|
|
- Long orgId = req.getOrgId();
|
|
|
|
- List<String> keys = req.getKeys();
|
|
|
|
- Map<String, String> properties = Maps.newHashMap();
|
|
|
|
- for (String key : keys) {
|
|
|
|
- String value = examService.getExamOrgProperty(examId, orgId, key);
|
|
|
|
- properties.put(key, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamPropertyListResp resp = new GetExamPropertyListResp();
|
|
|
|
- resp.setProperties(properties);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询正在考试的考试集合")
|
|
|
|
- @PostMapping("getOngoingExamList")
|
|
|
|
- @Override
|
|
|
|
- public GetOngoingExamListResp getOngoingExamList(@RequestBody GetOngoingExamListReq req) {
|
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
|
- String examType = req.getExamType();
|
|
|
|
- Long orgId = req.getOrgId();
|
|
|
|
- Long studentId = req.getStudentId();
|
|
|
|
-
|
|
|
|
- List<ExamSpecialSettingsEntity> resultList = onGoingExamService
|
|
|
|
- .getOngoingExamList(rootOrgId, examType, orgId, studentId);
|
|
|
|
-
|
|
|
|
- List<ExamSpecialSettingsBean> list = Lists.newArrayList();
|
|
|
|
- for (ExamSpecialSettingsEntity cur : resultList) {
|
|
|
|
- ExamSpecialSettingsBean bean = new ExamSpecialSettingsBean();
|
|
|
|
- list.add(bean);
|
|
|
|
- bean.setId(cur.getId());
|
|
|
|
- bean.setOrgId(cur.getOrgId());
|
|
|
|
- bean.setCourseId(cur.getCourseId());
|
|
|
|
- bean.setStudentId(cur.getStudentId());
|
|
|
|
- cur.setRootOrgId(cur.getRootOrgId());
|
|
|
|
- cur.setUpdateTime(cur.getUpdateTime());
|
|
|
|
- bean.setBeginTime(cur.getBeginTime());
|
|
|
|
- bean.setEndTime(cur.getEndTime());
|
|
|
|
- bean.setExamEnable(cur.getExamEnable());
|
|
|
|
- bean.setExamId(cur.getExamId());
|
|
|
|
- bean.setExamLimit(cur.getExamLimit());
|
|
|
|
- bean.setExamType(cur.getExamType().name());
|
|
|
|
- bean.setSpecialSettingsEnabled(cur.getSpecialSettingsEnabled());
|
|
|
|
- bean.setSpecialSettingsType(cur.getSpecialSettingsType());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetOngoingExamListResp resp = new GetOngoingExamListResp();
|
|
|
|
- resp.setExamSpecialSettingsList(list);
|
|
|
|
-
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "锁定考试")
|
|
|
|
- @PostMapping("lockExamStudents")
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public LockExamStudentsResp lockExamStudents(@RequestBody LockExamStudentsReq req) {
|
|
|
|
-
|
|
|
|
- List<Long> examIdList = req.getExamIdList();
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isEmpty(examIdList)) {
|
|
|
|
- throw new StatusException("002003", "examIdList is empty");
|
|
|
|
- }
|
|
|
|
- for (Long examId : examIdList) {
|
|
|
|
- if (null == examId) {
|
|
|
|
- throw new StatusException("002001", "examId is null");
|
|
|
|
- }
|
|
|
|
- ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
|
- if (null == exam) {
|
|
|
|
- throw new StatusException("002002", "ExamEntity is null");
|
|
|
|
- }
|
|
|
|
- exam.setExamStudentLocked(true);
|
|
|
|
- examRepo.save(exam);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- LockExamStudentsResp resp = new LockExamStudentsResp();
|
|
|
|
- resp.setExamIdList(examIdList);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "解锁考试")
|
|
|
|
- @PostMapping("unlockExamStudents")
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public UnlockExamStudentsResp unlockExamStudents(@RequestBody UnlockExamStudentsReq req) {
|
|
|
|
-
|
|
|
|
- List<Long> examIdList = req.getExamIdList();
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isEmpty(examIdList)) {
|
|
|
|
- throw new StatusException("002003", "examIdList is empty");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (Long examId : examIdList) {
|
|
|
|
- if (null == examId) {
|
|
|
|
- throw new StatusException("002001", "examId is null");
|
|
|
|
- }
|
|
|
|
- ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
|
- if (null == exam) {
|
|
|
|
- throw new StatusException("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 = PageRequest.of(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 (req.getUd() != null && req.getUd().assertNeedQueryRefIds()) {
|
|
|
|
- predicates.add(root.get("id").in(req.getUd().getRefIds()));
|
|
|
|
- }
|
|
|
|
- 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;
|
|
|
|
- boolean has = false;
|
|
|
|
- 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();
|
|
|
|
- has = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamListResp resp = new GetExamListResp();
|
|
|
|
- if (has) {
|
|
|
|
- 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();
|
|
|
|
- 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()]));
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Pageable pageable = PageRequest.of(0, 100, Sort.Direction.ASC, "courseId");
|
|
|
|
- Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification, pageable);
|
|
|
|
-
|
|
|
|
- Iterator<ExamCourseRelationEntity> iterator = page.iterator();
|
|
|
|
-
|
|
|
|
- List<ExamCourseRelationBean> list = Lists.newArrayList();
|
|
|
|
- long next = start;
|
|
|
|
- boolean has = false;
|
|
|
|
- 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);
|
|
|
|
- has = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamCourseListResp resp = new GetExamCourseListResp();
|
|
|
|
- if (has) {
|
|
|
|
- next++;
|
|
|
|
- }
|
|
|
|
- resp.setNext(next);
|
|
|
|
- resp.setRelationList(list);
|
|
|
|
-
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询考试课程特殊设置")
|
|
|
|
- @PostMapping("getExamCourseSetting")
|
|
|
|
- @Override
|
|
|
|
- public GetExamCourseResp getExamCourseSetting(@RequestBody GetExamCourseReq req) {
|
|
|
|
- ExamCourseRelationEntity entity = examCourseRelationRepo.findByExamIdAndCourseId(req.getExamId(), req.getCourseId());
|
|
|
|
-
|
|
|
|
- GetExamCourseResp resp = new GetExamCourseResp();
|
|
|
|
- if (entity != null) {
|
|
|
|
- ExamCourseRelationBean bean = new ExamCourseRelationBean();
|
|
|
|
- bean.setExamId(entity.getExamId());
|
|
|
|
- bean.setCourseId(entity.getCourseId());
|
|
|
|
- bean.setCourseCode(entity.getCourseCode());
|
|
|
|
- bean.setCourseLevel(entity.getCourseLevel());
|
|
|
|
- bean.setCourseName(entity.getCourseName());
|
|
|
|
- bean.setCourseEnable(entity.getCourseEnable());
|
|
|
|
- bean.setPassScoreLine(entity.getPassScoreLine());
|
|
|
|
- bean.setGoodScoreLine(entity.getGoodScoreLine());
|
|
|
|
- resp.setBean(bean);
|
|
|
|
- }
|
|
|
|
- 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 = PageRequest.of(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;
|
|
|
|
- boolean has = false;
|
|
|
|
- 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);
|
|
|
|
- has = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamCoursePaperTypeListResp resp = new GetExamCoursePaperTypeListResp();
|
|
|
|
- if (has) {
|
|
|
|
- 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("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("003006", "propertyName is wrong");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamStudentPropertyValueListResp resp = new GetExamStudentPropertyValueListResp();
|
|
|
|
- resp.setValueList(valueList);
|
|
|
|
-
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "按ID查询考试", notes = "")
|
|
|
|
- @PostMapping("getExamsByIdList")
|
|
|
|
- @Override
|
|
|
|
- public GetExamsByIdListResp getExamsByIdList(@RequestBody GetExamsByIdListReq req) {
|
|
|
|
- List<Long> examIdList = req.getExamIdList();
|
|
|
|
- List<ExamBean> list = Lists.newArrayList();
|
|
|
|
- for (Long cur : examIdList) {
|
|
|
|
- ExamEntity exam = GlobalHelper.getEntity(examRepo, cur, ExamEntity.class);
|
|
|
|
- if (null == exam) {
|
|
|
|
- throw new StatusException("012001", "no exam [id=" + cur + "]");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ExamBean bean = new ExamBean();
|
|
|
|
-
|
|
|
|
- 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.setCode(exam.getCode());
|
|
|
|
- bean.setRemark(exam.getRemark());
|
|
|
|
- bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
- bean.setExamLimit(exam.getExamLimit());
|
|
|
|
-
|
|
|
|
- list.add(bean);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamsByIdListResp resp = new GetExamsByIdListResp();
|
|
|
|
- resp.setExamList(list);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "遍历考试", notes = "")
|
|
|
|
- @PostMapping("getExams")
|
|
|
|
- @Override
|
|
|
|
- public GetExamsResp getExams(@RequestBody GetExamsReq req) {
|
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
|
- Boolean enable = req.getEnable();
|
|
|
|
-
|
|
|
|
- final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
|
-
|
|
|
|
- Pageable pageable = PageRequest.of(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));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- 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;
|
|
|
|
- boolean has = false;
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- ExamEntity exam = iterator.next();
|
|
|
|
- ExamBean bean = new ExamBean();
|
|
|
|
- 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.setCode(exam.getCode());
|
|
|
|
- bean.setRemark(exam.getRemark());
|
|
|
|
- bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
- bean.setExamLimit(exam.getExamLimit());
|
|
|
|
-
|
|
|
|
- next = exam.getId();
|
|
|
|
- list.add(bean);
|
|
|
|
- has = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamsResp resp = new GetExamsResp();
|
|
|
|
- if (has) {
|
|
|
|
- next++;
|
|
|
|
- }
|
|
|
|
- resp.setNext(next);
|
|
|
|
- resp.setExamBeanList(list);
|
|
|
|
-
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "保存学生特殊设置", notes = "")
|
|
|
|
- @PostMapping("saveStudentSpecialSettings")
|
|
|
|
- @Override
|
|
|
|
- public SaveStudentSpecialSettingsResp saveStudentSpecialSettings(
|
|
|
|
- @RequestBody SaveStudentSpecialSettingsReq req) {
|
|
|
|
-
|
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
|
- Long studentId = req.getStudentId();
|
|
|
|
- Long examId = req.getExamId();
|
|
|
|
- Date beginTime = req.getBeginTime();
|
|
|
|
- Date endTime = req.getEndTime();
|
|
|
|
-
|
|
|
|
- ExamSpecialSettingsInfo examSpecialInfo = new ExamSpecialSettingsInfo();
|
|
|
|
- examSpecialInfo.setBeginTime(beginTime);
|
|
|
|
- examSpecialInfo.setEndTime(endTime);
|
|
|
|
- examSpecialInfo.setExamId(examId);
|
|
|
|
- examSpecialInfo.setExamLimit(false);
|
|
|
|
- examSpecialInfo.setRootOrgId(rootOrgId);
|
|
|
|
- examSpecialInfo.setStudentId(studentId);
|
|
|
|
-
|
|
|
|
- ExamSpecialSettingsEntity saved = examService.saveExamSpecialSettings(examSpecialInfo);
|
|
|
|
-
|
|
|
|
- SaveStudentSpecialSettingsResp resp = new SaveStudentSpecialSettingsResp();
|
|
|
|
- resp.setSpecialSettingsId(saved.getId());
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @PostMapping("getExamMaps")
|
|
|
|
- @ApiOperation(value = "根据ID列表获取考试集合")
|
|
|
|
- public GetExamMapsResp getExamMaps(@RequestBody GetExamMapsReq req) {
|
|
|
|
- Map<Long, ExamEntity> exams = examService.getExamMapsByIds(req.getExamIds());
|
|
|
|
-
|
|
|
|
- Map<Long, ExamBean> examMaps = new HashMap<>();
|
|
|
|
- for (Map.Entry<Long, ExamEntity> exam : exams.entrySet()) {
|
|
|
|
- examMaps.put(exam.getKey(), toExamBean(exam.getValue()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- GetExamMapsResp resp = new GetExamMapsResp();
|
|
|
|
- resp.setExamMaps(examMaps);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private ExamBean toExamBean(ExamEntity entity) {
|
|
|
|
- ExamBean bean = new ExamBean();
|
|
|
|
-
|
|
|
|
- bean.setId(entity.getId());
|
|
|
|
- bean.setRootOrgId(entity.getRootOrgId());
|
|
|
|
- bean.setCode(entity.getCode());
|
|
|
|
- bean.setName(entity.getName());
|
|
|
|
- bean.setExamType(entity.getExamType().name());
|
|
|
|
- bean.setBeginTime(entity.getBeginTime());
|
|
|
|
- bean.setEndTime(entity.getEndTime());
|
|
|
|
- bean.setDuration(entity.getDuration());
|
|
|
|
- bean.setExamTimes(entity.getExamTimes());
|
|
|
|
- bean.setExamLimit(entity.getExamLimit());
|
|
|
|
- bean.setSpecialSettingsEnabled(entity.getSpecialSettingsEnabled());
|
|
|
|
- bean.setSpecialSettingsType(entity.getSpecialSettingsType());
|
|
|
|
- bean.setEnable(entity.getEnable());
|
|
|
|
-
|
|
|
|
- return bean;
|
|
|
|
- }
|
|
|
|
|
|
+ private static final long serialVersionUID = 6850508158980856785L;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RedisClient redisClient;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamService examService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamSpecialSettingsRepo examSpecialSettingsRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamRepo examRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamStudentRepo examStudentRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamPropertyRepo examPropertyRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamCourseRelationRepo examCourseRelationRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ OnGoingExamService onGoingExamService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "保存考试批次", notes = "保存")
|
|
|
|
+ @PostMapping("saveExam")
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public SaveExamResp saveExam(@RequestBody SaveExamReq req) {
|
|
|
|
+ ExamInfo examInfo = new ExamInfo();
|
|
|
|
+
|
|
|
|
+ examInfo.setBeginTime(req.getBeginTime());
|
|
|
|
+ examInfo.setDuration(req.getDuration());
|
|
|
|
+ examInfo.setEnable(req.getEnable());
|
|
|
|
+ examInfo.setEndTime(req.getEndTime());
|
|
|
|
+ examInfo.setExamTimes(req.getExamTimes());
|
|
|
|
+
|
|
|
|
+ examInfo.setExamType(req.getExamType());
|
|
|
|
+ examInfo.setCode(req.getCode());
|
|
|
|
+ examInfo.setName(req.getName());
|
|
|
|
+ examInfo.setRemark(req.getRemark());
|
|
|
|
+ examInfo.setRootOrgId(req.getRootOrgId());
|
|
|
|
+ examInfo.setExamLimit(req.getExamLimit());
|
|
|
|
+
|
|
|
|
+ Map<String, String> properties = req.getProperties();
|
|
|
|
+ examInfo.setProperties(properties);
|
|
|
|
+
|
|
|
|
+ ExamEntity saved = examService.saveExam(examInfo, CURD.CREATION_OR_UPDATE);
|
|
|
|
+
|
|
|
|
+ SaveExamResp resp = new SaveExamResp();
|
|
|
|
+ resp.setExamId(saved.getId());
|
|
|
|
+
|
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
|
+ resp.setExamBean(bean);
|
|
|
|
+
|
|
|
|
+ bean.setId(saved.getId());
|
|
|
|
+ bean.setBeginTime(saved.getBeginTime());
|
|
|
|
+ bean.setDuration(saved.getDuration());
|
|
|
|
+ bean.setEnable(saved.getEnable());
|
|
|
|
+ bean.setEndTime(saved.getEndTime());
|
|
|
|
+ bean.setExamTimes(saved.getExamTimes());
|
|
|
|
+ bean.setExamType(saved.getExamType().name());
|
|
|
|
+ bean.setName(saved.getName());
|
|
|
|
+ bean.setCode(saved.getCode());
|
|
|
|
+ bean.setRemark(saved.getRemark());
|
|
|
|
+ bean.setRootOrgId(saved.getRootOrgId());
|
|
|
|
+ bean.setExamLimit(saved.getExamLimit());
|
|
|
|
+
|
|
|
|
+ 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();
|
|
|
|
+ String code = req.getCode();
|
|
|
|
+
|
|
|
|
+ ExamEntity exam = null;
|
|
|
|
+
|
|
|
|
+ if (null != id) {
|
|
|
|
+ exam = GlobalHelper.getEntity(examRepo, id, ExamEntity.class);
|
|
|
|
+ } else if (StringUtils.isNotBlank(name)) {
|
|
|
|
+ if (null == rootOrgId) {
|
|
|
|
+ throw new StatusException("002004", "rootOrgId is null");
|
|
|
|
+ }
|
|
|
|
+ exam = examRepo.findByNameAndRootOrgId(name, rootOrgId);
|
|
|
|
+ } else if (StringUtils.isNotBlank(code)) {
|
|
|
|
+ if (null == rootOrgId) {
|
|
|
|
+ throw new StatusException("002003", "rootOrgId is null");
|
|
|
|
+ }
|
|
|
|
+ exam = examRepo.findByCodeAndRootOrgId(code, rootOrgId);
|
|
|
|
+ } else {
|
|
|
|
+ throw new StatusException("002002", "id,name,code are all null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null == exam) {
|
|
|
|
+ throw new StatusException("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.setCode(exam.getCode());
|
|
|
|
+ bean.setRemark(exam.getRemark());
|
|
|
|
+ bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
+ bean.setExamLimit(exam.getExamLimit());
|
|
|
|
+
|
|
|
|
+ return examResp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "设置考试属性")
|
|
|
|
+ @PostMapping("setExamProperty")
|
|
|
|
+ @Transactional
|
|
|
|
+ @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.getExamOrgProperty(examId, orgId, key);
|
|
|
|
+
|
|
|
|
+ GetExamPropertyResp resp = new GetExamPropertyResp();
|
|
|
|
+ resp.setValue(value);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询考试属性集合")
|
|
|
|
+ @PostMapping("getExamPropertyList")
|
|
|
|
+ @Override
|
|
|
|
+ public GetExamPropertyListResp getExamPropertyList(@RequestBody GetExamPropertyListReq req) {
|
|
|
|
+
|
|
|
|
+ Long examId = req.getExamId();
|
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
|
+ List<String> keys = req.getKeys();
|
|
|
|
+ Map<String, String> properties = Maps.newHashMap();
|
|
|
|
+ for (String key : keys) {
|
|
|
|
+ String value = examService.getExamOrgProperty(examId, orgId, key);
|
|
|
|
+ properties.put(key, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamPropertyListResp resp = new GetExamPropertyListResp();
|
|
|
|
+ resp.setProperties(properties);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询正在考试的考试集合")
|
|
|
|
+ @PostMapping("getOngoingExamList")
|
|
|
|
+ @Override
|
|
|
|
+ public GetOngoingExamListResp getOngoingExamList(@RequestBody GetOngoingExamListReq req) {
|
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
|
+ String examType = req.getExamType();
|
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
|
+ Long studentId = req.getStudentId();
|
|
|
|
+
|
|
|
|
+ List<ExamSpecialSettingsEntity> resultList = onGoingExamService.getOngoingExamList(rootOrgId, examType, orgId,
|
|
|
|
+ studentId);
|
|
|
|
+
|
|
|
|
+ List<ExamSpecialSettingsBean> list = Lists.newArrayList();
|
|
|
|
+ for (ExamSpecialSettingsEntity cur : resultList) {
|
|
|
|
+ ExamSpecialSettingsBean bean = new ExamSpecialSettingsBean();
|
|
|
|
+ list.add(bean);
|
|
|
|
+ bean.setId(cur.getId());
|
|
|
|
+ bean.setOrgId(cur.getOrgId());
|
|
|
|
+ bean.setCourseId(cur.getCourseId());
|
|
|
|
+ bean.setStudentId(cur.getStudentId());
|
|
|
|
+ cur.setRootOrgId(cur.getRootOrgId());
|
|
|
|
+ cur.setUpdateTime(cur.getUpdateTime());
|
|
|
|
+ bean.setBeginTime(cur.getBeginTime());
|
|
|
|
+ bean.setEndTime(cur.getEndTime());
|
|
|
|
+ bean.setExamEnable(cur.getExamEnable());
|
|
|
|
+ bean.setExamId(cur.getExamId());
|
|
|
|
+ bean.setExamLimit(cur.getExamLimit());
|
|
|
|
+ bean.setExamType(cur.getExamType().name());
|
|
|
|
+ bean.setSpecialSettingsEnabled(cur.getSpecialSettingsEnabled());
|
|
|
|
+ bean.setSpecialSettingsType(cur.getSpecialSettingsType());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetOngoingExamListResp resp = new GetOngoingExamListResp();
|
|
|
|
+ resp.setExamSpecialSettingsList(list);
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "锁定考试")
|
|
|
|
+ @PostMapping("lockExamStudents")
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public LockExamStudentsResp lockExamStudents(@RequestBody LockExamStudentsReq req) {
|
|
|
|
+
|
|
|
|
+ List<Long> examIdList = req.getExamIdList();
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isEmpty(examIdList)) {
|
|
|
|
+ throw new StatusException("002003", "examIdList is empty");
|
|
|
|
+ }
|
|
|
|
+ for (Long examId : examIdList) {
|
|
|
|
+ if (null == examId) {
|
|
|
|
+ throw new StatusException("002001", "examId is null");
|
|
|
|
+ }
|
|
|
|
+ ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
|
+ if (null == exam) {
|
|
|
|
+ throw new StatusException("002002", "ExamEntity is null");
|
|
|
|
+ }
|
|
|
|
+ exam.setExamStudentLocked(true);
|
|
|
|
+ examRepo.save(exam);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LockExamStudentsResp resp = new LockExamStudentsResp();
|
|
|
|
+ resp.setExamIdList(examIdList);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "解锁考试")
|
|
|
|
+ @PostMapping("unlockExamStudents")
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public UnlockExamStudentsResp unlockExamStudents(@RequestBody UnlockExamStudentsReq req) {
|
|
|
|
+
|
|
|
|
+ List<Long> examIdList = req.getExamIdList();
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isEmpty(examIdList)) {
|
|
|
|
+ throw new StatusException("002003", "examIdList is empty");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Long examId : examIdList) {
|
|
|
|
+ if (null == examId) {
|
|
|
|
+ throw new StatusException("002001", "examId is null");
|
|
|
|
+ }
|
|
|
|
+ ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
|
+ if (null == exam) {
|
|
|
|
+ throw new StatusException("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 = PageRequest.of(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 (req.getUd() != null && req.getUd().assertNeedQueryRefIds()) {
|
|
|
|
+ predicates.add(root.get("id").in(req.getUd().getRefIds()));
|
|
|
|
+ }
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (req.getCallType()!=null) {
|
|
|
|
+ predicates.add(cb.equal(root.get("callType"), req.getCallType()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ boolean has = false;
|
|
|
|
+ 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();
|
|
|
|
+ has = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamListResp resp = new GetExamListResp();
|
|
|
|
+ if (has) {
|
|
|
|
+ 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();
|
|
|
|
+ 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()]));
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Pageable pageable = PageRequest.of(0, 100, Sort.Direction.ASC, "courseId");
|
|
|
|
+ Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification, pageable);
|
|
|
|
+
|
|
|
|
+ Iterator<ExamCourseRelationEntity> iterator = page.iterator();
|
|
|
|
+
|
|
|
|
+ List<ExamCourseRelationBean> list = Lists.newArrayList();
|
|
|
|
+ long next = start;
|
|
|
|
+ boolean has = false;
|
|
|
|
+ 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);
|
|
|
|
+ has = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamCourseListResp resp = new GetExamCourseListResp();
|
|
|
|
+ if (has) {
|
|
|
|
+ next++;
|
|
|
|
+ }
|
|
|
|
+ resp.setNext(next);
|
|
|
|
+ resp.setRelationList(list);
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询考试课程特殊设置")
|
|
|
|
+ @PostMapping("getExamCourseSetting")
|
|
|
|
+ @Override
|
|
|
|
+ public GetExamCourseResp getExamCourseSetting(@RequestBody GetExamCourseReq req) {
|
|
|
|
+ ExamCourseRelationEntity entity = examCourseRelationRepo.findByExamIdAndCourseId(req.getExamId(),
|
|
|
|
+ req.getCourseId());
|
|
|
|
+
|
|
|
|
+ GetExamCourseResp resp = new GetExamCourseResp();
|
|
|
|
+ if (entity != null) {
|
|
|
|
+ ExamCourseRelationBean bean = new ExamCourseRelationBean();
|
|
|
|
+ bean.setExamId(entity.getExamId());
|
|
|
|
+ bean.setCourseId(entity.getCourseId());
|
|
|
|
+ bean.setCourseCode(entity.getCourseCode());
|
|
|
|
+ bean.setCourseLevel(entity.getCourseLevel());
|
|
|
|
+ bean.setCourseName(entity.getCourseName());
|
|
|
|
+ bean.setCourseEnable(entity.getCourseEnable());
|
|
|
|
+ bean.setPassScoreLine(entity.getPassScoreLine());
|
|
|
|
+ bean.setGoodScoreLine(entity.getGoodScoreLine());
|
|
|
|
+ resp.setBean(bean);
|
|
|
|
+ }
|
|
|
|
+ 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 = PageRequest.of(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;
|
|
|
|
+ boolean has = false;
|
|
|
|
+ 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);
|
|
|
|
+ has = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamCoursePaperTypeListResp resp = new GetExamCoursePaperTypeListResp();
|
|
|
|
+ if (has) {
|
|
|
|
+ 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("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("003006", "propertyName is wrong");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamStudentPropertyValueListResp resp = new GetExamStudentPropertyValueListResp();
|
|
|
|
+ resp.setValueList(valueList);
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "按ID查询考试", notes = "")
|
|
|
|
+ @PostMapping("getExamsByIdList")
|
|
|
|
+ @Override
|
|
|
|
+ public GetExamsByIdListResp getExamsByIdList(@RequestBody GetExamsByIdListReq req) {
|
|
|
|
+ List<Long> examIdList = req.getExamIdList();
|
|
|
|
+ List<ExamBean> list = Lists.newArrayList();
|
|
|
|
+ for (Long cur : examIdList) {
|
|
|
|
+ ExamEntity exam = GlobalHelper.getEntity(examRepo, cur, ExamEntity.class);
|
|
|
|
+ if (null == exam) {
|
|
|
|
+ throw new StatusException("012001", "no exam [id=" + cur + "]");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
|
+
|
|
|
|
+ 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.setCode(exam.getCode());
|
|
|
|
+ bean.setRemark(exam.getRemark());
|
|
|
|
+ bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
+ bean.setExamLimit(exam.getExamLimit());
|
|
|
|
+
|
|
|
|
+ list.add(bean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamsByIdListResp resp = new GetExamsByIdListResp();
|
|
|
|
+ resp.setExamList(list);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "遍历考试", notes = "")
|
|
|
|
+ @PostMapping("getExams")
|
|
|
|
+ @Override
|
|
|
|
+ public GetExamsResp getExams(@RequestBody GetExamsReq req) {
|
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
|
+ Boolean enable = req.getEnable();
|
|
|
|
+
|
|
|
|
+ final long start = null == req.getStart() ? 1 : req.getStart();
|
|
|
|
+
|
|
|
|
+ Pageable pageable = PageRequest.of(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));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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;
|
|
|
|
+ boolean has = false;
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ ExamEntity exam = iterator.next();
|
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
|
+ 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.setCode(exam.getCode());
|
|
|
|
+ bean.setRemark(exam.getRemark());
|
|
|
|
+ bean.setRootOrgId(exam.getRootOrgId());
|
|
|
|
+ bean.setExamLimit(exam.getExamLimit());
|
|
|
|
+
|
|
|
|
+ next = exam.getId();
|
|
|
|
+ list.add(bean);
|
|
|
|
+ has = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamsResp resp = new GetExamsResp();
|
|
|
|
+ if (has) {
|
|
|
|
+ next++;
|
|
|
|
+ }
|
|
|
|
+ resp.setNext(next);
|
|
|
|
+ resp.setExamBeanList(list);
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "保存学生特殊设置", notes = "")
|
|
|
|
+ @PostMapping("saveStudentSpecialSettings")
|
|
|
|
+ @Override
|
|
|
|
+ public SaveStudentSpecialSettingsResp saveStudentSpecialSettings(@RequestBody SaveStudentSpecialSettingsReq req) {
|
|
|
|
+
|
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
|
+ Long studentId = req.getStudentId();
|
|
|
|
+ Long examId = req.getExamId();
|
|
|
|
+ Date beginTime = req.getBeginTime();
|
|
|
|
+ Date endTime = req.getEndTime();
|
|
|
|
+
|
|
|
|
+ ExamSpecialSettingsInfo examSpecialInfo = new ExamSpecialSettingsInfo();
|
|
|
|
+ examSpecialInfo.setBeginTime(beginTime);
|
|
|
|
+ examSpecialInfo.setEndTime(endTime);
|
|
|
|
+ examSpecialInfo.setExamId(examId);
|
|
|
|
+ examSpecialInfo.setExamLimit(false);
|
|
|
|
+ examSpecialInfo.setRootOrgId(rootOrgId);
|
|
|
|
+ examSpecialInfo.setStudentId(studentId);
|
|
|
|
+
|
|
|
|
+ ExamSpecialSettingsEntity saved = examService.saveExamSpecialSettings(examSpecialInfo);
|
|
|
|
+
|
|
|
|
+ SaveStudentSpecialSettingsResp resp = new SaveStudentSpecialSettingsResp();
|
|
|
|
+ resp.setSpecialSettingsId(saved.getId());
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @PostMapping("getExamMaps")
|
|
|
|
+ @ApiOperation(value = "根据ID列表获取考试集合")
|
|
|
|
+ public GetExamMapsResp getExamMaps(@RequestBody GetExamMapsReq req) {
|
|
|
|
+ Map<Long, ExamEntity> exams = examService.getExamMapsByIds(req.getExamIds());
|
|
|
|
+
|
|
|
|
+ Map<Long, ExamBean> examMaps = new HashMap<>();
|
|
|
|
+ for (Map.Entry<Long, ExamEntity> exam : exams.entrySet()) {
|
|
|
|
+ examMaps.put(exam.getKey(), toExamBean(exam.getValue()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetExamMapsResp resp = new GetExamMapsResp();
|
|
|
|
+ resp.setExamMaps(examMaps);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ExamBean toExamBean(ExamEntity entity) {
|
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
|
+
|
|
|
|
+ bean.setId(entity.getId());
|
|
|
|
+ bean.setRootOrgId(entity.getRootOrgId());
|
|
|
|
+ bean.setCode(entity.getCode());
|
|
|
|
+ bean.setName(entity.getName());
|
|
|
|
+ bean.setExamType(entity.getExamType().name());
|
|
|
|
+ bean.setBeginTime(entity.getBeginTime());
|
|
|
|
+ bean.setEndTime(entity.getEndTime());
|
|
|
|
+ bean.setDuration(entity.getDuration());
|
|
|
|
+ bean.setExamTimes(entity.getExamTimes());
|
|
|
|
+ bean.setExamLimit(entity.getExamLimit());
|
|
|
|
+ bean.setSpecialSettingsEnabled(entity.getSpecialSettingsEnabled());
|
|
|
|
+ bean.setSpecialSettingsType(entity.getSpecialSettingsType());
|
|
|
|
+ bean.setEnable(entity.getEnable());
|
|
|
|
+
|
|
|
|
+ return bean;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|