feat(platform): link alert queue to trajectory evidence

This commit is contained in:
lingniu
2026-07-04 12:39:29 +08:00
parent 2e9d3fa5eb
commit a0f17f35c4
2 changed files with 95 additions and 1 deletions

View File

@@ -477,12 +477,13 @@ export function Quality({
{ title: '说明', dataIndex: 'detail' },
{
title: '操作',
width: 210,
width: 290,
render: (_: unknown, row: PriorityIssueRow) => {
const lookup = qualityIssueVehicleLookup(row);
return (
<Space spacing={4} wrap>
<Button size="small" disabled={!lookup.key || !onOpenRealtime} onClick={() => openIssueRealtime(row)}></Button>
<Button size="small" disabled={!lookup.key || !onOpenHistory} onClick={() => openIssueHistory(row)}></Button>
<Button size="small" disabled={!lookup.key} onClick={() => onOpenVehicle(lookup.key, row.protocol)}></Button>
</Space>
);

View File

@@ -2515,6 +2515,99 @@ test('opens realtime map context from quality priority queue', async () => {
expect(await screen.findByRole('heading', { name: '实时监控' })).toBeInTheDocument();
});
test('opens same-day trajectory evidence from quality priority queue', async () => {
window.history.replaceState(null, '', '/#/quality');
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: 120000, capacityFindings: [], redisOnlineKeys: 368, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/summary')) {
return {
ok: true,
json: async () => ({
data: {
issueVehicleCount: 1,
issueRecordCount: 1,
errorCount: 1,
warningCount: 0,
protocols: [{ name: 'GB32960', count: 1 }],
issueTypes: [{ name: 'FIELD_MISSING', count: 1 }]
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/issues')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-ALERT-TRACK',
plate: '粤A轨迹告警',
phone: '13307795425',
sourceEndpoint: '115.29.187.205:32960',
protocol: 'GB32960',
issueType: 'FIELD_MISSING',
severity: 'error',
lastSeen: '2026-07-03 20:12:10',
detail: 'GB32960 位置字段缺失,需要核对轨迹'
}],
total: 1,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/history/locations') || path.includes('/api/history/raw-frames')) {
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 10, offset: 0 },
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();
fireEvent.click(screen.getByRole('button', { name: '轨迹证据' }));
await waitFor(() => {
expect(window.location.hash.startsWith('#/history?')).toBe(true);
});
const params = new URLSearchParams(window.location.hash.slice('#/history?'.length));
expect(params.get('keyword')).toBe('VIN-ALERT-TRACK');
expect(params.get('protocol')).toBe('GB32960');
expect(params.get('dateFrom')).toBe('2026-07-03');
expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('tab')).toBeNull();
expect(await screen.findByRole('heading', { name: '轨迹回放' })).toBeInTheDocument();
});
test('opens vehicle service from quality issue with issue source evidence', async () => {
window.history.replaceState(null, '', '/#/quality');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {