feat(platform): expose missing source diagnosis
This commit is contained in:
@@ -106,6 +106,7 @@ export interface VehicleSourceConsistency {
|
||||
sourceCount: number;
|
||||
onlineSourceCount: number;
|
||||
locatedSourceCount: number;
|
||||
missingProtocols: string[];
|
||||
mileageDeltaKm: number;
|
||||
sourceTimeDeltaSeconds: number;
|
||||
scope: string;
|
||||
|
||||
@@ -156,6 +156,12 @@ export function VehicleDetail({
|
||||
const consistencyTimeDeltaSeconds = consistency?.sourceTimeDeltaSeconds ?? sourceTimeDeltaSeconds;
|
||||
const consistencyTitle = consistency?.title ?? '-';
|
||||
const consistencyDetail = consistency?.detail ?? '-';
|
||||
const missingProtocols = consistency?.missingProtocols ?? [];
|
||||
const missingProtocolText = missingProtocols.length > 0 ? (
|
||||
<Space spacing={4}>
|
||||
{missingProtocols.map((item) => <Tag key={item} color="orange">{item}</Tag>)}
|
||||
</Space>
|
||||
) : '-';
|
||||
const evidenceSourceCount = overview?.sourceCount ?? consistencySourceCount;
|
||||
const evidenceOnlineSourceCount = overview?.onlineSourceCount ?? consistencyOnlineSourceCount;
|
||||
const evidenceLocatedSourceCount = consistencyLocatedSourceCount;
|
||||
@@ -393,6 +399,7 @@ export function VehicleDetail({
|
||||
{ key: '一致性结论', value: consistencyTitle },
|
||||
{ key: '来源覆盖', value: consistencySourceCount > 0 ? `${consistencySourceCount} 个来源` : '-' },
|
||||
{ key: '在线来源', value: consistencySourceCount > 0 ? `${consistencyOnlineSourceCount}/${consistencySourceCount} 在线` : '-' },
|
||||
{ key: '缺失来源', value: missingProtocolText },
|
||||
{ key: '位置覆盖', value: consistencyLocatedSourceCount > 0 ? `${consistencyLocatedSourceCount} 个来源有位置` : '暂无位置' },
|
||||
{ key: '里程差异', value: formatCompactNumber(consistencyMileageDelta, ' km') },
|
||||
{ key: '来源时间差', value: formatSeconds(consistencyTimeDeltaSeconds) },
|
||||
|
||||
@@ -2607,13 +2607,14 @@ test('shows cross-source consistency for one vehicle service', async () => {
|
||||
sourceCount: 3,
|
||||
onlineSourceCount: 2,
|
||||
locatedSourceCount: 3,
|
||||
missingProtocols: ['YUTONG_MQTT'],
|
||||
mileageDeltaKm: 0.4,
|
||||
sourceTimeDeltaSeconds: 35,
|
||||
scope: 'all_sources',
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '部分来源离线',
|
||||
detail: '2/3 个来源在线,车辆服务可用但需要关注离线来源。'
|
||||
title: '来源不完整',
|
||||
detail: '2/3 个来源在线,车辆服务可用但缺少 YUTONG_MQTT 来源。'
|
||||
},
|
||||
sources: ['GB32960', 'JT808', 'YUTONG_MQTT'],
|
||||
sourceStatus: [
|
||||
@@ -2651,10 +2652,11 @@ test('shows cross-source consistency for one vehicle service', async () => {
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('跨来源一致性')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('部分来源离线').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('2/3 个来源在线,车辆服务可用但需要关注离线来源。').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('来源不完整').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('2/3 个来源在线,车辆服务可用但缺少 YUTONG_MQTT 来源。').length).toBeGreaterThan(0);
|
||||
expect(screen.getByText('3 个来源')).toBeInTheDocument();
|
||||
expect(screen.getByText('2/3 在线')).toBeInTheDocument();
|
||||
expect(screen.getByText('缺失来源')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('3 个来源有位置').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('0.4 km').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('35 秒').length).toBeGreaterThan(0);
|
||||
|
||||
Reference in New Issue
Block a user