feat(platform): add dispatch operations home

This commit is contained in:
lingniu
2026-07-05 21:51:44 +08:00
parent 52a73cba2d
commit a68db5e0eb
3 changed files with 332 additions and 1 deletions

View File

@@ -1950,6 +1950,58 @@ export function Dashboard({
onClick: openTimeMonitorRaw
}
];
const dispatchOperationsHighlights = [
{
label: '实时地图',
value: `${commandLocatedCount.toLocaleString()} 有定位`,
detail: '先看车辆空间分布、在线态势和最新位置。',
action: '打开地图',
color: commandLocatedCount > 0 ? 'blue' as const : 'orange' as const,
onClick: () => onOpenMap({ online: 'online' })
},
{
label: '今日重点',
value: `${formatCount(summary?.issueVehicles)} 告警`,
detail: highPriorityIssue ? `${qualityIssueLabel(highPriorityIssue.issueType)} / ${priorityIssueVehicleLabel(highPriorityIssue)}` : '没有高优先级告警,保持巡检。',
action: '处理告警',
color: (summary?.issueVehicles ?? 0) > 0 ? 'orange' as const : 'green' as const,
onClick: () => onOpenQuality(highPriorityIssue?.issueType ? { issueType: highPriorityIssue.issueType } : {})
}
];
const dispatchOperationsTasks = [
{
title: '看全域位置',
value: `${formatCount(serviceSummary?.onlineVehicles ?? summary?.onlineVehicles)} 在线`,
detail: '打开实时地图,确认在线车辆、有效坐标和重点区域。',
action: '实时地图',
color: 'green' as const,
onClick: () => onOpenMap({ online: 'online' })
},
{
title: '回放重点轨迹',
value: `${formatCount(summary?.activeToday)} 活跃`,
detail: '按车辆和时间窗回放路线,核对停驶、偏航和里程断点。',
action: '轨迹回放',
color: 'blue' as const,
onClick: openTimeMonitorHistory
},
{
title: '核对时间窗里程',
value: `${formatCount(serviceSummary?.totalVehicles)} 车辆`,
detail: '按同一时间范围核对区间里程、每日统计和 BI 口径。',
action: '统计查询',
color: 'blue' as const,
onClick: openTimeMonitorMileage
},
{
title: '导出客户证据',
value: `${formatCount(summary?.frameToday)}`,
detail: '导出历史位置、原始记录、解析字段和告警说明。',
action: '历史导出',
color: 'blue' as const,
onClick: openTimeMonitorRaw
}
];
return (
<div className="vp-page">
@@ -1980,6 +2032,65 @@ export function Dashboard({
))}
</div>
</section>
<section className="vp-dispatch-operations-home" aria-label="客户调度运营首页">
<div className="vp-dispatch-operations-map">
<div className="vp-dispatch-operations-copy">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={amapConfigured ? 'green' : 'orange'}>{amapConfigured ? '地图可用' : '坐标预览'}</Tag>
<Tag color={(summary?.issueVehicles ?? 0) > 0 ? 'orange' : 'green'}>{formatCount(summary?.issueVehicles)} </Tag>
</Space>
<Typography.Title heading={4} style={{ margin: 0 }}></Typography.Title>
<Typography.Text type="secondary">
</Typography.Text>
</div>
<VehicleMap
points={commandMapPoints}
maxFallbackPoints={120}
heightClassName="vp-dispatch-operations-map-canvas"
fallbackLabel="显示车辆调度坐标预览"
/>
<div className="vp-dispatch-operations-highlights">
{dispatchOperationsHighlights.map((item) => (
<button
key={item.label}
type="button"
className="vp-dispatch-operations-highlight"
onClick={item.onClick}
aria-label={`客户调度运营首页 ${item.label} ${item.value} ${item.action}`}
>
<Tag color={item.color}>{item.label}</Tag>
<strong>{item.value}</strong>
<span>{item.detail}</span>
<em>{item.action}</em>
</button>
))}
</div>
</div>
<div className="vp-dispatch-operations-panel">
<div className="vp-dispatch-operations-panel-head">
<Typography.Text strong></Typography.Text>
<Typography.Text type="secondary"></Typography.Text>
</div>
<div className="vp-dispatch-operations-task-grid">
{dispatchOperationsTasks.map((item) => (
<button
key={item.title}
type="button"
className="vp-dispatch-operations-task"
onClick={item.onClick}
aria-label={`调度运营任务 ${item.title} ${item.value} ${item.action}`}
>
<Tag color={item.color}>{item.title}</Tag>
<strong>{item.value}</strong>
<span>{item.detail}</span>
<em>{item.action}</em>
</button>
))}
</div>
</div>
</section>
<section className="vp-customer-map-situation" aria-label="车辆地图态势">
<div className="vp-customer-map-situation-map">
<VehicleMap

View File

