From 4eaa4be4d2cbd2aa49d36a313ce71ad3e743db4a Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期三, 02 九月 2026 12:22:53 +0800
Subject: [PATCH] 彻底清理补采完整性遗留依赖

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 1 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java
index 3938123..c7ce62a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java
@@ -15,6 +15,7 @@
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.server.ResponseStatusException;
+import org.springframework.beans.factory.annotation.Autowired;
 import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.device.bts.BtsDevelopmentSimulator;
 import com.ruoyi.device.bts.BtsDevelopmentSimulator.StateSnapshot;
@@ -24,6 +25,7 @@
 import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorMetricState;
 import com.ruoyi.device.simulator.DevelopmentCollectorSimulation.CollectorHistoryPage;
 import com.ruoyi.device.simulator.DevelopmentCollectorSimulation.CollectorRealtimeSnapshot;
+import com.ruoyi.device.bts.BtsDevelopmentSimulator.PlaybackSnapshot;
 
 /** 本机临时 BTS 模拟器控制 API。 */
 @Anonymous
@@ -32,12 +34,23 @@
 {
     private final BtsDevelopmentSimulator simulator;
     private final DeviceDiscoveryCandidateStore candidateStore;
+    private final com.ruoyi.config.DevelopmentCollectorStatusSynchronizer statusSynchronizer;
 
+    @Autowired
     public BtsDevelopmentSimulatorController(BtsDevelopmentSimulator simulator,
-            DeviceDiscoveryCandidateStore candidateStore)
+            DeviceDiscoveryCandidateStore candidateStore,
+            com.ruoyi.config.DevelopmentCollectorStatusSynchronizer statusSynchronizer)
     {
         this.simulator = simulator;
         this.candidateStore = candidateStore;
+        this.statusSynchronizer = statusSynchronizer;
+    }
+
+    /** 保留独立模拟器测试和工具调用的构造入口,不触发数据库同步。 */
+    public BtsDevelopmentSimulatorController(BtsDevelopmentSimulator simulator,
+            DeviceDiscoveryCandidateStore candidateStore)
+    {
+        this(simulator, candidateStore, null);
     }
 
     /** 返回临时控制页;匿名放行后仍由本机拦截器限制来源。 */
@@ -70,6 +83,7 @@
         if (command == null || command.poweredOn() == null)
             throw badRequest(new IllegalArgumentException("poweredOn must be true or false"));
         simulator.setAllDevicesPoweredOn(command.poweredOn());
+        synchronizeOnlineStatusIfConfigured();
         return simulator.snapshot();
     }
 
@@ -146,6 +160,7 @@
         try
         {
             simulator.updateCollector(collectorId, command.ip(), command.channelCount(), command.online());
+            synchronizeOnlineStatusIfConfigured();
             return simulator.snapshot();
         }
         catch (IllegalArgumentException exception)
@@ -251,9 +266,106 @@
         }
     }
 
+    /** 返回检测柜通道播放、record、step 和 cycle 的当前快照。 */
+    @GetMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback")
+    public PlaybackSnapshot btsPlayback(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @GetMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/records")
+    public List<com.ruoyi.device.simulator.BtsSimulatorStateStore.BtsHistoryRecord> btsRecords(
+            @PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { return simulator.btsRecords(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @GetMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/steps")
+    public List<BtsDevelopmentSimulator.BtsStepRecord> btsSteps(
+            @PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { return simulator.btsSteps(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @GetMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/cycles")
+    public List<BtsDevelopmentSimulator.BtsCycleRecord> btsCycles(
+            @PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { return simulator.btsCycles(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    /** 设置检测柜通道演示倍速。 */
+    @PutMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback")
+    public PlaybackSnapshot configureBtsPlayback(@PathVariable int deviceId, @PathVariable int channelId,
+            @RequestBody PlaybackCommand command)
+    {
+        try
+        {
+            if (command.speedMultiplier() != null) simulator.setBtsSpeed(deviceId, channelId, command.speedMultiplier());
+            if (command.playing() != null)
+            {
+                if (command.playing()) simulator.playBts(deviceId, channelId);
+                else simulator.pauseBts(deviceId, channelId);
+            }
+            return simulator.btsPlayback(deviceId, channelId);
+        }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/play")
+    public PlaybackSnapshot playBts(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.playBts(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/pause")
+    public PlaybackSnapshot pauseBts(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.pauseBts(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/resume")
+    public PlaybackSnapshot resumeBts(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.resumeBts(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/next-step")
+    public PlaybackSnapshot nextBtsStep(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.nextBtsStep(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/next-cycle")
+    public PlaybackSnapshot nextBtsCycle(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.nextBtsCycle(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
+    @PostMapping("/dev/bts-simulator/devices/{deviceId}/channels/{channelId}/playback/reset")
+    public PlaybackSnapshot resetBts(@PathVariable int deviceId, @PathVariable int channelId)
+    {
+        try { simulator.resetBts(deviceId, channelId); return simulator.btsPlayback(deviceId, channelId); }
+        catch (IllegalArgumentException exception) { throw badRequest(exception); }
+    }
+
     private ResponseStatusException badRequest(IllegalArgumentException exception)
     {
         return new ResponseStatusException(HttpStatus.BAD_REQUEST, exception.getMessage(), exception);
+    }
+
+    private void synchronizeOnlineStatusIfConfigured()
+    {
+        if (statusSynchronizer != null) statusSynchronizer.synchronizeOnlineStatus();
     }
 
     public record CreateDeviceCommand(String ip, int channelCount, String model)
@@ -292,4 +404,6 @@
     public record CollectorChannelCommand(List<CollectorMetricCommand> metrics) { }
 
     public record CollectorMetricCommand(String metricCode, BigDecimal value, String unit) { }
+
+    public record PlaybackCommand(Integer speedMultiplier, Boolean playing) { }
 }

--
Gitblit v1.7.1