docs: align jt808 mileage storage
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
## 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, and saves the current daily result into the common `vehicle-stat` metric repository.
|
||||
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. Runtime state is stored under the configured JT808 state store so the stream can continue after restart. The derived metric is written through `VehicleStatRepository.saveDailyStat(...)` into the common JDBC/MySQL metric table `vehicle_stat_metric`.
|
||||
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:
|
||||
|
||||
@@ -15,7 +15,7 @@ daily_mileage_km = last_total_mileage_km - first_total_mileage_km
|
||||
calculation_method = JT808_TOTAL_MILEAGE_DIFF
|
||||
```
|
||||
|
||||
The metric is saved only after at least two ordered JT808 location points with valid `total_mileage_km` have been received for the same vehicle and local day. If the difference is negative, no metric row is saved for that state update.
|
||||
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
|
||||
|
||||
@@ -27,10 +27,6 @@ VEHICLE_STAT_JT808_MILEAGE_ENABLED=true
|
||||
MYSQL_JDBC_URL=<jdbc-url>
|
||||
MYSQL_USERNAME=<user>
|
||||
MYSQL_PASSWORD=<password>
|
||||
REDIS_HOST=<host>
|
||||
REDIS_PORT=6379
|
||||
REDIS_DATABASE=50
|
||||
REDIS_PASSWORD=<password>
|
||||
```
|
||||
|
||||
Algorithm defaults use the Asia/Shanghai daily boundary. The rolling state stores only the fields needed by the GPS total-mileage difference calculation.
|
||||
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.
|
||||
|
||||
@@ -126,10 +126,11 @@ calculation_method = JT808_TOTAL_MILEAGE_DIFF
|
||||
|
||||
- Store the metric in `vehicle_stat_metric` with
|
||||
`metric_key = daily_mileage_km`.
|
||||
- Keep rolling daily calculation state in Redis.
|
||||
|
||||
There is no JT808-specific daily mileage table and no in-memory production
|
||||
state-store mode.
|
||||
state-store mode. Daily start total, latest total, and derived mileage are all
|
||||
stored in `vehicle_stat_metric`, so restart recovery does not require a separate
|
||||
Redis mileage state.
|
||||
|
||||
### Latest State
|
||||
|
||||
@@ -156,7 +157,6 @@ flowchart LR
|
||||
kafka --> state["vehicle-state-service"]
|
||||
history --> tdengine["TDengine<br/>raw_frames + locations"]
|
||||
analytics --> mysql["MySQL<br/>vehicle_stat_metric"]
|
||||
analytics --> redisCalc["Redis<br/>mileage state"]
|
||||
state --> redisState["Redis<br/>latest state"]
|
||||
```
|
||||
|
||||
@@ -167,7 +167,8 @@ flowchart LR
|
||||
- Kafka producer failures are handled by sink retry/circuit-breaker behavior and
|
||||
DLQ topics where configured.
|
||||
- History consumers should commit offsets only after TDengine writes succeed.
|
||||
- Analytics state can recover from Redis state or Kafka replay.
|
||||
- Analytics daily mileage state can recover from `vehicle_stat_metric` or Kafka
|
||||
replay.
|
||||
- Raw archive failures must be observable, but event publication and history
|
||||
indexing remain separate concerns.
|
||||
|
||||
@@ -182,6 +183,6 @@ flowchart LR
|
||||
- Location queries page over compact rows and reference raw records instead of
|
||||
duplicating full raw JSON.
|
||||
- JT808 daily mileage is stored only in `vehicle_stat_metric`.
|
||||
- Runtime state needed for 808 mileage uses Redis, with no production memory
|
||||
mode.
|
||||
- Runtime state needed for 808 mileage is also in `vehicle_stat_metric`, with no
|
||||
Redis or production memory state-store mode.
|
||||
- Build validation covers the active modules and their composition tests.
|
||||
|
||||
Reference in New Issue
Block a user