@@ -1248,6 +1248,133 @@ body {
overflow: hidden;
}
.vp-dispatch-operations-home {
margin-bottom: 16px;
padding: 14px;
border: 1px solid rgba(22, 100, 255, 0.18);
border-radius: 8px;
background: #ffffff;
display: grid;
grid-template-columns: minmax(460px, 1.28fr) minmax(300px, 0.72fr);
gap: 14px;
align-items: stretch;
}
.vp-dispatch-operations-map {
min-width: 0;
border: 1px solid var(--vp-border);
border-radius: 8px;
background: #f8fbff;
overflow: hidden;
display: grid;
grid-template-rows: auto minmax(260px, 1fr) auto;
}
.vp-dispatch-operations-copy {
padding: 14px;
display: grid;
gap: 8px;
}
.vp-dispatch-operations-copy .semi-typography {
color: var(--vp-text);
line-height: 24px;
}
.vp-dispatch-operations-map-canvas {
min-height: 280px;
}
.vp-dispatch-operations-highlights {
padding: 12px;
border-top: 1px solid var(--vp-border);
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.vp-dispatch-operations-highlight,
.vp-dispatch-operations-task {
min-width: 0;
border: 1px solid var(--vp-border);
border-radius: 8px;
background: #ffffff;
color: inherit;
cursor: pointer;
font: inherit;
text-align: left;
display: grid;
gap: 8px;
transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.vp-dispatch-operations-highlight {
min-height: 116px;
padding: 12px;
}
.vp-dispatch-operations-task {
min-height: 122px;
padding: 13px;
}
.vp-dispatch-operations-highlight:hover,
.vp-dispatch-operations-highlight:focus-visible,
.vp-dispatch-operations-task:hover,
.vp-dispatch-operations-task:focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f7fbff;
box-shadow: 0 0 0 3px rgba(22, 100, 255, 0.08);
outline: none;
}
.vp-dispatch-operations-highlight strong,
.vp-dispatch-operations-task strong {
color: var(--vp-text);
font-size: 20px;
line-height: 26px;
word-break: break-word;
}
.vp-dispatch-operations-highlight span,
.vp-dispatch-operations-task span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
word-break: break-word;
}
.vp-dispatch-operations-highlight em,
.vp-dispatch-operations-task em {
color: var(--vp-primary);
font-size: 12px;
font-style: normal;
font-weight: 700;
line-height: 18px;
}
.vp-dispatch-operations-panel {
min-width: 0;
padding: 14px;
border: 1px solid var(--vp-border);
border-radius: 8px;
background: #fbfcff;
display: grid;
gap: 12px;
align-content: start;
}
.vp-dispatch-operations-panel-head {
display: grid;
gap: 4px;
}
.vp-dispatch-operations-task-grid {
display: grid;
grid-template-columns: 1fr;
gap: 10px;
}
.vp-customer-map-situation {
margin-bottom: 16px;
padding: 14px;
@@ -10531,6 +10658,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-customer-service-package,
.vp-customer-service-grid,
.vp-vehicle-task-grid,
.vp-dispatch-operations-home,
.vp-dispatch-operations-highlights,
.vp-source-readiness-grid,
.vp-source-readiness-metrics,
.vp-map-ops-board,

View File

@@ -734,6 +734,97 @@ test('dashboard prioritizes customer vehicle service command over data sources',
expect(screen.getByRole('button', { name: '客户车队分组工作台 报表交付组 1,286,320 今日数据 历史导出' })).toBeInTheDocument();
});
test('dashboard presents a customer dispatch operations home', 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,
amapWebJsConfigured: true,
amapApiConfigured: true,
amapSecurityProxyEnabled: true,
amapSecurityCodeExposed: false
}
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/dashboard/summary')) {
return {
ok: true,
json: async () => ({
data: {
onlineVehicles: 3,
activeToday: 4,
frameToday: 1286320,
issueVehicles: 7,
kafkaLag: 0,
protocols: [],
serviceStatuses: [],
linkHealth: []
},
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: 208,
singleSourceVehicles: 391,
multiSourceVehicles: 181,
noDataVehicles: 461,
identityRequiredVehicles: 9,
serviceStatuses: [],
protocols: [],
missingSources: []
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 8, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('客户调度运营首页')).toBeInTheDocument();
expect(screen.getByText('值班人员进来先看地图态势和异常队列,再进入轨迹回放、时间窗统计、历史导出和告警通知。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户调度运营首页 实时地图 0 有定位 打开地图' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户调度运营首页 今日重点 7 告警 处理告警' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '调度运营任务 看全域位置 208 在线 实时地图' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '调度运营任务 回放重点轨迹 4 活跃 轨迹回放' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '调度运营任务 核对时间窗里程 1,033 车辆 统计查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '调度运营任务 导出客户证据 1,286,320 帧 历史导出' })).toBeInTheDocument();
});
test('dashboard guides customer custom time window service path', async () => {
window.history.replaceState(null, '', '/#/dashboard');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
@@ -1318,7 +1409,7 @@ test('dashboard exposes vehicle data center capability matrix', async () => {
await renderDashboard();
fireEvent.click(screen.getByRole('button', { name: '能力入口 统计查询' }));
expect(window.location.hash.startsWith('#/mileage')).toBe(true);
});
}, 10000);
test('dashboard exposes vehicle command center map actions', async () => {
window.history.replaceState(null, '', '/#/dashboard');