feat: add jt808 streaming daily mileage
This commit is contained in:
49
docs/operations/jt808-daily-mileage-runbook.md
Normal file
49
docs/operations/jt808-daily-mileage-runbook.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# JT808 Daily Mileage Streaming
|
||||
|
||||
## Scope
|
||||
|
||||
The analytics app can calculate daily mileage from JT808 telemetry only. It consumes `vehicle.event.jt808.v1`, keeps the rolling per-vehicle daily state in Redis or memory, and upserts the current daily result into MySQL.
|
||||
|
||||
## Required MySQL Table
|
||||
|
||||
```sql
|
||||
create table if not exists vehicle_daily_mileage_jt808 (
|
||||
stat_date date not null,
|
||||
vehicle_key varchar(64) not null,
|
||||
vin varchar(32) null,
|
||||
phone varchar(32) null,
|
||||
first_event_time timestamp null,
|
||||
last_event_time timestamp null,
|
||||
gps_mileage_km decimal(12,3) not null,
|
||||
speed_integral_km decimal(12,3) not null,
|
||||
odometer_mileage_km decimal(12,3) null,
|
||||
accepted_points int not null,
|
||||
bad_jump_segments int not null,
|
||||
long_gap_segments int not null,
|
||||
out_of_order_points int not null,
|
||||
odometer_anomalies int not null,
|
||||
data_quality varchar(16) not null,
|
||||
updated_at timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (stat_date, vehicle_key),
|
||||
key idx_vehicle_daily_mileage_jt808_vehicle_date (vehicle_key, stat_date)
|
||||
);
|
||||
```
|
||||
|
||||
## Runtime Settings
|
||||
|
||||
Set these in Portainer or Nacos, without committing secrets:
|
||||
|
||||
```text
|
||||
KAFKA_TOPIC_JT808_EVENT=vehicle.event.jt808.v1
|
||||
VEHICLE_STAT_JT808_MILEAGE_ENABLED=true
|
||||
VEHICLE_STAT_JT808_STATE_STORE=redis
|
||||
MYSQL_JDBC_URL=jdbc:mysql://<host>:3306/<database>?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
MYSQL_USERNAME=<user>
|
||||
MYSQL_PASSWORD=<password>
|
||||
REDIS_HOST=<host>
|
||||
REDIS_PORT=6379
|
||||
REDIS_DATABASE=50
|
||||
REDIS_PASSWORD=<password>
|
||||
```
|
||||
|
||||
Algorithm defaults are Asia/Shanghai daily boundary, 5 minute max segment gap, 200 km/h max implied speed, and short-gap jump guard of 300 meters within 10 seconds.
|
||||
Reference in New Issue
Block a user