feat(platform): expose coverage service status
This commit is contained in:
@@ -478,6 +478,57 @@ func buildVehicleServiceStatus(resolved bool, statuses []VehicleSourceStatus) *V
|
||||
}
|
||||
}
|
||||
|
||||
func buildVehicleCoverageServiceStatus(row VehicleCoverageRow) *VehicleServiceStatus {
|
||||
if row.BindingStatus != "bound" {
|
||||
return &VehicleServiceStatus{
|
||||
Status: "identity_required",
|
||||
Severity: "warning",
|
||||
Title: "身份未绑定",
|
||||
Detail: "车辆身份绑定不完整,需先维护 VIN、车牌或手机号映射。",
|
||||
SourceCount: row.SourceCount,
|
||||
OnlineSourceCount: row.OnlineSourceCount,
|
||||
}
|
||||
}
|
||||
if row.SourceCount == 0 {
|
||||
return &VehicleServiceStatus{
|
||||
Status: "no_data",
|
||||
Severity: "warning",
|
||||
Title: "暂无数据来源",
|
||||
Detail: "车辆已绑定,但暂未查询到 32960、808 或 MQTT 数据来源。",
|
||||
SourceCount: row.SourceCount,
|
||||
OnlineSourceCount: row.OnlineSourceCount,
|
||||
}
|
||||
}
|
||||
if row.OnlineSourceCount == 0 {
|
||||
return &VehicleServiceStatus{
|
||||
Status: "offline",
|
||||
Severity: "error",
|
||||
Title: "车辆离线",
|
||||
Detail: "所有已知数据来源均未在线,需要检查平台转发、终端上报或链路状态。",
|
||||
SourceCount: row.SourceCount,
|
||||
OnlineSourceCount: row.OnlineSourceCount,
|
||||
}
|
||||
}
|
||||
if row.OnlineSourceCount < row.SourceCount {
|
||||
return &VehicleServiceStatus{
|
||||
Status: "degraded",
|
||||
Severity: "warning",
|
||||
Title: "部分来源离线",
|
||||
Detail: sourceCoverageDetail(row.SourceCount, row.OnlineSourceCount, "车辆服务可用但需要关注离线来源。"),
|
||||
SourceCount: row.SourceCount,
|
||||
OnlineSourceCount: row.OnlineSourceCount,
|
||||
}
|
||||
}
|
||||
return &VehicleServiceStatus{
|
||||
Status: "healthy",
|
||||
Severity: "ok",
|
||||
Title: "服务正常",
|
||||
Detail: sourceCoverageDetail(row.SourceCount, row.OnlineSourceCount, "全部已知来源在线。"),
|
||||
SourceCount: row.SourceCount,
|
||||
OnlineSourceCount: row.OnlineSourceCount,
|
||||
}
|
||||
}
|
||||
|
||||
func sourceCoverageDetail(sourceCount int, onlineSourceCount int, suffix string) string {
|
||||
return strconv.Itoa(onlineSourceCount) + "/" + strconv.Itoa(sourceCount) + " 个来源在线," + suffix
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user