yeg
2026-08-30 9c0fd80309b277420c492180ae9f98f779f0f5c8
ruoyi-device/src/main/java/com/ruoyi/device/simulator/InMemoryBtsSimulatorStateStore.java
@@ -7,6 +7,8 @@
import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorHistoryAppend;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorHistoryBatch;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.CollectorMeasurementRecord;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.BtsHistoryRecord;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.BtsHistoryBatch;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.RecentRequest;
import com.ruoyi.device.simulator.BtsSimulatorStateStore.SimulatorState;
@@ -16,6 +18,7 @@
    private SimulatorState state;
    private List<RecentRequest> recentRequests = List.of();
    private final Map<String, ArrayList<CollectorMeasurementRecord>> collectorHistory = new LinkedHashMap<>();
    private final Map<String, ArrayList<BtsHistoryRecord>> btsHistory = new LinkedHashMap<>();
    public InMemoryBtsSimulatorStateStore() { }
@@ -85,6 +88,25 @@
    }
    @Override
    public synchronized BtsHistoryBatch loadBtsHistoryPage(String historyKey, long offset, int limit)
    {
        List<BtsHistoryRecord> history = btsHistory.getOrDefault(historyKey, new ArrayList<>());
        int from = (int) Math.min(offset, history.size());
        int count = Math.min(limit, history.size() - from);
        List<BtsHistoryRecord> records = new ArrayList<>(history.subList(from, from + count));
        long next = from + records.size();
        return new BtsHistoryBatch(offset, next, next < history.size(), history.size(), records);
    }
    @Override
    public synchronized void appendBtsHistory(String historyKey, BtsHistoryRecord record)
    {
        ArrayList<BtsHistoryRecord> history = btsHistory.computeIfAbsent(historyKey, key -> new ArrayList<>());
        history.add(record);
        if (history.size() > MAX_HISTORY_RECORDS) history.remove(0);
    }
    @Override
    public synchronized List<RecentRequest> loadRecentRequests()
    {
        return recentRequests;
@@ -102,5 +124,6 @@
        state = defaultState;
        recentRequests = List.of();
        collectorHistory.clear();
        btsHistory.clear();
    }
}