feat(platform): add customer realtime command center

This commit is contained in:
lingniu
2026-07-05 19:49:30 +08:00
parent 30bc03a262
commit 6bfc08a841
3 changed files with 306 additions and 0 deletions

View File

@@ -9673,6 +9673,136 @@ test('shows canonical service status in realtime vehicles', async () => {
expect(screen.getAllByText('数据通道不完整').length).toBeGreaterThan(0);
});
test('realtime page prioritizes customer vehicle monitoring command center', async () => {
window.history.replaceState(null, '', '/#/realtime');
vi.setSystemTime(new Date('2026-07-03T20:15:00+08:00'));
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,
platformRelease: 'platform-realtime-command-test',
amapWebJsConfigured: true,
amapApiConfigured: true,
amapSecurityProxyEnabled: true,
amapSecurityCodeExposed: false,
amapSecurityServiceHost: '/_AMapService'
}
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/realtime/vehicles')) {
return {
ok: true,
json: async () => ({
data: {
items: [
{
vin: 'VIN-RT-CUSTOMER-001',
plate: '粤A实时1',
phone: '13300000001',
oem: 'G7s',
protocols: ['JT808', 'GB32960'],
sourceStatus: [
{ protocol: 'JT808', online: true, lastSeen: '2026-07-03 20:14:30', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
{ protocol: 'GB32960', online: true, lastSeen: '2026-07-03 20:14:25', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true }
],
sourceCount: 2,
onlineSourceCount: 2,
online: true,
primaryProtocol: 'JT808',
longitude: 113.2,
latitude: 23.1,
speedKmh: 36,
socPercent: 78,
totalMileageKm: 119925,
lastSeen: '2026-07-03 20:14:30',
bindingStatus: 'bound',
serviceStatus: {
status: 'healthy',
severity: 'ok',
title: '服务正常',
detail: '车辆实时服务正常',
sourceCount: 2,
onlineSourceCount: 2
}
},
{
vin: 'VIN-RT-CUSTOMER-002',
plate: '粤A实时2',
phone: '13300000002',
oem: 'G7s',
protocols: ['JT808'],
sourceStatus: [
{ protocol: 'JT808', online: true, lastSeen: '2026-07-03 19:40:00', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
{ protocol: 'GB32960', online: false, lastSeen: '', hasRealtime: false, hasHistory: false, hasRaw: false, hasMileage: false }
],
sourceCount: 2,
onlineSourceCount: 1,
online: true,
primaryProtocol: 'JT808',
longitude: 0,
latitude: 0,
speedKmh: 0,
socPercent: 0,
totalMileageKm: 8899,
lastSeen: '2026-07-03 19:40:00',
bindingStatus: 'bound',
serviceStatus: {
status: 'degraded',
severity: 'warning',
title: '来源不完整',
detail: '缺少 GB32960',
sourceCount: 2,
onlineSourceCount: 1
}
}
],
total: 2,
limit: 50,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 10, 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: '客户实时监控总控台 实时地图 1 有定位 打开地图' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户实时监控总控台 在线车辆 2 在线 只看在线' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户实时监控总控台 异常车辆 1 关注 关注异常' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户实时监控总控台 轨迹复盘 粤A实时1 轨迹回放' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户实时监控总控台 导出交付 2 当前页 导出CSV' })).toBeInTheDocument();
expect(screen.getByText('来源证据仅用于可信度判断JT808 / GB32960')).toBeInTheDocument();
});
test('frames realtime page as one vehicle service with source evidence', async () => {
window.history.replaceState(null, '', '/#/realtime');
const writeText = vi.fn(() => Promise.resolve());