fix: expose jt808 mileage metadata
This commit is contained in:
@@ -285,6 +285,10 @@ public final class Jt808EventMapper implements EventMapper<Jt808Message> {
|
|||||||
loc.extensionItems().forEach((id, bytes) ->
|
loc.extensionItems().forEach((id, bytes) ->
|
||||||
copy.put("jt808.extra.0x" + String.format("%02X", id), hex(bytes)));
|
copy.put("jt808.extra.0x" + String.format("%02X", id), hex(bytes)));
|
||||||
copy.putAll(Jt808LocationAdditionalInfo.decode(loc.extensionItems()));
|
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);
|
return Map.copyOf(copy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,10 @@ class Jt808EventMapperTest {
|
|||||||
VehicleEvent.Location event = (VehicleEvent.Location) mapper.toEvents(new Jt808Message(header, body)).getFirst();
|
VehicleEvent.Location event = (VehicleEvent.Location) mapper.toEvents(new Jt808Message(header, body)).getFirst();
|
||||||
|
|
||||||
assertThat(event.payload().totalMileageKm()).isEqualTo(1234.5);
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user