fix: preserve jt808 location raw archive uri

This commit is contained in:
lingniu
2026-06-29 15:23:34 +08:00
parent b244984fcb
commit 6646b9b1e1
2 changed files with 23 additions and 1 deletions

View File

@@ -55,7 +55,9 @@ public final class TdengineEnvelopeRows {
return Optional.empty();
}
LocationPayload location = envelope.getLocation();
String rawUri = envelope.hasRawArchive() ? envelope.getRawArchive().getUri() : "";
String rawUri = firstNonBlank(
envelope.hasRawArchive() ? envelope.getRawArchive().getUri() : "",
envelope.getMetadataOrDefault("rawArchiveUri", ""));
String frameId = envelope.getMetadataOrDefault("frame_id", envelope.getEventId());
return Optional.of(new TdengineLocationRow(
instant(envelope.getEventTimeMs()),

View File

@@ -89,6 +89,26 @@ class TdengineEnvelopeRowsTest {
assertThat(row.rawUri()).isEqualTo("archive://gb32960/2026/06/29/frame-location-1.bin");
}
@Test
void mapsLocationRawUriFromMetadataWhenRawArchiveRefIsAbsent() {
VehicleEnvelope envelope = VehicleEnvelope.newBuilder()
.setEventId("evt-location-metadata-raw")
.setVin("unknown")
.setSource("JT808")
.setEventTimeMs(1_772_000_002_000L)
.setIngestTimeMs(1_772_000_002_321L)
.putMetadata("phone", "13079963291")
.putMetadata("rawArchiveUri", "archive://jt808/metadata-only.bin")
.setLocation(LocationPayload.newBuilder()
.setLongitude(119.12)
.setLatitude(29.45))
.build();
TdengineLocationRow row = TdengineEnvelopeRows.location(envelope).orElseThrow();
assertThat(row.rawUri()).isEqualTo("archive://jt808/metadata-only.bin");
}
@Test
void mapsTelemetrySnapshotEnvelopeToFieldRows() {
VehicleEnvelope envelope = VehicleEnvelope.newBuilder()