feat(dashboard): 接入预测结果聚合

This commit is contained in:
2026-05-11 22:21:57 +08:00
parent b11d37e9d8
commit 1a2ff19cf4
4 changed files with 125 additions and 12 deletions
+33
View File
@@ -59,4 +59,37 @@ describe('battery domain', () => {
snapshot.devices.length,
)
})
test('uses AI prediction values when available', () => {
const now = new Date('2026-05-11T00:00:00.000Z')
const items = rows.map(toBatteryInfo)
const snapshot = createDashboardSnapshot(
items,
now,
new Map([
[
'RING-A03',
{
mac: 'RING-A03',
nowSoh: 60,
monthSoh: 58,
trmonthSoh: 52,
riskScore: 40,
riskLevel: 'high',
status: '危险',
modelName: 'XGBoost',
cyclesUsed: 6,
updatedAt: '2026-05-11T00:00:00.000Z',
},
],
]),
)
const predicted = snapshot.devices.find((device) => device.id === 'RING-A03')
expect(predicted?.soh).toBe(60)
expect(predicted?.soh30d).toBe(58)
expect(predicted?.soh90d).toBe(52)
expect(predicted?.status).toBe('预警')
expect(predicted?.firmware).toBe('XGBoost')
})
})