ソースを参照

添加 开始练习 和 交卷练习。

tom 2 週間 前
コミット
3d11af2269

+ 18 - 4
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/RealExamController.java

@@ -75,9 +75,16 @@ public class RealExamController extends BaseController {
     }
 
     @GetMapping("/student/exam/start/{examId}")
-    @ApiOperation("[学生][演示使用]开始考试")
+    @ApiOperation("[学生][正式使用]开始考试")
     public AjaxResult studentStartRealExam(@PathVariable("examId") Long examId) {
-        l.info("[学生][演示使用]开始考试");
+        l.info("[学生][正式使用]开始考试");
+        return realExamService.studentStartRealExam(examId);
+    }
+
+    @GetMapping("/student/exercise/start/{examId}")
+    @ApiOperation("[学生][正式使用]开始练习")
+    public AjaxResult studentStartRealExercise(@PathVariable("examId") Long examId) {
+        l.info("[学生][正式使用]开始练习");
         return realExamService.studentStartRealExam(examId);
     }
 
@@ -88,9 +95,16 @@ public class RealExamController extends BaseController {
     }
 
     @GetMapping("/student/exam/submit/{examId}")
-    @ApiOperation("[学生][演示使用]交卷")
+    @ApiOperation("[学生][正式使用]交卷考试")
     public AjaxResult studentSubmitRealExam(@PathVariable("examId") Long examId) {
-        l.info("[学生][演示使用]交卷");
+        l.info("[学生][正式使用]交卷考试");
+        return realExamService.studentSubmitRealExam(examId);
+    }
+
+    @GetMapping("/student/exercise/submit/{examId}")
+    @ApiOperation("[学生][正式使用]交卷练习")
+    public AjaxResult studentSubmitRealExercise(@PathVariable("examId") Long examId) {
+        l.info("[学生][正式使用]交卷练习");
         return realExamService.studentSubmitRealExam(examId);
     }
 

+ 42 - 22
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -278,34 +278,22 @@ public class RealExamService {
      * @return RealExam
      */
     @Transactional
-    public AjaxResult studentStartRealExam(Long examId) {
+    public AjaxResult studentStartRealExam(final Long examId) {
         l.info("studentStartRealExam = {}", examId);
         // todo: 暂时没有解决方案 检查 考试的sim和seat,是否正确对应。
-        // check
-        // 检查 examId 是否正确存在
-        {
-            if (!exist(examId)) {
-                return AjaxResult.error("对应考试Id不存在!");
-            }
-        }
-        RealExam re = selectRealExamByExamId(examId);
-        // 检查 seat_id 是否正确存在
-        {
-            if (!seatService.exist(re.getSeatId())) {
-                return  AjaxResult.error("对应座Id不存在!");
-            }
-        }
-        // 检查 sim_id 是否正确存在
-        {
-            if (!simService.exist(re.getSimId())) {
-                return AjaxResult.error("对应模拟器Id不存在!");
-            }
-        }
         {
             // todo:delete
             // re.setSimId(getFakeSimId(re));
             // l.info("fake re = {}", re);
         }
+        // check part.
+        {
+            AjaxResult arE1 = checkExamId(examId);
+            if (arE1.isError()) {
+                return arE1;
+            }
+        }
+        RealExam re = selectRealExamByExamId(examId);
         // Step 1 读取对应一台模拟器 所有故障部位值。检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。
 
         // Step 2 清除对应一台模拟器 所有故障部位故障。
@@ -329,6 +317,30 @@ public class RealExamService {
         }
     }
 
+    public AjaxResult checkExamId(final Long examId) {
+        // check
+        // 检查 examId 是否正确存在
+        {
+            if (!exist(examId)) {
+                return AjaxResult.error("对应考试Id不存在!");
+            }
+        }
+        RealExam re = selectRealExamByExamId(examId);
+        // 检查 seat_id 是否正确存在
+        {
+            if (!seatService.exist(re.getSeatId())) {
+                return AjaxResult.error("对应座Id不存在!");
+            }
+        }
+        // 检查 sim_id 是否正确存在
+        {
+            if (!simService.exist(re.getSimId())) {
+                return AjaxResult.error("对应模拟器Id不存在!");
+            }
+        }
+        return AjaxResult.success();
+    }
+
     /**
      * 根据考试集合获得sim_id
      *
@@ -387,10 +399,18 @@ public class RealExamService {
             // todo:delete
             // re.setSimId(getFakeSimId(re));
         }
+        // check part.
+        {
+            AjaxResult arE1 = checkExamId(examId);
+            if (arE1.isError()) {
+                return arE1;
+            }
+        }
         // 最后检查一下模拟器状态。
         Sim s = simService.selectSimBySimId(re.getSimId());
+        // 如果模拟器离线
         if (s == null || !Sim.State.ONLINE.equals(s.getSimState())) {
-            return AjaxResult.error("模拟器离线,不允许交卷!");
+            return AjaxResult.error("未连接维修模拟器,请检查连接!");
         }
         // 最后读取一下模拟器电阻值。
         commSendService.readOneExamAtLast(re);