Explorar el Código

删除getFakeSimId。无用临时顶替部分。

tom hace 2 meses
padre
commit
abc2c9f2ec

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

@@ -72,28 +72,28 @@ public class RealExamController extends BaseController {
     @GetMapping("/student/exam/start/{examId}")
     @ApiOperation("[学生][正式使用]开始考试")
     public AjaxResult studentStartRealExam(@PathVariable("examId") Long examId, @RequestParam final String ip) {
-        l.info("[学生][正式使用]开始考试");
+        l.info("[学生][正式使用]开始考试;examId = {};ip = {}", examId, ip);
         return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.EXAM);
     }
 
     @GetMapping("/student/exercise/start/{examId}")
-    @ApiOperation("[学生][正式使用]开始练")
+    @ApiOperation("[学生][正式使用]开始练")
     public AjaxResult studentStartRealExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
-        l.info("[学生][正式使用]开始练习");
+        l.info("[学生][正式使用]开始训练;examId = {};ip = {}", examId, ip);
         return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.EXERCISE);
     }
 
     @GetMapping("/student/self-exercise/start/{examId}")
-    @ApiOperation("[学生][正式使用]开始自主练习")
+    @ApiOperation("[学生][正式使用]开始练习")
     public AjaxResult studentStartRealSelfExercise(@PathVariable("examId") Long examId, @RequestParam final String ip) {
-        l.info("[学生][正式使用]开始自主练习");
+        l.info("[学生][正式使用]开始练习;examId = {};ip = {}", examId, ip);
         return realExamService.studentStartRealExam(examId, ip, RealExamCollection.Type.SELF_EXERCISE);
     }
 
     @GetMapping("/student/refresh-sim-state")
     @ApiOperation("刷新模拟器状态")
     public AjaxResult studentRefreshSimState(@RequestParam final String ip) {
-        l.info("刷新模拟器状态");
+        l.info("刷新模拟器状态;ip = {}", ip);
         return realExamService.studentRefreshSimState(ip);
     }
 

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

@@ -290,35 +290,31 @@ public class RealExamService {
     }
 
     /**
-     * [学生]开始考试
+     * [学生]开始考试、训练、练习
      *
-     * @param examId
-     * @param studentBindIp
+     * @param examId             考试Id
+     * @param studentBindIp      考试学员IP
+     * @param examCollectionType 考试集合类型
      * @return
      */
-    @Transactional
     public AjaxResult studentStartRealExam(final Long examId, final String studentBindIp, final String examCollectionType) {
-        l.info("studentStartRealExam = {}", examId);
         // todo: 暂时没有解决方案 检查 考试的sim和seat,是否正确对应。
-        {
-            // todo:delete
-            // re.setSimId(getFakeSimId(re));
-            // l.info("fake re = {}", re);
-        }
-        // check id data.
-        // Step :检查参数examId有效性
         // Step :检查参数studentBindIp有效性
         // Step :检查参数examCollectionType有效性
+
+        // Check:检查参数examId有效性
         {
-            AjaxResult ar01 = checkExamId(examId);
-            if (ar01.isError()) {
-                return ar01;
+            AjaxResult ar = checkExamId(examId);
+            if (ar.isError()) {
+                return ar;
             }
         }
-        // todo:examCollectionType 类型对应
+        // Check:检查studentBindIp有效性
         if (StringUtils.isBlank(studentBindIp)) {
-            return AjaxResult.error("ip地址无效。");
+            return AjaxResult.error("IP地址无效");
         }
+        // todo:examCollectionType 类型对应
+
         RealExam re = selectRealExamByExamId(examId);
         Seat seat = seatService.uniqueByBindIp(studentBindIp);
         {
@@ -439,69 +435,25 @@ public class RealExamService {
 
     public AjaxResult studentRefreshSimState(final String studentBindIp) {
         Seat seat = seatService.uniqueByBindIp(studentBindIp);
+        // Check:Seat有效性。
         {
             if (seat == null) {
-                throw new IllegalArgumentException("XXX");
+                return AjaxResult.error("没有IP对应座次数据!");
             }
         }
-        AjaxResult ar = commCheckService.checkOneSeatState(seat, true);
-        return ar;
-//                return AjaxResult.success("QWERT-nihao");
+        return commCheckService.checkOneSeatState(seat, true);
     }
 
 
     public AjaxResult checkExamId(final Long examId) {
-        // check
-        // 检查 examId 是否正确存在
-        {
-            if (!exist(examId)) {
-                return AjaxResult.error("对应考试Id不存在!");
-            }
-        }
-        RealExam re = selectRealExamByExamId(examId);
-        // 检查 seat_id 是否正确存在
-        // Java后端处理填写,不检查。
-        if (false) {
-            if (!seatService.exist(re.getSeatId())) {
-                return AjaxResult.error("对应座Id不存在!");
-            }
-        }
-        // Java后端处理填写,不检查。
-        // 检查 sim_id 是否正确存在
-        if (false) {
-            if (!simService.existBySimId(re.getSimId())) {
-                return AjaxResult.error("对应模拟器Id不存在!");
-            }
-        }
-        return AjaxResult.success();
-    }
-
-    /**
-     * 根据考试集合获得sim_id
-     *
-     * @param exam
-     * @return
-     */
-    @Deprecated
-    public long getFakeSimId(RealExam exam) {
-        {
-            RealExamCollection coll = realExamCollectionService.selectRealExamCollectionByExamCollectionId(exam.getExamCollectionId());
-            String simType = coll.getSimType();
-            switch (simType) {
-                case Sim.TYPE_0001 -> {
-                    return 11L;
-                }
-                case Sim.TYPE_0002 -> {
-                    return 12L;
-                }
-                case Sim.TYPE_0003 -> {
-                    return 31L;
-                }
-            }
+        // Check:检查 examId 是否正确存在
+        if (!exist(examId)) {
+            return AjaxResult.error("对应考试Id不存在!");
+        } else {
+            return AjaxResult.success();
         }
-        return 0L;
     }
-
+    
     /**
      * [轮询][学生]正在考试界面。
      *
@@ -530,14 +482,9 @@ public class RealExamService {
     @Transactional
     public AjaxResult studentSubmitRealExam(final Long examId, final String studentBindIp, final String examCollectionType) {
         RealExam re = selectRealExamByExamId(examId);
-        {
-            // todo:delete
-            // re.setSimId(getFakeSimId(re));
-        }
         // Step :检查参数examId有效性
         // Step :检查参数studentBindIp有效性
         // Step :检查参数examCollectionType有效性
-
         // check part.
         {
             AjaxResult arE1 = checkExamId(examId);