wangwei %!s(int64=6) %!d(string=hai) anos
pai
achega
30b52fcb25

+ 82 - 0
examcloud-task-api-provider/src/main/java/cn/com/qmth/examcloud/task/api/controller/CopyExamStudentController.java

@@ -0,0 +1,82 @@
+package cn.com.qmth.examcloud.task.api.controller;
+
+import javax.transaction.Transactional;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+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.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 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 {
+
+	@Value("${$dir}")
+	private String dir;
+
+	@Autowired
+	CopyExamStudentRepo copyExamStudentRepo;
+
+	@Autowired
+	ExamCloudService examCloudService;
+
+	@ApiOperation(value = "添加考生复制任务")
+	@GetMapping("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);
+		CopyExamStudentEntity one = copyExamStudentRepo.findOne(pk);
+
+		if (null != one && (!one.getStatus().equals(CopyExamStudentStatus.COMPLETE))) {
+			throw new StatusException("T-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);
+
+		copyExamStudentRepo.save(one);
+	}
+
+}

+ 20 - 0
examcloud-task-dao/src/main/java/cn/com/qmth/examcloud/task/dao/entity/CopyExamStudentPK.java

@@ -26,6 +26,26 @@ public class CopyExamStudentPK implements Serializable {
 	 */
 	private Long examId2;
 
+	/**
+	 * 构造函数
+	 *
+	 */
+	public CopyExamStudentPK() {
+		super();
+	}
+
+	/**
+	 * 构造函数
+	 *
+	 * @param examId1
+	 * @param examId2
+	 */
+	public CopyExamStudentPK(Long examId1, Long examId2) {
+		super();
+		this.examId1 = examId1;
+		this.examId2 = examId2;
+	}
+
 	public Long getExamId1() {
 		return examId1;
 	}