yeg
2026-08-30 b985e6140e7f395ead7dc55e41e6b16d97f9f02b
ruoyi-admin/src/main/java/com/ruoyi/config/RedisBtsSimulatorStateStore.java
@@ -47,6 +47,29 @@
        return restoreState(stored);
    }
    @Override
    public SimulatorState resetHistoryForDemoStartup(SimulatorState state)
    {
        pendingEmbeddedHistory = List.of();
        Set<Object> historyKeys = redisTemplate.opsForSet().members(HISTORY_KEYS_KEY);
        if (historyKeys != null && !historyKeys.isEmpty()) redisTemplate.delete(historyKeys);
        redisTemplate.delete(HISTORY_KEYS_KEY);
        List<com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorState> collectors = state.collectors()
                .stream()
                .map(collector -> new com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorState(
                        collector.collectorId(), collector.deviceCode(), collector.ip(), collector.mac(),
                        collector.name(), collector.manufacturer(), collector.model(), collector.channelCount(),
                        collector.online(), collector.sampleIntervalMs(), 1L,
                        null, collector.channels(), List.of(), 0L,
                        collector.historyFaults()))
                .toList();
        SimulatorState reset = new SimulatorState(state.version(), state.devices(), collectors,
                state.nextDeviceId(), state.nextCollectorId(), state.tombstones());
        redisTemplate.opsForValue().set(STATE_KEY, JSON.toJSONString(reset));
        return reset;
    }
    private SimulatorState restoreState(Object stored)
    {
        ParsedSimulatorState parsed = parseState(stored);
@@ -88,6 +111,7 @@
                        List<Object> records = new ArrayList<>(
                                append.records().stream().map(JSON::toJSONString).toList());
                        typed.opsForList().rightPushAll(historyKey, records);
                        typed.opsForList().trim(historyKey, -MAX_HISTORY_RECORDS, -1);
                        typed.opsForSet().add(HISTORY_KEYS_KEY, historyKey);
                    }
                }