feat(platform): guide mileage anomaly handling
This commit is contained in:
@@ -32,6 +32,21 @@ function canOpenVehicle(vin?: string) {
|
||||
return Boolean(value && value !== 'unknown');
|
||||
}
|
||||
|
||||
function mileageActionRecommendation(row: DailyMileageRow) {
|
||||
if (row.anomalySeverity) {
|
||||
return {
|
||||
label: '核对里程来源',
|
||||
color: 'orange' as const,
|
||||
detail: '日里程异常,优先核对当天首末总里程、来源断链和补传数据。'
|
||||
};
|
||||
}
|
||||
return {
|
||||
label: '可用于日报统计',
|
||||
color: 'green' as const,
|
||||
detail: '该日里程未发现异常,可进入车辆服务查看来源证据。'
|
||||
};
|
||||
}
|
||||
|
||||
function mergeInitialFilters(initialVin: string, initialProtocol?: string, initialFilters: Record<string, string> = {}) {
|
||||
return {
|
||||
keyword: initialVin,
|
||||
@@ -188,6 +203,19 @@ export function Mileage({
|
||||
{ title: '日里程', dataIndex: 'dailyMileageKm' },
|
||||
{ title: '来源', dataIndex: 'source' },
|
||||
{ title: '异常', render: (_: unknown, row: DailyMileageRow) => row.anomalySeverity ? <Tag color="orange">{row.anomalySeverity}</Tag> : <Tag color="green">正常</Tag> },
|
||||
{
|
||||
title: '处置建议',
|
||||
width: 260,
|
||||
render: (_: unknown, row: DailyMileageRow) => {
|
||||
const action = mileageActionRecommendation(row);
|
||||
return (
|
||||
<div>
|
||||
<Tag color={action.color}>{action.label}</Tag>
|
||||
<div style={{ marginTop: 6 }}>{action.detail}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
|
||||
@@ -3235,6 +3235,71 @@ test('opens vehicle service from mileage row with row source evidence', async ()
|
||||
});
|
||||
});
|
||||
|
||||
test('shows mileage anomaly action guidance', async () => {
|
||||
window.history.replaceState(null, '', '/#/mileage?keyword=VIN-MILEAGE-ANOMALY&protocol=GB32960');
|
||||
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/mileage/summary')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { vehicleCount: 1, recordCount: 1, sourceCount: 1, totalMileageKm: -3.2, averageMileagePerVin: -3.2 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/mileage/daily')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [{
|
||||
vin: 'VIN-MILEAGE-ANOMALY',
|
||||
plate: '粤A异常1',
|
||||
source: 'GB32960',
|
||||
date: '2026-07-03',
|
||||
startMileageKm: 100,
|
||||
endMileageKm: 96.8,
|
||||
dailyMileageKm: -3.2,
|
||||
anomalySeverity: 'warning'
|
||||
}],
|
||||
total: 1,
|
||||
limit: 20,
|
||||
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-MILEAGE-ANOMALY')).toBeInTheDocument();
|
||||
expect(screen.getByText('核对里程来源')).toBeInTheDocument();
|
||||
expect(screen.getByText('日里程异常,优先核对当天首末总里程、来源断链和补传数据。')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens vehicle service from history results with row source evidence', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=%E7%B2%A4AG18312&protocol=JT808');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
|
||||
|
||||
Reference in New Issue
Block a user