# JT808 Kafka Streaming Mileage Plan ## Current Goal Consume JT808 Kafka location events, keep rolling daily state, and write the derived daily mileage into the common vehicle-stat metric repository. ## Current Design - Source topic: `vehicle.event.jt808.v1` - Runtime app: `vehicle-analytics-app` - State: Redis or in-memory `Jt808MileageStateStore` - Metric output: `VehicleStatRepository.saveDailyStat(...)` - Default metric storage: `VEHICLE_STAT_FILE_PATH/daily-stats.tsv` - Date boundary: `Asia/Shanghai` JT808 daily mileage is calculated only from the GPS total mileage reported by JT808 location additional information: ```text daily_mileage_km = last_total_mileage_km - first_total_mileage_km ``` The stream saves a metric only when at least two ordered location points for the same vehicle and local day contain valid `total_mileage_km`. Negative differences are treated as invalid and are not written. ## Runtime Properties ```text KAFKA_TOPIC_JT808_EVENT=vehicle.event.jt808.v1 VEHICLE_STAT_ENABLED=true VEHICLE_STAT_JT808_MILEAGE_ENABLED=true VEHICLE_STAT_JT808_STATE_STORE=redis VEHICLE_STAT_FILE_PATH=/data/vehicle-stat REDIS_HOST= REDIS_PORT=6379 REDIS_DATABASE=50 REDIS_PASSWORD= ``` ## Notes Do not create or write a protocol-specific JT808 daily-mileage table. Do not add GPS segment distance, speed integral, or jump-filter state back into this path unless the mileage definition changes again.