From 6c38637d89f346a660618558451f2dd7286dc7a5 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 31 八月 2026 22:51:54 +0800
Subject: [PATCH] 补齐检测柜模拟器完整 Excel 数据生命周期
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java | 95 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 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 5c4d084..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
@@ -25,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
@@ -265,6 +266,98 @@
}
}
+ /** 返回检测柜通道播放、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);
@@ -311,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