feat(platform): surface priority alert evidence
This commit is contained in:
@@ -8,6 +8,7 @@ import { SourceStatusTags } from '../components/SourceStatusTags';
|
||||
import { StatusTag } from '../components/StatusTag';
|
||||
import { VehicleMap, type VehicleMapPoint } from '../components/VehicleMap';
|
||||
import { isAMapConfigured } from '../config/appConfig';
|
||||
import { qualityIssueLabel, qualityProtocolLabel } from '../domain/qualityIssue';
|
||||
import { qualityIssueVehicleLookup } from '../domain/vehicleLookup';
|
||||
|
||||
const statusColor: Record<string, 'green' | 'orange' | 'red' | 'grey'> = {
|
||||
@@ -86,6 +87,33 @@ function hasValidCoordinate(row: VehicleRealtimeRow) {
|
||||
return Number.isFinite(row.longitude) && Number.isFinite(row.latitude) && row.longitude !== 0 && row.latitude !== 0;
|
||||
}
|
||||
|
||||
function issueEvidenceDate(value?: string) {
|
||||
const match = String(value ?? '').match(/^(\d{4})-(\d{2})-(\d{2})/);
|
||||
return match ? `${match[1]}-${match[2]}-${match[3]}` : '';
|
||||
}
|
||||
|
||||
function nextDate(value: string) {
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
||||
if (!match) return '';
|
||||
const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]) + 1));
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function priorityIssueVehicleLabel(row: QualityIssueRow) {
|
||||
const identity = row.vin?.trim() && row.vin !== 'unknown' ? row.vin.trim() : row.phone?.trim();
|
||||
return [row.plate?.trim(), identity].filter(Boolean).join(' / ') || row.sourceEndpoint || '-';
|
||||
}
|
||||
|
||||
function priorityIssueEvidenceFilters(row: QualityIssueRow) {
|
||||
const lookup = qualityIssueVehicleLookup(row);
|
||||
const dateFrom = issueEvidenceDate(row.lastSeen);
|
||||
return {
|
||||
keyword: lookup.key,
|
||||
protocol: row.protocol,
|
||||
...(dateFrom ? { dateFrom, dateTo: nextDate(dateFrom) } : {})
|
||||
};
|
||||
}
|
||||
|
||||
function sourceConsistencyAction(row: VehicleCoverageRow, onFilter: (filters: Record<string, string>) => void) {
|
||||
const consistency = row.sourceConsistency;
|
||||
if (!consistency) {
|
||||
@@ -235,6 +263,8 @@ export function Dashboard({
|
||||
const commandLocatedCount = locations.filter(hasValidCoordinate).length;
|
||||
const commandDegradedCount = locations.filter((row) => row.onlineSourceCount <= 0 || row.onlineSourceCount < row.sourceCount).length;
|
||||
const highPriorityIssue = qualityIssues.find((item) => item.severity === 'error') ?? qualityIssues[0];
|
||||
const highPriorityLookup = highPriorityIssue ? qualityIssueVehicleLookup(highPriorityIssue) : undefined;
|
||||
const highPriorityEvidenceFilters = highPriorityIssue ? priorityIssueEvidenceFilters(highPriorityIssue) : undefined;
|
||||
const unhealthyLinkCount = (summary?.linkHealth ?? []).filter((item) => item.status !== 'ok').length;
|
||||
const commandMapPoints: VehicleMapPoint[] = locations.map((row, index) => ({
|
||||
id: row.vin || `${row.primaryProtocol || 'source'}-${index}`,
|
||||
@@ -389,6 +419,57 @@ export function Dashboard({
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
{highPriorityIssue ? (
|
||||
<Card bordered title="最高优先级告警" style={{ marginBottom: 16 }}>
|
||||
<div className="vp-priority-alert">
|
||||
<div className="vp-priority-alert-main">
|
||||
<Space wrap>
|
||||
<Tag color={highPriorityIssue.severity === 'error' ? 'red' : 'orange'}>
|
||||
{highPriorityIssue.severity === 'error' ? 'P0' : 'P1'}
|
||||
</Tag>
|
||||
<Tag color="orange">{qualityIssueLabel(highPriorityIssue.issueType)}</Tag>
|
||||
<Tag color="blue">{qualityProtocolLabel(highPriorityIssue.protocol)}</Tag>
|
||||
<Tag color="grey">{highPriorityIssue.lastSeen || '-'}</Tag>
|
||||
</Space>
|
||||
<Typography.Title heading={6} style={{ margin: '10px 0 4px' }}>
|
||||
{priorityIssueVehicleLabel(highPriorityIssue)}
|
||||
</Typography.Title>
|
||||
<Typography.Text type="secondary">{highPriorityIssue.detail || '暂无告警详情'}</Typography.Text>
|
||||
</div>
|
||||
<Space wrap>
|
||||
<Button
|
||||
size="small"
|
||||
theme="solid"
|
||||
type="primary"
|
||||
disabled={!highPriorityLookup?.key}
|
||||
onClick={() => highPriorityLookup?.key && onOpenVehicle(highPriorityLookup.key, highPriorityIssue.protocol)}
|
||||
>
|
||||
车辆服务
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
theme="light"
|
||||
aria-label="首页告警轨迹证据"
|
||||
disabled={!highPriorityEvidenceFilters?.keyword}
|
||||
onClick={() => highPriorityEvidenceFilters && onOpenHistory(highPriorityEvidenceFilters)}
|
||||
>
|
||||
轨迹证据
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
theme="light"
|
||||
disabled={!highPriorityEvidenceFilters?.keyword}
|
||||
onClick={() => highPriorityEvidenceFilters && onOpenHistory({ ...highPriorityEvidenceFilters, tab: 'raw', includeFields: 'true' })}
|
||||
>
|
||||
RAW证据
|
||||
</Button>
|
||||
<Button size="small" theme="light" type="warning" onClick={() => onOpenQuality({ issueType: highPriorityIssue.issueType })}>
|
||||
告警队列
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
<Card bordered title="车辆业务能力矩阵" style={{ marginBottom: 16 }}>
|
||||
<div className="vp-capability-grid">
|
||||
{capabilities.map((item) => (
|
||||
|
||||
Reference in New Issue
Block a user