feat(platform): add operations workflow cockpit
This commit is contained in:
@@ -235,6 +235,7 @@ export function Dashboard({
|
|||||||
const commandLocatedCount = locations.filter(hasValidCoordinate).length;
|
const commandLocatedCount = locations.filter(hasValidCoordinate).length;
|
||||||
const commandDegradedCount = locations.filter((row) => row.onlineSourceCount <= 0 || row.onlineSourceCount < row.sourceCount).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 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) => ({
|
const commandMapPoints: VehicleMapPoint[] = locations.map((row, index) => ({
|
||||||
id: row.vin || `${row.primaryProtocol || 'source'}-${index}`,
|
id: row.vin || `${row.primaryProtocol || 'source'}-${index}`,
|
||||||
label: row.plate || row.vin || 'unknown',
|
label: row.plate || row.vin || 'unknown',
|
||||||
@@ -285,6 +286,56 @@ export function Dashboard({
|
|||||||
onClick: () => onOpenMileage()
|
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 (
|
return (
|
||||||
<div className="vp-page">
|
<div className="vp-page">
|
||||||
@@ -313,6 +364,31 @@ export function Dashboard({
|
|||||||
<Tag color={(summary?.kafkaLag ?? 0) > 0 ? 'orange' : 'green'}>Kafka Lag {formatLag(summary?.kafkaLag)}</Tag>
|
<Tag color={(summary?.kafkaLag ?? 0) > 0 ? 'orange' : 'green'}>Kafka Lag {formatLag(summary?.kafkaLag)}</Tag>
|
||||||
</Space>
|
</Space>
|
||||||
</Card>
|
</Card>
|
||||||
|
<Card bordered title="全链路值班闭环" style={{ marginBottom: 16 }}>
|
||||||
|
<div className="vp-operation-flow">
|
||||||
|
{workflowSteps.map((item, index) => (
|
||||||
|
<div key={item.title} className="vp-operation-step">
|
||||||
|
<div className="vp-operation-index">{index + 1}</div>
|
||||||
|
<div className="vp-operation-content">
|
||||||
|
<Space spacing={8} align="center">
|
||||||
|
<Typography.Title heading={6} style={{ margin: 0 }}>{item.title}</Typography.Title>
|
||||||
|
<Tag color={item.color}>{item.value}</Tag>
|
||||||
|
</Space>
|
||||||
|
<Typography.Text type="secondary">{item.detail}</Typography.Text>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
theme="light"
|
||||||
|
type="primary"
|
||||||
|
aria-label={`闭环入口 ${item.title}`}
|
||||||
|
onClick={item.onClick}
|
||||||
|
>
|
||||||
|
{item.action}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
<Card bordered title="车辆业务能力矩阵" style={{ marginBottom: 16 }}>
|
<Card bordered title="车辆业务能力矩阵" style={{ marginBottom: 16 }}>
|
||||||
<div className="vp-capability-grid">
|
<div className="vp-capability-grid">
|
||||||
{capabilities.map((item) => (
|
{capabilities.map((item) => (
|
||||||
|
|||||||
@@ -699,6 +699,47 @@ body {
|
|||||||
min-width: 0;
|
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 {
|
.vp-capability-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
@@ -804,6 +845,7 @@ body {
|
|||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.vp-evidence-grid,
|
.vp-evidence-grid,
|
||||||
.vp-action-grid,
|
.vp-action-grid,
|
||||||
|
.vp-operation-flow,
|
||||||
.vp-capability-grid,
|
.vp-capability-grid,
|
||||||
.vp-conclusion-grid,
|
.vp-conclusion-grid,
|
||||||
.vp-monitor-layout,
|
.vp-monitor-layout,
|
||||||
|
|||||||
@@ -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(<App />);
|
||||||
|
|
||||||
|
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 () => {
|
test('dashboard keeps core vehicle service metrics when preview requests fail', async () => {
|
||||||
window.history.replaceState(null, '', '/#/dashboard');
|
window.history.replaceState(null, '', '/#/dashboard');
|
||||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user