From bb60630fd73a51dbde58f2e6960fb58da6b309d0 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Mon, 25 May 2026 06:51:45 +0800 Subject: [PATCH] =?UTF-8?q?LiveTemperatureThresholdChart=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=9A=E7=A7=BB=E9=99=A4=E8=B7=91=E9=81=93=E6=AD=BB?= =?UTF-8?q?=E4=BB=A3=E7=A0=81+=E4=BA=BA=E9=80=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=8D=88=E5=A4=9C?= =?UTF-8?q?=20toTimestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除 RunwayObsPayload 类型和 runway_obs 读数分支(ScanOpportunityRow 无此字段,死代码)。toTimestamp 感知跨午夜:若解析时间超前当前>2h则回溯一天。 --- .../LiveTemperatureThresholdChart.tsx | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx b/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx index d66552fc..c7e84b01 100644 --- a/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx +++ b/frontend/components/dashboard/scan-terminal/LiveTemperatureThresholdChart.tsx @@ -32,17 +32,6 @@ type EvidenceSeries = { values: Array; }; -type RunwayObsPayload = { - runway_pairs?: Array<[string, string] | string[] | null> | null; - temperatures?: Array<[number | null, number | null] | Array | null> | null; - point_temperatures?: Array<{ - runway?: string | null; - tdz_temp?: number | null; - mid_temp?: number | null; - end_temp?: number | null; - } | null> | null; -}; - // Sliding window: keep at most this many observation points (24h at 1-min ≈ 1440) const MAX_OBS_POINTS = 1440; @@ -55,11 +44,17 @@ function toTimestamp(value?: string | null): number | null { if (!raw) return null; const d = new Date(raw); if (!Number.isNaN(d.getTime())) return d.getTime(); - // HH:MM or HH:MM:SS — treat as today + // HH:MM or HH:MM:SS — treat as today, but handle cross-midnight: + // if parsed time is >2h ahead of now, assume yesterday const m = raw.match(/(\d{1,2}):(\d{2})/); if (m) { const now = new Date(); - return new Date(now.getFullYear(), now.getMonth(), now.getDate(), +m[1], +m[2]).getTime(); + const h = +m[1], min = +m[2]; + const candidate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), h, min); + if (candidate.getTime() - now.getTime() > 2 * 60 * 60 * 1000) { + candidate.setDate(candidate.getDate() - 1); + } + return candidate.getTime(); } return null; } @@ -126,19 +121,6 @@ function buildSlidingChartData( }); } - // Runway obs - const runwayObs = (row as any)?.amos?.runway_obs || (row as any)?.runway_obs; - if (runwayObs) { - const pairs = runwayObs.runway_pairs || []; - const temps = runwayObs.temperatures || []; - pairs.forEach((_: any, idx: number) => { - const tArr = Array.isArray(temps[idx]) ? temps[idx] || [] : []; - tArr.forEach((tVal: unknown) => { - if (validNumber(tVal) !== null) allTimes.add(Date.now() - (MAX_OBS_POINTS - idx) * 60_000); - }); - }); - } - // Sort timestamps const sorted = [...allTimes].sort((a, b) => a - b); if (!sorted.length) return { data: [], series: [] };