feat(platform): frame realtime sources as evidence

This commit is contained in:
lingniu
2026-07-06 01:49:55 +08:00
parent 442afb8aa5
commit 06904748cc
2 changed files with 74 additions and 9 deletions

View File

@@ -2689,7 +2689,7 @@ export function Realtime({
applyFilters(nextFilters);
}} style={{ marginBottom: 12 }}>
<Form.Input field="keyword" label="车辆关键词" placeholder="VIN / 车牌 / 手机号 / OEM" style={{ width: 260 }} />
<Form.Select field="protocol" label="数据通道" placeholder="全部数据通道" style={{ width: 180 }}>
<Form.Select field="protocol" label="来源证据筛选" placeholder="全部来源证据" style={{ width: 180 }}>
<Select.Option value="GB32960">GB32960</Select.Option>
<Select.Option value="JT808">JT808</Select.Option>
<Select.Option value="YUTONG_MQTT">YUTONG_MQTT</Select.Option>
@@ -2743,7 +2743,7 @@ export function Realtime({
{ label: '定位有效', value: locatedCount, color: locatedCount > 0 ? 'blue' as const : 'orange' as const },
{ label: '需要关注', value: degradedCount, color: degradedCount > 0 ? 'orange' as const : 'green' as const, action: () => applyFilters({ ...filters, serviceStatus: 'degraded' }) },
{ label: '更新超时', value: staleCount, color: staleCount > 0 ? 'red' as const : 'green' as const },
{ label: '数据通道', value: primaryProtocols.size, color: 'blue' as const }
{ label: '来源证据', value: primaryProtocols.size, color: 'blue' as const }
].map((item) => (
item.action ? (
<button
@@ -2783,7 +2783,7 @@ export function Realtime({
</div>
</div>
<div className="vp-source-coverage-board">
<div className="vp-current-service-title"></div>
<div className="vp-current-service-title"></div>
<div className="vp-source-coverage-grid">
{sourceCoverageRows.length === 0 ? (
<Typography.Text type="tertiary"></Typography.Text>
@@ -2792,7 +2792,7 @@ export function Realtime({
key={item.protocol}
type="button"
className="vp-source-coverage-item"
aria-label={`筛选数据通道 ${item.protocol}`}
aria-label={`筛选来源证据 ${item.protocol}`}
onClick={() => applyFilters({ ...filters, protocol: item.protocol })}
>
<div className="vp-source-coverage-item-head">

View File

@@ -10430,6 +10430,71 @@ test('realtime page prioritizes customer vehicle monitoring command center', asy
expect(screen.getByRole('button', { name: '实时处置优先级 1 粤A实时2 查看告警' })).toBeInTheDocument();
});
test('realtime page treats protocol filters as source evidence for vehicle service', async () => {
window.history.replaceState(null, '', '/#/realtime');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/realtime/vehicles')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-RT-EVIDENCE',
plate: '粤A证据1',
protocols: ['GB32960', 'JT808'],
sourceStatus: [
{ protocol: 'GB32960', online: true, lastSeen: '2026-07-03 20:12:10', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true },
{ protocol: 'JT808', online: true, lastSeen: '2026-07-03 20:12:08', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: true }
],
sourceCount: 2,
onlineSourceCount: 2,
online: true,
primaryProtocol: 'GB32960',
longitude: 113.2,
latitude: 23.1,
speedKmh: 30,
socPercent: 78,
totalMileageKm: 119925,
lastSeen: '2026-07-03 20:12:10',
bindingStatus: 'bound',
serviceStatus: {
status: 'healthy',
severity: 'ok',
title: '服务正常',
detail: '2/2 来源在线',
sourceCount: 2,
onlineSourceCount: 2
}
}],
total: 1,
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.findByRole('heading', { name: '实时监控' })).toBeInTheDocument();
expect(screen.getByText('来源证据筛选')).toBeInTheDocument();
expect(screen.getByText('全部来源证据')).toBeInTheDocument();
expect(screen.getByText('车辆来源证据覆盖')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选来源证据 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());
@@ -11077,10 +11142,10 @@ test('copies realtime operations summary from realtime page', async () => {
expect(screen.getByRole('button', { name: '实时筛选 需要关注 2' })).toBeInTheDocument();
expect(screen.getByText('建议处置')).toBeInTheDocument();
expect(screen.getByText('查看需关注车辆 2')).toBeInTheDocument();
expect(screen.getByText('车辆覆盖概览')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选数据通道 GB32960' })).toHaveTextContent('GB32960');
expect(screen.getByRole('button', { name: '筛选数据通道 JT808' })).toHaveTextContent('2 辆');
expect(screen.getByRole('button', { name: '筛选数据通道 YUTONG_MQTT' })).toHaveTextContent('超时 1');
expect(screen.getByText('车辆来源证据覆盖')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '筛选来源证据 GB32960' })).toHaveTextContent('GB32960');
expect(screen.getByRole('button', { name: '筛选来源证据 JT808' })).toHaveTextContent('2 辆');
expect(screen.getByRole('button', { name: '筛选来源证据 YUTONG_MQTT' })).toHaveTextContent('超时 1');
expect(screen.getByText('实时覆盖判读')).toBeInTheDocument();
expect(screen.getByText('在线率')).toBeInTheDocument();
expect(screen.getAllByText('66.7%').length).toBeGreaterThanOrEqual(3);
@@ -11122,7 +11187,7 @@ test('copies realtime operations summary from realtime page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史查询http://localhost:3000/api/history/raw-frames?protocol=JT808&vin=VIN-RT-SUMMARY-003&limit=20&includeFields=true'));
fireEvent.click(screen.getByRole('button', { name: '实时筛选 需要关注 2' }));
expect(window.location.hash).toBe('#/realtime?protocol=JT808&serviceStatus=degraded&online=online');
fireEvent.click(screen.getByRole('button', { name: '筛选数据通道 GB32960' }));
fireEvent.click(screen.getByRole('button', { name: '筛选来源证据 GB32960' }));
expect(window.location.hash).toBe('#/realtime?protocol=GB32960&serviceStatus=degraded&online=online');
});