feat(platform): customerize history export workflow

This commit is contained in:
lingniu
2026-07-05 00:39:24 +08:00
parent 74ccddb1a7
commit 9a428198b4
2 changed files with 71 additions and 71 deletions

View File

@@ -199,11 +199,11 @@ const rawExportColumns: CsvColumn<RawFrameRow>[] = [
{ title: '大小B', value: (row) => row.rawSizeBytes }, { title: '大小B', value: (row) => row.rawSizeBytes },
{ title: '设备时间', value: (row) => row.deviceTime }, { title: '设备时间', value: (row) => row.deviceTime },
{ title: '入库时间', value: (row) => row.serverTime }, { title: '入库时间', value: (row) => row.serverTime },
{ title: '解析字段', value: (row) => row.parsedFields ?? {} } { title: '字段明细', value: (row) => row.parsedFields ?? {} }
]; ];
const rawFieldExportColumns: CsvColumn<RawFieldRow>[] = [ const rawFieldExportColumns: CsvColumn<RawFieldRow>[] = [
{ title: 'RAW ID', value: (row) => row.rawId }, { title: '原始记录ID', value: (row) => row.rawId },
{ title: 'VIN', value: (row) => row.vin }, { title: 'VIN', value: (row) => row.vin },
{ title: '车牌', value: (row) => row.plate }, { title: '车牌', value: (row) => row.plate },
{ title: '数据来源', value: (row) => row.protocol }, { title: '数据来源', value: (row) => row.protocol },
@@ -316,20 +316,20 @@ function historyEvidencePackageText({
...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {}) ...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {})
}; };
return [ return [
'【历史证据包】', '【数据复核包】',
`车辆:${vehicle || '全部车辆'}`, `车辆:${vehicle || '全部车辆'}`,
`数据来源:${protocol || '全部来源'}`, `数据来源:${protocol || '全部来源'}`,
`查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`, `查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`,
`位置记录:${locationCount.toLocaleString()},有效定位:${validPointCount.toLocaleString()}`, `位置记录:${locationCount.toLocaleString()},有效定位:${validPointCount.toLocaleString()}`,
`RAW帧${rawCount.toLocaleString()}解析字段:${fieldCount.toLocaleString()}`, `原始记录${rawCount.toLocaleString()},字段明细${fieldCount.toLocaleString()}`,
`区间里程:${formatNumber(mileageDelta, ' km')},最高速度:${formatNumber(maxSpeed, ' km/h')}`, `区间里程:${formatNumber(mileageDelta, ' km')},最高速度:${formatNumber(maxSpeed, ' km/h')}`,
`起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`, `起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`,
`终点:${lastLocation?.deviceTime || lastLocation?.serverTime || '-'}`, `终点:${lastLocation?.deviceTime || lastLocation?.serverTime || '-'}`,
`异常:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`, `异常:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`,
`轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`,
`历史位置:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`, `历史位置:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`,
`RAW证据${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`, `原始记录${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`,
`解析字段:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`, `字段明细${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`,
`里程复核:${appURL(buildAppHash({ page: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `里程复核:${appURL(buildAppHash({ page: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`,
`车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}`
].join('\n'); ].join('\n');
@@ -379,14 +379,14 @@ function trajectoryReviewPackageText({
...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {}) ...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {})
}; };
const anomalyAction = anomalySummary.gapCount > 0 || anomalySummary.mileageRollbackCount > 0 || anomalySummary.overspeedCount > 0 const anomalyAction = anomalySummary.gapCount > 0 || anomalySummary.mileageRollbackCount > 0 || anomalySummary.overspeedCount > 0
? '建议核对 RAW 帧、解析字段、当日里程统计,并确认平台是否存在断链或补发。' ? '建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。'
: '当前页未发现明显断点、里程回退或速度异常,可作为轨迹证据使用。'; : '当前页未发现明显断点、里程回退或速度异常,可作为轨迹证据使用。';
return [ return [
'【轨迹复盘交接包】', '【轨迹复盘交接包】',
`车辆:${vehicle || '全部车辆'}`, `车辆:${vehicle || '全部车辆'}`,
`数据来源:${protocol || '全部来源'}`, `数据来源:${protocol || '全部来源'}`,
`查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`, `查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`,
`轨迹规模:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / RAW ${rawCount.toLocaleString()} / 解析字段 ${fieldCount.toLocaleString()}`, `轨迹规模:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / 原始记录 ${rawCount.toLocaleString()} / 字段明细 ${fieldCount.toLocaleString()}`,
`轨迹质量:定位覆盖率 ${formatPercent(coverageRate)} / 回放跨度 ${formatDurationMinutes(playbackSpanMinutes)} / 采样间隔 ${formatDurationMinutes(playbackIntervalMinutes, '/点')}`, `轨迹质量:定位覆盖率 ${formatPercent(coverageRate)} / 回放跨度 ${formatDurationMinutes(playbackSpanMinutes)} / 采样间隔 ${formatDurationMinutes(playbackIntervalMinutes, '/点')}`,
`里程速度:区间里程 ${formatNumber(mileageDelta, ' km')} / 最高速度 ${formatNumber(maxSpeed, ' km/h')}`, `里程速度:区间里程 ${formatNumber(mileageDelta, ' km')} / 最高速度 ${formatNumber(maxSpeed, ' km/h')}`,
`起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`, `起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`,
@@ -400,8 +400,8 @@ function trajectoryReviewPackageText({
`下一步:${anomalyAction}`, `下一步:${anomalyAction}`,
`轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`,
`历史位置:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`, `历史位置:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`,
`RAW证据${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`, `原始记录${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`,
`解析字段:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`, `字段明细${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`,
`里程复核:${appURL(buildAppHash({ page: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `里程复核:${appURL(buildAppHash({ page: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`,
`车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}`
].join('\n'); ].join('\n');
@@ -448,15 +448,15 @@ function trajectoryImpactPackageText({
`数据来源:${protocol || '全部来源'}`, `数据来源:${protocol || '全部来源'}`,
`查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`, `查询范围:${filters.dateFrom?.trim() || '-'}${filters.dateTo?.trim() || '-'}`,
`业务状态:${operationState}`, `业务状态:${operationState}`,
`轨迹范围:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / RAW ${rawCount.toLocaleString()} / 字段 ${fieldCount.toLocaleString()}`, `轨迹范围:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / 原始记录 ${rawCount.toLocaleString()} / 字段明细 ${fieldCount.toLocaleString()}`,
`定位覆盖率:${formatPercent(coverageRate)}`, `定位覆盖率:${formatPercent(coverageRate)}`,
`回放跨度:${formatDurationMinutes(playbackSpanMinutes)},采样间隔:${formatDurationMinutes(playbackIntervalMinutes, '/点')}`, `回放跨度:${formatDurationMinutes(playbackSpanMinutes)},采样间隔:${formatDurationMinutes(playbackIntervalMinutes, '/点')}`,
`里程速度:${formatNumber(mileageDelta, ' km')} / ${formatNumber(maxSpeed, ' km/h')}`, `里程速度:${formatNumber(mileageDelta, ' km')} / ${formatNumber(maxSpeed, ' km/h')}`,
`异常影响:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`, `异常影响:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`,
`地图能力:${amapConfigured ? '高德 JS API 已配置' : '高德 JS API 待配置'}`, `地图能力:${amapConfigured ? '高德 JS API 已配置' : '高德 JS API 待配置'}`,
`轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`,
`历史查询${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`, `数据导出${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'location' } }))}`,
`RAW证据${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`, `原始记录${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`,
`车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}`
].join('\n'); ].join('\n');
} }
@@ -576,7 +576,7 @@ export function History({
if ((forceIncludeFields || isIncludeFieldsEnabled(nextFilters.includeFields)) && shouldBlockRawFieldQuery(nextFilters)) { if ((forceIncludeFields || isIncludeFieldsEnabled(nextFilters.includeFields)) && shouldBlockRawFieldQuery(nextFilters)) {
setRawFrames({ items: [], total: 0, limit: pageSize, offset: (page - 1) * pageSize }); setRawFrames({ items: [], total: 0, limit: pageSize, offset: (page - 1) * pageSize });
setRawPagination({ currentPage: page, pageSize }); setRawPagination({ currentPage: page, pageSize });
Toast.warning('RAW 解析字段查询需要车辆、时间范围或字段裁剪'); Toast.warning('字段明细查询需要车辆、时间范围或字段裁剪');
return; return;
} }
setLoadingRaw(true); setLoadingRaw(true);
@@ -669,13 +669,13 @@ export function History({
const hasTrajectoryAnomaly = trajectoryAnomalies.gapCount > 0 || trajectoryAnomalies.mileageRollbackCount > 0 || trajectoryAnomalies.overspeedCount > 0; const hasTrajectoryAnomaly = trajectoryAnomalies.gapCount > 0 || trajectoryAnomalies.mileageRollbackCount > 0 || trajectoryAnomalies.overspeedCount > 0;
const currentVehicleKeyword = filters.keyword?.trim() ?? ''; const currentVehicleKeyword = filters.keyword?.trim() ?? '';
const currentProtocol = filters.protocol?.trim() ?? ''; const currentProtocol = filters.protocol?.trim() ?? '';
const pageTitle = mode === 'query' ? '历史查询' : '轨迹回放'; const pageTitle = mode === 'query' ? '数据导出' : '轨迹回放';
const pageDescription = mode === 'query' const pageDescription = mode === 'query'
? '按车辆查询历史位置、RAW 帧和扁平解析字段,支持分页、字段裁剪和证据导出' ? '按车辆、时间和数据通道导出位置记录、原始记录和字段明细,支持分页、字段裁剪和 CSV 导出'
: '按车辆查询历史位置轨迹回放和 RAW 帧证据,数据来源只作为过滤和诊断维度'; : '按车辆查询历史位置轨迹回放,原始记录只作为复核证据,数据来源仅用于过滤';
const scopeDescription = mode === 'query' const scopeDescription = mode === 'query'
? '历史位置、RAW 帧和解析字段按当前车辆与来源范围分页查询。' ? '位置记录、原始记录和字段明细按当前车辆与时间范围分页查询。'
: '历史位置和 RAW 帧按当前车辆与来源范围查询。'; : '历史位置和原始记录按当前车辆与时间范围查询。';
const amapConfigured = isAMapConfigured(); const amapConfigured = isAMapConfigured();
const selectedFieldCount = splitFields(filters.fields).length; const selectedFieldCount = splitFields(filters.fields).length;
const playbackRows = validLocations.length > 0 ? validLocations : locationItems; const playbackRows = validLocations.length > 0 ? validLocations : locationItems;
@@ -697,7 +697,7 @@ export function History({
currentProtocol ? `数据来源:${currentProtocol}` : '', currentProtocol ? `数据来源:${currentProtocol}` : '',
filters.dateFrom?.trim() ? `开始时间:${filters.dateFrom.trim()}` : '', filters.dateFrom?.trim() ? `开始时间:${filters.dateFrom.trim()}` : '',
filters.dateTo?.trim() ? `结束时间:${filters.dateTo.trim()}` : '', filters.dateTo?.trim() ? `结束时间:${filters.dateTo.trim()}` : '',
isIncludeFieldsEnabled(filters.includeFields) ? '返回解析字段' : '', isIncludeFieldsEnabled(filters.includeFields) ? '返回字段明细' : '',
selectedFieldCount > 0 ? `字段裁剪:${selectedFieldCount}` : '' selectedFieldCount > 0 ? `字段裁剪:${selectedFieldCount}` : ''
].filter(Boolean); ].filter(Boolean);
const clearRangeFilters = () => { const clearRangeFilters = () => {
@@ -713,19 +713,19 @@ export function History({
}; };
const exportRawFrames = () => { const exportRawFrames = () => {
if (rawFrames.items.length === 0) { if (rawFrames.items.length === 0) {
Toast.warning('当前没有可导出的 RAW 帧'); Toast.warning('当前没有可导出的原始记录');
return; return;
} }
downloadCsv(exportFileName('raw-frames', filters), buildCsv(rawExportColumns, rawFrames.items)); downloadCsv(exportFileName('raw-frames', filters), buildCsv(rawExportColumns, rawFrames.items));
Toast.success(`已导出 ${rawFrames.items.length} RAW 帧`); Toast.success(`已导出 ${rawFrames.items.length}原始记录`);
}; };
const exportRawFields = () => { const exportRawFields = () => {
if (rawFieldRows.length === 0) { if (rawFieldRows.length === 0) {
Toast.warning('当前没有可导出的解析字段'); Toast.warning('当前没有可导出的字段明细');
return; return;
} }
downloadCsv(exportFileName('raw-fields', filters), buildCsv(rawFieldExportColumns, rawFieldRows)); downloadCsv(exportFileName('raw-fields', filters), buildCsv(rawFieldExportColumns, rawFieldRows));
Toast.success(`已导出 ${rawFieldRows.length}解析字段`); Toast.success(`已导出 ${rawFieldRows.length} 条字段明细`);
}; };
const copyTrajectorySummary = () => { const copyTrajectorySummary = () => {
copyText( copyText(
@@ -755,7 +755,7 @@ export function History({
lastLocation, lastLocation,
anomalySummary: trajectoryAnomalies anomalySummary: trajectoryAnomalies
}), }),
'历史证据包' '数据复核包'
); );
}; };
const copyTrajectoryReviewPackage = () => { const copyTrajectoryReviewPackage = () => {
@@ -911,7 +911,7 @@ export function History({
description={pageDescription} description={pageDescription}
actions={( actions={(
<Space> <Space>
<Button icon={<IconCopy />} onClick={copyHistoryEvidencePackage}></Button> <Button icon={<IconCopy />} onClick={copyHistoryEvidencePackage}></Button>
<Button disabled={!currentVehicleKeyword} onClick={() => onOpenVehicle(currentVehicleKeyword, currentProtocol)}> <Button disabled={!currentVehicleKeyword} onClick={() => onOpenVehicle(currentVehicleKeyword, currentProtocol)}>
</Button> </Button>
@@ -934,7 +934,7 @@ export function History({
<Form.Input field="dateFrom" label="开始时间" placeholder="2026-07-03 00:00:00" style={{ width: 210 }} /> <Form.Input field="dateFrom" label="开始时间" placeholder="2026-07-03 00:00:00" style={{ width: 210 }} />
<Form.Input field="dateTo" label="结束时间" placeholder="2026-07-03 23:59:59" style={{ width: 210 }} /> <Form.Input field="dateTo" label="结束时间" placeholder="2026-07-03 23:59:59" style={{ width: 210 }} />
<Form.Checkbox field="includeFields" noLabel> <Form.Checkbox field="includeFields" noLabel>
</Form.Checkbox> </Form.Checkbox>
<Form.TextArea <Form.TextArea
field="fields" field="fields"
@@ -970,7 +970,7 @@ export function History({
</Space> </Space>
<Typography.Text strong>{currentVehicleKeyword || '全部车辆'}</Typography.Text> <Typography.Text strong>{currentVehicleKeyword || '全部车辆'}</Typography.Text>
<Typography.Text type="secondary"> <Typography.Text type="secondary">
RAW
</Typography.Text> </Typography.Text>
<Space wrap> <Space wrap>
<Button size="small" icon={<IconCopy />} onClick={copyTrajectoryImpactPackage}></Button> <Button size="small" icon={<IconCopy />} onClick={copyTrajectoryImpactPackage}></Button>
@@ -999,9 +999,9 @@ export function History({
color: hasTrajectoryAnomaly ? 'orange' as const : 'green' as const color: hasTrajectoryAnomaly ? 'orange' as const : 'green' as const
}, },
{ {
label: 'RAW证据', label: '原始记录',
value: `${(rawFrames.total ?? 0).toLocaleString()}`, value: `${(rawFrames.total ?? 0).toLocaleString()}`,
detail: rawFieldRows.length > 0 ? `${rawFieldRows.length.toLocaleString()}解析字段可直接导出。` : '可切换 RAW 帧并请求解析字段。', detail: rawFieldRows.length > 0 ? `${rawFieldRows.length.toLocaleString()} 个字段明细可直接导出。` : '可切换原始记录并请求字段明细。',
color: (rawFrames.total ?? 0) > 0 ? 'blue' as const : 'grey' as const color: (rawFrames.total ?? 0) > 0 ? 'blue' as const : 'grey' as const
}, },
{ {
@@ -1026,7 +1026,7 @@ export function History({
<Space> <Space>
<span></span> <span></span>
<Button size="small" theme="light" icon={<IconCopy />} onClick={copyTrajectorySummary}></Button> <Button size="small" theme="light" icon={<IconCopy />} onClick={copyTrajectorySummary}></Button>
<Button size="small" theme="light" icon={<IconCopy />} onClick={copyHistoryEvidencePackage}></Button> <Button size="small" theme="light" icon={<IconCopy />} onClick={copyHistoryEvidencePackage}></Button>
<Button size="small" theme="light" icon={<IconCopy />} onClick={copyTrajectoryReviewPackage}></Button> <Button size="small" theme="light" icon={<IconCopy />} onClick={copyTrajectoryReviewPackage}></Button>
<Button size="small" theme="light" disabled={validLocations.length === 0} onClick={openAmapTrajectory}>线</Button> <Button size="small" theme="light" disabled={validLocations.length === 0} onClick={openAmapTrajectory}>线</Button>
</Space> </Space>
@@ -1209,9 +1209,9 @@ export function History({
))} ))}
</div> </div>
<div className="vp-trajectory-anomaly-action"> <div className="vp-trajectory-anomaly-action">
<Tag color={hasTrajectoryAnomaly ? 'orange' : 'green'}>{hasTrajectoryAnomaly ? '建议核对 RAW 帧和当日里程统计' : '轨迹质量可用'}</Tag> <Tag color={hasTrajectoryAnomaly ? 'orange' : 'green'}>{hasTrajectoryAnomaly ? '建议核对原始记录和当日里程统计' : '轨迹质量可用'}</Tag>
<Typography.Text type="secondary"> <Typography.Text type="secondary">
{hasTrajectoryAnomaly ? '异常点会影响轨迹回放、定位复盘和区间里程判断,请结合 RAW 解析字段与里程统计交叉确认。' : '当前页轨迹未发现明显断点、里程回退或速度异常。'} {hasTrajectoryAnomaly ? '异常点会影响轨迹回放、定位复盘和区间里程判断,请结合字段明细与里程统计交叉确认。' : '当前页轨迹未发现明显断点、里程回退或速度异常。'}
</Typography.Text> </Typography.Text>
</div> </div>
</Card> </Card>
@@ -1258,21 +1258,21 @@ export function History({
<Space wrap> <Space wrap>
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}></Button> <Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}></Button>
<Button disabled={!canOpenVehicle(row.vin) || !onOpenMileage} onClick={() => openLocationMileage(row)}></Button> <Button disabled={!canOpenVehicle(row.vin) || !onOpenMileage} onClick={() => openLocationMileage(row)}></Button>
<Button disabled={!canOpenVehicle(row.vin) || !onOpenRaw} onClick={() => openLocationRaw(row)}> RAW</Button> <Button disabled={!canOpenVehicle(row.vin) || !onOpenRaw} onClick={() => openLocationRaw(row)}></Button>
</Space> </Space>
) )
} }
]} ]}
/> />
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane tab="RAW 帧" itemKey="raw"> <Tabs.TabPane tab="原始记录" itemKey="raw">
<div className="vp-table-toolbar"> <div className="vp-table-toolbar">
<Space wrap> <Space wrap>
<Tag color="blue"> {rawFrames.items.length.toLocaleString()} </Tag> <Tag color="blue"> {rawFrames.items.length.toLocaleString()} </Tag>
<Tag color={isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? 'green' : 'orange'}> <Tag color={isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? 'green' : 'orange'}>
{isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? '包含解析字段' : '未请求解析字段'} {isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? '包含字段明细' : '未请求字段明细'}
</Tag> </Tag>
<Button size="small" onClick={exportRawFrames}> RAW CSV</Button> <Button size="small" onClick={exportRawFrames}> CSV</Button>
</Space> </Space>
</div> </div>
<Table <Table
@@ -1310,13 +1310,13 @@ export function History({
]} ]}
/> />
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane tab="解析字段" itemKey="fields"> <Tabs.TabPane tab="字段明细" itemKey="fields">
<div className="vp-table-toolbar"> <div className="vp-table-toolbar">
<Space wrap> <Space wrap>
<Tag color="green"> {rawFieldRows.length.toLocaleString()} </Tag> <Tag color="green"> {rawFieldRows.length.toLocaleString()} </Tag>
<Tag color="blue">{rawFrames.items.length.toLocaleString()} RAW </Tag> <Tag color="blue">{rawFrames.items.length.toLocaleString()} </Tag>
{selectedFieldCount > 0 ? <Tag color="blue"> {selectedFieldCount.toLocaleString()} </Tag> : <Tag color="grey"></Tag>} {selectedFieldCount > 0 ? <Tag color="blue"> {selectedFieldCount.toLocaleString()} </Tag> : <Tag color="grey"></Tag>}
<Button size="small" onClick={exportRawFields}> CSV</Button> <Button size="small" onClick={exportRawFields}> CSV</Button>
</Space> </Space>
</div> </div>
<Table <Table
@@ -1338,7 +1338,7 @@ export function History({
{ title: '数据来源', dataIndex: 'protocol', width: 120 }, { title: '数据来源', dataIndex: 'protocol', width: 120 },
{ title: '帧类型', dataIndex: 'frameType', width: 190 }, { title: '帧类型', dataIndex: 'frameType', width: 190 },
{ title: '设备时间', dataIndex: 'deviceTime', width: 190 }, { title: '设备时间', dataIndex: 'deviceTime', width: 190 },
{ title: 'RAW ID', dataIndex: 'rawId', width: 260 }, { title: '原始记录ID', dataIndex: 'rawId', width: 260 },
{ {
title: '操作', title: '操作',
width: 170, width: 170,
@@ -1351,19 +1351,19 @@ export function History({
]} ]}
/> />
<Space wrap style={{ marginTop: 12 }}> <Space wrap style={{ marginTop: 12 }}>
<Tag color="grey">沿 RAW </Tag> <Tag color="grey">沿</Tag>
<Tag color="grey"> parsedFields</Tag> <Tag color="grey"> parsedFields</Tag>
</Space> </Space>
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs>
</Card> </Card>
<SideSheet title="RAW 解析字段" visible={Boolean(selectedRaw)} onCancel={() => setSelectedRaw(null)} width={720}> <SideSheet title="原始记录字段明细" visible={Boolean(selectedRaw)} onCancel={() => setSelectedRaw(null)} width={720}>
<Space vertical align="start" spacing={12} style={{ width: '100%' }}> <Space vertical align="start" spacing={12} style={{ width: '100%' }}>
<Typography.Text type="tertiary"> <Typography.Text type="tertiary">
{selectedRaw?.protocol ?? '-'} / {selectedRaw?.plate || selectedRaw?.vin || '-'} / {rawFieldCount} {selectedRaw?.protocol ?? '-'} / {selectedRaw?.plate || selectedRaw?.vin || '-'} / {rawFieldCount}
</Typography.Text> </Typography.Text>
{rawFieldCount === 0 ? ( {rawFieldCount === 0 ? (
<Typography.Text type="secondary"></Typography.Text> <Typography.Text type="secondary"></Typography.Text>
) : null} ) : null}
</Space> </Space>
<pre className="vp-json">{JSON.stringify(selectedRaw?.parsedFields ?? {}, null, 2)}</pre> <pre className="vp-json">{JSON.stringify(selectedRaw?.parsedFields ?? {}, null, 2)}</pre>

View File

@@ -200,7 +200,7 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
fireEvent.click(screen.getByRole('button', { name: '顶部数据导出' })); fireEvent.click(screen.getByRole('button', { name: '顶部数据导出' }));
expect(window.location.hash.startsWith('#/history-query')).toBe(true); expect(window.location.hash.startsWith('#/history-query')).toBe(true);
expect(new URLSearchParams(window.location.hash.split('?')[1] ?? '').get('tab')).toBe('raw'); expect(new URLSearchParams(window.location.hash.split('?')[1] ?? '').get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '顶部里程统计' })); fireEvent.click(screen.getByRole('button', { name: '顶部里程统计' }));
expect(window.location.hash.startsWith('#/mileage')).toBe(true); expect(window.location.hash.startsWith('#/mileage')).toBe(true);
fireEvent.click(await screen.findByRole('button', { name: '顶部告警事件正常' })); fireEvent.click(await screen.findByRole('button', { name: '顶部告警事件正常' }));
@@ -4788,7 +4788,7 @@ test('opens same-day raw evidence from quality priority queue', async () => {
expect(params.get('dateTo')).toBe('2026-07-04'); expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true'); expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw'); expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
}); });
test('opens vehicle service from quality issue with issue source evidence', async () => { test('opens vehicle service from quality issue with issue source evidence', async () => {
@@ -5145,7 +5145,7 @@ test('opens same-day raw evidence from quality issue row', async () => {
expect(params.get('dateTo')).toBe('2026-07-04'); expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true'); expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw'); expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
}); });
test('copies trajectory playback summary from history page', async () => { test('copies trajectory playback summary from history page', async () => {
@@ -5258,17 +5258,17 @@ test('copies trajectory playback summary from history page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('起点2026-07-03 10:00:00')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('起点2026-07-03 10:00:00'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('终点2026-07-03 11:00:00')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('终点2026-07-03 11:00:00'));
fireEvent.click(screen.getAllByRole('button', { name: /复制历史证据包/ })[0]); fireEvent.click(screen.getAllByRole('button', { name: /复制数据复核包/ })[0]);
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【历史证据包】')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【数据复核包】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('位置记录2有效定位2')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('位置记录2有效定位2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW帧1解析字段2')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录1字段明细2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常:断点 1 / 里程回退 0 / 超速 0')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹回放http://localhost:3000/#/history?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹回放http://localhost:3000/#/history?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史位置http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史位置http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('解析字段http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=fields&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('字段明细http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=fields&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程复核http://localhost:3000/#/mileage?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程复核http://localhost:3000/#/mileage?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆服务http://localhost:3000/#/detail?keyword=VIN-HISTORY-SUMMARY&protocol=JT808')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆服务http://localhost:3000/#/detail?keyword=VIN-HISTORY-SUMMARY&protocol=JT808'));
@@ -5278,25 +5278,25 @@ test('copies trajectory playback summary from history page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据来源JT808')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据来源JT808'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('业务状态:需要复核')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('业务状态:需要复核'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹范围:位置 2 / 有效定位 2 / RAW 1 / 字段 2')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹范围:位置 2 / 有效定位 2 / 原始记录 1 / 字段明细 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('定位覆盖率100%')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('定位覆盖率100%'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('回放跨度60 分钟采样间隔60 分钟/点')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('回放跨度60 分钟采样间隔60 分钟/点'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常影响:断点 1 / 里程回退 0 / 超速 0')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常影响:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('地图能力:高德 JS API 待配置')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('地图能力:高德 JS API 待配置'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史查询http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据导出http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
fireEvent.click(screen.getByRole('button', { name: /复制轨迹复盘包/ })); fireEvent.click(screen.getByRole('button', { name: /复制轨迹复盘包/ }));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【轨迹复盘交接包】')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【轨迹复盘交接包】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹规模:位置 2 / 有效定位 2 / RAW 1 / 解析字段 2')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹规模:位置 2 / 有效定位 2 / 原始记录 1 / 字段明细 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹质量:定位覆盖率 100% / 回放跨度 60 分钟 / 采样间隔 60 分钟/点')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹质量:定位覆盖率 100% / 回放跨度 60 分钟 / 采样间隔 60 分钟/点'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程速度:区间里程 22.6 km / 最高速度 58.8 km/h')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程速度:区间里程 22.6 km / 最高速度 58.8 km/h'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('当前回放点:点 1/22026-07-03 10:00:0012.5 km/h1,000 km')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('当前回放点:点 1/22026-07-03 10:00:0012.5 km/h1,000 km'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常判读:断点 1 / 里程回退 0 / 超速 0')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常判读:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('下一步:建议核对 RAW 帧、解析字段、当日里程统计,并确认平台是否存在断链或补发。')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('下一步:建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
}); });
test('opens same-day mileage statistics from quality issue row', async () => { test('opens same-day mileage statistics from quality issue row', async () => {
@@ -6185,7 +6185,7 @@ test('shows and clears current history filters while keeping vehicle scope', asy
expect(screen.getByText('数据来源JT808')).toBeInTheDocument(); expect(screen.getByText('数据来源JT808')).toBeInTheDocument();
expect(screen.getByText('开始时间2026-07-01 00:00:00')).toBeInTheDocument(); expect(screen.getByText('开始时间2026-07-01 00:00:00')).toBeInTheDocument();
expect(screen.getByText('结束时间2026-07-01 23:59:59')).toBeInTheDocument(); expect(screen.getByText('结束时间2026-07-01 23:59:59')).toBeInTheDocument();
expect(screen.getAllByText('返回解析字段').length).toBeGreaterThanOrEqual(2); expect(screen.getAllByText('返回字段明细').length).toBeGreaterThanOrEqual(2);
expect(screen.getByText('字段裁剪2 个')).toBeInTheDocument(); expect(screen.getByText('字段裁剪2 个')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '清空筛选' })); fireEvent.click(screen.getByRole('button', { name: '清空筛选' }));
@@ -6259,8 +6259,8 @@ test('shows parsed field history as a flattened evidence table', async () => {
render(<App />); render(<App />);
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
expect(await screen.findByRole('tab', { name: '解析字段' })).toHaveAttribute('aria-selected', 'true'); expect(await screen.findByRole('tab', { name: '字段明细' })).toHaveAttribute('aria-selected', 'true');
expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', expect.objectContaining({ expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', expect.objectContaining({
method: 'POST', method: 'POST',
body: expect.stringContaining('"includeFields":true') body: expect.stringContaining('"includeFields":true')
@@ -6357,10 +6357,10 @@ test('prevents unscoped raw parsed-field query from history form', async () => {
await waitFor(() => { await waitFor(() => {
expect(keywordInput).toHaveValue(''); expect(keywordInput).toHaveValue('');
}); });
fireEvent.click(screen.getByRole('checkbox', { name: '返回解析字段' })); fireEvent.click(screen.getByRole('checkbox', { name: '返回字段明细' }));
fireEvent.click(screen.getByRole('button', { name: 'search 查询' })); fireEvent.click(screen.getByRole('button', { name: 'search 查询' }));
expect((await screen.findAllByText('RAW 解析字段查询需要车辆、时间范围或字段裁剪')).length).toBeGreaterThanOrEqual(1); expect((await screen.findAllByText('字段明细查询需要车辆、时间范围或字段裁剪')).length).toBeGreaterThanOrEqual(1);
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/history/locations?'), undefined); expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/history/locations?'), undefined);
expect(fetchMock).not.toHaveBeenCalledWith('/api/history/raw-frames/query', expect.anything()); expect(fetchMock).not.toHaveBeenCalledWith('/api/history/raw-frames/query', expect.anything());
}); });
@@ -6417,7 +6417,7 @@ test('shows trajectory playback workspace from history locations', async () => {
expect(screen.getByText('轨迹范围')).toBeInTheDocument(); expect(screen.getByText('轨迹范围')).toBeInTheDocument();
expect(screen.getByText('定位覆盖')).toBeInTheDocument(); expect(screen.getByText('定位覆盖')).toBeInTheDocument();
expect(screen.getByText('异常影响')).toBeInTheDocument(); expect(screen.getByText('异常影响')).toBeInTheDocument();
expect(screen.getByText('RAW证据')).toBeInTheDocument(); expect(screen.getAllByText('原始记录').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('地图能力')).toBeInTheDocument(); expect(screen.getByText('地图能力')).toBeInTheDocument();
expect(screen.getByText('轨迹回放作业台')).toBeInTheDocument(); expect(screen.getByText('轨迹回放作业台')).toBeInTheDocument();
expect(screen.getByText('2 个有效轨迹点')).toBeInTheDocument(); expect(screen.getByText('2 个有效轨迹点')).toBeInTheDocument();
@@ -6520,7 +6520,7 @@ test('flags trajectory playback anomalies for gap mileage and speed review', asy
expect(screen.getByText('2 km')).toBeInTheDocument(); expect(screen.getByText('2 km')).toBeInTheDocument();
expect(screen.getByText('速度异常')).toBeInTheDocument(); expect(screen.getByText('速度异常')).toBeInTheDocument();
expect(screen.getAllByText('132 km/h').length).toBeGreaterThan(0); expect(screen.getAllByText('132 km/h').length).toBeGreaterThan(0);
expect(screen.getByText('建议核对 RAW 帧和当日里程统计')).toBeInTheDocument(); expect(screen.getByText('建议核对原始记录和当日里程统计')).toBeInTheDocument();
}); });
test('opens amap route from trajectory playback workspace', async () => { test('opens amap route from trajectory playback workspace', async () => {
@@ -6975,7 +6975,7 @@ test('exports current raw frame page as csv with parsed fields', async () => {
render(<App />); render(<App />);
expect((await screen.findAllByText('raw-export-001')).length).toBeGreaterThanOrEqual(1); expect((await screen.findAllByText('raw-export-001')).length).toBeGreaterThanOrEqual(1);
fireEvent.click(screen.getByRole('button', { name: '导出 RAW 当前页 CSV' })); fireEvent.click(screen.getByRole('button', { name: '导出原始记录当前页 CSV' }));
expect(createObjectURL).toHaveBeenCalled(); expect(createObjectURL).toHaveBeenCalled();
expect(revokeObjectURL).toHaveBeenCalledWith('blob:history-raw'); expect(revokeObjectURL).toHaveBeenCalledWith('blob:history-raw');
@@ -7469,7 +7469,7 @@ test('opens same-day raw frame evidence from mileage row', async () => {
expect(params.get('dateFrom')).toBe('2026-07-03'); expect(params.get('dateFrom')).toBe('2026-07-03');
expect(params.get('dateTo')).toBe('2026-07-04'); expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('tab')).toBe('raw'); expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
}); });
test('shows mileage anomaly action guidance', async () => { test('shows mileage anomaly action guidance', async () => {
@@ -8236,7 +8236,7 @@ test('opens same-day raw evidence from history location row', async () => {
render(<App />); render(<App />);
expect((await screen.findAllByText('VIN-HISTORY-RAW')).length).toBeGreaterThan(0); expect((await screen.findAllByText('VIN-HISTORY-RAW')).length).toBeGreaterThan(0);
fireEvent.click(screen.getByRole('button', { name: '核对 RAW' })); fireEvent.click(screen.getByRole('button', { name: '核对原始记录' }));
await waitFor(() => { await waitFor(() => {
expect(window.location.hash.startsWith('#/history-query?')).toBe(true); expect(window.location.hash.startsWith('#/history-query?')).toBe(true);
@@ -8248,7 +8248,7 @@ test('opens same-day raw evidence from history location row', async () => {
expect(params.get('dateTo')).toBe('2026-07-04'); expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true'); expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw'); expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('tab', { name: 'RAW 帧' })).toHaveAttribute('aria-selected', 'true'); expect(await screen.findByRole('tab', { name: '原始记录' })).toHaveAttribute('aria-selected', 'true');
expect((await screen.findAllByText('raw-from-location-001')).length).toBeGreaterThanOrEqual(1); expect((await screen.findAllByText('raw-from-location-001')).length).toBeGreaterThanOrEqual(1);
}); });
@@ -8333,7 +8333,7 @@ test('opens vehicle service from raw history rows with row source evidence', asy
render(<App />); render(<App />);
fireEvent.click(await screen.findByRole('tab', { name: 'RAW 帧' })); fireEvent.click(await screen.findByRole('tab', { name: '原始记录' }));
expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument(); expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument();
fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]); fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);