From 65ac26ef994143d538efaf836451a33a15de32d7 Mon Sep 17 00:00:00 2001 From: lingniu Date: Sun, 5 Jul 2026 16:34:16 +0800 Subject: [PATCH] feat(platform): add history replay customer navigation --- .../apps/web/src/pages/History.tsx | 70 ++++++++++++++++++ .../apps/web/src/styles/global.css | 73 +++++++++++++++++++ .../apps/web/src/test/App.test.tsx | 10 ++- .../docs/fleet-platform-product-research.md | 2 + 4 files changed, 153 insertions(+), 2 deletions(-) diff --git a/vehicle-data-platform/apps/web/src/pages/History.tsx b/vehicle-data-platform/apps/web/src/pages/History.tsx index e68c8493..819a868b 100644 --- a/vehicle-data-platform/apps/web/src/pages/History.tsx +++ b/vehicle-data-platform/apps/web/src/pages/History.tsx @@ -1346,6 +1346,44 @@ export function History({ } loadRawFrames(nextFilters, 1, rawPagination.pageSize, tab === 'fields'); }; + const customerReplayNavigation = [ + { + title: '选车和时间', + value: currentVehicleKeyword || '待选择车辆', + detail: `${currentProtocol || '全部数据通道'} / ${filters.dateFrom || '-'} 至 ${filters.dateTo || '-'}`, + action: '调整筛选', + color: currentVehicleKeyword ? 'green' as const : 'orange' as const, + disabled: false, + onClick: () => document.querySelector('input[name="keyword"]')?.focus() + }, + { + title: '回放路线', + value: validLocations.length > 0 ? `${validLocations.length.toLocaleString()} 点` : '待查询', + detail: '按时间顺序播放轨迹,核对路线、停留和断点。', + action: '播放轨迹', + color: validLocations.length > 0 ? 'green' as const : 'grey' as const, + disabled: validLocations.length === 0, + onClick: () => openQueryTab('location') + }, + { + title: '核对里程', + value: formatNumber(mileageDelta, ' km'), + detail: '跳到同一车辆和时间窗的里程统计,检查区间差值。', + action: '统计查询', + color: isFiniteNumber(mileageDelta) ? 'green' as const : 'grey' as const, + disabled: !onOpenMileage || !currentVehicleKeyword, + onClick: () => onOpenMileage?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, ...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}), ...(filters.dateTo ? { dateTo: filters.dateTo } : {}) }) + }, + { + title: '导出证据', + value: deliveryState, + detail: '复制客户交付包,包含轨迹、位置、RAW、字段和统计链接。', + action: '复制交付', + color: deliveryStateColor, + disabled: false, + onClick: copyDeliveryPackage + } + ]; return (
@@ -1528,6 +1566,38 @@ export function History({
) : null} + +
+
+ + Trips History + {trajectoryDecisionState} + {deliveryState} + + 像 Trips History 一样,先锁定车辆和时间,再回放路线、核对里程、导出证据。 + + 客户复盘不从 RAW 开始,而是从车辆、时间、路线和交付结果开始;字段和原始记录只作为证明材料。 + +
+
+ {customerReplayNavigation.map((item) => ( + + ))} +
+
+
diff --git a/vehicle-data-platform/apps/web/src/styles/global.css b/vehicle-data-platform/apps/web/src/styles/global.css index d8160244..505efc37 100644 --- a/vehicle-data-platform/apps/web/src/styles/global.css +++ b/vehicle-data-platform/apps/web/src/styles/global.css @@ -5510,6 +5510,77 @@ button.vp-realtime-command-item:focus-visible { font-weight: 700; } +.vp-history-replay-nav { + display: grid; + grid-template-columns: minmax(300px, 0.7fr) minmax(0, 1.3fr); + gap: 14px; +} + +.vp-history-replay-nav-summary { + min-height: 158px; + padding: 14px; + border: 1px solid rgba(22, 100, 255, 0.18); + border-radius: var(--vp-radius); + background: #f7faff; + display: grid; + gap: 10px; + align-content: start; +} + +.vp-history-replay-nav-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 12px; +} + +.vp-history-replay-nav-item { + min-height: 158px; + padding: 12px; + border: 1px solid var(--vp-border); + border-radius: var(--vp-radius); + background: #fbfcff; + color: inherit; + text-align: left; + font: inherit; + cursor: pointer; + display: grid; + gap: 8px; + align-content: start; +} + +.vp-history-replay-nav-item:hover, +.vp-history-replay-nav-item:focus-visible { + border-color: rgba(22, 100, 255, 0.42); + box-shadow: 0 10px 24px rgba(24, 39, 75, 0.08); + outline: none; +} + +.vp-history-replay-nav-item:disabled { + cursor: not-allowed; + opacity: 0.62; +} + +.vp-history-replay-nav-item strong { + color: var(--vp-text); + font-size: 18px; + line-height: 24px; + font-weight: 700; + word-break: break-word; +} + +.vp-history-replay-nav-item span { + color: var(--vp-text-muted); + font-size: 12px; + line-height: 18px; +} + +.vp-history-replay-nav-item em { + color: var(--vp-primary); + font-size: 12px; + font-style: normal; + font-weight: 700; +} + .vp-history-query-workbench { display: grid; grid-template-columns: minmax(260px, 0.68fr) minmax(0, 1.32fr); @@ -7121,6 +7192,8 @@ button.vp-realtime-command-item:focus-visible { .vp-history-report-template-grid, .vp-history-question-board, .vp-history-question-grid, + .vp-history-replay-nav, + .vp-history-replay-nav-grid, .vp-history-query-workbench, .vp-history-query-grid, .vp-history-package-board, 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 c037b236..524f7f52 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -5516,6 +5516,12 @@ test('copies trajectory playback summary from history page', async () => { expect((await screen.findAllByText('VIN-HISTORY-SUMMARY')).length).toBeGreaterThan(0); expect(screen.getByText('轨迹回放工作台')).toBeInTheDocument(); + expect(screen.getByText('客户复盘导航')).toBeInTheDocument(); + expect(screen.getByText('像 Trips History 一样,先锁定车辆和时间,再回放路线、核对里程、导出证据。')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户复盘导航 选车和时间 调整筛选' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户复盘导航 回放路线 播放轨迹' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户复盘导航 核对里程 统计查询' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户复盘导航 导出证据 复制交付' })).toBeInTheDocument(); expect(screen.getByText('按车辆和时间窗复盘每一段行程')).toBeInTheDocument(); expect(screen.getByText('客户需要看到路线、起止时间、里程变化、速度异常和可导出的证据。明细证据和字段裁剪只作为轨迹复盘的依据。')).toBeInTheDocument(); expect(screen.getByRole('button', { name: '轨迹回放指标 轨迹点 2' })).toBeInTheDocument(); @@ -7267,7 +7273,7 @@ test('exports current history location page as csv', async () => { render(); - expect(await screen.findByText('VIN-EXPORT-LOC')).toBeInTheDocument(); + expect((await screen.findAllByText('VIN-EXPORT-LOC')).length).toBeGreaterThan(0); fireEvent.click(screen.getByRole('button', { name: '导出位置当前页 CSV' })); expect(createObjectURL).toHaveBeenCalled(); @@ -8570,7 +8576,7 @@ test('opens same-day mileage statistics from history location row', async () => render(); - expect(await screen.findByText('VIN-HISTORY-MILEAGE')).toBeInTheDocument(); + expect((await screen.findAllByText('VIN-HISTORY-MILEAGE')).length).toBeGreaterThan(0); const locationRow = screen.getByRole('row', { name: /VIN-HISTORY-MILEAGE/ }); fireEvent.click(within(locationRow).getByRole('button', { name: '统计查询' })); diff --git a/vehicle-data-platform/docs/fleet-platform-product-research.md b/vehicle-data-platform/docs/fleet-platform-product-research.md index c1e6c1f2..b19b1b73 100644 --- a/vehicle-data-platform/docs/fleet-platform-product-research.md +++ b/vehicle-data-platform/docs/fleet-platform-product-research.md @@ -16,6 +16,7 @@ - Geotab 关于远程车队管理的说明把数据流描述为:车辆采集位置和健康信息,经网络到云端,再在 Web/Mobile dashboard 展示实时报告和告警。这与本项目架构一致,但产品表达应从 dashboard 和 alerts 开始,而不是从接入来源开始。参考:https://www.geotab.com/blog/remote-fleet-management/ - Fleetio 的车辆资产和报表资料把 Vehicle List、Vehicle Details、Service History、Service Schedule 等作为车队管理的高频入口。这说明车辆中心不能只是数据覆盖表,还要提供最近车辆、待维护车辆、服务历史/报表导出的资产作业入口。参考:https://www.fleetio.com/ 和 https://www.fleetio.com/blog/fleet-management-reports - Azuga 的车队跟踪资料强调实时跟踪、车辆资产保护、维护告警和洞察报表。这对应本项目车辆中心的作业栏:最近上报、待关注车辆、身份维护和报表导出。参考:https://www.azuga.com/ +- Verizon Connect 把 live map 与 historic replays 放在同一个 GPS tracking 叙事里,Geotab Trips History 支持查看车辆实时位置和历史行程,Samsara GPS tracking 也把 Trip history 作为分析车辆行程效率的核心入口。因此历史页要先呈现“车辆 + 时间窗 + 轨迹回放 + 证据导出”的客户复盘路径,而不是先暴露 RAW/字段表。参考:https://www.verizonconnect.com/solutions/gps-fleet-tracking-software/、https://support.geotab.com/help/mygeotab/fleet-activity/trips/trips-history、https://www.samsara.com/products/telematics/gps-fleet-tracking ## 对标后的产品改造规则 @@ -23,6 +24,7 @@ - “32960 / 808 / MQTT”不作为主任务名称,只在车辆档案、历史证据、运维质量中作为来源可信度出现。 - 自定义时间窗必须成为跨页面共享的查询意图:轨迹、里程、历史数据、告警复盘使用同一组参数。 - 车辆中心要像资产系统一样把车辆清单变成作业入口:最近上报、待关注、身份维护、报表导出,而不是只提供表格筛选。 +- 轨迹/历史页要像 Trips History:先锁定车辆和时间,随后回放路线、核对里程、导出证据;RAW 和字段裁剪只作为复盘依据。 - 内部可观测性继续保留,但默认折叠在运维/依据层,避免客户把系统理解为“协议接入平台”。 ## 本项目采用的产品原则