yeg
2026-08-29 370ef4f5e663fdfc1d19d2774dfc4ec1ed0af60e
ruoyi-device/src/main/java/com/ruoyi/device/simulator/InMemoryBtsSimulatorStateStore.java
@@ -1,6 +1,11 @@
package com.ruoyi.device.simulator;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorHistoryAppend;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorMeasurementRecord;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.RecentRequest;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.SimulatorState;
@@ -9,6 +14,7 @@
{
    private SimulatorState state;
    private List<RecentRequest> recentRequests = List.of();
    private final Map<String, List<CollectorMeasurementRecord>> collectorHistory = new LinkedHashMap<>();
    public InMemoryBtsSimulatorStateStore() { }
@@ -31,6 +37,32 @@
    }
    @Override
    public synchronized void save(SimulatorState state, List<CollectorHistoryAppend> historyAppends)
    {
        for (CollectorHistoryAppend append : historyAppends)
        {
            List<CollectorMeasurementRecord> records = new ArrayList<>(
                    collectorHistory.getOrDefault(append.collectorCode(), List.of()));
            records.addAll(append.records());
            collectorHistory.put(append.collectorCode(), List.copyOf(records));
        }
        this.state = state;
    }
    @Override
    public synchronized List<CollectorMeasurementRecord> loadCollectorHistory(String collectorCode)
    {
        return collectorHistory.getOrDefault(collectorCode, List.of());
    }
    @Override
    public synchronized void saveAndDeleteCollectorHistory(SimulatorState state, String collectorCode)
    {
        collectorHistory.remove(collectorCode);
        this.state = state;
    }
    @Override
    public synchronized List<RecentRequest> loadRecentRequests()
    {
        return recentRequests;
@@ -47,5 +79,6 @@
    {
        state = defaultState;
        recentRequests = List.of();
        collectorHistory.clear();
    }
}