feat(platform): prioritize customer vehicle command center

This commit is contained in:
lingniu
2026-07-05 19:43:20 +08:00
parent e1126a6fcc
commit 30bc03a262
3 changed files with 279 additions and 0 deletions

View File

@@ -1738,11 +1738,89 @@ export function Dashboard({
onClick: () => onOpenQuality(highPriorityIssue?.issueType ? { issueType: highPriorityIssue.issueType } : {})
}
];
const customerServiceCommandItems = [
{
label: '实时地图',
value: `${formatCount(serviceSummary?.onlineVehicles ?? summary?.onlineVehicles)} 在线`,
detail: `${commandLocatedCount.toLocaleString()} 辆有有效定位,优先回答车辆在哪里。`,
action: '进入地图',
color: 'green' as const,
onClick: () => onOpenMap({ online: 'online' })
},
{
label: '轨迹回放',
value: `${formatCount(summary?.activeToday)} 活跃`,
detail: `${dayRangeText(timeMonitorScopeValue.dateFrom, timeMonitorScopeValue.dateTo)},按车辆复盘路线、速度和里程断点。`,
action: '回放轨迹',
color: 'blue' as const,
onClick: openTimeMonitorHistory
},
{
label: '统计查询',
value: `${formatCount(serviceSummary?.totalVehicles)} 车辆`,
detail: '按车辆口径核对区间里程、日统计和异常来源。',
action: '查统计',
color: 'blue' as const,
onClick: openTimeMonitorMileage
},
{
label: '数据导出',
value: `${formatCount(summary?.frameToday)} 今日数据`,
detail: '按车辆、时间和字段裁剪位置、原始记录和解析字段。',
action: '查询导出',
color: 'blue' as const,
onClick: openTimeMonitorRaw
},
{
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 } : {})
}
];
return (
<div className="vp-page">
<PageHeader title="车辆服务工作台" description="面向客户的车辆地图、实时监控、轨迹回放、统计查询、自定义时间窗复盘、历史查询、告警通知和数据导出" />
<Spin spinning={loading}>
<section className="vp-customer-service-command" aria-label="客户车辆服务总控台">
<div className="vp-customer-service-command-main">
<div className="vp-customer-service-command-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>
<div className="vp-customer-service-command-evidence">
<span>GB32960 / JT808 / YUTONG_MQTT</span>
<strong>{vehicleServiceOnlineText(serviceSummary, summary)}</strong>
<small>{dayRangeText(timeMonitorScopeValue.dateFrom, timeMonitorScopeValue.dateTo)}</small>
</div>
</div>
<div className="vp-customer-service-command-grid">
{customerServiceCommandItems.map((item) => (
<button
key={item.label}
type="button"
className="vp-customer-service-command-item"
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>
</section>
<section className="vp-customer-cockpit" aria-label="现代车队运营台">
<div className="vp-customer-cockpit-summary">
<Space wrap>

View File

@@ -1195,6 +1195,113 @@ body {
grid-template-columns: minmax(280px, 0.62fr) minmax(0, 1.38fr);
}
.vp-customer-service-command {
margin-bottom: 16px;
border: 1px solid rgba(22, 100, 255, 0.16);
border-radius: var(--vp-radius);
background: #ffffff;
overflow: hidden;
}
.vp-customer-service-command-main {
padding: 18px;
border-bottom: 1px solid var(--vp-border);
background: #f8fbff;
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
gap: 16px;
align-items: stretch;
}
.vp-customer-service-command-copy {
display: grid;
gap: 10px;
align-content: center;
}
.vp-customer-service-command-copy .semi-typography {
line-height: 26px;
}
.vp-customer-service-command-evidence {
padding: 14px;
border: 1px solid rgba(22, 100, 255, 0.14);
border-radius: 8px;
background: #ffffff;
display: grid;
gap: 6px;
align-content: center;
}
.vp-customer-service-command-evidence span,
.vp-customer-service-command-evidence small {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
}
.vp-customer-service-command-evidence strong {
color: var(--vp-text);
font-size: 20px;
line-height: 26px;
font-weight: 700;
}
.vp-customer-service-command-grid {
padding: 14px;
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
}
.vp-customer-service-command-item {
min-height: 132px;
padding: 12px;
border: 1px solid var(--vp-border);
border-radius: 8px;
background: #fbfcff;
color: inherit;
cursor: pointer;
font: inherit;
text-align: left;
display: grid;
gap: 8px;
align-content: start;
transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.vp-customer-service-command-item:hover,
.vp-customer-service-command-item:focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f5f9ff;
box-shadow: 0 0 0 3px rgba(22, 100, 255, 0.08);
outline: none;
}
.vp-customer-service-command-item strong {
color: var(--vp-text);
font-size: 18px;
line-height: 24px;
font-weight: 700;
word-break: break-word;
}
.vp-customer-service-command-item span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
word-break: break-word;
}
.vp-customer-service-command-item em {
align-self: end;
color: var(--vp-primary);
font-size: 12px;
font-style: normal;
font-weight: 700;
line-height: 18px;
}
.vp-customer-cockpit-summary {
padding: 18px;
border-right: 1px solid var(--vp-border);
@@ -9002,6 +9109,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-map-ops-board,
.vp-map-ops-readiness,
.vp-map-ops-work,
.vp-customer-service-command-main,
.vp-customer-service-command-grid,
.vp-customer-cockpit,
.vp-customer-cockpit-actions,
.vp-customer-vehicle-monitor,

View File

@@ -620,6 +620,98 @@ test('dashboard presents one vehicle service operating posture', async () => {
expect(screen.getByText('7 告警事件')).toBeInTheDocument();
});
test('dashboard prioritizes customer vehicle service command over data sources', 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,
amapSecurityServiceHost: '/_AMapService'
}
},
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: '客户车辆服务总控台 实时地图 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();
expect(screen.getByRole('button', { name: '客户车辆服务总控台 告警通知 7 告警 闭环告警' })).toBeInTheDocument();
expect(screen.getByText('来源证据GB32960 / JT808 / YUTONG_MQTT')).toBeInTheDocument();
});
test('dashboard exposes vehicle data center capability matrix', async () => {
window.history.replaceState(null, '', '/#/dashboard');
const writeText = vi.fn(() => Promise.resolve());