13 Комити 0cc5457cb2 ... 18302e3187

Аутор SHA1 Порука Датум
  tom 18302e3187 修改注释。 пре 1 недеља
  tom d064046aa7 debug_fault 表。 пре 1 недеља
  tom a366758fb5 sim表。 пре 1 недеља
  tom 0554d31133 [教师][正式使用]关闭全部(考试+练习+自主练习)集合。 пре 1 недеља
  tom e0285b40a0 默认打开扫描。 пре 1 недеља
  tom b3e159ee2b 修改为mx表,mx_debug_fault 。 пре 1 недеља
  tom df87c5fa59 修复 出题值,答题值,没有被正确写入数据库的问题。 пре 1 недеља
  tom fa6df9ab3e 添加 DebugFault 数据库插入和修改相关。 пре 1 недеља
  tom 03d2822624 优化地址配置文件。 пре 1 недеља
  tom cf9be02dd1 主动查询一次模拟器状态。 пре 1 недеља
  tom b9c3d09ace receive报文检验错误。 пре 1 недеља
  tom a03c790ea1 调整无响应异常超时时间,调整发送指令挂起时间。 пре 1 недеља
  tom 8e97b17002 debug 下发故障 和 读取当前状态 api基本实现。 пре 1 недеља
22 измењених фајлова са 623 додато и 147 уклоњено
  1. 59 0
      pla-sim/01_SQL/02_table/mx_debug_fault.sql
  2. 75 0
      pla-sim/01_SQL/02_table/mx_sim.sql
  3. 40 0
      pla-sim/01_SQL/02_table/sim_debug_fault.sql
  4. 26 26
      pla-sim/01_SQL/02_table/sim_sim.sql
  5. 3 0
      ruoyi-admin/src/main/resources/application-druid.yml
  6. 11 0
      ruoyi-admin/src/main/resources/application.yml
  7. 1 1
      ruoyi-sim/src/main/java/com/ruoyi/sim/config/SimDebugConfig.java
  8. 1 1
      ruoyi-sim/src/main/java/com/ruoyi/sim/controller/FaultController.java
  9. 25 7
      ruoyi-sim/src/main/java/com/ruoyi/sim/controller/HardwareCommDebugController.java
  10. 11 5
      ruoyi-sim/src/main/java/com/ruoyi/sim/controller/RealExamCollectionController.java
  11. 14 0
      ruoyi-sim/src/main/java/com/ruoyi/sim/controller/RealExamController.java
  12. 13 0
      ruoyi-sim/src/main/java/com/ruoyi/sim/domain/DebugFault.java
  13. 12 1
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommBuildService.java
  14. 9 4
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommConst.java
  15. 75 26
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommReceiveService.java
  16. 174 46
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java
  17. 27 0
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/DebugFaultService.java
  18. 15 8
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/FaultService.java
  19. 4 0
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamCollectionService.java
  20. 20 14
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java
  21. 3 3
      ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/SimService.java
  22. 5 5
      ruoyi-sim/src/main/resources/mapper/sim/DebugFaultMapper.xml

+ 59 - 0
pla-sim/01_SQL/02_table/mx_debug_fault.sql

