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

@@ -0,0 +1,7 @@
-- Keep the actual vehicle brand in the OneOS-owned supplemental master data.
-- vehicle_identity_binding.oem may describe a TBox/GPS platform and remains
-- untouched for gateway compatibility and historical audit.
ALTER TABLE vehicle_profile
ADD COLUMN brand_name VARCHAR(128) NOT NULL DEFAULT '' AFTER vin;
CREATE INDEX idx_vehicle_profile_brand ON vehicle_profile(brand_name);

View File

@@ -0,0 +1,58 @@
-- Expand the single protocol-field catalog used by realtime telemetry,
-- history selection/export and alert rules. Vehicle mileage semantics remain
-- protocol-specific in the UI: JT808 is GPS mileage; GB32960/Yutong is meter mileage.
UPDATE vehicle_metric_definition
SET description='车辆累计行驶里程JT808 为 GPS 里程,其余为仪表盘里程'
WHERE metric_key='total_mileage_km';
UPDATE vehicle_metric_protocol_mapping
SET source_field='yutong_mqtt.data.total_mileage_km'
WHERE metric_key='total_mileage_km' AND protocol='YUTONG_MQTT';
INSERT INTO vehicle_metric_definition
(metric_key,label,description,unit,category,value_type,protocols_json,searchable,chartable,alertable,enabled,sort_order) VALUES
('vehicle_status','车辆状态','GB/T 32960 整车状态码','','vehicle','numeric','["GB32960"]',1,0,1,1,90),
('charge_status','充电状态','GB/T 32960 充电状态码','','energy','numeric','["GB32960"]',1,0,1,1,100),
('total_voltage_v','总电压','动力电池总电压','V','energy','numeric','["GB32960"]',1,1,1,1,110),
('total_current_a','总电流','动力电池总电流','A','energy','numeric','["GB32960"]',1,1,1,1,120),
('insulation_kohm','绝缘电阻','整车绝缘电阻','','safety','numeric','["GB32960"]',1,1,1,1,130),
('fuel_cell_voltage_v','燃料电池电压','燃料电池系统输出电压','V','fuel-cell','numeric','["GB32960"]',1,1,1,1,140),
('fuel_cell_current_a','燃料电池电流','燃料电池系统输出电流','A','fuel-cell','numeric','["GB32960"]',1,1,1,1,150),
('hydrogen_consumption_kg_per_100km','百公里氢耗','燃料电池系统百公里氢气消耗量','kg/100km','fuel-cell','numeric','["GB32960"]',1,1,1,1,160),
('hydrogen_concentration_ppm','最高氢气浓度','燃料电池系统氢气浓度探针的最高读数','ppm','fuel-cell','numeric','["GB32960"]',1,1,1,1,170),
('hydrogen_pressure_mpa','最高氢气压力','燃料电池系统氢气压力探针的最高读数','MPa','fuel-cell','numeric','["GB32960"]',1,1,1,1,180),
('hydrogen_temperature_c','最高氢气温度','燃料电池系统氢气温度探针的最高读数','','fuel-cell','numeric','["GB32960"]',1,1,1,1,190),
('engine_speed_rpm','发动机转速','发动机曲轴转速','rpm','vehicle','numeric','["GB32960"]',1,1,1,1,200),
('max_cell_voltage_v','单体最高电压','动力电池单体电压最高值','V','energy','numeric','["GB32960"]',1,1,1,1,210),
('min_cell_voltage_v','单体最低电压','动力电池单体电压最低值','V','energy','numeric','["GB32960"]',1,1,1,1,220),
('max_battery_temperature_c','电池最高温度','动力电池温度探针最高值','','energy','numeric','["GB32960"]',1,1,1,1,230),
('min_battery_temperature_c','电池最低温度','动力电池温度探针最低值','','energy','numeric','["GB32960"]',1,1,1,1,240),
('gnss_satellite_count','GNSS 卫星数','JT/T 808 定位终端参与定位的卫星数量','','location','numeric','["JT808"]',1,1,1,1,250),
('network_signal_strength','通信信号强度','JT/T 808 终端无线通信信号强度','','quality','numeric','["JT808"]',1,1,1,1,260),
('fuel_l','油量','JT/T 808 终端上报的车辆油量','L','vehicle','numeric','["JT808"]',1,1,1,1,270)
ON DUPLICATE KEY UPDATE
label=VALUES(label),description=VALUES(description),unit=VALUES(unit),category=VALUES(category),
value_type=VALUES(value_type),protocols_json=VALUES(protocols_json),searchable=VALUES(searchable),
chartable=VALUES(chartable),alertable=VALUES(alertable),enabled=VALUES(enabled),sort_order=VALUES(sort_order);
INSERT INTO vehicle_metric_protocol_mapping(metric_key,protocol,source_field) VALUES
('vehicle_status','GB32960','gb32960.vehicle.vehicle_status'),
('charge_status','GB32960','gb32960.vehicle.charge_status'),
('total_voltage_v','GB32960','gb32960.vehicle.total_voltage_v'),
('total_current_a','GB32960','gb32960.vehicle.total_current_a'),
('insulation_kohm','GB32960','gb32960.vehicle.insulation_kohm'),
('fuel_cell_voltage_v','GB32960','gb32960.fuel_cell.fuel_cell_voltage_v'),
('fuel_cell_current_a','GB32960','gb32960.fuel_cell.fuel_cell_current_a'),
('hydrogen_consumption_kg_per_100km','GB32960','gb32960.fuel_cell.hydrogen_consumption_kg_per_100km'),
('hydrogen_concentration_ppm','GB32960','gb32960.fuel_cell.max_hydrogen_concentration_ppm'),
('hydrogen_pressure_mpa','GB32960','gb32960.fuel_cell.max_hydrogen_pressure_mpa'),
('hydrogen_temperature_c','GB32960','gb32960.fuel_cell.max_hydrogen_temperature_c'),
('engine_speed_rpm','GB32960','gb32960.engine.crank_speed_rpm'),
('max_cell_voltage_v','GB32960','gb32960.extreme.max_voltage_v'),
('min_cell_voltage_v','GB32960','gb32960.extreme.min_voltage_v'),
('max_battery_temperature_c','GB32960','gb32960.extreme.max_temp_c'),
('min_battery_temperature_c','GB32960','gb32960.extreme.min_temp_c'),
('gnss_satellite_count','JT808','jt808.location.additional.gnss_satellite_count'),
('network_signal_strength','JT808','jt808.location.additional.network_signal_strength'),
('fuel_l','JT808','jt808.location.additional.fuel_l')
ON DUPLICATE KEY UPDATE source_field=VALUES(source_field);

