|
@@ -1,96 +1,99 @@
|
|
|
-package cn.com.qmth.examcloud.task.api.controller;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
-
|
|
|
-import javax.transaction.Transactional;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.LockExamStudentsReq;
|
|
|
-import cn.com.qmth.examcloud.task.dao.CopyExamStudentRepo;
|
|
|
-import cn.com.qmth.examcloud.task.dao.entity.CopyExamStudentEntity;
|
|
|
-import cn.com.qmth.examcloud.task.dao.entity.CopyExamStudentPK;
|
|
|
-import cn.com.qmth.examcloud.task.dao.enums.CopyExamStudentStatus;
|
|
|
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-/**
|
|
|
- * 考生复制
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @date 2018年9月12日
|
|
|
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
- */
|
|
|
-@Transactional
|
|
|
-@RestController
|
|
|
-@RequestMapping("${$rmp.ctr.task}" + "copyExamStudent")
|
|
|
-public class CopyExamStudentController extends ControllerSupport {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- CopyExamStudentRepo copyExamStudentRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamCloudService examCloudService;
|
|
|
-
|
|
|
- @ApiOperation(value = "添加考生复制任务")
|
|
|
- @PostMapping("addCopyTask")
|
|
|
- public void addCopyTask(@RequestParam(required = true) Long examId1,
|
|
|
- @RequestParam(required = true) Long examId2) {
|
|
|
-
|
|
|
- User accessUser = getAccessUser();
|
|
|
- Long rootOrgId = accessUser.getRootOrgId();
|
|
|
-
|
|
|
- GetExamReq req = new GetExamReq();
|
|
|
- req.setRootOrgId(rootOrgId);
|
|
|
-
|
|
|
- req.setId(examId1);
|
|
|
- ExamBean exam1 = examCloudService.getExam(req).getExamBean();
|
|
|
-
|
|
|
- req.setId(examId2);
|
|
|
- ExamBean exam2 = examCloudService.getExam(req).getExamBean();
|
|
|
-
|
|
|
- CopyExamStudentPK pk = new CopyExamStudentPK(examId1, examId2);
|
|
|
- Optional<CopyExamStudentEntity> opt = copyExamStudentRepo.findById(pk);
|
|
|
- CopyExamStudentEntity one = null;
|
|
|
- if (opt.isPresent()) {
|
|
|
- one = opt.get();
|
|
|
- }
|
|
|
- if (null != one && (!one.getStatus().equals(CopyExamStudentStatus.COMPLETE))) {
|
|
|
- throw new StatusException("620001", "复制中,请勿重复操作");
|
|
|
- }
|
|
|
-
|
|
|
- if (null == one) {
|
|
|
- one = new CopyExamStudentEntity();
|
|
|
- one.setExamId1(exam1.getId());
|
|
|
- one.setExamId2(exam2.getId());
|
|
|
- one.setRootOrgId(rootOrgId);
|
|
|
- }
|
|
|
-
|
|
|
- one.setStart(1L);
|
|
|
- one.setStatus(CopyExamStudentStatus.NONE);
|
|
|
-
|
|
|
- // 锁定
|
|
|
- List<Long> examIdList = Lists.newArrayList();
|
|
|
- examIdList.add(one.getExamId1());
|
|
|
- examIdList.add(one.getExamId2());
|
|
|
-
|
|
|
- LockExamStudentsReq lockReq = new LockExamStudentsReq();
|
|
|
- lockReq.setExamIdList(examIdList);
|
|
|
- examCloudService.lockExamStudents(lockReq);
|
|
|
-
|
|
|
- copyExamStudentRepo.save(one);
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package cn.com.qmth.examcloud.task.api.controller;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+import javax.transaction.Transactional;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.LockExamStudentsReq;
|
|
|
+import cn.com.qmth.examcloud.task.dao.CopyExamStudentRepo;
|
|
|
+import cn.com.qmth.examcloud.task.dao.entity.CopyExamStudentEntity;
|
|
|
+import cn.com.qmth.examcloud.task.dao.entity.CopyExamStudentPK;
|
|
|
+import cn.com.qmth.examcloud.task.dao.enums.CopyExamStudentStatus;
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 考生复制
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年9月12日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Transactional
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.ctr.task}" + "copyExamStudent")
|
|
|
+public class CopyExamStudentController extends ControllerSupport {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CopyExamStudentRepo copyExamStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamCloudService examCloudService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加考生复制任务")
|
|
|
+ @PostMapping("addCopyTask")
|
|
|
+ public void addCopyTask(@RequestParam(required = true) Long examId1, @RequestParam(required = true) Long examId2) {
|
|
|
+
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ GetExamReq req = new GetExamReq();
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
+
|
|
|
+ req.setId(examId1);
|
|
|
+ ExamBean exam1 = examCloudService.getExam(req).getExamBean();
|
|
|
+ if (exam1.getArchived()) {
|
|
|
+ throw new StatusException("考试已归档");
|
|
|
+ }
|
|
|
+ req.setId(examId2);
|
|
|
+ ExamBean exam2 = examCloudService.getExam(req).getExamBean();
|
|
|
+ if (exam2.getArchived()) {
|
|
|
+ throw new StatusException("考试已归档");
|
|
|
+ }
|
|
|
+ CopyExamStudentPK pk = new CopyExamStudentPK(examId1, examId2);
|
|
|
+ Optional<CopyExamStudentEntity> opt = copyExamStudentRepo.findById(pk);
|
|
|
+ CopyExamStudentEntity one = null;
|
|
|
+ if (opt.isPresent()) {
|
|
|
+ one = opt.get();
|
|
|
+ }
|
|
|
+ if (null != one && (!one.getStatus().equals(CopyExamStudentStatus.COMPLETE))) {
|
|
|
+ throw new StatusException("620001", "复制中,请勿重复操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == one) {
|
|
|
+ one = new CopyExamStudentEntity();
|
|
|
+ one.setExamId1(exam1.getId());
|
|
|
+ one.setExamId2(exam2.getId());
|
|
|
+ one.setRootOrgId(rootOrgId);
|
|
|
+ }
|
|
|
+
|
|
|
+ one.setStart(1L);
|
|
|
+ one.setStatus(CopyExamStudentStatus.NONE);
|
|
|
+
|
|
|
+ // 锁定
|
|
|
+ List<Long> examIdList = Lists.newArrayList();
|
|
|
+ examIdList.add(one.getExamId1());
|
|
|
+ examIdList.add(one.getExamId2());
|
|
|
+
|
|
|
+ LockExamStudentsReq lockReq = new LockExamStudentsReq();
|
|
|
+ lockReq.setExamIdList(examIdList);
|
|
|
+ examCloudService.lockExamStudents(lockReq);
|
|
|
+
|
|
|
+ copyExamStudentRepo.save(one);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|