diff --git a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx index bc214fb8..a8d85c9d 100644 --- a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx +++ b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx @@ -235,6 +235,7 @@ 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 unhealthyLinkCount = (summary?.linkHealth ?? []).filter((item) => item.status !== 'ok').length; const commandMapPoints: VehicleMapPoint[] = locations.map((row, index) => ({ id: row.vin || `${row.primaryProtocol || 'source'}-${index}`, label: row.plate || row.vin || 'unknown', @@ -285,6 +286,56 @@ export function Dashboard({ onClick: () => onOpenMileage() } ]; + const workflowSteps = [ + { + title: '接入巡检', + value: unhealthyLinkCount > 0 ? `${unhealthyLinkCount.toLocaleString()} 项关注` : '链路正常', + color: unhealthyLinkCount > 0 ? 'orange' as const : 'green' as const, + detail: '检查平台转发、Kafka、Redis、MySQL、TDengine 等关键链路。', + action: '查看告警', + onClick: () => onOpenQuality() + }, + { + title: '实时态势', + value: `${formatCount(serviceSummary?.onlineVehicles ?? summary?.onlineVehicles)} 在线`, + color: 'green' as const, + detail: '确认车辆是否在线、是否有有效坐标以及来源是否完整。', + action: '实时监控', + onClick: () => onOpenRealtime({ online: 'online' }) + }, + { + title: '轨迹复盘', + value: `${formatCount(summary?.activeToday)} 活跃`, + color: 'blue' as const, + detail: '按车辆进入历史轨迹,复盘位置、速度、里程和断点。', + action: '轨迹回放', + onClick: () => onOpenHistory() + }, + { + title: '历史证据', + value: `${formatCount(summary?.frameToday)} 帧`, + color: 'blue' as const, + detail: '查询 RAW 帧和解析字段,形成可追溯的数据证据。', + action: '历史查询', + onClick: () => onOpenHistory({ tab: 'raw' }) + }, + { + title: '告警通知', + value: `${formatCount(summary?.issueVehicles)} 车辆`, + color: (summary?.issueVehicles ?? 0) > 0 ? 'orange' as const : 'green' as const, + detail: '把断链、缺 VIN、字段缺失等问题进入通知和处置队列。', + action: '告警通知', + onClick: () => onOpenQuality() + }, + { + title: '统计复核', + value: `${formatCount(serviceSummary?.totalVehicles)} 车辆`, + color: 'green' as const, + detail: '核对里程统计口径,保证区间统计和每日统计闭合。', + action: '统计查询', + onClick: () => onOpenMileage() + } + ]; return (
@@ -313,6 +364,31 @@ export function Dashboard({ 0 ? 'orange' : 'green'}>Kafka Lag {formatLag(summary?.kafkaLag)} + +
+ {workflowSteps.map((item, index) => ( +
+
{index + 1}
+
+ + {item.title} + {item.value} + + {item.detail} + +
+
+ ))} +
+
{capabilities.map((item) => ( diff --git a/vehicle-data-platform/apps/web/src/styles/global.css b/vehicle-data-platform/apps/web/src/styles/global.css index 4987744f..98d04965 100644 --- a/vehicle-data-platform/apps/web/src/styles/global.css +++ b/vehicle-data-platform/apps/web/src/styles/global.css @@ -699,6 +699,47 @@ body { min-width: 0; } +.vp-operation-flow { + display: grid; + grid-template-columns: repeat(6, minmax(0, 1fr)); + gap: 12px; +} + +.vp-operation-step { + min-height: 176px; + padding: 14px; + border: 1px solid var(--vp-border); + border-radius: var(--vp-radius); + background: #fbfcff; + display: grid; + grid-template-rows: auto 1fr; + gap: 12px; +} + +.vp-operation-index { + width: 28px; + height: 28px; + border-radius: 7px; + background: rgba(22, 100, 255, 0.1); + color: var(--vp-primary); + display: flex; + align-items: center; + justify-content: center; + font-size: 13px; + font-weight: 700; +} + +.vp-operation-content { + min-width: 0; + display: grid; + gap: 10px; + align-content: space-between; +} + +.vp-operation-content .semi-typography { + line-height: 20px; +} + .vp-capability-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); @@ -804,6 +845,7 @@ body { @media (max-width: 900px) { .vp-evidence-grid, .vp-action-grid, + .vp-operation-flow, .vp-capability-grid, .vp-conclusion-grid, .vp-monitor-layout, diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index f83dde53..3072c27c 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -727,6 +727,99 @@ test.each([ }); }); +test('dashboard exposes end-to-end operations workflow entries', async () => { + window.history.replaceState(null, '', '/#/dashboard'); + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => { + const path = String(input); + if (path.includes('/api/ops/health')) { + return { + ok: true, + json: async () => ({ + data: { linkHealth: [], kafkaLag: 0, activeConnections: 0, capacityFindings: [], redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + if (path.includes('/api/dashboard/summary')) { + return { + ok: true, + json: async () => ({ + data: { + onlineVehicles: 88, + activeToday: 96, + frameToday: 1286320, + issueVehicles: 7, + kafkaLag: 0, + protocols: [], + serviceStatuses: [], + linkHealth: [{ name: 'Kafka', status: 'ok' }] + }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + if (path.includes('/api/vehicle-service/summary')) { + return { + ok: true, + json: async () => ({ + data: { + totalVehicles: 1033, + boundVehicles: 1024, + onlineVehicles: 88, + singleSourceVehicles: 391, + multiSourceVehicles: 181, + noDataVehicles: 0, + identityRequiredVehicles: 0, + archiveIncompleteVehicles: 0, + serviceStatuses: [], + protocols: [], + missingSources: [], + archiveMissingFields: [] + }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + if (path.includes('/api/quality/summary')) { + return { + ok: true, + json: async () => ({ + data: { issueVehicleCount: 7, issueRecordCount: 9, errorCount: 1, warningCount: 8, protocols: [], issueTypes: [] }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + return { + ok: true, + json: async () => ({ + data: { items: [], total: 0, limit: 20, offset: 0 }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + }); + + render(); + + expect(await screen.findByText('全链路值班闭环')).toBeInTheDocument(); + expect(screen.getByText('接入巡检')).toBeInTheDocument(); + expect(screen.getByText('实时态势')).toBeInTheDocument(); + expect(screen.getByText('轨迹复盘')).toBeInTheDocument(); + expect(screen.getByText('历史证据')).toBeInTheDocument(); + expect(screen.getAllByText('告警通知').length).toBeGreaterThanOrEqual(1); + expect(screen.getByText('统计复核')).toBeInTheDocument(); + + fireEvent.click(screen.getByRole('button', { name: '闭环入口 轨迹复盘' })); + + await waitFor(() => { + expect(window.location.hash).toBe('#/history?keyword=LB9A32A24R0LS1426'); + }); +}); + test('dashboard keeps core vehicle service metrics when preview requests fail', async () => { window.history.replaceState(null, '', '/#/dashboard'); vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {