diff --git a/vehicle-data-platform/apps/web/src/pages/Quality.tsx b/vehicle-data-platform/apps/web/src/pages/Quality.tsx index 76eb5900..6a485d00 100644 --- a/vehicle-data-platform/apps/web/src/pages/Quality.tsx +++ b/vehicle-data-platform/apps/web/src/pages/Quality.tsx @@ -123,6 +123,16 @@ type PriorityIssueRow = QualityIssueRow & { notificationText?: string; }; +type AlertDispatchOwnerRow = { + owner: string; + activeRuleCount: number; + hitCount: number; + p0Count: number; + primaryIssueType: string; + primarySla: string; + primaryHitCount: number; +}; + function qualityParams(values: Record) { const params = new URLSearchParams(); if (values?.keyword) params.set('keyword', values.keyword); @@ -217,6 +227,35 @@ function alertRuleRows(summary: QualitySummary, health: OpsHealth | null): Alert return rows; } +function alertDispatchOwnerRows(rules: AlertRuleRow[]): AlertDispatchOwnerRow[] { + const ownerMap = new Map(); + rules.forEach((rule) => { + const owner = rule.owner || '未分配'; + const current = ownerMap.get(owner) ?? { + owner, + activeRuleCount: 0, + hitCount: 0, + p0Count: 0, + primaryIssueType: rule.issueType, + primarySla: rule.sla, + primaryHitCount: 0 + }; + current.activeRuleCount += rule.count > 0 ? 1 : 0; + current.hitCount += rule.count; + current.p0Count += rule.count > 0 && rule.level === 'P0' ? 1 : 0; + const shouldReplacePrimary = rule.count > current.primaryHitCount || (rule.count === current.primaryHitCount && rule.level === 'P0'); + if (shouldReplacePrimary) { + current.primaryIssueType = rule.issueType; + current.primarySla = rule.sla; + current.primaryHitCount = rule.count; + } + ownerMap.set(owner, current); + }); + return [...ownerMap.values()] + .filter((row) => row.hitCount > 0 || row.activeRuleCount > 0) + .sort((left, right) => right.p0Count - left.p0Count || right.hitCount - left.hitCount || left.owner.localeCompare(right.owner)); +} + function issueSla(issueType: string) { return alertRuleTemplates.find((item) => item.issueType === issueType)?.sla ?? '当日闭环'; } @@ -627,6 +666,7 @@ export function Quality({ const activeRuleCount = notificationPlan?.activeRuleCount ?? rules.filter((item) => item.count > 0).length; const p0RuleCount = notificationPlan?.p0RuleCount ?? rules.filter((item) => item.count > 0 && item.level === 'P0').length; const priorityRows = normalizePriorityIssues(notificationPlan?.priorityIssues) ?? priorityIssueRows(issues); + const dispatchOwnerRows = alertDispatchOwnerRows(rules); const loadIssues = (values: Record = filters, page = pagination.currentPage, pageSize = pagination.pageSize) => { setLoadingIssues(true); @@ -836,6 +876,33 @@ export function Quality({ ))} + +
+ {dispatchOwnerRows.length === 0 ? ( + 暂无待分派告警 + ) : dispatchOwnerRows.map((item) => ( + + ))} +
+
{