feat(platform): link quality issues to raw evidence
This commit is contained in:
@@ -395,7 +395,7 @@ export default function App() {
|
||||
detail: <VehicleDetail vin={activeVin} protocol={activeProtocol} onOpenRealtime={openRealtimeForVehicle} onOpenHistory={openHistoryForVehicle} onOpenRaw={openRawForVehicle} onOpenMileage={openMileageForVehicle} onOpenVehicles={openVehicles} onOpenQuality={openQuality} onQueryChange={updateVehicleDetailQuery} />,
|
||||
history: <History initialVin={analysisVin} initialProtocol={activeProtocol} initialTab={historyTab} initialFilters={historyFilters} onFiltersChange={updateHistoryFilters} onOpenVehicle={openVehicle} onOpenMileage={openMileageWithFilters} onOpenRaw={openRawWithFilters} />,
|
||||
mileage: <Mileage initialVin={analysisVin} initialProtocol={activeProtocol} initialFilters={mileageFilters} onFiltersChange={updateMileageFilters} onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} />,
|
||||
quality: <Quality onOpenVehicle={openVehicle} onOpenRealtime={openRealtime} onOpenHistory={openHistoryWithFilters} onOpenMileage={openMileageWithFilters} onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} />
|
||||
quality: <Quality onOpenVehicle={openVehicle} onOpenRealtime={openRealtime} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} onOpenMileage={openMileageWithFilters} onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} />
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -265,6 +265,7 @@ export function Quality({
|
||||
onOpenVehicle,
|
||||
onOpenRealtime,
|
||||
onOpenHistory,
|
||||
onOpenRaw,
|
||||
onOpenMileage,
|
||||
onHealthLoaded,
|
||||
onFiltersChange,
|
||||
@@ -273,6 +274,7 @@ export function Quality({
|
||||
onOpenVehicle: (vin: string, protocol?: string) => void;
|
||||
onOpenRealtime?: (filters: Record<string, string>) => void;
|
||||
onOpenHistory?: (filters: Record<string, string>) => void;
|
||||
onOpenRaw?: (filters: Record<string, string>) => void;
|
||||
onOpenMileage?: (filters: Record<string, string>) => void;
|
||||
onHealthLoaded?: (health: OpsHealth) => void;
|
||||
onFiltersChange?: (filters: Record<string, string>) => void;
|
||||
@@ -367,6 +369,18 @@ export function Quality({
|
||||
...(dateTo ? { dateTo } : {})
|
||||
});
|
||||
};
|
||||
const openIssueRaw = (row: QualityIssueRow) => {
|
||||
const lookup = qualityIssueVehicleLookup(row);
|
||||
const dateFrom = issueEvidenceDate(row.lastSeen);
|
||||
const dateTo = nextDate(dateFrom);
|
||||
onOpenRaw?.({
|
||||
keyword: lookup.key,
|
||||
protocol: row.protocol,
|
||||
...(dateFrom ? { dateFrom } : {}),
|
||||
...(dateTo ? { dateTo } : {}),
|
||||
includeFields: 'true'
|
||||
});
|
||||
};
|
||||
const openIssueRealtime = (row: QualityIssueRow) => {
|
||||
const lookup = qualityIssueVehicleLookup(row);
|
||||
onOpenRealtime?.({
|
||||
@@ -620,7 +634,7 @@ export function Quality({
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 410,
|
||||
width: 480,
|
||||
render: (_: unknown, row: QualityIssueRow) => {
|
||||
const lookup = qualityIssueVehicleLookup(row);
|
||||
return (
|
||||
@@ -629,6 +643,7 @@ export function Quality({
|
||||
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.sourceEndpoint, '来源')}>来源</Button>
|
||||
<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 || !onOpenRaw} onClick={() => openIssueRaw(row)}>核对 RAW</Button>
|
||||
<Button size="small" disabled={!lookup.key || !onOpenMileage} onClick={() => openIssueMileage(row)}>核对里程</Button>
|
||||
<Button size="small" disabled={!lookup.key} onClick={() => onOpenVehicle(lookup.key, row.protocol)}>
|
||||
{lookup.label}
|
||||
|
||||
@@ -2589,6 +2589,100 @@ test('opens same-day history evidence from quality issue row', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('opens same-day raw evidence from quality issue row', 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, redisOnlineKeys: 0, 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: 0,
|
||||
warningCount: 1,
|
||||
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-QUALITY-RAW',
|
||||
plate: '粤A告警RAW',
|
||||
phone: '',
|
||||
sourceEndpoint: '115.29.187.205:32960',
|
||||
protocol: 'GB32960',
|
||||
issueType: 'FIELD_MISSING',
|
||||
severity: 'warning',
|
||||
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('VIN-QUALITY-RAW')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '核对 RAW' }));
|
||||
|
||||
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-QUALITY-RAW');
|
||||
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('includeFields')).toBe('true');
|
||||
expect(params.get('tab')).toBe('raw');
|
||||
expect(await screen.findByRole('heading', { name: '轨迹回放' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens same-day mileage statistics from quality issue row', async () => {
|
||||
window.history.replaceState(null, '', '/#/quality');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user