fix: 仪表盘 totalCapacity 聚合值转为数字
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user