View File

@@ -0,0 +1,65 @@
-- Align GB/T 32960 business terminology and concentration units with the
-- authoritative protocol-field reference. RAW ppm remains available as
-- evidence, while catalog, charts and new alert rules use percent.
INSERT INTO vehicle_metric_definition
(metric_key,label,description,unit,category,value_type,protocols_json,searchable,chartable,alertable,enabled,sort_order) VALUES
('hydrogen_concentration_percent','最高氢浓度','氢气浓度最高值','%','fuel-cell','numeric','["GB32960"]',1,1,1,1,170)
ON DUPLICATE KEY UPDATE
label=VALUES(label),description=VALUES(description),unit=VALUES(unit),category=VALUES(category),
value_type=VALUES(value_type),protocols_json=VALUES(protocols_json),searchable=VALUES(searchable),
chartable=VALUES(chartable),alertable=VALUES(alertable),enabled=VALUES(enabled),sort_order=VALUES(sort_order);
INSERT INTO vehicle_metric_protocol_mapping(metric_key,protocol,source_field) VALUES
('hydrogen_concentration_percent','GB32960','gb32960.fuel_cell.max_hydrogen_concentration_percent')
ON DUPLICATE KEY UPDATE source_field=VALUES(source_field);
UPDATE vehicle_metric_definition
SET label='最高氢浓度原始值', description='协议原始浓度计数,仅用于历史证据兼容;业务展示使用百分比', enabled=0
WHERE metric_key='hydrogen_concentration_ppm';
DELETE FROM vehicle_alert_candidate
WHERE rule_id IN (SELECT id FROM vehicle_alert_rule WHERE metric='hydrogen_concentration_ppm');
DELETE FROM vehicle_alert_rule_state
WHERE rule_id IN (SELECT id FROM vehicle_alert_rule WHERE metric='hydrogen_concentration_ppm');
UPDATE vehicle_alert_rule
SET metric='hydrogen_concentration_percent',
threshold_value=threshold_value / 10000,
threshold_high=threshold_high / 10000,
recovery_threshold=recovery_threshold / 10000,
description=REPLACE(description, 'ppm', '%'),
version=version + 1
WHERE metric='hydrogen_concentration_ppm';
UPDATE vehicle_metric_definition
SET label='车辆状态', description='车辆运行、停止等状态编码'
WHERE metric_key='vehicle_status';
UPDATE vehicle_metric_definition
SET label='充电状态', description='车辆充电状态编码'
WHERE metric_key='charge_status';
UPDATE vehicle_metric_definition
SET description='动力系统总电压'
WHERE metric_key='total_voltage_v';
UPDATE vehicle_metric_definition
SET description='动力系统总电流'
WHERE metric_key='total_current_a';
UPDATE vehicle_metric_definition
SET description='高压系统绝缘电阻'
WHERE metric_key='insulation_kohm';
UPDATE vehicle_metric_definition
SET label='氢耗', description='燃料电池氢气消耗率'
WHERE metric_key='hydrogen_consumption_kg_per_100km';
UPDATE vehicle_metric_definition
SET label='最高氢压力', description='氢系统最高压力'
WHERE metric_key='hydrogen_pressure_mpa';
UPDATE vehicle_metric_definition
SET label='氢系统最高温度', description='氢系统最高温度'
WHERE metric_key='hydrogen_temperature_c';