fix: 仪表盘 totalCapacity 聚合值转为数字

This commit is contained in:
2026-08-05 17:53:44 +08:00
parent 1e1e24f0f0
commit 2a519a3714

View File

@@ -101,7 +101,8 @@ export class DashboardService {
.select('SUM(r.capacity)', 'total')
.where('r.status != :archived', { archived: 'archived' });
const totalCapacity = await capQb.getRawOne();
const cap = totalCapacity?.total || 0;
// MySQL 的 SUM() 聚合默认以字符串返回,需显式转成 number
const cap = Number(totalCapacity?.total ?? 0) || 0;
const occupancyRate = cap > 0 ? ((occupiedBeds / cap) * 100).toFixed(1) : 0;
const billStatsQb = this.billRepo