feat(platform): add vehicle data management console

This commit is contained in:
lingniu
2026-07-03 20:55:54 +08:00
parent 0d8916df47
commit 859bc3e9ee
45 changed files with 6837 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import type {
ApiEnvelope,
DailyMileageRow,
DashboardSummary,
HistoryLocationRow,
OpsHealth,
Page,
QualityIssueRow,
RawFrameRow,
RealtimeLocationRow,
VehicleRow
} from './types';
async function request<T>(path: string, init?: RequestInit): Promise<T> {
const response = await fetch(path, init);
if (!response.ok) {
throw new Error(`request failed ${response.status}`);
}
const envelope = (await response.json()) as ApiEnvelope<T>;
return envelope.data;
}
export const api = {
dashboardSummary: () => request<DashboardSummary>('/api/dashboard/summary'),
vehicles: (params = new URLSearchParams()) => request<Page<VehicleRow>>(`/api/vehicles?${params.toString()}`),
realtimeLocations: (params = new URLSearchParams()) => request<Page<RealtimeLocationRow>>(`/api/realtime/locations?${params.toString()}`),
historyLocations: (params = new URLSearchParams()) => request<Page<HistoryLocationRow>>(`/api/history/locations?${params.toString()}`),
rawFrames: (params = new URLSearchParams()) => request<Page<RawFrameRow>>(`/api/history/raw-frames?${params.toString()}`),
dailyMileage: (params = new URLSearchParams()) => request<Page<DailyMileageRow>>(`/api/mileage/daily?${params.toString()}`),
qualityIssues: (params = new URLSearchParams()) => request<Page<QualityIssueRow>>(`/api/quality/issues?${params.toString()}`),
opsHealth: () => request<OpsHealth>('/api/ops/health')
};

View File

@@ -0,0 +1,103 @@
export interface ApiEnvelope<T> {
data: T;
traceId: string;
timestamp: number;
}
export interface ProtocolStat {
protocol: string;
online: number;
total: number;
}
export interface LinkHealth {
name: string;
status: string;
detail?: string;
}
export interface DashboardSummary {
onlineVehicles: number;
activeToday: number;
frameToday: number;
issueVehicles: number;
kafkaLag: number;
protocols: ProtocolStat[];
linkHealth: LinkHealth[];
}
export interface VehicleRow {
vin: string;
plate: string;
phone: string;
oem: string;
protocol: string;
online: boolean;
lastSeen: string;
locationText: string;
bindingScore: number;
}
export interface RealtimeLocationRow {
vin: string;
plate: string;
protocol: string;
longitude: number;
latitude: number;
speedKmh: number;
socPercent: number;
totalMileageKm: number;
lastSeen: string;
}
export interface HistoryLocationRow extends RealtimeLocationRow {
deviceTime: string;
serverTime: string;
}
export interface RawFrameRow {
id: string;
vin: string;
protocol: string;
frameType: string;
deviceTime: string;
serverTime: string;
rawSizeBytes: number;
parsedFields?: Record<string, unknown>;
}
export interface DailyMileageRow {
vin: string;
plate: string;
date: string;
startMileageKm: number;
endMileageKm: number;
dailyMileageKm: number;
source: string;
anomalySeverity?: string;
}
export interface QualityIssueRow {
vin: string;
plate: string;
protocol: string;
issueType: string;
severity: string;
lastSeen: string;
detail: string;
}
export interface OpsHealth {
linkHealth: LinkHealth[];
kafkaLag: number;
redisOnlineKeys: number;
tdengineWritable: boolean;
mysqlWritable: boolean;
}
export interface Page<T> {
items: T[];
total: number;
limit: number;
offset: number;
}