fix: expose jt808 location raw archive uri
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.lingniu.ingest.eventhistory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineHistoryReader;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineLocationQuery;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineLocationRow;
|
||||
@@ -29,6 +31,8 @@ import java.util.List;
|
||||
@Tag(name = "jt-808-location-controller", description = "JT808 位置历史分页查询接口。")
|
||||
public final class Jt808LocationHistoryController {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
private final TdengineHistoryReader reader;
|
||||
|
||||
public Jt808LocationHistoryController(TdengineHistoryReader reader) {
|
||||
@@ -142,8 +146,23 @@ public final class Jt808LocationHistoryController {
|
||||
row.alarmFlag(),
|
||||
row.statusFlag(),
|
||||
row.totalMileageKm(),
|
||||
row.rawUri(),
|
||||
rawUri(row),
|
||||
row.metadataJson());
|
||||
}
|
||||
|
||||
private static String rawUri(TdengineLocationRow row) {
|
||||
if (row.rawUri() != null && !row.rawUri().isBlank()) {
|
||||
return row.rawUri();
|
||||
}
|
||||
String metadataJson = row.metadataJson();
|
||||
if (metadataJson == null || metadataJson.isBlank()) {
|
||||
return row.rawUri();
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readTree(metadataJson).path("rawArchiveUri").asText(row.rawUri());
|
||||
} catch (JsonProcessingException ignored) {
|
||||
return row.rawUri();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user