From 370ef4f5e663fdfc1d19d2774dfc4ec1ed0af60e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 29 八月 2026 14:57:48 +0800
Subject: [PATCH] 修复采集器历史状态持续序列化错误
---
ruoyi-device/src/main/java/com/ruoyi/device/simulator/BtsSimulatorStateStore.java | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/ruoyi-device/src/main/java/com/ruoyi/device/simulator/BtsSimulatorStateStore.java b/ruoyi-device/src/main/java/com/ruoyi/device/simulator/BtsSimulatorStateStore.java
index 7f70ae5..e417b5a 100644
--- a/ruoyi-device/src/main/java/com/ruoyi/device/simulator/BtsSimulatorStateStore.java
+++ b/ruoyi-device/src/main/java/com/ruoyi/device/simulator/BtsSimulatorStateStore.java
@@ -16,6 +16,29 @@
/** 完整保存下一版模拟器状态。 */
void save(SimulatorState state);
+ /** 状态和独立历史全部校验通过后,提交兼容旧格式所需的迁移。 */
+ default void completeValidatedRestore(SimulatorState state) { }
+
+ /** 原子保存主状态并追加本轮新产生的原始历史。 */
+ default void save(SimulatorState state, List<CollectorHistoryAppend> historyAppends)
+ {
+ if (!historyAppends.isEmpty())
+ throw new UnsupportedOperationException("Collector history append is not supported");
+ save(state);
+ }
+
+ /** 读取指定采集器的只追加原始历史。 */
+ default List<CollectorMeasurementRecord> loadCollectorHistory(String collectorCode)
+ {
+ return List.of();
+ }
+
+ /** 原子保存删除采集器后的主状态,并删除该采集器的独立历史。 */
+ default void saveAndDeleteCollectorHistory(SimulatorState state, String collectorCode)
+ {
+ throw new UnsupportedOperationException("Atomic collector deletion is not supported");
+ }
+
/** 读取短期保留的最近请求。 */
List<RecentRequest> loadRecentRequests();
@@ -47,13 +70,12 @@
String manufacturer, String model, int channelCount, boolean online, int sampleIntervalMs,
long nextSequence, Instant lastSampledAt, List<CollectorChannelState> channels,
List<CollectorRealtimeMeasurement> latestMeasurements,
- List<CollectorMeasurementRecord> history, CollectorHistoryFaults historyFaults)
+ long historyRecordCount, CollectorHistoryFaults historyFaults)
{
public CollectorState
{
channels = List.copyOf(channels);
latestMeasurements = List.copyOf(latestMeasurements);
- history = List.copyOf(history);
historyFaults = historyFaults == null ? CollectorHistoryFaults.none() : historyFaults;
}
@@ -63,7 +85,7 @@
{
this(collectorId, deviceCode, ip, mac, name, manufacturer, model, channelCount, online,
DevelopmentCollectorSimulation.DEFAULT_SAMPLE_INTERVAL_MS, 1L, null,
- DevelopmentCollectorSimulation.defaultChannels(channelCount), List.of(), List.of(),
+ DevelopmentCollectorSimulation.defaultChannels(channelCount), List.of(), 0L,
CollectorHistoryFaults.none());
}
}
@@ -83,6 +105,11 @@
long sequenceId, Instant deviceTime, String deviceTimeRaw, Instant serverReceivedAt,
String metricCode, BigDecimal value, String unit) { }
+ record CollectorHistoryAppend(String collectorCode, List<CollectorMeasurementRecord> records)
+ {
+ public CollectorHistoryAppend { records = List.copyOf(records); }
+ }
+
record CollectorHistoryFaults(List<Long> missingSequences, Long duplicateSequence,
Long conflictingSequence, boolean outOfOrder)
{
--
Gitblit v1.7.1