yeg
2026-08-30 1c26cdb81070af7f29df4462d3bfc1ae588ff8f3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorController.java
@@ -63,13 +63,26 @@
        return simulator.snapshot();
    }
    /** 模拟现场人工统一开关全部检测柜和采集器,不发送任何设备控制命令。 */
    @PostMapping("/dev/bts-simulator/power")
    public StateSnapshot setPower(@RequestBody SimulatorPowerCommand command)
    {
        if (command == null || command.poweredOn() == null)
            throw badRequest(new IllegalArgumentException("poweredOn must be true or false"));
        simulator.setAllDevicesPoweredOn(command.poweredOn());
        return simulator.snapshot();
    }
    /** 添加一台虚拟设备。 */
    @PostMapping("/dev/bts-simulator/devices")
    public StateSnapshot createDevice(@RequestBody CreateDeviceCommand command)
    {
        try
        {
            simulator.addDevice(command.ip(), command.channelCount());
            if (command.model() == null || command.model().isBlank())
                simulator.addDevice(command.ip(), command.channelCount());
            else
                simulator.addNewareDevice(command.ip(), command.model());
            return simulator.snapshot();
        }
        catch (IllegalArgumentException exception)
@@ -85,6 +98,8 @@
        try
        {
            simulator.updateDevice(deviceId, command.ip(), command.channelCount(), command.online());
            if (command.model() != null && !command.model().isBlank())
                simulator.configureNewareProfile(deviceId, command.model());
            return simulator.snapshot();
        }
        catch (IllegalArgumentException exception)
@@ -241,9 +256,23 @@
        return new ResponseStatusException(HttpStatus.BAD_REQUEST, exception.getMessage(), exception);
    }
    public record CreateDeviceCommand(String ip, int channelCount) { }
    public record CreateDeviceCommand(String ip, int channelCount, String model)
    {
        public CreateDeviceCommand(String ip, int channelCount)
        {
            this(ip, channelCount, null);
        }
    }
    public record DeviceStateCommand(String ip, int channelCount, boolean online) { }
    public record SimulatorPowerCommand(Boolean poweredOn) { }
    public record DeviceStateCommand(String ip, int channelCount, boolean online, String model)
    {
        public DeviceStateCommand(String ip, int channelCount, boolean online)
        {
            this(ip, channelCount, online, null);
        }
    }
    public record ChannelStateCommand(boolean online, DeviceWorkStatus workStatus) { }