fix(go): project full yutong mqtt data to realtime kv

This commit is contained in:
lingniu
2026-07-03 12:01:32 +08:00
parent 0344c65e5b
commit 7bf78f91ba
2 changed files with 26 additions and 2 deletions

View File

@@ -90,7 +90,13 @@ func realtimeKVFields(env envelope.FrameEnvelope, parsed map[string]any) []Realt
}
rows = add(rows, "location", fields)
case envelope.ProtocolYutongMQTT:
rows = add(rows, "vehicle", cloneFields(env.Fields))
fields := cloneFields(env.Fields)
if data, ok := parsed["data"].(map[string]any); ok {
for key, value := range data {
fields[key] = value
}
}
rows = add(rows, "vehicle", fields)
}
return rows
}
@@ -171,6 +177,8 @@ func stringifyKVValue(value any) (string, string, bool) {
return strconv.FormatFloat(typed, 'f', -1, 64), "number", true
case float32:
return strconv.FormatFloat(float64(typed), 'f', -1, 64), "number", true
case json.Number:
return typed.String(), "number", strings.TrimSpace(typed.String()) != ""
case int:
return strconv.Itoa(typed), "number", true
case int8, int16, int32, int64: