feat(platform): surface realtime source consistency
This commit is contained in:
@@ -43,6 +43,20 @@ function serviceStatusWeight(row: VehicleRealtimeRow) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function sourceIssueTags(row: VehicleRealtimeRow) {
|
||||
const tags = (row.sourceStatus ?? [])
|
||||
.filter((source) => !source.online || !source.hasRealtime)
|
||||
.map((source) => `${source.protocol} ${source.hasRealtime ? '离线' : '未接入'}`) ?? [];
|
||||
if (tags.length > 0) return tags;
|
||||
if (row.onlineSourceCount < row.sourceCount) return ['来源缺失'];
|
||||
return [];
|
||||
}
|
||||
|
||||
function hasSourceIssue(row: VehicleRealtimeRow) {
|
||||
const severity = row.serviceStatus?.severity;
|
||||
return severity === 'warning' || severity === 'error' || row.onlineSourceCount < row.sourceCount || sourceIssueTags(row).length > 0;
|
||||
}
|
||||
|
||||
function isValidCoordinate(row: VehicleRealtimeRow) {
|
||||
return Number.isFinite(row.longitude) && Number.isFinite(row.latitude) && row.longitude !== 0 && row.latitude !== 0;
|
||||
}
|
||||
@@ -126,6 +140,14 @@ export function Realtime({
|
||||
const locatedCount = rows.filter(isValidCoordinate).length;
|
||||
const degradedCount = rows.filter((row) => row.onlineSourceCount < row.sourceCount).length;
|
||||
const primaryProtocols = new Set(rows.map((row) => row.primaryProtocol).filter(Boolean));
|
||||
const sourceIssueRows = rows
|
||||
.filter((row) => canOpenVehicle(row.vin) && hasSourceIssue(row))
|
||||
.sort((a, b) => {
|
||||
const statusDelta = serviceStatusWeight(b) - serviceStatusWeight(a);
|
||||
if (statusDelta !== 0) return statusDelta;
|
||||
return String(b.lastSeen ?? '').localeCompare(String(a.lastSeen ?? ''));
|
||||
})
|
||||
.slice(0, 4);
|
||||
const mapServiceRows = rows
|
||||
.filter((row) => isValidCoordinate(row) && canOpenVehicle(row.vin))
|
||||
.sort((a, b) => {
|
||||
@@ -217,6 +239,43 @@ export function Realtime({
|
||||
<Typography.Text type="secondary">
|
||||
高德 Web JS Key 和安全密钥通过运行环境配置,前端只读取公开 Key;安全密钥后续走服务端代理,避免明文下发。
|
||||
</Typography.Text>
|
||||
<div className="vp-source-consistency-panel">
|
||||
<div className="vp-map-service-queue-title">多来源一致性检查</div>
|
||||
{sourceIssueRows.length === 0 ? (
|
||||
<Typography.Text type="tertiary">当前页车辆来源一致</Typography.Text>
|
||||
) : (
|
||||
sourceIssueRows.map((row) => {
|
||||
const status = vehicleServiceStatus(row);
|
||||
return (
|
||||
<div key={`${row.vin}-${row.primaryProtocol}-consistency`} className="vp-map-service-item">
|
||||
<div className="vp-map-service-item-main">
|
||||
<div>
|
||||
<Typography.Text strong>{row.plate || row.vin}</Typography.Text>
|
||||
<Typography.Text type="tertiary" size="small">{row.vin}</Typography.Text>
|
||||
</div>
|
||||
<Tag color={status.color}>{status.label}</Tag>
|
||||
</div>
|
||||
<Space spacing={4} wrap>
|
||||
<Tag color="blue">{sourceEvidenceText(row)}</Tag>
|
||||
{sourceIssueTags(row).map((item) => (
|
||||
<Tag key={item} color="orange">一致性:{item}</Tag>
|
||||
))}
|
||||
</Space>
|
||||
<Typography.Text type="secondary" size="small">
|
||||
一致性诊断:{row.serviceStatus?.detail || sourceEvidenceText(row)}
|
||||
</Typography.Text>
|
||||
<div className="vp-map-service-item-footer">
|
||||
<Typography.Text type="tertiary" size="small">{row.lastSeen || '-'}</Typography.Text>
|
||||
<Space spacing={4} wrap>
|
||||
<Button size="small" disabled={!onOpenQuality} onClick={() => openQualityEvidence(row)}>检查质量</Button>
|
||||
<Button size="small" onClick={() => onOpenVehicle(row.vin, filters.protocol || row.primaryProtocol)}>查看服务</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
<div className="vp-map-service-queue">
|
||||
<div className="vp-map-service-queue-title">地图车辆服务队列</div>
|
||||
{mapServiceRows.length === 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user