fix: enrich xinda raw frame metadata
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.lingniu.ingest.eventhistory;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineHistoryReader;
|
||||
import com.lingniu.ingest.tdenginehistory.TdenginePage;
|
||||
import com.lingniu.ingest.tdenginehistory.TdenginePageCursor;
|
||||
@@ -22,6 +24,7 @@ import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty(prefix = "lingniu.ingest.event-history", name = "enabled", havingValue = "true")
|
||||
@@ -30,6 +33,9 @@ import java.util.Locale;
|
||||
@Tag(name = "Raw Frame API", description = "原始帧索引分页查询接口。")
|
||||
public final class RawFrameHistoryController {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
private static final TypeReference<Map<String, Object>> MAP_TYPE = new TypeReference<>() {};
|
||||
|
||||
private final TdengineHistoryReader reader;
|
||||
|
||||
public RawFrameHistoryController(TdengineHistoryReader reader) {
|
||||
@@ -165,6 +171,7 @@ public final class RawFrameHistoryController {
|
||||
String parseError,
|
||||
String peer,
|
||||
String metadataJson,
|
||||
Map<String, Object> metadata,
|
||||
String protocol,
|
||||
String vehicleKey,
|
||||
String vin,
|
||||
@@ -185,10 +192,22 @@ public final class RawFrameHistoryController {
|
||||
row.parseError(),
|
||||
row.peer(),
|
||||
row.metadataJson(),
|
||||
metadata(row.metadataJson()),
|
||||
row.protocol(),
|
||||
row.vehicleKey(),
|
||||
row.vin(),
|
||||
row.phone());
|
||||
}
|
||||
|
||||
private static Map<String, Object> metadata(String metadataJson) {
|
||||
if (metadataJson == null || metadataJson.isBlank()) {
|
||||
return Map.of();
|
||||
}
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(metadataJson, MAP_TYPE);
|
||||
} catch (Exception ignored) {
|
||||
return Map.of("_raw", metadataJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user