33 lines
1.4 KiB
Markdown
33 lines
1.4 KiB
Markdown
# JT808 Daily Mileage Streaming
|
|
|
|
## Scope
|
|
|
|
The analytics app can calculate daily mileage from JT808 telemetry only. It consumes `vehicle.event.jt808.v1` and saves the current daily result into the common `vehicle-stat` metric repository.
|
|
|
|
## Storage
|
|
|
|
There is no separate JT808 daily-mileage table and no Redis mileage state. The current day start total, latest total, and derived daily mileage are all stored in the common JDBC/MySQL metric table `vehicle_stat_metric`.
|
|
|
|
The JT808 daily-mileage value is calculated from the GPS total mileage reported in location additional information:
|
|
|
|
```text
|
|
daily_mileage_km = last_total_mileage_km - first_total_mileage_km
|
|
calculation_method = JT808_TOTAL_MILEAGE_DIFF
|
|
```
|
|
|
|
The first valid JT808 location point for a vehicle and local day stores the day start total and writes `daily_mileage_km=0.0`. Later ordered points update the latest total and the derived `daily_mileage_km`. If a later total mileage is lower than the stored start or latest total, the update is ignored and the previous metric remains.
|
|
|
|
## 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
|
|
MYSQL_JDBC_URL=<jdbc-url>
|
|
MYSQL_USERNAME=<user>
|
|
MYSQL_PASSWORD=<password>
|
|
```
|
|
|
|
Algorithm defaults use the Asia/Shanghai daily boundary. Restart recovery reads the same `vehicle_stat_metric` rows, so no separate mileage state store is required.
|