feat: 仪表盘成本统计数据驱动化 — CloudAccount新增MonthlyCost字段 + dashboard实时聚合云账号月费用
This commit is contained in:
1 parent
a1237587f6
commit
5db69e8abc
5 files changed
+84
-26
No files matched your search
@@ -153,3 +153,25 @@ cd ~/devops/aiops
|
||||
- 浏览器UI验证: 服务器列表页正常渲染,内存显示为GB(128GB而非131072MB),公网IP列正确显示 ✅
|
||||
- 表单UI验证: 添加服务器弹窗字段正确,验证逻辑正常(hostname+ip必填时按钮启用)✅
|
||||
- 服务运行中: 后端:8080 + 前端:5173 ✅
|
||||
|
||||
## 2026-06-14 06:30 自动推进
|
||||
|
||||
- **任务**: 仪表盘成本统计从硬编码改为基于实际云账号月费用计算 — 新增 CloudAccount.MonthlyCost 字段,dashboard 接口实时聚合
|
||||
- **修改**:
|
||||
- `backend/internal/models/server.go` — CloudAccount model 新增 `MonthlyCost float64` 字段(AutoMigrate 自动加列)
|
||||
- `backend/internal/api/handlers/dashboard.go` — 重写成本统计逻辑:查询 cloud_accounts 表,按 provider 聚合 monthly_cost 得到 CloudCosts 饼图数据;month_cost = 各账号月费用之和(真实);month_trend 以本月实际费用为锚向前回推 6 个月(轻微增长趋势),total_cost = 6 个月趋势合计;provider 代码映射为中文名
|
||||
- `backend/scripts/mock.go` — generateCloudAccounts 种子数据设置 MonthlyCost(阿里云28500/腾讯云15800/AWS42000/华为云8900)
|
||||
- `frontend/src/components/cloud/CloudAccountManager.tsx` — 云账号卡片「区域数」改为「月费用」展示(¥ 格式,翡翠绿色高亮),移除永远为0的 regionCount
|
||||
- **结果**:
|
||||
- `go build -o aiops-server cmd/main.go` 编译通过 ✅
|
||||
- `npx tsc --noEmit` 类型检查通过 ✅
|
||||
- `npm run build` 构建通过 ✅
|
||||
- API 验证: `/dashboard/stats` cost_stats.month_cost=95200 (=28500+15800+42000+8900 真实求和), cloud_costs 4 条真实平台数据, month_trend 6个月(1月~6月)当前月=95200 ✅
|
||||
- 已有 DB 4 个账号 backfill monthly_cost(AutoMigrate 加列后 SQL UPDATE)✅
|
||||
- 浏览器验证: 仪表盘「本月云成本」显示 ¥95,200(真实计算值)✅
|
||||
- 健康检查 /health 正常 ✅
|
||||
- **下一步建议**:
|
||||
- 云账号「添加账号」按钮弹窗表单实现(当前点击无响应,无法录入月费用)
|
||||
- K8s 集群拓扑图(TopologyView)前后端数据联调
|
||||
- 告警「通知配置」按钮功能实现(通知渠道管理弹窗)
|
||||
- 仪表盘「+12.5%」等增长率标签从硬编码改为基于 month_trend 真实计算
|
||||
Reference in new issue
Block a user