feat: build vehicle data platform and production pipeline

This commit is contained in:
lingniu
2026-07-14 12:35:33 +08:00
parent b452be3b94
commit bb59303a4b
270 changed files with 88016 additions and 1975 deletions

View File

@@ -0,0 +1,40 @@
import type { VehicleRealtimeRow } from '../../api/types';
import { describe, expect, it } from 'vitest';
import { formatNumber, statusLabel, vehicleStatus } from './monitor';
function vehicle(overrides: Partial<VehicleRealtimeRow> = {}): VehicleRealtimeRow {
return {
vin: 'LTEST000000000001',
plate: '粤A00001',
phone: '',
oem: '',
protocols: ['JT808'],
sourceStatus: [],
sourceCount: 1,
onlineSourceCount: 1,
online: true,
bindingStatus: 'bound',
primaryProtocol: 'JT808',
longitude: 113.2,
latitude: 23.1,
speedKmh: 0,
socPercent: 80,
totalMileageKm: 10,
lastSeen: '2026-07-14 01:00:00',
...overrides
};
}
describe('monitor domain', () => {
it('keeps online, motion and unknown status semantics separate', () => {
expect(vehicleStatus(vehicle({ online: false }))).toBe('offline');
expect(vehicleStatus(vehicle({ speedKmh: 32 }))).toBe('driving');
expect(vehicleStatus(vehicle({ speedKmh: 0 }))).toBe('idle');
expect(vehicleStatus(vehicle({ lastSeen: '' }))).toBe('unknown');
});
it('formats dense monitor values consistently', () => {
expect(formatNumber(12560)).toBe('12,560');
expect(statusLabel('driving')).toBe('行驶');
});
});