feat(platform): share vehicle service verdict logic
This commit is contained in:
@@ -7,6 +7,7 @@ import { DataEmpty } from '../components/DataEmpty';
|
||||
import { PageHeader } from '../components/PageHeader';
|
||||
import { SourceStatusTags } from '../components/SourceStatusTags';
|
||||
import { StatusTag } from '../components/StatusTag';
|
||||
import { summarizeVehicleService } from '../domain/vehicleService';
|
||||
|
||||
function vehicleServiceStatus(row: VehicleCoverageRow) {
|
||||
if (row.serviceStatus) {
|
||||
@@ -15,19 +16,14 @@ function vehicleServiceStatus(row: VehicleCoverageRow) {
|
||||
color: row.serviceStatus.severity === 'ok' ? 'green' as const : row.serviceStatus.severity === 'error' ? 'red' as const : 'orange' as const
|
||||
};
|
||||
}
|
||||
if (row.bindingStatus !== 'bound') {
|
||||
return { label: '身份未绑定', color: 'orange' as const };
|
||||
}
|
||||
if (row.sourceCount <= 0) {
|
||||
return { label: '暂无数据来源', color: 'orange' as const };
|
||||
}
|
||||
if (row.onlineSourceCount <= 0) {
|
||||
return { label: '车辆离线', color: 'red' as const };
|
||||
}
|
||||
if (row.onlineSourceCount < row.sourceCount) {
|
||||
return { label: '来源不完整', color: 'orange' as const };
|
||||
}
|
||||
return { label: '服务正常', color: 'green' as const };
|
||||
const verdict = summarizeVehicleService({
|
||||
bindingStatus: row.bindingStatus,
|
||||
sourceCount: row.sourceCount,
|
||||
onlineSourceCount: row.onlineSourceCount,
|
||||
missingProtocols: row.missingProtocols,
|
||||
mileageDeltaKm: row.sourceConsistency?.mileageDeltaKm
|
||||
});
|
||||
return { label: verdict.status, color: verdict.color };
|
||||
}
|
||||
|
||||
function sourceEvidenceText(row: VehicleCoverageRow) {
|
||||
@@ -101,19 +97,26 @@ type VehicleActionRecommendation = {
|
||||
};
|
||||
|
||||
function vehicleActionRecommendation(row: VehicleCoverageRow): VehicleActionRecommendation {
|
||||
const verdict = summarizeVehicleService({
|
||||
bindingStatus: row.bindingStatus,
|
||||
sourceCount: row.sourceCount,
|
||||
onlineSourceCount: row.onlineSourceCount,
|
||||
missingProtocols: row.missingProtocols,
|
||||
mileageDeltaKm: row.sourceConsistency?.mileageDeltaKm
|
||||
});
|
||||
if (row.bindingStatus !== 'bound') {
|
||||
return { label: '维护身份绑定', color: 'orange' as const, filters: { bindingStatus: 'unbound' } };
|
||||
return { label: '维护身份绑定', color: verdict.color, filters: { bindingStatus: 'unbound' } };
|
||||
}
|
||||
if ((row.missingProtocols ?? []).length > 0) {
|
||||
return { label: `补齐 ${row.missingProtocols.join('、')} 来源`, color: 'orange' as const, filters: { missingProtocol: row.missingProtocols[0] } };
|
||||
return { label: `补齐 ${row.missingProtocols.join('、')} 来源`, color: verdict.color, filters: { missingProtocol: row.missingProtocols[0] } };
|
||||
}
|
||||
if (row.sourceCount <= 0) {
|
||||
return { label: '确认平台转发配置', color: 'orange' as const, filters: { serviceStatus: 'no_data' } };
|
||||
return { label: '确认平台转发配置', color: verdict.color, filters: { serviceStatus: 'no_data' } };
|
||||
}
|
||||
if (row.onlineSourceCount <= 0) {
|
||||
return { label: '排查离线链路', color: 'red' as const, filters: { online: 'offline' } };
|
||||
return { label: '排查离线链路', color: verdict.color, filters: { online: 'offline' } };
|
||||
}
|
||||
return { label: '持续观察', color: 'green' as const, filters: null };
|
||||
return { label: '持续观察', color: verdict.color, filters: null };
|
||||
}
|
||||
|
||||
function sourceConsistencyAction(row: VehicleCoverageRow, onFilter: (filters: Record<string, string>) => void) {
|
||||
|
||||
Reference in New Issue
Block a user