xiatian 7 сар өмнө
parent
commit
50d083beed

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

@@ -77,9 +77,7 @@ import io.swagger.annotations.ApiOperation;
 @RestController
 @RestController
 @Api(tags = "RPC-考生相关接口")
 @Api(tags = "RPC-考生相关接口")
 @RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
 @RequestMapping("${$rmp.cloud.examwork}" + "examStudent")
-public class ExamStudentCloudServiceProvider extends ControllerSupport
-        implements
-        ExamStudentCloudService {
+public class ExamStudentCloudServiceProvider extends ControllerSupport implements ExamStudentCloudService {
 
 
     private static final long serialVersionUID = -89062090947597841L;
     private static final long serialVersionUID = -89062090947597841L;
 
 
@@ -103,6 +101,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 
     @Autowired
     @Autowired
     CourseCloudService courseCloudService;
     CourseCloudService courseCloudService;
+
     @Autowired
     @Autowired
     ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
     ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
 
 
@@ -112,7 +111,13 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
     @Override
     @Override
     public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
     public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
         trim(req);
         trim(req);
-
+        ExamEntity exam = GlobalHelper.getEntity(examRepo, req.getExamId(), ExamEntity.class);
+        if (exam == null) {
+            throw new StatusException("未找到考试");
+        }
+        if (exam.getArchived()) {
+            throw new StatusException("考试已归档,不能新增考生");
+        }
         ExamStudentInfo info = new ExamStudentInfo();
         ExamStudentInfo info = new ExamStudentInfo();
         info.setCourseCode(req.getCourseCode());
         info.setCourseCode(req.getCourseCode());
         info.setCourseName(req.getCourseName());
         info.setCourseName(req.getCourseName());
@@ -143,7 +148,6 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 
         info.setExamStageId(req.getExamStageId());
         info.setExamStageId(req.getExamStageId());
         info.setExamStageOrder(req.getExamStageOrder());
         info.setExamStageOrder(req.getExamStageOrder());
-        
 
 
         ExamStudentInfo saved = examStudentService.saveExamStudent(info);
         ExamStudentInfo saved = examStudentService.saveExamStudent(info);
 
 
@@ -173,12 +177,12 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 
         resp.setExamStudentBean(examStudentBean);
         resp.setExamStudentBean(examStudentBean);
 
 
-        //操作日志
-        ReportsUtil.report(new OperateReport(saved.getRootOrgId(), null, saved.getStudentId(), saved.getId(), UserType.COMMON,
-                OperateContent.EXAM_STUDENT_IMPORT.getDesc()));
+        // 操作日志
+        ReportsUtil.report(new OperateReport(saved.getRootOrgId(), null, saved.getStudentId(), saved.getId(),
+                UserType.COMMON, OperateContent.EXAM_STUDENT_IMPORT.getDesc()));
         return resp;
         return resp;
     }
     }
-    
+
     @ApiOperation(value = "复制考生")
     @ApiOperation(value = "复制考生")
     @PostMapping("copyExamStudents")
     @PostMapping("copyExamStudents")
     @Transactional
     @Transactional
