feat: sync vehicle monitoring and accumulated platform updates

Add monitoring metrics, numeric sorting, report-time display, vehicle number labels, and map layout fixes. Include accumulated mileage, hydrogen, OneOS authentication, open platform, ingestion, deployment, and UI updates.

Exclude temporary files, generated reports, and credentials. Validate frontend 632 tests and production build, API packages, vehicle-map tests, and release installer tests. Gateway suite has one pre-existing date-sensitive identity throttling test failure reproduced on the parent commit.
This commit is contained in:
lingniu
2026-10-26 18:05:59 +08:00
parent 8b32ae2988
commit d6b957dfc8
290 changed files with 28238 additions and 1647 deletions
@@ -51,6 +51,17 @@ func ExtractFrames(stream []byte) (frames [][]byte, remainder []byte, err error)
}
func ParseFrame(raw []byte, receivedAtMS int64, sourceEndpoint string) (envelope.FrameEnvelope, error) {
return parseFrame(raw, receivedAtMS, sourceEndpoint, false)
}
// ParseFrameForPlatform selects Feichi's opaque, length-prefixed 0x80 format
// using the account established by this TCP connection's platform login.
// All other accounts retain the existing Guangdong extension decoder.
func ParseFrameForPlatform(raw []byte, receivedAtMS int64, sourceEndpoint, platformAccount string) (envelope.FrameEnvelope, error) {
return parseFrame(raw, receivedAtMS, sourceEndpoint, strings.TrimSpace(platformAccount) == "Feichi")
}
func parseFrame(raw []byte, receivedAtMS int64, sourceEndpoint string, feichiCustom80 bool) (envelope.FrameEnvelope, error) {
if len(raw) < minFrameLen {
return envelope.FrameEnvelope{}, fmt.Errorf("%w: len=%d", ErrFrameTooShort, len(raw))
}
@@ -86,7 +97,7 @@ func ParseFrame(raw []byte, receivedAtMS int64, sourceEndpoint string) (envelope
eventTimeMS := receivedAtMS
if command == 0x02 || command == 0x03 {
eventTime, units := parseDataBody(version, body, fields)
eventTime, units := parseDataBodyWithCustom80(version, body, fields, feichiCustom80)
if !eventTime.IsZero() {
eventTimeMS = eventTime.UnixMilli()
fields["device_time"] = eventTime.Format(time.RFC3339)
@@ -117,17 +128,33 @@ func ParseFrame(raw []byte, receivedAtMS int64, sourceEndpoint string) (envelope
Fields: fields,
ParseStatus: envelope.ParseOK,
}
if feichiCustom80 {
if units, ok := parsed["data_units"].([]map[string]any); ok {
for _, unit := range units {
if unit["name"] == "feichi_custom_80" && unit["error"] != nil {
env.ParseStatus = envelope.ParsePartial
env.ParseError = "Feichi 0x80: " + fmt.Sprint(unit["error"])
break
}
}
}
}
env.EventID = env.StableEventID()
return env, nil
}
func parseDataBody(version string, body []byte, fields map[string]any) (time.Time, []map[string]any) {
return parseDataBodyWithCustom80(version, body, fields, false)
}
func parseDataBodyWithCustom80(version string, body []byte, fields map[string]any, feichiCustom80 bool) (time.Time, []map[string]any) {
if len(body) < 6 {
return time.Time{}, nil
}
eventTime := parseGBTime(body[:6])
cursor := 6
var units []map[string]any
custom80Blocks := 0
for cursor < len(body) {
unitType := body[cursor]
cursor++
@@ -293,6 +320,16 @@ func parseDataBody(version string, body []byte, fields map[string]any) (time.Tim
fields["gd_fc_vehicle_hydrogen_mass_kg"] = unit["hydrogen_mass_kg"]
cursor += 7
case 0x80:
if feichiCustom80 {
custom80Blocks++
unit, size := parseFeichiCustom80Data(body[cursor:], custom80Blocks)
units = append(units, unit)
cursor += size
if unit["error"] != nil {
return eventTime, units
}
continue
}
if len(body[cursor:]) < 11 {
units = append(units, map[string]any{"type": "0x80", "error": "truncated"})
return eventTime, units
@@ -323,6 +360,43 @@ func parseDataBody(version string, body []byte, fields map[string]any) (time.Tim
return eventTime, units
}
func parseFeichiCustom80Data(data []byte, blockNumber int) (map[string]any, int) {
size := len(data)
lengthSize := min(2, len(data))
payload := []byte(nil)
block := map[string]any{
"length_hex": strings.ToUpper(hex.EncodeToString(data[:lengthSize])),
}
parseError := ""
if len(data) < 2 {
parseError = "truncated_length"
} else {
declared := int(binary.BigEndian.Uint16(data[:2]))
block["declared_length"] = declared
size = min(2+declared, len(data))
payload = data[2:size]
if size < 2+declared {
parseError = "truncated_payload"
}
}
block["actual_length"] = len(payload)
block["payload_hex"] = strings.ToUpper(hex.EncodeToString(payload))
block["raw_hex"] = "80" + strings.ToUpper(hex.EncodeToString(data[:size]))
unit := map[string]any{
"type": "0x80",
"name": "feichi_custom_80",
"value": map[string]any{
// Distinct keys preserve repeated 0x80 blocks in flattened RAW fields.
"blocks": map[string]any{fmt.Sprintf("block_%d", blockNumber): block},
},
}
if parseError != "" {
unit["error"] = parseError
block["parse_error"] = parseError
}
return unit, size
}
func frameLength(frameStart []byte, bodyLen int) int {
standardLen := headerLen + bodyLen + 1
if len(frameStart) < headerLen || frameStart[2] != 0x05 || bodyLen != 41 {