diff --git a/frontend/src/views/machine/MachineListPage.vue b/frontend/src/views/machine/MachineListPage.vue
index b4f8f9f..366010b 100644
--- a/frontend/src/views/machine/MachineListPage.vue
+++ b/frontend/src/views/machine/MachineListPage.vue
@@ -48,8 +48,7 @@
- {{ row.isOnline ? '在线' : '离线' }}
- {{ row.lastPingLatency }}ms
+ {{ row.isOnline ? '在线' : '离线' }}{{ row.lastPingLatency != null ? `-${row.lastPingLatency}ms` : '' }}
diff --git a/src/CncCollector/Core/CollectWorker.cs b/src/CncCollector/Core/CollectWorker.cs
index b7d4450..c723f03 100644
--- a/src/CncCollector/Core/CollectWorker.cs
+++ b/src/CncCollector/Core/CollectWorker.cs
@@ -253,10 +253,10 @@ namespace CncCollector.Core
conn.Execute(@"UPDATE cnc_machine SET last_ping_time = NOW(), last_ping_latency = @Latency, updated_at = NOW() WHERE id = @Id",
new { Id = kv.Key, Latency = kv.Value });
}
- // 离线机床:清空延迟,不更新 last_ping_time
+ // 离线机床:不更新 last_ping_time,保留上次延迟值
if (offlineIds.Count > 0)
{
- conn.Execute(@"UPDATE cnc_machine SET last_ping_latency = NULL, updated_at = NOW() WHERE id IN @Ids",
+ conn.Execute(@"UPDATE cnc_machine SET updated_at = NOW() WHERE id IN @Ids",
new { Ids = offlineIds });
}
}