@@ -0,0 +1,59 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : fhxy-192.168.1.61-polardbx
+ Source Server Type    : MySQL
+ Source Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ Source Host           : 192.168.1.61:4886
+ Source Schema         : pla-chem-sim-dev-1
+
+ Target Server Type    : MySQL
+ Target Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ File Encoding         : 65001
+
+ Date: 14/02/2025 16:27:41
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for mx_debug_fault
+-- ----------------------------
+DROP TABLE IF EXISTS `mx_debug_fault`;
+CREATE TABLE `mx_debug_fault`  (
+  `ref_id` bigint NOT NULL AUTO_INCREMENT COMMENT '关联ID',
+  `sim_id` bigint NOT NULL COMMENT '模拟器ID',
+  `fault_id` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '故障ID',
+  `flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '7' COMMENT '选择状态:[7]-未知,[1]-选中,[0]-没有选中',
+  `ref_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]故障已经下发,[3]-轮询读取刷新电阻代表值,[4]-考试结束',
+  `answer_right` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '答题正确:[0]-初始化,[1]-正确,[2]-错误',
+  `sim_fault_question_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器出题值/电阻代表值',
+  `sim_fault_answer_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器答题值/电阻代表值',
+  `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 '更新时间',
+  PRIMARY KEY (`ref_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 342 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-调试故障表' ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Records of mx_debug_fault
+-- ----------------------------
+INSERT INTO `mx_debug_fault` VALUES (327, 169, '0003GZBW0001', '1', '', '1', '00000002', '0000000C', NULL, '2025-02-14 16:25:49', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (328, 169, '0003GZBW0002', '1', '', '2', '00000002', '00000002', NULL, '2025-02-14 16:25:50', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (329, 169, '0003GZBW0003', '1', '', '2', '0000000C', '0000000C', NULL, '2025-02-14 16:25:50', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (330, 169, '0003GZBW0004', '0', '', '0', '00000002', '00000002', NULL, '2025-02-14 16:25:50', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (331, 169, '0003GZBW0005', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:50', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (332, 169, '0003GZBW0006', '0', '', '0', '00000009', '00000009', NULL, '2025-02-14 16:25:50', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (333, 169, '0003GZBW0007', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:51', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (334, 169, '0003GZBW0008', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:51', NULL, '2025-02-14 16:26:07');
+INSERT INTO `mx_debug_fault` VALUES (335, 169, '0003GZBW0009', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:51', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (336, 169, '0003GZBW0010', '0', '', '0', '00000001', '00000001', NULL, '2025-02-14 16:25:51', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (337, 169, '0003GZBW0011', '0', '', '0', '0000000F', '0000000F', NULL, '2025-02-14 16:25:52', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (338, 169, '0003GZBW0012', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:52', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (339, 169, '0003GZBW0013', '0', '', '0', '00000001', '00000001', NULL, '2025-02-14 16:25:52', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (340, 169, '0003GZBW0014', '0', '', '0', '00000001', '00000001', NULL, '2025-02-14 16:25:52', NULL, '2025-02-14 16:26:08');
+INSERT INTO `mx_debug_fault` VALUES (341, 169, '0003GZBW0015', '0', '', '0', '00000000', '00000000', NULL, '2025-02-14 16:25:52', NULL, '2025-02-14 16:26:08');
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 75 - 0
pla-sim/01_SQL/02_table/mx_sim.sql

@@ -0,0 +1,75 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : fhxy-192.168.1.61-polardbx
+ Source Server Type    : MySQL
+ Source Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ Source Host           : 192.168.1.61:4886
+ Source Schema         : pla-chem-sim-dev-1
+
+ Target Server Type    : MySQL
+ Target Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ File Encoding         : 65001
+
+ Date: 14/02/2025 17:04:39
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for mx_sim
+-- ----------------------------
+DROP TABLE IF EXISTS `mx_sim`;
+CREATE TABLE `mx_sim`  (
+  `sim_id` bigint NOT NULL AUTO_INCREMENT COMMENT '模拟器ID',
+  `seat_id` bigint NOT NULL DEFAULT 0 COMMENT '座ID',
+  `sim_type` char(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '模拟器类型',
+  `sim_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '模拟器状态:[0]:可用初始化,[1]:在线,[2]:模拟器离线,[3]:网关离线,[4]:硬件故障异常,[5]:手动禁用',
+  `sim_sn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '模拟器序列号',
+  `sim_num` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '模拟器设备编号',
+  `last_sent_time` datetime NULL DEFAULT NULL COMMENT '最后一次成功发送报文时间',
+  `last_received_time` datetime NULL DEFAULT NULL COMMENT '最后一次成功收到报文时间',
+  `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 (`sim_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 171 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-模拟器表' ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Records of mx_sim
+-- ----------------------------
+INSERT INTO `mx_sim` VALUES (1, 1, '0001', '0', '', '01', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (2, 2, '0001', '0', '', '02', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (3, 3, '0001', '0', '', '03', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (4, 4, '0001', '0', '', '04', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (5, 5, '0001', '0', '', '05', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (6, 6, '0001', '0', '', '06', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (7, 7, '0001', '0', '', '07', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (8, 8, '0001', '0', '', '08', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (9, 9, '0001', '0', '', '09', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (10, 10, '0001', '0', '', '10', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (81, 1, '0002', '0', '', '51', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (82, 2, '0002', '0', '', '52', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (83, 3, '0002', '0', '', '53', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (84, 4, '0002', '0', '', '54', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (85, 5, '0002', '0', '', '55', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (86, 6, '0002', '0', '', '56', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (87, 7, '0002', '0', '', '57', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (88, 8, '0002', '0', '', '58', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (89, 9, '0002', '0', '', '59', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (90, 10, '0002', '0', '', '5A', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (161, 1, '0003', '0', '', 'A1', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (162, 2, '0003', '0', '', 'A2', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (163, 3, '0003', '0', '', 'A3', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (164, 4, '0003', '0', '', 'A4', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (165, 5, '0003', '0', '', 'A5', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (166, 6, '0003', '0', '', 'A6', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (167, 7, '0003', '0', '', 'A7', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (168, 8, '0003', '0', '', 'A8', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (169, 9, '0003', '0', '', 'A9', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `mx_sim` VALUES (170, 10, '0003', '0', '', 'AA', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 40 - 0
pla-sim/01_SQL/02_table/sim_debug_fault.sql

@@ -0,0 +1,40 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : fhxy-192.168.1.61-polardbx
+ Source Server Type    : MySQL
+ Source Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ Source Host           : 192.168.1.61:4886
+ Source Schema         : pla-chem-sim-dev-1
+
+ Target Server Type    : MySQL
+ Target Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ File Encoding         : 65001
+
+ Date: 14/02/2025 13:02:59
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sim_debug_fault
+-- ----------------------------
+DROP TABLE IF EXISTS `sim_debug_fault`;
+CREATE TABLE `sim_debug_fault`  (
+  `ref_id` bigint NOT NULL AUTO_INCREMENT COMMENT '关联ID',
+  `sim_id` bigint NOT NULL COMMENT '模拟器ID',
+  `fault_id` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '故障ID',
+  `flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '7' COMMENT '选择状态:[7]-未知,[1]-选中,[0]-没有选中',
+  `ref_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]故障已经下发,[3]-轮询读取刷新电阻代表值,[4]-考试结束',
+  `answer_right` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '答题正确:[0]-初始化,[1]-正确,[2]-错误',
+  `sim_fault_question_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器出题值/电阻代表值',
+  `sim_fault_answer_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器答题值/电阻代表值',
+  `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 '更新时间',
+  PRIMARY KEY (`ref_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 91 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-调试故障表' ROW_FORMAT = DYNAMIC;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 26 - 26
pla-sim/01_SQL/02_table/sim_sim.sql

@@ -1,17 +1,17 @@
 /*
  Navicat Premium Dump SQL
 
- Source Server         : 47.104.188.84-sim
+ Source Server         : fhxy-192.168.1.61-polardbx
  Source Server Type    : MySQL
- Source Server Version : 80020 (8.0.20)
- Source Host           : 47.104.188.84:65006
+ Source Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
+ Source Host           : 192.168.1.61:4886
  Source Schema         : pla-chem-sim-dev-1
 
  Target Server Type    : MySQL
- Target Server Version : 80020 (8.0.20)
+ Target Server Version : 80032 (8.0.32-X-Cluster-8.4.19-20241112)
  File Encoding         : 65001
 
- Date: 08/02/2025 17:59:39
+ Date: 14/02/2025 17:04:58
 */
 
 SET NAMES utf8mb4;
@@ -36,7 +36,7 @@ CREATE TABLE `sim_sim`  (
   `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
   `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`sim_id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 140 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-模拟器表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 171 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-模拟器表' ROW_FORMAT = DYNAMIC;
 
 -- ----------------------------
 -- Records of sim_sim
@@ -51,25 +51,25 @@ INSERT INTO `sim_sim` VALUES (7, 7, '0001', '0', '', '07', NULL, NULL, NULL, NUL
 INSERT INTO `sim_sim` VALUES (8, 8, '0001', '0', '', '08', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 INSERT INTO `sim_sim` VALUES (9, 9, '0001', '0', '', '09', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 INSERT INTO `sim_sim` VALUES (10, 10, '0001', '0', '', '10', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (65, 1, '0002', '0', '', '41', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (66, 2, '0002', '0', '', '42', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (67, 3, '0002', '0', '', '43', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (68, 4, '0002', '0', '', '44', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (69, 5, '0002', '0', '', '45', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (70, 6, '0002', '0', '', '46', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (71, 7, '0002', '0', '', '47', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (72, 8, '0002', '0', '', '48', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (73, 9, '0002', '0', '', '49', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (74, 10, '0002', '0', '', '4A', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (129, 1, '0003', '0', '', '81', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (130, 2, '0003', '0', '', '82', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (131, 3, '0003', '0', '', '83', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (132, 4, '0003', '0', '', '84', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (133, 5, '0003', '0', '', '85', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (134, 6, '0003', '0', '', '86', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (135, 7, '0003', '0', '', '87', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (136, 8, '0003', '0', '', '88', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (137, 9, '0003', '0', '', '89', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-INSERT INTO `sim_sim` VALUES (138, 10, '0003', '0', '', '8A', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (81, 1, '0002', '0', '', '51', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (82, 2, '0002', '0', '', '52', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (83, 3, '0002', '0', '', '53', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (84, 4, '0002', '0', '', '54', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (85, 5, '0002', '0', '', '55', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (86, 6, '0002', '0', '', '56', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (87, 7, '0002', '0', '', '57', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (88, 8, '0002', '0', '', '58', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (89, 9, '0002', '0', '', '59', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (90, 10, '0002', '0', '', '5A', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (161, 1, '0003', '0', '', 'A1', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (162, 2, '0003', '0', '', 'A2', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (163, 3, '0003', '0', '', 'A3', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (164, 4, '0003', '0', '', 'A4', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (165, 5, '0003', '0', '', 'A5', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (166, 6, '0003', '0', '', 'A6', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (167, 7, '0003', '0', '', 'A7', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (168, 8, '0003', '0', '', 'A8', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (169, 9, '0003', '0', '', 'A9', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO `sim_sim` VALUES (170, 10, '0003', '0', '', 'AA', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 SET FOREIGN_KEY_CHECKS = 1;

+ 3 - 0
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,15 +6,18 @@ spring:
         druid:
             # 主库数据源
             master:
+                # server-阿里云47服务器内网
                 # url: jdbc:mysql://127.0.0.1:3306/pla-chem-sim-dev-1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 # url: jdbc:mysql://47.104.188.84:65006/pla-chem-sim-dev-1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 # username: sim
                 # password: 6JwWnz6PEXRGYLr3
 
+                # server-
                 # url: jdbc:mysql://192.168.1.40:3306/pla-chem-sim-dev-1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 # username: root
                 # password: 8M6ahN7BXsXXDccR
 
+                # server-现场实验室
                 url: jdbc:mysql://192.168.1.61:4886/pla-chem-sim-dev-1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
                 password: 7ZNo#9Arn3DFBN8N

+ 11 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -7,6 +7,7 @@ ruoyi:
   # 版权年份
   copyrightYear: 2024
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
+  # Windows
   # profile: C:/ruoyi/uploadPath
   profile: /home/ruoyi/uploadPath
   # 获取ip地址开关
@@ -17,7 +18,9 @@ ruoyi:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
+  # server-其他环境
   port: 8080
+  # server-阿里云47
   # port: 8093
   servlet:
     # 应用的访问路径
@@ -70,19 +73,27 @@ spring:
   # redis 配置
   redis:
     # 地址
+    # server-阿里云47服务器内网
     # host: 127.0.0.1
     # host: 192.168.1.40
     host: 192.168.1.61
+    # server-阿里云47服务器外网
     # host: 47.104.188.84
     # 端口,默认为6379
     port: 6379
     # port: 65007
     # 数据库索引
+    # server-阿里云47服务器内网
     # database: 2
+    # server-其他
     database: 0
     # 密码
+    # server-阿里云47
     # password: Z*eQ8xXK7ryYynFv
+    # server-现场实验室
     password: x2fs#W3rZ9dZXiMb
+    # server-李硕红米本机
+    # password: redis123456
     # 连接超时时间
     timeout: 10s
     lettuce:

+ 1 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/config/SimDebugConfig.java

@@ -10,7 +10,7 @@ public class SimDebugConfig {
 
     public static final String KEY_SCHEDULED_CONNECT = "SCHEDULED_CONNECT";
     /**
-     * 是否运行 连接情况 的 定时任务。
+     * 是否运行 连接情况 的 定时任务。默认true todo:
      */
     public static boolean SCHEDULED_CONNECT = true;
 }

+ 1 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/FaultController.java

@@ -114,7 +114,7 @@ public class FaultController extends BaseController {
     @GetMapping("/listTypeRealGZBW/{simType}")
     @ApiOperation("list某模拟器型号,所有的真实的[故障部位]基础数据。")
     public AjaxResult listType3(@PathVariable(value = "simType") String simType) {
-        return faultService.listType3(simType);
+        return faultService.listType3Ar(simType);
     }
 
     @GetMapping("/listTypeGZXX/{simType}")

+ 25 - 7
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/HardwareCommDebugController.java

@@ -2,6 +2,7 @@ package com.ruoyi.sim.controller;
 
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.sim.service.impl.CommBuildService;
 import com.ruoyi.sim.service.impl.CommSendService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -17,6 +18,8 @@ public class HardwareCommDebugController extends BaseController {
     @Autowired
     private CommSendService commSendService;
     @Autowired
+    private CommBuildService commBuildService;
+    @Autowired
     private ApplicationContext applicationContext;
 
     @GetMapping(value = "/spring-boot-close")
@@ -44,6 +47,12 @@ public class HardwareCommDebugController extends BaseController {
         return success(commSendService.debugReadAllFaultResistance(simNum));
     }
 
+    @GetMapping(value = "/debugReadAllFaultResistanceBySimNum/{simNum}")
+    @ApiOperation("debug通过simNum读取一台模拟器所有故障答题值,保存debug_fault表中,类似交卷")
+    public AjaxResult debugReadAllFaultResistanceBySimNum(@PathVariable("simNum") final String simNum) {
+        return commSendService.debugReadAllFaultResistanceBySimNum(simNum);
+    }
+
     @GetMapping(value = "/debugClearOneFault/{simNum}/{bindHardwareMsg}")
     @ApiOperation("debug清除一个故障")
     public AjaxResult debugClearOneFault(@PathVariable("simNum") final String simNum,
@@ -51,7 +60,7 @@ public class HardwareCommDebugController extends BaseController {
         return success(commSendService.debugClearOneFault(simNum, bindHardwareMsg));
     }
 
-    @GetMapping(value = "/debugClearAllFaultViaSimNum/{simNum}")
+    @GetMapping(value = "/debugClearAllFaultBySimNum/{simNum}")
     @ApiOperation("debug通过simNum清除一台模拟器所有故障")
     public AjaxResult debugClearAllFaultBySimNum(@PathVariable("simNum") final String simNum) {
         return commSendService.debugClearAllFaultBySimNum(simNum);
@@ -76,11 +85,20 @@ public class HardwareCommDebugController extends BaseController {
         return success(commSendService.debugWriteAllFault(simNum));
     }
 
-    @GetMapping(value = "/debugWriteSelectedFault/{simNum}/{faultIds}")
-    @ApiOperation("debug下发所选故障")
-    public AjaxResult debugWriteAllFault(@PathVariable("simNum") final String simNum,
-                                         @PathVariable("faultIds") final String[] faultIds,
-                                         @RequestParam final Boolean checkReplace) {
-        return success(commSendService.debugWriteSelectedFaultBySimNum(simNum, faultIds, checkReplace));
+    @GetMapping(value = "/debugWriteSelectedFaultBySimNum/{simNum}/{faultIds}")
+    @ApiOperation("debug下发所选故障,保存debug_fault表中,类似开始考试")
+    public AjaxResult debugWriteSelectedFaultBySimNum(@PathVariable("simNum") final String simNum,
+                                                      @PathVariable("faultIds") final String[] faultIds,
+                                                      @RequestParam final Boolean checkReplace) {
+        return commSendService.debugWriteSelectedFaultBySimNum(simNum, faultIds, checkReplace);
+    }
+
+    @GetMapping(value = "/debugBuildMsg/")
+    @ApiOperation("debugBuildMsg")
+    public AjaxResult debugBuildMsg(@RequestParam final String simNum,
+                                    @RequestParam final String cmd,
+                                    @RequestParam final String cmdId,
+                                    @RequestParam final String data) {
+        return commBuildService.debugBuildSendMsg(simNum, cmd, cmdId, data);
     }
 }

+ 11 - 5
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/RealExamCollectionController.java

@@ -98,28 +98,34 @@ public class RealExamCollectionController extends BaseController {
     }
 
     @PutMapping(value = "/teacher/exam/open/{examCollectionId}")
-    @ApiOperation("[教师][演示使用]打开考试集合")
+    @ApiOperation("[教师][正式使用]打开考试集合")
     public AjaxResult openExam(@PathVariable("examCollectionId") Long examCollectionId) {
-        l.info("[教师][演示使用]打开考试集合");
+        l.info("[教师][正式使用]打开考试集合");
         return service.open(examCollectionId);
     }
 
     @PutMapping(value = "/teacher/exercise/open/{examCollectionId}")
-    @ApiOperation("[教师]打开练习集合")
+    @ApiOperation("[教师][正式使用]打开练习集合")
     public AjaxResult openExercise(@PathVariable("examCollectionId") Long examCollectionId) {
         return service.open(examCollectionId);
     }
 
     @PutMapping(value = "/teacher/exam/close/{examCollectionId}")
-    @ApiOperation("[教师][演示使用]关闭考试集合")
+    @ApiOperation("[教师][正式使用]关闭考试集合")
     public AjaxResult closeExam(@PathVariable("examCollectionId") Long examCollectionId) {
         l.info("[教师][演示使用]关闭考试集合");
         return service.close(examCollectionId);
     }
 
     @PutMapping(value = "/teacher/exercise/close/{examCollectionId}")
-    @ApiOperation("[教师]关闭练习集合")
+    @ApiOperation("[教师][正式使用]关闭练习集合")
     public AjaxResult closeExercise(@PathVariable("examCollectionId") Long examCollectionId) {
         return service.close(examCollectionId);
     }
+
+    @PutMapping(value = "/teacher/all/close/")
+    @ApiOperation("[教师][正式使用]关闭全部(考试+练习+自主练习)集合")
+    public AjaxResult closeAll() {
+        return service.closeAll();
+    }
 }

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

@@ -88,6 +88,13 @@ public class RealExamController extends BaseController {
         return realExamService.studentStartRealExam(examId);
     }
 
+    @GetMapping("/student/self-exercise/start/{examId}")
+    @ApiOperation("[学生][正式使用]开始自主练习")
+    public AjaxResult studentStartRealSelfExercise(@PathVariable("examId") Long examId) {
+        l.info("[学生][正式使用]开始自主练习");
+        return realExamService.studentStartRealExam(examId);
+    }
+
     @GetMapping("/student/exam/answering/{examId}")
     @ApiOperation("[轮询][学生]正在考试界面")
     public AjaxResult studentLoopAnsweringRealExam(@PathVariable("examId") Long examId) {
@@ -108,6 +115,13 @@ public class RealExamController extends BaseController {
         return realExamService.studentSubmitRealExam(examId);
     }
 
+    @GetMapping("/student/self-exercise/submit/{examId}")
+    @ApiOperation("[学生][正式使用]交卷自主练习")
+    public AjaxResult studentSubmitRealSelfExercise(@PathVariable("examId") Long examId) {
+        l.info("[学生][正式使用]交卷自主练习");
+        return realExamService.studentSubmitRealExam(examId);
+    }
+
     @GetMapping("/student/exam/report/{examId}")
     @ApiOperation("[轮询][学生]结束考试界面")
     public AjaxResult studentLoopPostRealExam(@PathVariable("examId") Long examId) {

+ 13 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/DebugFault.java

@@ -143,4 +143,17 @@ public class DebugFault extends BaseEntity {
                 .append("updateTime", getUpdateTime())
                 .toString();
     }
+
+    // -------------------------------- tom add  --------------------------------
+    public interface Flag {
+        String YES = "1";
+        String NO = "0";
+        String UNKNOWN = "7";
+    }
+
+    public interface AnswerRight {
+        String UNKNOWN = "0";
+        String YES = "1";
+        String NO = "2";
+    }
 }

+ 12 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommBuildService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.sim.service.impl;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.sim.domain.SimMsg;
 import com.ruoyi.sim.util.CRC16Modbus;
 import org.apache.commons.lang3.StringUtils;
@@ -7,6 +8,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import static com.ruoyi.sim.service.impl.CommConst.*;
 
@@ -69,7 +71,7 @@ public class CommBuildService {
 
     public SimMsg buildSendMsg(final String simNum, final String cmd, final String cmdId, final String data) {
         SimMsg smS = new SimMsg();
-        smS.setSimId(idService.nextId());
+        smS.setSimMsgId(idService.nextId());
         if (StringUtils.isEmpty(simNum) || StringUtils.isEmpty(cmd) || StringUtils.isEmpty(cmdId) || StringUtils.isEmpty(data)) {
             throw new IllegalArgumentException("buildSendMsg error 01");
         }
@@ -112,6 +114,14 @@ public class CommBuildService {
         return smS;
     }
 
+    public AjaxResult debugBuildSendMsg(@RequestParam final String simNum,
+                                        @RequestParam final String cmd,
+                                        @RequestParam final String cmdId,
+                                        @RequestParam final String data) {
+        SimMsg sm = buildSendMsg(simNum, cmd, cmdId, data);
+        return AjaxResult.success(sm);
+    }
+
     /**
      * check receiveMsg
      *
@@ -141,6 +151,7 @@ public class CommBuildService {
             return false;
         }
         // 计算CRC16
+        // todo: receive报文检验错误。
         if (false) {
             String crcContent = receiveMsg.substring(0, 18);
             l.debug("crcContent: {}", crcContent.toUpperCase());

+ 9 - 4
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommConst.java

@@ -47,20 +47,24 @@ public interface CommConst {
      */
     int LENGTH_20 = 20;
     /**
-     * 添加CRC后的报文长度
+     * 添加CRC校验后的报文长度
      */
     int LENGTH_24 = 24;
 
     /**
      * 请求间隔睡眠时间-long
      */
-    Long SLEEP_LONG = 1024L;
+    Long SLEEP_LONG = 200L;
+    /**
+     * 请求间隔睡眠时间-mid
+     */
+    Long SLEEP_MID = 100L;
     /**
      * 请求间隔睡眠时间-short
      */
-    Long SLEEP_SHORT = 256L;
+    Long SLEEP_SHORT = 64L;
 
-    int SOCKET_TIME_OUT = 1536;
+    int SOCKET_TIME_OUT = 200;
 
     String[] TYPE_1_BIND_MSG = new String[]{"01", "02", "03", "04", "05",
             "06", "07", "08", "09", "0A"};
@@ -76,6 +80,7 @@ public interface CommConst {
     int RETRY_COUNT_CLEAR_ONE_FAULT = 2;
     int RETRY_COUNT_WRITE_ONE_FAULT = 2;
     int RETRY_COUNT_READ_ONE_RESISTANCE = 4;
+    int RETRY_COUNT_QUERY_SN_IMPORTANT = 1;
     int RETRY_COUNT_0 = 0;
 
     int OFFLINE_LIMIT = 6;

+ 75 - 26
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommReceiveService.java

@@ -1,16 +1,16 @@
 package com.ruoyi.sim.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.sim.domain.Fault;
-import com.ruoyi.sim.domain.RealExamFault;
-import com.ruoyi.sim.domain.Sim;
-import com.ruoyi.sim.domain.SimMsg;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.sim.domain.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashSet;
+
 import static com.ruoyi.sim.service.impl.CommConst.*;
 
 @Service
@@ -25,6 +25,10 @@ public class CommReceiveService {
     private RealExamFaultService realExamFaultService;
     @Autowired
     private SimService simService;
+    @Autowired
+    private DebugFaultService debugFaultService;
+    @Autowired
+    private FaultService faultService;
 
     /**
      * 只要返回信息,即认为在线。
@@ -57,10 +61,11 @@ public class CommReceiveService {
      *
      * @param sm
      * @param s
-     * @param reF
+     * @param reF      debug模式下为null。
      * @param f
+     * @param faultIds debug模式下为null。
      */
-    public void setFaultQuestionValue(SimMsg sm, Sim s, RealExamFault reF, Fault f) {
+    public void setFaultQuestionValue(SimMsg sm, Sim s, RealExamFault reF, Fault f, String[] faultIds) {
         // check
 
         //
@@ -71,13 +76,49 @@ public class CommReceiveService {
             return;
         }
         l.info("faultQuestionValue = {}", faultQuestionValue);
-        // 修改关联状态。
-        reF.setSimFaultQuestionValue(faultQuestionValue);
-        realExamFaultService.updateRealExamFault(reF);
-        if (RealExamFault.Flag.YES.equals(reF.getFlag())) {
-            realExamFaultService.updateRefStateByRefId(reF.getRefId(), RealExamFault.State.WRITTEN);
-        } else if (RealExamFault.Flag.NO.equals(reF.getFlag())) {
-            realExamFaultService.updateRefStateByRefId(reF.getRefId(), RealExamFault.State.LOOP_READ);
+        if (reF != null) {
+            // 修改关联状态。
+            reF.setSimFaultQuestionValue(faultQuestionValue);
+            realExamFaultService.updateRealExamFault(reF);
+            if (RealExamFault.Flag.YES.equals(reF.getFlag())) {
+                realExamFaultService.updateRefStateByRefId(reF.getRefId(), RealExamFault.State.WRITTEN);
+            } else if (RealExamFault.Flag.NO.equals(reF.getFlag())) {
+                realExamFaultService.updateRefStateByRefId(reF.getRefId(), RealExamFault.State.LOOP_READ);
+            }
+        } else {
+            //
+
+            //
+            HashSet<String> fSet = new HashSet<>();
+            for (String fId : faultIds) {
+                fSet.add(fId);
+            }
+            l.info("fSet.size() = {}", fSet.size());
+            String faultId = f.getFaultId();
+            l.info("faultId = {}", faultId);
+            DebugFault df = debugFaultService.exist(s.getSimId(), faultId);
+            if (df == null) {
+                df = new DebugFault();
+                df.setSimId(s.getSimId());
+                df.setFaultId(f.getFaultId());
+                if (fSet.contains(faultId)) {
+                    df.setFlag(DebugFault.Flag.YES);
+                } else {
+                    df.setFlag(DebugFault.Flag.NO);
+                }
+                df.setSimFaultQuestionValue(faultQuestionValue);
+                df.setSimFaultAnswerValue("");
+                debugFaultService.insertDebugFault(df);
+            } else {
+                if (fSet.contains(faultId)) {
+                    df.setFlag(DebugFault.Flag.YES);
+                } else {
+                    df.setFlag(DebugFault.Flag.NO);
+                }
+                df.setSimFaultQuestionValue(faultQuestionValue);
+                df.setSimFaultAnswerValue("");
+                debugFaultService.updateDebugFault(df);
+            }
         }
     }
 
@@ -86,16 +127,12 @@ public class CommReceiveService {
      *
      * @param sm
      * @param s
-     * @param reF
+     * @param reF      debug模式为null
      * @param f
-     * @param refState 轮询时候为null
+     * @param refState 轮询时候为null debug模式为null
      */
     public void setFaultAnswerValue(SimMsg sm, Sim s, RealExamFault reF, Fault f, String refState) {
         // check
-        if (reF == null) {
-            l.info("reF null!");
-            return;
-        }
         //
         String faultAnswerValue = parseGetData(sm.getReceiveMsg());
         // todo:
@@ -104,11 +141,25 @@ public class CommReceiveService {
             return;
         }
         l.info("faultAnswerValue = {}", faultAnswerValue);
-        if (StringUtils.isNotBlank(refState)) {
-            reF.setRefState(refState);
+        if (reF != null && refState != null) {
+            if (StringUtils.isNotBlank(refState)) {
+                reF.setRefState(refState);
+            }
+            reF.setSimFaultAnswerValue(faultAnswerValue);
+            realExamFaultService.updateRealExamFault(reF);
+        } else {
+            DebugFault df = debugFaultService.exist(s.getSimId(), f.getFaultId());
+            if (df == null) {
+                df = new DebugFault();
+                df.setSimId(s.getSimId());
+                df.setFaultId(f.getFaultId());
+                df.setSimFaultAnswerValue(faultAnswerValue);
+                debugFaultService.insertDebugFault(df);
+            } else {
+                df.setSimFaultAnswerValue(faultAnswerValue);
+                debugFaultService.updateDebugFault(df);
+            }
         }
-        reF.setSimFaultAnswerValue(faultAnswerValue);
-        realExamFaultService.updateRealExamFault(reF);
     }
 
     /**
@@ -139,9 +190,7 @@ public class CommReceiveService {
         }
         if (BLANK_CONTENT.equals(checkValue)) {
             l.info("故障部位[" + f.getBindHardwareMsg() + "][" + f.getReplaceName() + "]未正确安装;");
-            return AjaxResult.error(
-                    "故障部位[" + f.getBindHardwareMsg() + "][" + f.getReplaceName() + "]未正确安装;"
-                    , f);
+            return AjaxResult.error("故障部位[" + f.getBindHardwareMsg() + "][" + f.getReplaceName() + "]未正确安装;", f);
         } else {
             return AjaxResult.success(f);
         }

+ 174 - 46
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java

@@ -5,6 +5,7 @@ import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.sim.config.SimConfig;
 import com.ruoyi.sim.config.SimDebugConfig;
 import com.ruoyi.sim.domain.*;
+import com.ruoyi.sim.domain.vo.SelectSysDeptVo;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -18,10 +19,7 @@ import java.io.OutputStream;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 import static com.ruoyi.sim.service.impl.CommConst.*;
 
@@ -107,6 +105,35 @@ public class CommSendService {
         }
     }
 
+    public void readOneSimAtLastByDebug(Sim s) {
+        l.info("readOneSimAtLastByDebug");
+        List<Fault> list = faultService.listType3(s.getSimType());
+        for (Fault f : list) {
+            readOneSimOneFaultResistance(s, null, f, null);
+        }
+    }
+
+    public AjaxResult debugReadAllFaultResistanceBySimNum(String simNum) {
+        // check
+
+        //
+        // 打开socket
+        {
+            AjaxResult ar1 = openSocket();
+            if (ar1.isError()) {
+                return ar1;
+            }
+        }
+        //
+        Sim s = simService.uniqueBySimNum(simNum);
+        if (s == null || !Sim.State.ONLINE.equals(s.getSimState())) {
+            return AjaxResult.error("未连接维修模拟器,请检查连接!");
+        }
+        // todo: aj改造
+        readOneSimAtLastByDebug(s);
+        return AjaxResult.success("成功读取!");
+    }
+
     @Async("tp-comm")
     public void readOneExamAtLastAsync(RealExam re) {
         l.info("readOneExamAtLastAsync");
@@ -218,7 +245,10 @@ public class CommSendService {
         }
     }
 
-    public void checkOneSimState(final Sim s) {
+    /**
+     * @param s
+     */
+    public void checkOneSimState(final Sim s, final boolean important) {
         // check
         if (s == null) {
             return;
@@ -233,7 +263,12 @@ public class CommSendService {
         }
         //
         SimMsg smS = commBuildService.buildSendMsgReadSimType(s.getSimNum());
-        SimMsg smR = send(smS, s, RETRY_COUNT_0, SLEEP_SHORT);
+        int retryCount = RETRY_COUNT_0;
+        long sleep = SLEEP_SHORT;
+        if (important) {
+            retryCount = RETRY_COUNT_QUERY_SN_IMPORTANT;
+        }
+        SimMsg smR = send(smS, s, retryCount, sleep);
         if (StringUtils.isNotBlank(smR.getReceiveMsg())) {
             l.info("isNotBlank");
             commFailCountClearOne(s.getSimId());
@@ -250,7 +285,9 @@ public class CommSendService {
         if (ecF != null) {
             List<Sim> list = simService.listAllEnableBySimType(ecF.getSimType());
             l.info("checkAllSimState list.size() = {}", list.size());
-            list.forEach(this::checkOneSimState);
+            list.forEach(s -> {
+                checkOneSimState(s, false);
+            });
         }
     }
 
@@ -277,18 +314,28 @@ public class CommSendService {
         if (list != null) {
             l.info("清除exam list = {}", list.size());
         }
-        list.forEach(ref -> {
-            Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
-            if (faultService.isDisable(f.getFaultId())) {
-                l.warn("故障 {} -被禁用", f.getName());
-                throw new IllegalArgumentException("故障被禁用");
-            }
-            Sim s = simService.selectSimBySimId(re.getSimId());
-            // check
+        assert list != null;
+        list
+                .forEach(ref -> {
+                    Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
+                    if (faultService.isDisable(f.getFaultId())) {
+                        l.warn("故障 {} -被禁用", f.getName());
+                        throw new IllegalArgumentException("故障被禁用");
+                    }
+                    Sim s = simService.selectSimBySimId(re.getSimId());
+                    // check
 
-            //
-            clearOneSimOneFault(s, ref, f);
-        });
+                    //
+                    clearOneSimOneFault(s, ref, f);
+                });
+    }
+
+    public void clearOneSimAllFaultBySim(Sim s) {
+        l.info("clearOneSimAllFaultBySim = {}", s);
+        faultService.listType3EnableBySimType(s.getSimType())
+                .forEach(f -> {
+                    clearOneSimOneFault(s, null, f);
+                });
     }
 
     /**
@@ -336,6 +383,7 @@ public class CommSendService {
     }
 
     public AjaxResult debugClearAllOnlineSimAllFault() {
+        l.info("debugClearAllOnlineSimAllFault");
         simService.listAllOnline().forEach(s -> {
             AjaxResult ar = debugClearAllFaultBySimNum(s.getSimNum());
         });
@@ -369,7 +417,7 @@ public class CommSendService {
 
     /**
      * @param s
-     * @param reF 可以为空,表示不关联考试的,单独执行的。
+     * @param reF 可以为空,表示不关联考试的,单独执行的。调试模式下为空。
      * @param f
      */
     public void clearOneSimOneFault(Sim s, RealExamFault reF, Fault f) {
@@ -380,7 +428,12 @@ public class CommSendService {
         // step1
         SimMsg smS = commBuildService.buildSendMsgClearFault(s.getSimNum(), f.getBindHardwareMsg());
         SimMsg smR = send(smS, s, RETRY_COUNT_CLEAR_ONE_FAULT, SLEEP_LONG);
-        simReceiveService.clearOneFault(smR, s, reF, f);
+        if (reF != null) {
+            simReceiveService.clearOneFault(smR, s, reF, f);
+        } else {
+            l.info("reF == null");
+        }
+
         // step2
 
         // 下发故障独立运行。下面屏蔽。
@@ -427,16 +480,64 @@ public class CommSendService {
 
     /**
      * todo:尚未实现
+     * 实现方式类似 studentStartRealExam方法。
      *
      * @param simNum
      * @param faultIds
+     * @param checkReplace 是否进行可换件检查
      * @return
      */
     public AjaxResult debugWriteSelectedFaultBySimNum(final String simNum,
                                                       final String[] faultIds,
                                                       final Boolean checkReplace) {
+        // check faultIds 有效性
 
-        return null;
+        //
+        Sim s = simService.uniqueBySimNum(simNum);
+        // check sim
+        // 打开socket
+        {
+            AjaxResult ar1 = openSocket();
+            if (ar1.isError()) {
+                return ar1;
+            }
+        }
+        // Step 1 主动查询一次模拟器状态。
+        {
+            checkOneSimState(s, true);
+            // 如果模拟器离线
+            if (s == null || !Sim.State.ONLINE.equals(s.getSimState())) {
+                return AjaxResult.error("未连接模拟器,请检查连接!");
+            }
+        }
+        // Step 2
+        // msg判断,是否含有"故障部位"字符串
+        {
+            if (checkReplace) {
+
+                AjaxResult arE2 = readOneSimAllFaultCheck(s);
+                if (arE2.isError()) {
+                    return arE2;
+                }
+            }
+        }
+        // Step 3 清除对应一台模拟器 所有故障部位故障。
+        {
+            clearOneSimAllFaultBySim(s);
+        }
+        // Step 4 下发对应一台模拟器 出题选中的 故障位置故障。
+        {
+            Fault[] faults = new Fault[faultIds.length];
+            for (int i = 0; i < faultIds.length; i++) {
+                faults[i] = faultService.selectFaultByFaultId(faultIds[i]);
+            }
+            writeOneSimAllSelectFaultByDebug(s, faults);
+        }
+        // Step 5 读取
+        {
+            readOneSimAllFaultFirstTimeBySim(s, faultIds);
+        }
+        return AjaxResult.success("下发故障流程执行成功!");
     }
 
     private String[] getGZBWBySimType(String simType) {
@@ -464,7 +565,7 @@ public class CommSendService {
      *
      * @param re
      */
-    public void writeOneSimAllSelectFault(RealExam re) {
+    public void writeOneSimAllSelectFaultByExam(RealExam re) {
         // 更新Exam状态。
         realExamService.updateOneState(re.getExamId(), RealExam.State.SIM_WRITING);
         List<RealExamFault> list = realExamFaultService.listAllType2FlagYesClearedStateByExamId(re.getExamId());
@@ -476,6 +577,12 @@ public class CommSendService {
         }
     }
 
+    public void writeOneSimAllSelectFaultByDebug(Sim s, Fault[] faults) {
+        for (Fault f : faults) {
+            writeOneSimOneFault(s, null, f);
+        }
+    }
+
     public void writeOneSimOneFault(Sim s, RealExamFault ref, Fault f) {
         l.info("下发故障:getSimId = {},fault.getName = {}", s.getSimId(), f.getName());
         // todo:ref is null.
@@ -485,7 +592,7 @@ public class CommSendService {
     }
 
     /**
-     * 检查读取。
+     * 开始考试前检查读取。
      *
      * @param s
      * @return
@@ -525,6 +632,7 @@ public class CommSendService {
      * @return
      */
     public AjaxResult readOneSimOneFaultCheck(Sim s, Fault f) {
+        l.info("readOneSimOneFaultCheck s = {},f = {}", s, f);
         SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
         SimMsg sm2 = send(sm1, s, RETRY_COUNT_CHECK_ONE_FAULT, SLEEP_LONG);
         return simReceiveService.getOneFaultCheck(sm2, s, f);
@@ -535,12 +643,27 @@ public class CommSendService {
      *
      * @param re
      */
-    public void readOneSimAllFaultFirstTime(RealExam re) {
+    public void readOneSimAllFaultFirstTimeByExam(RealExam re) {
+        l.info("readOneSimAllFaultFirstTimeByExam re = {}", re);
         List<RealExamFault> list = realExamFaultService.listAllType2(re.getExamId());
         for (RealExamFault ref : list) {
             Sim s = simService.selectSimBySimId(re.getSimId());
             Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
-            readOneSimOneFaultFirstTime(s, ref, f);
+            readOneSimOneFaultFirstTime(s, ref, f, null);
+        }
+    }
+
+    /**
+     * 第一次读取,作为出题值。debug模式。
+     *
+     * @param s
+     * @param faultIds
+     */
+    public void readOneSimAllFaultFirstTimeBySim(Sim s, final String[] faultIds) {
+        l.info("readOneSimAllFaultFirstTimeBySim s = {}", s);
+        List<Fault> list = faultService.listType3(s.getSimType());
+        for (Fault f : list) {
+            readOneSimOneFaultFirstTime(s, null, f, faultIds);
         }
     }
 
@@ -548,18 +671,16 @@ public class CommSendService {
      * 第一次读取,作为出题值。
      *
      * @param s
-     * @param ref
+     * @param ref      debug调试模式为空。可以为空。
      * @param f
+     * @param faultIds debug调试模式为空。
      */
-    public void readOneSimOneFaultFirstTime(Sim s, RealExamFault ref, Fault f) {
+    public void readOneSimOneFaultFirstTime(Sim s, RealExamFault ref, Fault f, String[] faultIds) {
+        l.info("readOneSimOneFaultFirstTime");
         // 读取一次当前电阻代表值作为出题值。
         SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
         SimMsg sm2 = send(sm1, s, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
-        if (ref != null) {
-            simReceiveService.setFaultQuestionValue(sm2, s, ref, f);
-        } else {
-            l.info("ref is null");
-        }
+        simReceiveService.setFaultQuestionValue(sm2, s, ref, f, faultIds);
     }
 
     /**
@@ -595,27 +716,33 @@ public class CommSendService {
      * @param s
      * @param reF
      * @param f
-     * @param refState 中间轮询是null,交卷最后一次读取为finish状态。用来修改状态的。
+     * @param refState 中间轮询是null,交卷最后一次读取为finish状态。用来修改状态的。debug模式下执行为null。
      */
     public void readOneSimOneFaultResistance(Sim s, RealExamFault reF, Fault f, String refState) {
-        l.info("readOneFaultResistance");
+        l.info("readOneSimOneFaultResistance");
         SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
         SimMsg sm2 = null;
-        if (RealExamFault.State.FINISH.equals(refState)) { // 是否最后一次读取。
-            sm2 = send(sm1, s, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
+        if (reF != null && refState != null) {
+            if (RealExamFault.State.FINISH.equals(refState)) { // 是否最后一次读取。
+                sm2 = send(sm1, s, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
+            } else {
+                sm2 = send(sm1, s, RETRY_COUNT_0, SLEEP_SHORT);
+            }
         } else {
-            sm2 = send(sm1, s, RETRY_COUNT_0, SLEEP_SHORT);
+            sm2 = send(sm1, s, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
         }
         simReceiveService.setFaultAnswerValue(sm2, s, reF, f, refState);
     }
 
+    private long previousSendSleep = 0;
+
     /**
      * send hex message
      *
      * @param sm              发送
      * @param s               可以为空,更新最后发送/接收时间 用。
      * @param retryTotalCount 重试次数
-     * @param sleep           不使用传入0
+     * @param sleep           不使用传入0,不进行挂起。
      * @return
      */
     public synchronized SimMsg send(final SimMsg sm, final Sim s, final int retryTotalCount, final long sleep) {
@@ -638,10 +765,11 @@ public class CommSendService {
             openSocket();
             {
                 // sleep ,追求顺序请求。
-                if (sleep > 0) {
-                    Thread.sleep(sleep);
+                if (sleep > 0 && previousSendSleep != 0L) {
+                    Thread.sleep(previousSendSleep);
                 }
             }
+            previousSendSleep = sleep;
             InputStream is = cachedSocket.getInputStream();
             OutputStream os = cachedSocket.getOutputStream();
             os.write(hexStrToByteArrs(sm.getSendMsg()));
@@ -649,7 +777,7 @@ public class CommSendService {
             if (s != null) {
                 simService.updateLastSentTime(s);
             }
-            byte[] buffer = new byte[LENGTH_20];
+            byte[] buffer = new byte[LENGTH_24];
             int length = is.read(buffer);
             StringBuffer sbHex = new StringBuffer();
             for (int i = 0; i < length; i++) {
@@ -680,7 +808,7 @@ public class CommSendService {
             // 先考虑一台模拟器演示。
             // 进行重试 start
             if (sm.getRetryCount() == RETRY_COUNT_0) {
-                l.warn("####RetryTotalCount不重试RETRY_COUNT_0#### = {}", sm);
+                l.warn("####RetryTotalCount不重试RETRY_COUNT_0#### = getSimMsgId = {}", sm.getSimMsgId());
                 return sm;
             }
             if (sm.getRetryCount() < retryTotalCount) {
@@ -742,11 +870,11 @@ public class CommSendService {
             }
         } catch (IOException e) {
             e.printStackTrace();
-            return AjaxResult.error("openSocket IOException");
+            return AjaxResult.error("开启连接失败!请检查物联网网关连接或配置。");
         } finally {
 
         }
-        return AjaxResult.success();
+        return AjaxResult.success("开启连接成功!");
     }
 
     /**
@@ -770,12 +898,12 @@ public class CommSendService {
             }
         } catch (IOException e) {
             e.printStackTrace();
-            return AjaxResult.success("closeSocket IOException");
+            return AjaxResult.success("关闭连接失败!请检查物联网网关连接或配置。");
         } finally {
             cachedSocket = null;
             commFailCountClearAll();
         }
-        return AjaxResult.success();
+        return AjaxResult.success("关闭连接成功!");
     }
 
     /**

+ 27 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/DebugFaultService.java

@@ -3,6 +3,9 @@ package com.ruoyi.sim.service.impl;
 import java.util.List;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.sim.domain.Fault;
+import com.ruoyi.sim.domain.Sim;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.sim.mapper.DebugFaultMapper;
@@ -80,4 +83,28 @@ public class DebugFaultService {
     public int deleteDebugFaultByRefId(Long refId) {
         return debugFaultMapper.deleteDebugFaultByRefId(refId);
     }
+
+    // -------------------------------- tom add  --------------------------------
+    public DebugFault exist(Long simId, String faultId) {
+        if (simId == null || simId == 0L) {
+            return null;
+        }
+        if (StringUtils.isEmpty(faultId)) {
+            return null;
+        }
+        DebugFault q = new DebugFault();
+        q.setSimId(simId);
+        q.setFaultId(faultId);
+        List<DebugFault> list = selectDebugFaultList(q);
+        if (!list.isEmpty()) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public interface Flag {
+        String YES = "1";
+        String NO = "0";
+        String UNKNOWN = "7";
+    }
 }

+ 15 - 8
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/FaultService.java

@@ -220,7 +220,7 @@ public class FaultService {
      * @param simType
      * @return
      */
-    public AjaxResult listType3(final String simType) {
+    public AjaxResult listType3Ar(final String simType) {
         // check
         if (StringUtils.isEmpty(simType)) {
             return AjaxResult.error("simType empty!");
@@ -228,6 +228,17 @@ public class FaultService {
         if (!simService.checkSimTypeOk(simType)) {
             return AjaxResult.error("simType value error!");
         }
+        List<Fault> list1 = listType3(simType);
+        List<FaultShowVo> list2 = new ArrayList<>();
+        for (Fault f : list1) {
+            FaultShowVo vo = new FaultShowVo();
+            BeanUtils.copyProperties(f, vo);
+            list2.add(vo);
+        }
+        return AjaxResult.success(list2);
+    }
+
+    public List<Fault> listType3(final String simType) {
         // do query.
         List<Fault> list1 = new ArrayList<>();
         Fault q3 = new Fault();
@@ -235,14 +246,9 @@ public class FaultService {
         q3.setFaultState(Fault.State.ENABLE);
         q3.setFaultType(Fault.Type.REAL_GZBW);
         list1.addAll(selectFaultList(q3));
+        // faultId 升序排序
         Collections.sort(list1);
-        List<FaultShowVo> list2 = new ArrayList<>();
-        for (Fault f : list1) {
-            FaultShowVo vo = new FaultShowVo();
-            BeanUtils.copyProperties(f, vo);
-            list2.add(vo);
-        }
-        return AjaxResult.success(list2);
+        return list1;
     }
 
     /**
@@ -277,6 +283,7 @@ public class FaultService {
 
     /**
      * todo: 修改成数据库查询。
+     *
      * @param simType
      * @param faultType
      * @return

+ 4 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamCollectionService.java

@@ -347,6 +347,10 @@ public class RealExamCollectionService extends Ele6RYBaseService {
         return commSendService.closeSocket();
     }
 
+    public AjaxResult closeAll() {
+        return commSendService.closeSocket();
+    }
+
     public void closeAllType(String type) {
         RealExamCollection q = new RealExamCollection();
         q.setExamCollectionType(type);

+ 20 - 14
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -298,7 +298,7 @@ public class RealExamService {
             // re.setSimId(getFakeSimId(re));
             // l.info("fake re = {}", re);
         }
-        // check part.
+        // check id data.
         {
             AjaxResult arE1 = checkExamId(examId);
             if (arE1.isError()) {
@@ -306,30 +306,36 @@ public class RealExamService {
             }
         }
         RealExam re = selectRealExamByExamId(examId);
-        // Step 1 读取对应一台模拟器 所有故障部位值。检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。
+        Sim s = simService.selectSimBySimId(re.getSimId());
+        // Step 1 主动查询一次模拟器状态。获取模拟器在线/离线状态。
+        {
+            commSendService.checkOneSimState(s, true);
+            // 如果模拟器离线
+            if (s == null || !Sim.State.ONLINE.equals(s.getSimState())) {
+                return AjaxResult.error("未连接模拟器,请检查连接!");
+            }
+        }
+        // Step 2 读取对应一台模拟器 所有故障部位值。检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。特殊的故障部位要单独判断。
         if (SimDebugConfig.CHECK_REPLACE_EMPTY) {
-            Sim sim = simService.selectSimBySimId(re.getSimId());
-            AjaxResult arE2 = commSendService.readOneSimAllFaultCheck(sim);
+            AjaxResult arE2 = commSendService.readOneSimAllFaultCheck(s);
             if (arE2.isError()) {
                 return arE2;
             }
         }
-        // Step 2 清除对应一台模拟器 所有故障部位故障。
+        // Step 3 清除对应一台模拟器 所有 真实的 故障部位故障。
         {
             commSendService.clearOneSimAllFaultByExam(re);
         }
-        // Step 3 下发对应一台模拟器 出题选中的 故障位置故障。
+        // Step 4 下发对应一台模拟器 出题选中的 故障位置故障。
         {
-
+            commSendService.writeOneSimAllSelectFaultByExam(re);
         }
-        commSendService.writeOneSimAllSelectFault(re);
-        // Step 4 读取对应一台模拟器 所有的 真实的 故障部位 电阻值 作为出题值。
+        // Step 5 读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值。
         // 修改关联状态
         {
-            commSendService.readOneSimAllFaultFirstTime(re);
+            commSendService.readOneSimAllFaultFirstTimeByExam(re);
         }
-        // Step 5 修改Exam状态
-
+        // Step 6 修改当前Exam状态。
         if (realExamFaultService.isType2ExamPrepareStartOk(re.getExamId())) {
             updateOneState(re.getExamId(), RealExam.State.SIM_PREPARE_OK);
             updateOneState(re.getExamId(), RealExam.State.ANSWERING);
@@ -431,11 +437,11 @@ public class RealExamService {
                 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);

+ 3 - 3
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/SimService.java

@@ -117,9 +117,9 @@ public class SimService {
     public Sim uniqueBySimNum(final String simNum) {
         Sim q = new Sim();
         q.setSimNum(simNum);
-        List<Sim> simList = simMapper.selectSimList(q);
-        if (!simList.isEmpty()) {
-            return simList.get(0);
+        List<Sim> list = simMapper.selectSimList(q);
+        if (!list.isEmpty()) {
+            return list.get(0);
         }
         return null;
     }

+ 5 - 5
ruoyi-sim/src/main/resources/mapper/sim/DebugFaultMapper.xml

@@ -32,7 +32,7 @@
                create_time,
                update_by,
                update_time
-        from sim_debug_fault
+        from mx_debug_fault
     </sql>
 
     <select id="selectDebugFaultList" parameterType="DebugFault" resultMap="DebugFaultResult">
@@ -61,7 +61,7 @@
         <selectKey keyProperty="refId" order="AFTER" resultType="java.lang.Long">
             select LAST_INSERT_ID()
         </selectKey>
-        insert into sim_debug_fault
+        insert into mx_debug_fault
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="refId != null">ref_id,</if>
             <if test="simId != null">sim_id,</if>
@@ -93,7 +93,7 @@
     </insert>
 
     <update id="updateDebugFault" parameterType="DebugFault">
-        update sim_debug_fault
+        update mx_debug_fault
         <trim prefix="SET" suffixOverrides=",">
             <if test="simId != null">sim_id = #{simId},</if>
             <if test="faultId != null and faultId != ''">fault_id = #{faultId},</if>
@@ -112,12 +112,12 @@
 
     <delete id="deleteDebugFaultByRefId" parameterType="Long">
         delete
-        from sim_debug_fault
+        from mx_debug_fault
         where ref_id = #{refId}
     </delete>
 
     <delete id="deleteDebugFaultByRefIds" parameterType="String">
-        delete from sim_debug_fault where ref_id in
+        delete from mx_debug_fault where ref_id in
         <foreach item="refId" collection="array" open="(" separator="," close=")">
             #{refId}
         </foreach>