LiveTemperatureThresholdChart 修复:移除跑道死代码+人造时间戳,修复跨午夜 toTimestamp
删除 RunwayObsPayload 类型和 runway_obs 读数分支(ScanOpportunityRow 无此字段,死代码)。toTimestamp 感知跨午夜:若解析时间超前当前>2h则回溯一天。
This commit is contained in:
@@ -32,17 +32,6 @@ type EvidenceSeries = {
|
||||
values: Array<number | null>;
|
||||
};
|
||||
|
||||
type RunwayObsPayload = {
|
||||
runway_pairs?: Array<[string, string] | string[] | null> | null;
|
||||
temperatures?: Array<[number | null, number | null] | Array<number | null> | 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: [] };
|
||||
|
||||
Reference in New Issue
Block a user