xiatian 1 rok temu
rodzic
commit
0f771503ca

+ 36 - 33
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamStudentCloudServiceProvider.java

@@ -1,5 +1,27 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.criteria.Predicate;
+
+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.api.commons.security.bean.UserType;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
@@ -16,10 +38,8 @@ import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamStageRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStageEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamService;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
@@ -27,34 +47,25 @@ import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean4Reset;
-import cn.com.qmth.examcloud.examwork.api.request.*;
-import cn.com.qmth.examcloud.examwork.api.response.*;
+import cn.com.qmth.examcloud.examwork.api.request.CopyExamStudentsReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentPageReq;
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.ResetExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.SaveExamStudentReq;
+import cn.com.qmth.examcloud.examwork.api.request.UpdateExamStudentStatusReq;
+import cn.com.qmth.examcloud.examwork.api.response.CopyExamStudentsResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentPageResp;
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.ResetExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.SaveExamStudentResp;
+import cn.com.qmth.examcloud.examwork.api.response.UpdateExamStudentStatusResp;
 import cn.com.qmth.examcloud.reports.commons.bean.OperateReport;
 import cn.com.qmth.examcloud.reports.commons.enums.OperateContent;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-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 javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * {@link StatusException} 状态码范围:088XXX<br>
@@ -93,8 +104,6 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
     @Autowired
     CourseCloudService courseCloudService;
     @Autowired
-    private ExamStageRepo examStageRepo;
-    @Autowired
     ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
 
     @ApiOperation(value = "保存考生")
@@ -134,13 +143,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
         info.setExamStageId(req.getExamStageId());
         info.setExamStageOrder(req.getExamStageOrder());
-        if(req.getExamStageOrder()!=null) {
-        	ExamStageEntity esEntity = examStageRepo.findByExamIdAndStageOrder(req.getExamId(), req.getExamStageOrder());
-            if(esEntity==null) {
-            	throw new StatusException("该场次号还未创建,场次号:"+req.getExamStageOrder());
-            }
-            info.setExamStageId(esEntity.getId());
-        }
+        
 
         ExamStudentInfo saved = examStudentService.saveExamStudent(info);
 
@@ -175,7 +178,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
                 OperateContent.EXAM_STUDENT_IMPORT.getDesc()));
         return resp;
     }
-
+    
     @ApiOperation(value = "复制考生")
     @PostMapping("copyExamStudents")
     @Transactional

+ 26 - 2
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -20,10 +20,12 @@ import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamStageRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStageEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
@@ -51,7 +53,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
     @Autowired
     ExamStudentRepo examStudentRepo;
-
+    @Autowired
+    private ExamStageRepo examStageRepo;
     @Autowired
     ExamRepo examRepo;
 
@@ -177,7 +180,26 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
         deleteExamStudentsByStudentIds(IdList);
     }
-
+    
+    private void disposeStage(Long examId,ExamStudentInfo info) {
+    	ExamStageEntity stage=null;
+    	if(info.getExamStageId()!=null) {
+    		stage= GlobalHelper.getEntity(examStageRepo, info.getExamStageId(), ExamStageEntity.class);
+    		if(stage==null) {
+    			throw new StatusException("examStageId 错误");
+    		}
+    		if(!examId.equals(stage.getExamId())) {
+    			throw new StatusException("examStageId 的场次的考试不一致");
+    		}
+    		info.setExamStageOrder(stage.getStageOrder());
+    	}else if(info.getExamStageOrder()!=null) {
+    		stage = examStageRepo.findByExamIdAndStageOrder(examId, info.getExamStageOrder());
+            if(stage==null) {
+            	throw new StatusException("该场次号还未创建,场次号:"+info.getExamStageOrder());
+            }
+            info.setExamStageId(stage.getId());
+    	}
+    }
     /*
      * 实现
      *
@@ -230,6 +252,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         } else {
             throw new StatusException("100002", "examId,examCode,examName cannot be all empty");
         }
+        
+        disposeStage(exam.getId(), examStudentInfo);
 
         String identityNumber = examStudentInfo.getIdentityNumber();