Browse Source

修改 sim_real_exam_collection 表相关。

tom 5 tháng trước cách đây
mục cha
commit
f1e0c513ed

+ 13 - 12
pla-sim/01_SQL/02_table/sim_real_exam_collection.sql

@@ -1,17 +1,17 @@
 /*
  Navicat Premium Dump SQL
 
- Source Server         : qdhome.iot321.top-dev
+ Source Server         : 47.104.188.84-sim
  Source Server Type    : MySQL
- Source Server Version : 50740 (5.7.40-log)
- Source Host           : qdhome.iot321.top:33103
+ Source Server Version : 80020 (8.0.20)
+ Source Host           : 47.104.188.84:65006
  Source Schema         : pla-chem-sim-dev-1
 
  Target Server Type    : MySQL
- Target Server Version : 50740 (5.7.40-log)
+ Target Server Version : 80020 (8.0.20)
  File Encoding         : 65001
 
- Date: 15/12/2024 19:22:55
+ Date: 23/12/2024 11:50:02
 */
 
 SET NAMES utf8mb4;
@@ -22,22 +22,23 @@ SET FOREIGN_KEY_CHECKS = 0;
 -- ----------------------------
 DROP TABLE IF EXISTS `sim_real_exam_collection`;
 CREATE TABLE `sim_real_exam_collection`  (
-  `exam_collection_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '考试集合ID',
+  `exam_collection_id` bigint NOT NULL AUTO_INCREMENT COMMENT '考试集合ID',
   `sim_type` char(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '模拟器类型',
-  `question_setting_method` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出题方式:\r\n1 系统随机\r\n2 教师自选\r\n3 任务自选\r\n',
-  `exam_collection_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '考试类型\r\n1:练习\r\n2:自主练习\r\n3:考试',
+  `question_setting_method` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '出题方式:[1]-系统随机,[2]-教师自选,[3]任务自选\r\n',
+  `exam_collection_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '考试类型:[1]-练习,[2]-自主练习,[3]-考试',
+  `exam_collection_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '考试集合状态:[0]-初始化,[2]-打开,[3]-关闭',
   `exam_collection_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '考试名称',
-  `task_id` bigint(20) NULL DEFAULT 0 COMMENT '任务ID',
-  `limit_duration` int(6) NULL DEFAULT NULL COMMENT '限制时长(分钟)',
+  `task_id` bigint NULL DEFAULT 0 COMMENT '任务ID',
+  `limit_duration` int NULL DEFAULT NULL COMMENT '限制时长(分钟)',
   `start_time` datetime NULL DEFAULT NULL COMMENT '考试开始时间(天)',
   `end_time` datetime NULL DEFAULT NULL COMMENT '考试结束时间(天)',
-  `create_user_id` bigint(20) NULL DEFAULT 0 COMMENT '创建教师ID/用户ID',
+  `create_user_id` bigint NULL DEFAULT 0 COMMENT '创建教师ID/用户ID',
   `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
   `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
   `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
   `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
   `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`exam_collection_id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-考试集合表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-考试集合表' ROW_FORMAT = DYNAMIC;
 
 SET FOREIGN_KEY_CHECKS = 1;

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 394 - 249
pla-sim/01_SQL/03_dev_backup/pla-chem-sim-dev-1.sql


+ 63 - 59
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/RealExamCollectionController.java

@@ -1,12 +1,9 @@
 package com.ruoyi.sim.controller;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
+import com.ruoyi.sim.domain.vo.RealExamCollectionVo;
 import com.ruoyi.sim.service.impl.RealExamCollectionService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -21,8 +18,6 @@ import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.sim.domain.RealExamCollection;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
 
 /**
  * 考试集合Controller
@@ -34,70 +29,79 @@ import com.ruoyi.common.core.page.TableDataInfo;
 @RequestMapping("/sim/real-exam-collection")
 @Api("考试集合Controller")
 public class RealExamCollectionController extends BaseController {
+
     @Autowired
-    private RealExamCollectionService realExamCollectionService;
+    private RealExamCollectionService service;
+
+    @GetMapping("/teacher/exam/list")
+    @ApiOperation("[教师][分页]查询考试集合列表")
+    public AjaxResult listExamByTeacher(RealExamCollection p) {
+        return service.listExamByTeacher(p);
+    }
+
+    @GetMapping("/teacher/exercise/list")
+    @ApiOperation("[教师][分页]查询考试集合列表")
+    public AjaxResult listExerciseByTeacher(RealExamCollection p) {
+        return service.listExerciseByTeacher(p);
+    }
+
+    @GetMapping(value = "/teacher/exam/{id}")
+    @ApiOperation("[教师]获取考试集合详细信息")
+    public AjaxResult getExamInfoByTeacher(@PathVariable("id") Long id) {
+        return service.getExamInfoByTeacher(id);
+    }
+
+    @GetMapping(value = "/teacher/exercise/{id}")
+    @ApiOperation("[教师]获取练习集合详细信息")
+    public AjaxResult getExerciseInfoByTeacher(@PathVariable("id") Long id) {
+        return service.getExerciseInfoByTeacher(id);
+    }
+
+    @PostMapping(value = "/teacher/exam/")
+    @ApiOperation("[教师]新增考试集合")
+    public AjaxResult addExam(@RequestBody RealExamCollectionVo vo) {
+        return service.addExam(vo);
+    }
+
+    @PostMapping(value = "/teacher/exercise/")
+    @ApiOperation("[教师]新增练习集合")
+    public AjaxResult addExercise(@RequestBody RealExamCollectionVo vo) {
+        return service.addExercise(vo);
+    }
 
-    // @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:list')")
-    @GetMapping("/list")
-    @ApiOperation("[老师]查询考试集合列表")
-    public TableDataInfo list(RealExamCollection realExamCollection) {
-        startPage();
-        List<RealExamCollection> list = realExamCollectionService.selectRealExamCollectionList(realExamCollection);
-        return getDataTable(list);
+    @PutMapping(value = "/teacher/exam/")
+    @ApiOperation("[教师]修改考试集合")
+    public AjaxResult editExam(@RequestBody RealExamCollectionVo vo) {
+        return service.editExam(vo);
     }
 
-    /**
-     * 导出考试集合列表
-     */
-    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:export')")
-    @Log(title = "考试集合", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, RealExamCollection realExamCollection) {
-        List<RealExamCollection> list = realExamCollectionService.selectRealExamCollectionList(realExamCollection);
-        ExcelUtil<RealExamCollection> util = new ExcelUtil<RealExamCollection>(RealExamCollection.class);
-        util.exportExcel(response, list, "考试集合数据");
+    @PutMapping(value = "/teacher/exercise/")
+    @ApiOperation("[教师]修改练习集合")
+    public AjaxResult edit(@RequestBody RealExamCollectionVo vo) {
+        return service.editExercise(vo);
     }
 
-    /**
-     * 获取考试集合详细信息
-     */
-    // @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:query')")
-    @GetMapping(value = "/{examCollectionId}")
-    @ApiOperation("[老师]获取考试集合详细信息")
-    public AjaxResult getInfo(@PathVariable("examCollectionId") Long examCollectionId) {
-        return success(realExamCollectionService.selectRealExamCollectionByExamCollectionId(examCollectionId));
+    @DeleteMapping("/teacher/exam/{ids}")
+    @ApiOperation("[教师]删除多个考试集合")
+    public AjaxResult deleteExams(@PathVariable Long[] ids) {
+        return service.deleteExams(ids);
     }
 
-    /**
-     * 新增考试集合
-     */
-    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:add')")
-    @Log(title = "考试集合", businessType = BusinessType.INSERT)
-    @PostMapping
-    @ApiOperation("[老师]新增考试集合")
-    public AjaxResult add(@RequestBody RealExamCollection realExamCollection) {
-        return toAjax(realExamCollectionService.insertRealExamCollection(realExamCollection));
+    @DeleteMapping("/teacher/exercise/{ids}")
+    @ApiOperation("[教师]删除多个考试集合")
+    public AjaxResult deleteExercises(@PathVariable Long[] ids) {
+        return service.deleteExercises(ids);
     }
 
-    /**
-     * 修改考试集合
-     */
-    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:edit')")
-    @Log(title = "考试集合", businessType = BusinessType.UPDATE)
-    @PutMapping
-    @ApiOperation("[老师]修改考试集合")
-    public AjaxResult edit(@RequestBody RealExamCollection realExamCollection) {
-        return toAjax(realExamCollectionService.updateRealExamCollection(realExamCollection));
+    @PutMapping(value = "/teacher/exam/open/{id}")
+    @ApiOperation("[教师]打开考试集合")
+    public AjaxResult openExam(@PathVariable("id") Long id) {
+        return service.openExam(id);
     }
 
-    /**
-     * 删除考试集合
-     */
-    @PreAuthorize("@ss.hasPermi('sim:real-exam-collection:remove')")
-    @Log(title = "考试集合", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{examCollectionIds}")
-    @ApiOperation("[老师]删除考试集合")
-    public AjaxResult remove(@PathVariable Long[] examCollectionIds) {
-        return toAjax(realExamCollectionService.deleteRealExamCollectionByExamCollectionIds(examCollectionIds));
+    @PutMapping(value = "/teacher/exam/close/{id}")
+    @ApiOperation("[教师]关闭考试集合")
+    public AjaxResult closeExam(@PathVariable("id") Long id) {
+        return service.closeExam(id);
     }
 }

+ 2 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/RealExam.java

@@ -15,6 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
  * @date 2024-12-15
  */
 public class RealExam extends BaseEntity {
+
     private static final long serialVersionUID = 1L;
 
     /**
@@ -224,6 +225,7 @@ public class RealExam extends BaseEntity {
     // -------------------------------- tom add  --------------------------------
 
     public static final String STATE_NOT_LOGGED_IN = "0";
+
     public static final String STATE_LOGGED_IN = "1";
     public static final String STATE_SIM_WRITING = "2????";// todo:??
     public static final String STATE_SIM_PREPARE_OK = "2";

+ 43 - 11
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/RealExamCollection.java

@@ -15,6 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
  * @date 2024-12-17
  */
 public class RealExamCollection extends BaseEntity {
+
     private static final long serialVersionUID = 1L;
 
     /**
@@ -28,18 +29,15 @@ public class RealExamCollection extends BaseEntity {
     @Excel(name = "模拟器类型")
     private String simType;
 
-    /** 出题方式:
-     1 系统随机
-     2 教师自选
-     3 任务自选
+    /**
+     * 出题方式:[1]-系统随机,[2]-教师自选,[3]任务自选
      */
     @Excel(name = "出题方式")
     private String questionSettingMethod;
 
-    /** 考试类型
-     1:练习
-     2:自主练习
-     3:考试 */
+    /**
+     * 考试类型:[1]-练习,[2]-自主练习,[3]-考试
+     */
     @Excel(name = "考试类型")
     private String examCollectionType;
 
@@ -50,6 +48,12 @@ public class RealExamCollection extends BaseEntity {
     private String examCollectionName;
 
     /**
+     * 考试集合状态:[0]-初始化,[2]-打开,[3]-关闭
+     */
+    @Excel(name = "考试集合状态:[0]-初始化,[2]-打开,[3]-关闭")
+    private String examCollectionState;
+
+    /**
      * 任务ID
      */
     @Excel(name = "任务ID")
@@ -59,7 +63,7 @@ public class RealExamCollection extends BaseEntity {
      * 限制时长(分钟)
      */
     @Excel(name = "限制时长(分钟)")
-    private Integer limitDuration;
+    private Long limitDuration;
 
     /**
      * 考试开始时间(天)
@@ -121,6 +125,14 @@ public class RealExamCollection extends BaseEntity {
         return examCollectionName;
     }
 
+    public void setExamCollectionState(String examCollectionState) {
+        this.examCollectionState = examCollectionState;
+    }
+
+    public String getExamCollectionState() {
+        return examCollectionState;
+    }
+
     public void setTaskId(Long taskId) {
         this.taskId = taskId;
     }
@@ -129,11 +141,11 @@ public class RealExamCollection extends BaseEntity {
         return taskId;
     }
 
-    public void setLimitDuration(Integer limitDuration) {
+    public void setLimitDuration(Long limitDuration) {
         this.limitDuration = limitDuration;
     }
 
-    public Integer getLimitDuration() {
+    public Long getLimitDuration() {
         return limitDuration;
     }
 
@@ -169,6 +181,7 @@ public class RealExamCollection extends BaseEntity {
                 .append("questionSettingMethod", getQuestionSettingMethod())
                 .append("examCollectionType", getExamCollectionType())
                 .append("examCollectionName", getExamCollectionName())
+                .append("examCollectionState", getExamCollectionState())
                 .append("taskId", getTaskId())
                 .append("limitDuration", getLimitDuration())
                 .append("startTime", getStartTime())
@@ -181,4 +194,23 @@ public class RealExamCollection extends BaseEntity {
                 .append("remark", getRemark())
                 .toString();
     }
+
+    // -------------------------------- tom add  --------------------------------
+    public interface SettingMethod {
+        String SYSTEM_RANDOM = "1";
+        String TEACHER_SELECT = "2";
+        String TASK_SELECT = "3";
+    }
+
+    public interface Type {
+        String EXERCISE = "1";
+        String SELF_EXERCISE = "2";
+        String EXAM = "3";
+    }
+
+    public interface State {
+        String INIT = "0";
+        String OPENED = "2";
+        String CLOSED = "3";
+    }
 }

+ 13 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/Sim.java

@@ -170,7 +170,11 @@ public class Sim extends BaseEntity {
     public static final String TYPE_0002_NAME = "FZB006";
     public static final String TYPE_0003_NAME = "防化兵用毒剂报警器";
 
-    public static final Map<String, String> TYPE_NAME_MAP = Map.ofEntries(Map.entry(TYPE_0001, TYPE_0001_NAME), Map.entry(TYPE_0002, TYPE_0002_NAME), Map.entry(TYPE_0003, TYPE_0003_NAME));
+    public static final Map<String, String> TYPE_NAME_MAP = Map.ofEntries(
+            Map.entry(TYPE_0001, TYPE_0001_NAME),
+            Map.entry(TYPE_0002, TYPE_0002_NAME),
+            Map.entry(TYPE_0003, TYPE_0003_NAME)
+    );
 
     public static String STATE_ENABLE_INIT = "0";
     public static String STATE_ONLINE = "1";
@@ -179,5 +183,12 @@ public class Sim extends BaseEntity {
     public static String STATE_SIM_ERROR = "4";
     public static String STATE_DISABLE = "5";
 
-    public static final Set<String> STATE_SET = new HashSet<>(Arrays.asList(STATE_ENABLE_INIT, STATE_ONLINE, STATE_SIM_OFFLINE, STATE_GATEWAY_OFFLINE, STATE_SIM_ERROR, STATE_DISABLE));
+    public static final Set<String> STATE_SET = new HashSet<>(Arrays.asList(
+            STATE_ENABLE_INIT,
+            STATE_ONLINE,
+            STATE_SIM_OFFLINE,
+            STATE_GATEWAY_OFFLINE,
+            STATE_SIM_ERROR,
+            STATE_DISABLE
+    ));
 }

+ 19 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/RealExamCollectionVo.java

@@ -0,0 +1,19 @@
+package com.ruoyi.sim.domain.vo;
+
+import com.ruoyi.sim.domain.RealExamCollection;
+
+public class RealExamCollectionVo extends RealExamCollection {
+
+    /**
+     * 班级Id数组
+     */
+    private Long[] clazzIds;
+
+    public Long[] getClazzIds() {
+        return clazzIds;
+    }
+
+    public void setClazzIds(Long[] clazzIds) {
+        this.clazzIds = clazzIds;
+    }
+}

+ 18 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/StudentRealExamIngVo.java

@@ -0,0 +1,18 @@
+package com.ruoyi.sim.domain.vo;
+
+/**
+ * [学生]正在考试页面Vo。
+ */
+public class StudentRealExamIngVo {
+
+    private Long remainingMilliseconds;
+
+
+    public Long getRemainingMilliseconds() {
+        return remainingMilliseconds;
+    }
+
+    public void setRemainingMilliseconds(Long remainingMilliseconds) {
+        this.remainingMilliseconds = remainingMilliseconds;
+    }
+}

+ 4 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/StudentRealExamPostVo.java

@@ -0,0 +1,4 @@
+package com.ruoyi.sim.domain.vo;
+
+public class StudentRealExamPostVo {
+}

+ 212 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamCollectionService.java

@@ -1,12 +1,22 @@
 package com.ruoyi.sim.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import cn.ele6.catalyzer.ruoyi.custom.BaseService;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.sim.domain.vo.RealExamCollectionVo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.sim.mapper.RealExamCollectionMapper;
 import com.ruoyi.sim.domain.RealExamCollection;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
 
 /**
  * 考试集合Service业务层处理
@@ -15,7 +25,7 @@ import com.ruoyi.sim.domain.RealExamCollection;
  * @date 2024-12-17
  */
 @Service
-public class RealExamCollectionService {
+public class RealExamCollectionService extends BaseService {
     @Autowired
     private RealExamCollectionMapper realExamCollectionMapper;
 
@@ -80,4 +90,205 @@ public class RealExamCollectionService {
     public int deleteRealExamCollectionByExamCollectionId(Long examCollectionId) {
         return realExamCollectionMapper.deleteRealExamCollectionByExamCollectionId(examCollectionId);
     }
+
+    // -------------------------------- tom add  --------------------------------
+
+    /**
+     * [教师][分页]查询考试集合列表
+     *
+     * @param p
+     * @return
+     */
+    public AjaxResult listExamByTeacher(RealExamCollection p) {
+        startPage();
+        p.setExamCollectionType(RealExamCollection.Type.EXAM);
+        List<RealExamCollectionVo> list = new ArrayList<>();
+        realExamCollectionMapper.selectRealExamCollectionList(p).forEach((RealExamCollection s) -> {
+            RealExamCollectionVo t = new RealExamCollectionVo();
+            BeanUtils.copyProperties(s, t);
+            list.add(t);
+        });
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * [教师][分页]查询练习集合列表
+     *
+     * @param p
+     * @return
+     */
+    public AjaxResult listExerciseByTeacher(RealExamCollection p) {
+        startPage();
+        p.setExamCollectionType(RealExamCollection.Type.EXERCISE);
+        List<RealExamCollectionVo> list = new ArrayList<>();
+        realExamCollectionMapper.selectRealExamCollectionList(p).forEach((RealExamCollection s) -> {
+            RealExamCollectionVo t = new RealExamCollectionVo();
+            BeanUtils.copyProperties(s, t);
+            list.add(t);
+        });
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * [教师]获取考试集合详细信息
+     */
+    public AjaxResult getExamInfoByTeacher(Long id) {
+        RealExamCollection f = realExamCollectionMapper.
+                selectRealExamCollectionByExamCollectionId(id);
+        return AjaxResult.success(f);
+    }
+
+    /**
+     * [教师]获取练习集合详细信息
+     */
+    public AjaxResult getExerciseInfoByTeacher(Long id) {
+        RealExamCollection f = realExamCollectionMapper.
+                selectRealExamCollectionByExamCollectionId(id);
+        return AjaxResult.success(f);
+    }
+
+    /**
+     * [教师]新增考试集合
+     *
+     * @param vo
+     * @return
+     */
+    public AjaxResult addExam(@RequestBody RealExamCollectionVo vo) {
+        // check
+        if (StringUtils.isBlank(vo.getExamCollectionName())) {
+
+        }
+        //
+        RealExamCollection p = new RealExamCollection();
+        BeanUtils.copyProperties(vo, p);
+        p.setExamCollectionType(RealExamCollection.Type.EXAM);
+        insertRealExamCollection(p);
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]新增练习集合
+     *
+     * @param vo
+     * @return
+     */
+    public AjaxResult addExercise(@RequestBody RealExamCollectionVo vo) {
+        // check
+
+        //
+        RealExamCollection p = new RealExamCollection();
+        BeanUtils.copyProperties(vo, p);
+        p.setExamCollectionType(RealExamCollection.Type.EXERCISE);
+        insertRealExamCollection(p);
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]修改考试集合
+     *
+     * @param vo
+     * @return
+     */
+    public AjaxResult editExam(@RequestBody RealExamCollectionVo vo) {
+        // check
+
+        //
+        RealExamCollection p = new RealExamCollection();
+        BeanUtils.copyProperties(vo, p);
+        p.setExamCollectionType(RealExamCollection.Type.EXAM);
+        updateRealExamCollection(p);
+        // todo:更新关联
+
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]修改练习集合
+     *
+     * @param vo
+     * @return
+     */
+    public AjaxResult editExercise(@RequestBody RealExamCollectionVo vo) {
+        // check
+
+        // do.
+        RealExamCollection p = new RealExamCollection();
+        BeanUtils.copyProperties(vo, p);
+        p.setExamCollectionType(RealExamCollection.Type.EXERCISE);
+        updateRealExamCollection(p);
+        // todo:更新关联
+
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]删除多个考试集合
+     *
+     * @param ids
+     * @return
+     */
+    public AjaxResult deleteExams(Long[] ids) {
+        // check
+
+        // do.
+        deleteRealExamCollectionByExamCollectionIds(ids);
+        // todo:更新关联
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]删除多个练习集合
+     *
+     * @param ids
+     * @return
+     */
+    public AjaxResult deleteExercises(Long[] ids) {
+        // check
+
+        // do.
+        deleteRealExamCollectionByExamCollectionIds(ids);
+        // todo:更新关联
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]打开考试集合
+     *
+     * @param id
+     * @return
+     */
+    @Transactional
+    public AjaxResult openExam(Long id) {
+        // check
+        int countOpened = 0;
+        {
+            RealExamCollection q = new RealExamCollection();
+            q.setExamCollectionState(RealExamCollection.State.OPENED);
+            l.info("q = {}", q);
+            countOpened = selectRealExamCollectionList(q).size();
+        }
+        l.info("countOpened = {}", countOpened);
+        if (countOpened > 0) {
+            return AjaxResult.error("已经有打开的考试!");
+        }
+        // check datetime
+        // do.
+        RealExamCollection f = selectRealExamCollectionByExamCollectionId(id);
+        f.setExamCollectionState(RealExamCollection.State.OPENED);
+        updateRealExamCollection(f);
+        return AjaxResult.success();
+    }
+
+    /**
+     * [教师]关闭考试集合
+     *
+     * @param id
+     * @return
+     */
+    public AjaxResult closeExam(Long id) {
+        RealExamCollection f = selectRealExamCollectionByExamCollectionId(id);
+        f.setExamCollectionState(RealExamCollection.State.CLOSED);
+        updateRealExamCollection(f);
+        return AjaxResult.success();
+    }
 }

+ 51 - 4
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -3,8 +3,10 @@ package com.ruoyi.sim.service.impl;
 import java.util.List;
 import java.util.Objects;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.sim.domain.*;
+import com.ruoyi.sim.domain.vo.StudentRealExamPostVo;
 import com.ruoyi.sim.domain.vo.StudentRealExamPreVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -138,12 +140,22 @@ public class RealExamService {
     }
 
     /**
-     * [轮询]学生准备考试界面。
+     * [学生]进入考试。
+     *
+     * @return
+     */
+    public AjaxResult studentEnterRealExam() {
+        RealExam re = null;
+        return AjaxResult.success(re);
+    }
+
+    /**
+     * [轮询][学生]准备考试界面。
      *
      * @param realExamId
      * @return
      */
-    public StudentRealExamPreVo studentPrepareExam(Long realExamId) {
+    public StudentRealExamPreVo studentPrepareRealExam(Long realExamId) {
         // check
         if (realExamId == null || realExamId == 0) {
             // todo:
@@ -155,6 +167,7 @@ public class RealExamService {
         }
         // todo: 日期,不可进入考试。
         //
+        // todo: 验证学生登录身份
         Objects.requireNonNull(re);
         RealExamCollection collection =
                 realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
@@ -171,7 +184,7 @@ public class RealExamService {
         v.setSim(sim);
         v.setStudent(student);
         v.setSeat(seat);
-        boolean next = studentPrepareExamCheck(v);
+        boolean next = studentPrepareRealExamCheck(v);
         v.setNext(next);
         if (!next) {
             // 执行模拟器通信,让模拟器准备好。
@@ -181,7 +194,7 @@ public class RealExamService {
         return v;
     }
 
-    public boolean studentPrepareExamCheck(StudentRealExamPreVo v) {
+    public boolean studentPrepareRealExamCheck(StudentRealExamPreVo v) {
         if (v == null ||
                 v.getRealExam() == null ||
                 v.getRealExamCollection() == null ||
@@ -203,4 +216,38 @@ public class RealExamService {
         }
         return false;
     }
+
+    /**
+     * [轮询][学生]正在考试界面。
+     *
+     * @param realExamId
+     * @return
+     */
+    public StudentRealExamPreVo studentIngRealExam(Long realExamId) {
+        return null;
+    }
+
+    /**
+     * [学生]交卷
+     *
+     * @param realExamId
+     * @return
+     */
+    public AjaxResult studentSubmitRealExam(Long realExamId) {
+        // 最后检查一下模拟器状态。
+        
+        // 最后读取一下模拟器电阻值。
+        return AjaxResult.success();
+    }
+
+    /**
+     * [轮询][学生]结束考试界面。
+     *
+     * @param realExamId
+     * @return
+     */
+    public AjaxResult studentPostRealExam(Long realExamId) {
+        StudentRealExamPostVo vo = new StudentRealExamPostVo();
+        return AjaxResult.success(vo);
+    }
 }

+ 8 - 0
ruoyi-sim/src/main/resources/mapper/sim/RealExamCollectionMapper.xml

@@ -9,6 +9,7 @@
         <result property="simType" column="sim_type"/>
         <result property="questionSettingMethod" column="question_setting_method"/>
         <result property="examCollectionType" column="exam_collection_type"/>
+        <result property="examCollectionState" column="exam_collection_state"/>
         <result property="examCollectionName" column="exam_collection_name"/>
         <result property="taskId" column="task_id"/>
         <result property="limitDuration" column="limit_duration"/>
@@ -27,6 +28,7 @@
                sim_type,
                question_setting_method,
                exam_collection_type,
+               exam_collection_state,
                exam_collection_name,
                task_id,
                limit_duration,
@@ -51,6 +53,9 @@
             <if test="examCollectionType != null  and examCollectionType != ''">and exam_collection_type =
                 #{examCollectionType}
             </if>
+            <if test="examCollectionState != null  and examCollectionState != ''">and exam_collection_state =
+                #{examCollectionState}
+            </if>
             <if test="examCollectionName != null  and examCollectionName != ''">and exam_collection_name like
                 concat('%', #{examCollectionName}, '%')
             </if>
@@ -77,6 +82,7 @@
             <if test="simType != null and simType != ''">sim_type,</if>
             <if test="questionSettingMethod != null and questionSettingMethod != ''">question_setting_method,</if>
             <if test="examCollectionType != null and examCollectionType != ''">exam_collection_type,</if>
+            <if test="examCollectionState != null">exam_collection_state,</if>
             <if test="examCollectionName != null and examCollectionName != ''">exam_collection_name,</if>
             <if test="taskId != null">task_id,</if>
             <if test="limitDuration != null">limit_duration,</if>
@@ -93,6 +99,7 @@
             <if test="simType != null and simType != ''">#{simType},</if>
             <if test="questionSettingMethod != null and questionSettingMethod != ''">#{questionSettingMethod},</if>
             <if test="examCollectionType != null and examCollectionType != ''">#{examCollectionType},</if>
+            <if test="examCollectionState != null">#{examCollectionState},</if>
             <if test="examCollectionName != null and examCollectionName != ''">#{examCollectionName},</if>
             <if test="taskId != null">#{taskId},</if>
             <if test="limitDuration != null">#{limitDuration},</if>
@@ -117,6 +124,7 @@
             <if test="examCollectionType != null and examCollectionType != ''">exam_collection_type =
                 #{examCollectionType},
             </if>
+            <if test="examCollectionState != null">exam_collection_state = #{examCollectionState},</if>
             <if test="examCollectionName != null and examCollectionName != ''">exam_collection_name =
                 #{examCollectionName},
             </if>

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác