feat(platform): harden telemetry pipeline and unify Semi UI workspaces

This commit is contained in:
lingniu
2026-07-18 00:26:36 +08:00
parent 65b4e4f055
commit 159c80b0ae
136 changed files with 21616 additions and 1785 deletions

View File

@@ -206,10 +206,13 @@ test -n "$MYSQL_DSN"
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/016_business_scope_dimensions.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/017_reconciliation_center.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/018_vehicle_oem_audit.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/019_vehicle_source_provider.sql
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/019_vehicle_source_provider.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/020_vehicle_profile_brand.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/021_protocol_metric_catalog.sql \
/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/deploy/migrations/022_gb32960_reference_catalog.sql
```
The API guards the access-threshold tables for compatibility, while alert and reconciliation APIs deliberately require their migrations to exist. Run every numbered migration explicitly before switching traffic so DDL permission and index creation failures are caught early. The migration journal records filename and SHA-256 and refuses a changed file; duplicate forward `ADD COLUMN` and `CREATE INDEX` statements are tolerated only when resuming partially executed MySQL DDL. Full-line SQL comments are removed before statement splitting, so punctuation in a comment cannot become executable SQL. Migration `008` adds forward-compatible access evidence columns and an index to the gateway-owned realtime snapshot table without changing its `(protocol, vin)` primary key. Migration `009` creates the per-group/topic/partition event-time checkpoint used to make MySQL effects authoritative before Kafka offsets are committed. Migration `012` creates the atomic, versioned business Scope projection; its reserved `row_number` column is quoted for production MySQL compatibility. Migration `014` backfills active vehicle-grant start times, creates the grant-interval history table and adds the active time lookup index; apply it before starting an API binary that writes grant history. Migration `015` adds platform-owned optimistic versions and immutable audits for per-vehicle location-source policy changes. It does not alter the gateway election SQL or expose the gateway `source_key`; the API resolves an opaque `sourceRef` server-side and the gateway applies the saved policy on the next valid vehicle report. Migration `016` adds customer name, department and responsible-person dimensions plus bounded lookup indexes to the platform-owned Scope projection. Migration `017` creates the reconciliation run, issue and immutable action tables; the unique fingerprint index is the database-level duplicate-work-item guard. Migration `018` records every OneOS-sourced brand fill before the platform identity OEM field changes; it does not grant access to OneOS or run a cross-database sync. Migration `019` stores administrator-maintained provider names by exact vehicle/protocol/source key and writes an immutable versioned audit. The browser still receives only the SHA-256 `sourceRef`; raw source keys remain server-side.
The API guards the access-threshold tables for compatibility, while alert and reconciliation APIs deliberately require their migrations to exist. Run every numbered migration explicitly before switching traffic so DDL permission and index creation failures are caught early. The migration journal records filename and SHA-256 and refuses a changed file; duplicate forward `ADD COLUMN` and `CREATE INDEX` statements are tolerated only when resuming partially executed MySQL DDL. Full-line SQL comments are removed before statement splitting, so punctuation in a comment cannot become executable SQL. Migration `008` adds forward-compatible access evidence columns and an index to the gateway-owned realtime snapshot table without changing its `(protocol, vin)` primary key. Migration `009` creates the per-group/topic/partition event-time checkpoint used to make MySQL effects authoritative before Kafka offsets are committed. Migration `012` creates the atomic, versioned business Scope projection; its reserved `row_number` column is quoted for production MySQL compatibility. Migration `014` backfills active vehicle-grant start times, creates the grant-interval history table and adds the active time lookup index; apply it before starting an API binary that writes grant history. Migration `015` adds platform-owned optimistic versions and immutable audits for per-vehicle location-source policy changes. It does not alter the gateway election SQL or expose the gateway `source_key`; the API resolves an opaque `sourceRef` server-side and the gateway applies the saved policy on the next valid vehicle report. Migration `016` adds customer name, department and responsible-person dimensions plus bounded lookup indexes to the platform-owned Scope projection. Migration `017` creates the reconciliation run, issue and immutable action tables; the unique fingerprint index is the database-level duplicate-work-item guard. Migration `018` records every OneOS-sourced brand fill before the platform identity OEM field changes; it does not grant access to OneOS or run a cross-database sync. Migration `019` stores administrator-maintained provider names by exact vehicle/protocol/source key and writes an immutable versioned audit. The browser still receives only the SHA-256 `sourceRef`; raw source keys remain server-side. Migration `020` separates the actual vehicle brand in `vehicle_profile.brand_name` from T-Box/GPS provider identity. Migration `021` adds the cross-protocol core metric catalog and correct source paths for JT808 GPS mileage, GB32960/YUTONG instrument mileage and GB32960 fuel-cell/engine telemetry. Migration `022` applies the authoritative GB/T 32960 Chinese terminology, changes business hydrogen-concentration metrics and alert thresholds from ppm to percent, and leaves the ppm field only as disabled historical evidence.
`docs/oneos-brand-backfill.sql` is an explicit one-time calibration, not a service dependency. It reads OneOS vehicle/model master data, inserts immutable source evidence, and fills only empty `vehicle_identity_binding.oem` values. Review the pre-run count, apply migration `018`, run the script once through the migration runner or a transaction-capable MySQL client, and verify its final audit/missing counts. Never overwrite a non-empty platform brand and never schedule this script; future updates belong in the formal OneOS API.

View File

@@ -0,0 +1,22 @@
# GB/T 32960 字段展示基准
车辆数据中台的 GB/T 32960 中文名称、单位、状态值和广东燃料电池扩展说明,以以下业务参考文件为基准:
- `/Users/lingniu/Library/Mobile Documents/com~apple~CloudDocs/【字段】32960+广东燃料电池协议.json`
- SHA-256`0f0847b86cc692f2130255babbee37e6cb3cf36d717b18d6698164289f66eb82`
## 展示规则
- 整车状态、充电状态、运行模式、DC/DC 状态、驱动电机状态、定位状态、坐标系、最高报警等级、空调状态和碰撞报警,展示“中文含义(协议值)”。
- `0xFE/0xFF``0xFFFE/0xFFFF``0xFFFFFFFE/0xFFFFFFFF` 等协议异常或无效标记不得作为正常测量值展示。
- 最高氢浓度的业务单位为 `%`;解析层保留 ppm 原始计数用于历史证据兼容,但指标目录、图表和新告警规则统一使用百分比。
- 2025 版位置单元展示坐标系编码:`1=WGS84``2=GCJ-02``3=其他`
- 广东燃料电池电堆的单体电压为分段上报;当前帧可展示起始序号、数量和电压列表,但在完成跨帧 snapshot 合并前,不得声称已覆盖全部单体。
- 参考文件未定义中文、单位或状态值的厂家私有字段,保留原始字段和值,不推测业务含义。
## 页面范围
- 单车详情:实时协议字段使用权威中文、单位和状态中文值。
- 历史数据:字段选择器可按中文、状态含义和字段 key 搜索;明细及 CSV 导出使用相同状态释义。
- 全局监控GB/T 32960 重点指标使用相同中文和单位。
- 告警中心:最高氢浓度以百分比配置阈值;旧 ppm 规则迁移时按 `ppm / 10000` 转换并重新开始状态评估。

View File

@@ -1,18 +1,62 @@
# 车辆数据中台 0716 会议待办与 Goal 清单
# 车辆数据中台 07-17 会议待办与 Goal 清单
更新时间2026-07-16
更新时间2026-07-17
唯一会议依据:`张兰发起的视频会议_0716.txt`
最新会议依据:`07-17 车辆数据中台优化.txt`
来源校验:
- 原文件:`/Users/lingniu/Library/Mobile Documents/com~apple~CloudDocs/rsync/张兰发起的视频会议_0716.txt`
- 文件修改时间:`2026-07-16 15:16:16 +0800`
- 文件大小43,820 字节,共 1,259 行
- SHA-256`57f34ac130ec5a96d9d7929df4977acad50b5aeeae869f864c77bf99017063c3`
- 原文件:`/Users/lingniu/Library/Mobile Documents/com~apple~CloudDocs/rsync/07-17 车辆数据中台优化.txt`
- 文件大小12,418 字节,共 86 行
- SHA-256`65759bb62995b4a09c10124de85c139bfabe4bdc82356e50bee4a2539e36f785`
当前项目:`vehicle-data-platform`
## 0. 07-17 Goal 验收总表
本节覆盖 07-17 会议新增要求;后文保留 0716 的授权、客户 Scope、导出审计和运维基线二者共同构成当前 Goal。
| 编号 | 会议要求 | 状态 | 已交付和生产证据 |
| --- | --- | --- | --- |
| G17-01 | 全国地图按省展示简短全名和车辆总数,不展示省级在线数 | 已完成 | 省/市/自治区后缀统一压缩;省级标记只保留完整短名称和总车辆数,放大后继续使用现有空间聚合。 |
| G17-02 | 监控详情按“最新上报、实时状态、车辆信息”排序,并说明协议和里程语义 | 已完成 | 详情顺序已调整显示接收时间、坐标、协议和来源JT808 明确显示“GPS 总里程”GB32960/YUTONG 显示“仪表盘总里程”。 |
| G17-03 | GB32960 关键燃料电池、发动机、电池等字段进入实时详情 | 已完成 | 指标目录扩展至 27 个核心指标GB32960 最新遥测按 20 秒受控轮询,重点展示燃料电池电压/电流、氢耗、最高氢浓度/压力/温度、发动机转速、总电压/电流及极值。 |
| G17-04 | 单车详情按真实协议切页,三类协议字段不能互相覆盖 | 已完成 | 仅展示车辆实际存在的协议页签;同一业务指标按协议独立保留;字段按车辆、位置、电池、燃料电池、电机、告警、质量和扩展分类。 |
| G17-05 | 三类协议字段提供中文目录,统一支撑实时、历史、导出、图表和告警 | 已完成 | `metric_definition + metric_source_mapping` 成为统一语义目录RAW 中文元数据覆盖三类协议并带单位推断;历史字段选择、实时卡片和告警规则读取同一目录。 |
| G17-06 | 沪A03561F 2026-07-16 自动轨迹应选择完整 JT808 轨迹 | 已完成 | 自动来源改为逐协议分析有效移动、范围、距离和静止占比,不再按静态点数误选;生产验收为 JT808、有效点 4,937、距离约 476.3 km。 |
| G17-07 | 轨迹查询栏收起后,在同一侧恢复展开 | 已完成 | 展开入口移动到查询栏原侧边缘,避免“右侧按钮打开左侧面板”的反直觉交互。 |
| G17-08 | 告警配置既简单又覆盖协议字段;支持离线 10 小时和氢气浓度场景 | 已完成 | 新增“离线超过 10 小时”和“最高氢浓度”快捷模板;离线模板自动配置 36,000 秒、恢复和重复提醒;氢浓度按协议参考以百分比配置,强制管理员按车型/厂家安全标准填写阈值,不写死未经确认的安全值。 |
| G17-09 | 真实车辆品牌/车型来自 OneOS不能把 T-Box/GPS 厂家当车辆品牌 | 已完成 | 新增独立 `vehicle_profile.brand_name`;导入 OneOS 1,024 台车辆主档保留设备提供方为独立来源属性8 条 OneOS VIN 校验位差异仅在车牌唯一匹配后映射到平台规范 VIN。 |
| G17-10 | 消化 808 品牌映射;同 IP 未知来源需有证据后归类 | 已完成 | 101 条缺少提供方记录已按文件和稳定来源证据补齐G7s 56、东方北斗 36、信达 7、广安北斗 2`58.33.87.196` 为赛格证据,`115.159.85.149` 主要为 G7未把同 IP 未知车辆无证据批量误判为赛格。 |
| G17-11 | OneOS 后续通过正式 API 提供车辆和业务关联数据 | 外部依赖 | 当前使用 2026-07-17 Excel 快照完成主档导入;已保留版本化 Profile/Scope 同步接口和来源审计,待 OneOS 提供内部 API、服务令牌、签名和网络白名单后切换。 |
### 0.1 三类协议语义边界
| 协议 | 里程语义 | 主要字段族 | 系统用途 |
| --- | --- | --- | --- |
| JT808 | GPS 总里程,不能标成仪表盘里程 | 定位、速度、方向、海拔、GNSS、信号、附加里程/油量、告警位 | 地图、轨迹、GPS 里程、在线与位置告警 |
| GB32960 | 仪表盘总里程 | 整车、驱动电机、燃料电池、发动机、极值、报警、储能子系统及广东氢能扩展 | 氢能数字孪生、历史字段查询、仪表里程和安全告警 |
| YUTONG_MQTT | 仪表盘总里程 | 宇通车况、位置、SOC、电压电流、里程和厂家扩展 | 宇通车辆实时状态、历史和仪表里程 |
任何融合推荐只决定默认展示来源,不删除或覆盖其他协议的原始证据。缺失字段显示 `-`;协议未提供的字段不得通过其他协议旧快照伪装成当前上报值。
### 0.2 生产发布与验证
- 平台发布:`protocol-field-alert-mobile-202607170141`API 基线来自 `protocol-field-alert-202607170132`)。
- 网关发布:`go-native-hydrogen-ppm-202607170128`
- OneOS 主档导入1,024 台,冲突 0、缺失 0。
- 生产最新遥测抽样:同车同时保留 GB32960 121 项、JT808 38 项;燃料电池字段 23 项。
- 网关同时保留 `gb32960.fuel_cell.max_hydrogen_concentration_ppm` 原始计数与业务展示字段 `gb32960.fuel_cell.max_hydrogen_concentration_percent`;页面、图表和告警使用百分比。
- 平台 API 全量 Go 测试通过;网关全量 Go 测试通过;监控/单车/告警定向前端 30 项测试和生产构建通过。
- 全量前端现有 262 项中仅剩 1 项与当前日期推进相关的里程测试夹具失败,实际页面和本轮功能无回归。
### 0.3 剩余运维项(不阻塞 07-17 功能交付)
1. OneOS 正式 API 尚未提供Excel 只是带来源版本的可审计快照,不应成为长期同步方式。
2. 氢气浓度告警阈值必须由车型、厂家或安全责任人确认后启用,平台不替业务方猜测安全阈值。
3. JT808 仍有 1 个近期终端手机号未绑定 VIN另有 G7 终端标识覆盖率和东方北斗来源显示名不一致的诊断项,属于来源主数据治理,不影响本轮已确认的提供方覆盖。
4. 统计消费者仍在追赶历史 Kafka 积压;网关发布仅豁免了与本次解析无关的旧积压总量和端到端陈旧延迟,服务就绪、实时写入、解析字段、队列错误及契约门禁继续执行。
## 1. 范围与执行原则
本清单以 2026-07-16 最新会议纪要为准,替代此前根据 0715 及更早纪要整理的版本。待办已经结合当前代码、数据库迁移和生产能力去重。