From 136b8a040c40461b8fa4e97e00e940ef55fa655a Mon Sep 17 00:00:00 2001 From: lingniu Date: Wed, 1 Jul 2026 09:55:44 +0800 Subject: [PATCH] fix: expose jt808 mileage metadata --- .../ingest/protocol/jt808/mapper/Jt808EventMapper.java | 4 ++++ .../ingest/protocol/jt808/mapper/Jt808EventMapperTest.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/protocols/protocol-jt808/src/main/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapper.java b/modules/protocols/protocol-jt808/src/main/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapper.java index 931209ea..0fba341d 100644 --- a/modules/protocols/protocol-jt808/src/main/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapper.java +++ b/modules/protocols/protocol-jt808/src/main/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapper.java @@ -285,6 +285,10 @@ public final class Jt808EventMapper implements EventMapper { loc.extensionItems().forEach((id, bytes) -> copy.put("jt808.extra.0x" + String.format("%02X", id), hex(bytes))); copy.putAll(Jt808LocationAdditionalInfo.decode(loc.extensionItems())); + Double totalMileageKm = totalMileageKm(loc); + if (totalMileageKm != null) { + copy.put("total_mileage_km", Double.toString(totalMileageKm)); + } } return Map.copyOf(copy); } diff --git a/modules/protocols/protocol-jt808/src/test/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapperTest.java b/modules/protocols/protocol-jt808/src/test/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapperTest.java index 2b4d6fbe..03279b1e 100644 --- a/modules/protocols/protocol-jt808/src/test/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapperTest.java +++ b/modules/protocols/protocol-jt808/src/test/java/com/lingniu/ingest/protocol/jt808/mapper/Jt808EventMapperTest.java @@ -137,7 +137,10 @@ class Jt808EventMapperTest { VehicleEvent.Location event = (VehicleEvent.Location) mapper.toEvents(new Jt808Message(header, body)).getFirst(); assertThat(event.payload().totalMileageKm()).isEqualTo(1234.5); - assertThat(event.metadata()).containsEntry("jt808.extra.0x01", "00003039"); + assertThat(event.metadata()) + .containsEntry("jt808.extra.0x01", "00003039") + .containsEntry("jt808.extra.mileage_km", "1234.5") + .containsEntry("total_mileage_km", "1234.5"); } @Test