From 9a428198b492d678f02d9996dbfbc4b9137b649d Mon Sep 17 00:00:00 2001 From: lingniu Date: Sun, 5 Jul 2026 00:39:24 +0800 Subject: [PATCH] feat(platform): customerize history export workflow --- .../apps/web/src/pages/History.tsx | 90 +++++++++---------- .../apps/web/src/test/App.test.tsx | 52 +++++------ 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/vehicle-data-platform/apps/web/src/pages/History.tsx b/vehicle-data-platform/apps/web/src/pages/History.tsx index a3612a02..ca5e7b90 100644 --- a/vehicle-data-platform/apps/web/src/pages/History.tsx +++ b/vehicle-data-platform/apps/web/src/pages/History.tsx @@ -199,11 +199,11 @@ const rawExportColumns: CsvColumn[] = [ { title: '大小B', value: (row) => row.rawSizeBytes }, { title: '设备时间', value: (row) => row.deviceTime }, { title: '入库时间', value: (row) => row.serverTime }, - { title: '解析字段', value: (row) => row.parsedFields ?? {} } + { title: '字段明细', value: (row) => row.parsedFields ?? {} } ]; const rawFieldExportColumns: CsvColumn[] = [ - { title: 'RAW ID', value: (row) => row.rawId }, + { title: '原始记录ID', value: (row) => row.rawId }, { title: 'VIN', value: (row) => row.vin }, { title: '车牌', value: (row) => row.plate }, { title: '数据来源', value: (row) => row.protocol }, @@ -316,20 +316,20 @@ function historyEvidencePackageText({ ...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {}) }; return [ - '【历史证据包】', + '【数据复核包】', `车辆:${vehicle || '全部车辆'}`, `数据来源:${protocol || '全部来源'}`, `查询范围:${filters.dateFrom?.trim() || '-'} 至 ${filters.dateTo?.trim() || '-'}`, `位置记录:${locationCount.toLocaleString()},有效定位:${validPointCount.toLocaleString()}`, - `RAW帧:${rawCount.toLocaleString()},解析字段:${fieldCount.toLocaleString()}`, + `原始记录:${rawCount.toLocaleString()},字段明细:${fieldCount.toLocaleString()}`, `区间里程:${formatNumber(mileageDelta, ' km')},最高速度:${formatNumber(maxSpeed, ' km/h')}`, `起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`, `终点:${lastLocation?.deviceTime || lastLocation?.serverTime || '-'}`, `异常:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `历史位置:${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: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`, + `原始记录:${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: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` ].join('\n'); @@ -379,14 +379,14 @@ function trajectoryReviewPackageText({ ...(filters.dateTo?.trim() ? { dateTo: filters.dateTo.trim() } : {}) }; const anomalyAction = anomalySummary.gapCount > 0 || anomalySummary.mileageRollbackCount > 0 || anomalySummary.overspeedCount > 0 - ? '建议核对 RAW 帧、解析字段、当日里程统计,并确认平台是否存在断链或补发。' + ? '建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。' : '当前页未发现明显断点、里程回退或速度异常,可作为轨迹证据使用。'; return [ '【轨迹复盘交接包】', `车辆:${vehicle || '全部车辆'}`, `数据来源:${protocol || '全部来源'}`, `查询范围:${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, '/点')}`, `里程速度:区间里程 ${formatNumber(mileageDelta, ' km')} / 最高速度 ${formatNumber(maxSpeed, ' km/h')}`, `起点:${firstLocation?.deviceTime || firstLocation?.serverTime || '-'}`, @@ -400,8 +400,8 @@ function trajectoryReviewPackageText({ `下一步:${anomalyAction}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `历史位置:${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: 'fields', includeFields: 'true', ...(filters.fields?.trim() ? { fields: filters.fields.trim() } : {}) } }))}`, + `原始记录:${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: 'mileage', keyword: vehicle, protocol, filters: evidenceFilters }))}`, `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` ].join('\n'); @@ -448,15 +448,15 @@ function trajectoryImpactPackageText({ `数据来源:${protocol || '全部来源'}`, `查询范围:${filters.dateFrom?.trim() || '-'} 至 ${filters.dateTo?.trim() || '-'}`, `业务状态:${operationState}`, - `轨迹范围:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / RAW ${rawCount.toLocaleString()} / 字段 ${fieldCount.toLocaleString()}`, + `轨迹范围:位置 ${locationCount.toLocaleString()} / 有效定位 ${validPointCount.toLocaleString()} / 原始记录 ${rawCount.toLocaleString()} / 字段明细 ${fieldCount.toLocaleString()}`, `定位覆盖率:${formatPercent(coverageRate)}`, `回放跨度:${formatDurationMinutes(playbackSpanMinutes)},采样间隔:${formatDurationMinutes(playbackIntervalMinutes, '/点')}`, `里程速度:${formatNumber(mileageDelta, ' km')} / ${formatNumber(maxSpeed, ' km/h')}`, `异常影响:断点 ${anomalySummary.gapCount.toLocaleString()} / 里程回退 ${anomalySummary.mileageRollbackCount.toLocaleString()} / 超速 ${anomalySummary.overspeedCount.toLocaleString()}`, `地图能力:${amapConfigured ? '高德 JS API 已配置' : '高德 JS API 待配置'}`, `轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: vehicle, protocol, filters: evidenceFilters }))}`, - `历史查询:${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: 'location' } }))}`, + `原始记录:${appURL(buildAppHash({ page: 'history-query', keyword: vehicle, protocol, filters: { ...evidenceFilters, tab: 'raw', includeFields: 'true' } }))}`, `车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: vehicle, protocol }))}` ].join('\n'); } @@ -576,7 +576,7 @@ export function History({ if ((forceIncludeFields || isIncludeFieldsEnabled(nextFilters.includeFields)) && shouldBlockRawFieldQuery(nextFilters)) { setRawFrames({ items: [], total: 0, limit: pageSize, offset: (page - 1) * pageSize }); setRawPagination({ currentPage: page, pageSize }); - Toast.warning('RAW 解析字段查询需要车辆、时间范围或字段裁剪'); + Toast.warning('字段明细查询需要车辆、时间范围或字段裁剪'); return; } setLoadingRaw(true); @@ -669,13 +669,13 @@ export function History({ const hasTrajectoryAnomaly = trajectoryAnomalies.gapCount > 0 || trajectoryAnomalies.mileageRollbackCount > 0 || trajectoryAnomalies.overspeedCount > 0; const currentVehicleKeyword = filters.keyword?.trim() ?? ''; const currentProtocol = filters.protocol?.trim() ?? ''; - const pageTitle = mode === 'query' ? '历史查询' : '轨迹回放'; + const pageTitle = mode === 'query' ? '数据导出' : '轨迹回放'; const pageDescription = mode === 'query' - ? '按车辆查询历史位置、RAW 帧和扁平解析字段,支持分页、字段裁剪和证据导出' - : '按车辆查询历史位置、轨迹回放和 RAW 帧证据,数据来源只作为过滤和诊断维度'; + ? '按车辆、时间和数据通道导出位置记录、原始记录和字段明细,支持分页、字段裁剪和 CSV 导出' + : '按车辆查询历史位置和轨迹回放,原始记录只作为复核证据,数据来源仅用于过滤'; const scopeDescription = mode === 'query' - ? '历史位置、RAW 帧和解析字段按当前车辆与来源范围分页查询。' - : '历史位置和 RAW 帧按当前车辆与来源范围查询。'; + ? '位置记录、原始记录和字段明细按当前车辆与时间范围分页查询。' + : '历史位置和原始记录按当前车辆与时间范围查询。'; const amapConfigured = isAMapConfigured(); const selectedFieldCount = splitFields(filters.fields).length; const playbackRows = validLocations.length > 0 ? validLocations : locationItems; @@ -697,7 +697,7 @@ export function History({ currentProtocol ? `数据来源:${currentProtocol}` : '', filters.dateFrom?.trim() ? `开始时间:${filters.dateFrom.trim()}` : '', filters.dateTo?.trim() ? `结束时间:${filters.dateTo.trim()}` : '', - isIncludeFieldsEnabled(filters.includeFields) ? '返回解析字段' : '', + isIncludeFieldsEnabled(filters.includeFields) ? '返回字段明细' : '', selectedFieldCount > 0 ? `字段裁剪:${selectedFieldCount} 个` : '' ].filter(Boolean); const clearRangeFilters = () => { @@ -713,19 +713,19 @@ export function History({ }; const exportRawFrames = () => { if (rawFrames.items.length === 0) { - Toast.warning('当前没有可导出的 RAW 帧'); + Toast.warning('当前没有可导出的原始记录'); return; } downloadCsv(exportFileName('raw-frames', filters), buildCsv(rawExportColumns, rawFrames.items)); - Toast.success(`已导出 ${rawFrames.items.length} 条 RAW 帧`); + Toast.success(`已导出 ${rawFrames.items.length} 条原始记录`); }; const exportRawFields = () => { if (rawFieldRows.length === 0) { - Toast.warning('当前没有可导出的解析字段'); + Toast.warning('当前没有可导出的字段明细'); return; } downloadCsv(exportFileName('raw-fields', filters), buildCsv(rawFieldExportColumns, rawFieldRows)); - Toast.success(`已导出 ${rawFieldRows.length} 条解析字段`); + Toast.success(`已导出 ${rawFieldRows.length} 条字段明细`); }; const copyTrajectorySummary = () => { copyText( @@ -755,7 +755,7 @@ export function History({ lastLocation, anomalySummary: trajectoryAnomalies }), - '历史证据包' + '数据复核包' ); }; const copyTrajectoryReviewPackage = () => { @@ -911,7 +911,7 @@ export function History({ description={pageDescription} actions={( - + @@ -934,7 +934,7 @@ export function History({ - 返回解析字段 + 返回字段明细 {currentVehicleKeyword || '全部车辆'} - 轨迹、历史查询、RAW 证据和里程复核按同一车辆范围联动,用于调度复盘、客户问询和断链定位。 + 轨迹、数据导出、原始记录和里程复核按同一车辆范围联动,用于调度复盘、客户问询和断链定位。 @@ -999,9 +999,9 @@ export function History({ color: hasTrajectoryAnomaly ? 'orange' as const : 'green' as const }, { - label: 'RAW证据', + label: '原始记录', 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 }, { @@ -1026,7 +1026,7 @@ export function History({ 轨迹回放作业台 - + @@ -1209,9 +1209,9 @@ export function History({ ))}
- {hasTrajectoryAnomaly ? '建议核对 RAW 帧和当日里程统计' : '轨迹质量可用'} + {hasTrajectoryAnomaly ? '建议核对原始记录和当日里程统计' : '轨迹质量可用'} - {hasTrajectoryAnomaly ? '异常点会影响轨迹回放、定位复盘和区间里程判断,请结合 RAW 解析字段与里程统计交叉确认。' : '当前页轨迹未发现明显断点、里程回退或速度异常。'} + {hasTrajectoryAnomaly ? '异常点会影响轨迹回放、定位复盘和区间里程判断,请结合字段明细与里程统计交叉确认。' : '当前页轨迹未发现明显断点、里程回退或速度异常。'}
@@ -1258,21 +1258,21 @@ export function History({ - + ) } ]} /> - +
当前页 {rawFrames.items.length.toLocaleString()} 条 0 ? 'green' : 'orange'}> - {isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? '包含解析字段' : '未请求解析字段'} + {isIncludeFieldsEnabled(filters.includeFields) || splitFields(filters.fields).length > 0 ? '包含字段明细' : '未请求字段明细'} - +
- +
当前页 {rawFieldRows.length.toLocaleString()} 个字段 - {rawFrames.items.length.toLocaleString()} 条 RAW 来源 - {selectedFieldCount > 0 ? 字段裁剪 {selectedFieldCount.toLocaleString()} 个 : 全量解析字段} - + {rawFrames.items.length.toLocaleString()} 条原始记录 + {selectedFieldCount > 0 ? 字段裁剪 {selectedFieldCount.toLocaleString()} 个 : 全量字段明细} +
- 分页沿用 RAW 帧分页 + 分页沿用原始记录分页 字段来自 parsedFields,保留协议字段映射后的路径 - setSelectedRaw(null)} width={720}> + setSelectedRaw(null)} width={720}> {selectedRaw?.protocol ?? '-'} / {selectedRaw?.plate || selectedRaw?.vin || '-'} / {rawFieldCount} 个字段 {rawFieldCount === 0 ? ( - 当前查询未返回解析字段,请勾选“返回解析字段”或配置字段裁剪后重新查询。 + 当前查询未返回字段明细,请勾选“返回字段明细”或配置字段裁剪后重新查询。 ) : null}
{JSON.stringify(selectedRaw?.parsedFields ?? {}, null, 2)}
diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index eaf32a50..2baa6a55 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -200,7 +200,7 @@ test('exposes AMap operations shortcuts when map key is configured', async () => fireEvent.click(screen.getByRole('button', { name: '顶部数据导出' })); expect(window.location.hash.startsWith('#/history-query')).toBe(true); 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: '顶部里程统计' })); expect(window.location.hash.startsWith('#/mileage')).toBe(true); 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('includeFields')).toBe('true'); 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 () => { @@ -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('includeFields')).toBe('true'); 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 () => { @@ -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 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('位置记录: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('轨迹回放: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('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=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=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/#/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')); @@ -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('数据来源:JT808')); 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('回放跨度:60 分钟,采样间隔:60 分钟/点')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常影响:断点 1 / 里程回退 0 / 超速 0')); 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('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=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=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true')); fireEvent.click(screen.getByRole('button', { name: /复制轨迹复盘包/ })); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【轨迹复盘交接包】')); 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('里程速度:区间里程 22.6 km / 最高速度 58.8 km/h')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('当前回放点:点 1/2,2026-07-03 10:00:00,12.5 km/h,1,000 km')); expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常判读:断点 1 / 里程回退 0 / 超速 0')); - expect(writeText).toHaveBeenCalledWith(expect.stringContaining('下一步:建议核对 RAW 帧、解析字段、当日里程统计,并确认平台是否存在断链或补发。')); - 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('下一步:建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。')); + 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 () => { @@ -6185,7 +6185,7 @@ test('shows and clears current history filters while keeping vehicle scope', asy expect(screen.getByText('数据来源:JT808')).toBeInTheDocument(); expect(screen.getByText('开始时间:2026-07-01 00:00:00')).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(); fireEvent.click(screen.getByRole('button', { name: '清空筛选' })); @@ -6259,8 +6259,8 @@ test('shows parsed field history as a flattened evidence table', async () => { render(); - expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument(); - expect(await screen.findByRole('tab', { name: '解析字段' })).toHaveAttribute('aria-selected', 'true'); + expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument(); + expect(await screen.findByRole('tab', { name: '字段明细' })).toHaveAttribute('aria-selected', 'true'); expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', expect.objectContaining({ method: 'POST', body: expect.stringContaining('"includeFields":true') @@ -6357,10 +6357,10 @@ test('prevents unscoped raw parsed-field query from history form', async () => { await waitFor(() => { expect(keywordInput).toHaveValue(''); }); - fireEvent.click(screen.getByRole('checkbox', { name: '返回解析字段' })); + fireEvent.click(screen.getByRole('checkbox', { name: '返回字段明细' })); 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).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('RAW证据')).toBeInTheDocument(); + expect(screen.getAllByText('原始记录').length).toBeGreaterThanOrEqual(1); expect(screen.getByText('地图能力')).toBeInTheDocument(); expect(screen.getByText('轨迹回放作业台')).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('速度异常')).toBeInTheDocument(); 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 () => { @@ -6975,7 +6975,7 @@ test('exports current raw frame page as csv with parsed fields', async () => { render(); 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(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('dateTo')).toBe('2026-07-04'); 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 () => { @@ -8236,7 +8236,7 @@ test('opens same-day raw evidence from history location row', async () => { render(); 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(() => { 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('includeFields')).toBe('true'); 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); }); @@ -8333,7 +8333,7 @@ test('opens vehicle service from raw history rows with row source evidence', asy render(); - fireEvent.click(await screen.findByRole('tab', { name: 'RAW 帧' })); + fireEvent.click(await screen.findByRole('tab', { name: '原始记录' })); expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument(); fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);