@@ -234,8 +238,8 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
         while (iterator.hasNext()) {
         while (iterator.hasNext()) {
             ExamStudentEntity es = iterator.next();
             ExamStudentEntity es = iterator.next();
 
 
-            ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2,
-                    es.getStudentId(), es.getCourseId());
+            ExamStudentEntity finded = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examId2, es.getStudentId(),
+                    es.getCourseId());
 
 
             if (null != finded) {
             if (null != finded) {
                 continue;
                 continue;
@@ -273,9 +277,10 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
             one.setExt5(es.getExt5());
             one.setExt5(es.getExt5());
 
 
             ExamStudentInfo saved = examStudentService.saveExamStudent(one);
             ExamStudentInfo saved = examStudentService.saveExamStudent(one);
-            //            //操作日志
-            //            ReportsUtil.report(new OperateReport(saved.getRootOrgId(), null, saved.getStudentId(),saved.getId(), UserType.COMMON,
-            //            		OperateContent.EXAM_STUDENT_COPY.getDesc()));
+            // //操作日志
+            // ReportsUtil.report(new OperateReport(saved.getRootOrgId(), null,
+            // saved.getStudentId(),saved.getId(), UserType.COMMON,
+            // OperateContent.EXAM_STUDENT_COPY.getDesc()));
             examStudentIds.add(saved.getId());
             examStudentIds.add(saved.getId());
 
 
             next = es.getId();
             next = es.getId();
@@ -299,8 +304,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
     public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
     public GetExamStudentResp getExamStudent(@RequestBody GetExamStudentReq req) {
         Long examStudentId = req.getExamStudentId();
         Long examStudentId = req.getExamStudentId();
 
 
-        ExamStudentEntity examStudent = GlobalHelper.getEntity(examStudentRepo, examStudentId,
-                ExamStudentEntity.class);
+        ExamStudentEntity examStudent = GlobalHelper.getEntity(examStudentRepo, examStudentId, ExamStudentEntity.class);
 
 
         if (examStudent == null) {
         if (examStudent == null) {
             throw new StatusException("考生信息不存在!id=" + examStudentId);
             throw new StatusException("考生信息不存在!id=" + examStudentId);
@@ -403,8 +407,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
         };
 
 
-        PageRequest pageRequest = PageRequest.of(curPage, pageSize,
-                Sort.by(Direction.DESC, "updateTime", "id"));
+        PageRequest pageRequest = PageRequest.of(curPage, pageSize, Sort.by(Direction.DESC, "updateTime", "id"));
 
 
         Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
         Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
 
 
@@ -451,8 +454,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
     @PostMapping("updateExamStudentStatus")
     @PostMapping("updateExamStudentStatus")
     @Transactional
     @Transactional
     @Override
     @Override
-    public UpdateExamStudentStatusResp updateExamStudentStatus(
-            @RequestBody UpdateExamStudentStatusReq req) {
+    public UpdateExamStudentStatusResp updateExamStudentStatus(@RequestBody UpdateExamStudentStatusReq req) {
         Long rootOrgId = req.getRootOrgId();
         Long rootOrgId = req.getRootOrgId();
         Long examId = req.getExamId();
         Long examId = req.getExamId();
         String examCode = req.getExamCode();
         String examCode = req.getExamCode();
@@ -503,8 +505,8 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
         GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
         GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
         StudentBean studentBean = gsResp.getStudentInfo();
         StudentBean studentBean = gsResp.getStudentInfo();
 
 
-        ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(
-                examEntity.getId(), studentBean.getId(), courseBean.getId());
+        ExamStudentEntity es = examStudentRepo.findByExamIdAndStudentIdAndCourseId(examEntity.getId(),
+                studentBean.getId(), courseBean.getId());
 
 
         es.setEnable(enable);
         es.setEnable(enable);
 
 
@@ -512,13 +514,13 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 
         examStudentService.syncExamStudent(saved.getId());
         examStudentService.syncExamStudent(saved.getId());
 
 
-        //操作日志
+        // 操作日志
         if (enable) {
         if (enable) {
-            ReportsUtil.report(new OperateReport(es.getRootOrgId(), null, es.getStudentId(), es.getId(), UserType.COMMON,
-                    OperateContent.EXAM_STUDENT_ENABLE.getDesc()));
+            ReportsUtil.report(new OperateReport(es.getRootOrgId(), null, es.getStudentId(), es.getId(),
+                    UserType.COMMON, OperateContent.EXAM_STUDENT_ENABLE.getDesc()));
         } else {
         } else {
-            ReportsUtil.report(new OperateReport(es.getRootOrgId(), null, es.getStudentId(), es.getId(), UserType.COMMON,
-                    OperateContent.EXAM_STUDENT_DISABLE.getDesc()));
+            ReportsUtil.report(new OperateReport(es.getRootOrgId(), null, es.getStudentId(), es.getId(),
+                    UserType.COMMON, OperateContent.EXAM_STUDENT_DISABLE.getDesc()));
         }
         }
         UpdateExamStudentStatusResp resp = new UpdateExamStudentStatusResp();
         UpdateExamStudentStatusResp resp = new UpdateExamStudentStatusResp();
         resp.setExamStudentId(saved.getId());
         resp.setExamStudentId(saved.getId());
@@ -571,8 +573,8 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
         GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
         GetStudentResp gsResp = studentCloudService.getStudent(gsReq);
         StudentBean studentBean = gsResp.getStudentInfo();
         StudentBean studentBean = gsResp.getStudentInfo();
 
 
-        List<ExamStudentEntity> presentExamStudentList = examStudentRepo
-                .findByExamIdAndStudentId(examId, studentBean.getId());
+        List<ExamStudentEntity> presentExamStudentList = examStudentRepo.findByExamIdAndStudentId(examId,
+                studentBean.getId());
 
 
         for (ExamStudentEntity cur : presentExamStudentList) {
         for (ExamStudentEntity cur : presentExamStudentList) {
             cur.setEnable(false);
             cur.setEnable(false);