Drop the 每日/总览 sub-tabs on 电能 — only 龙王路充电站 in scope, so
the overview is light (3 KPI cards + 1 bar chart) and combining
saves a click for daily ops. ElectricView now renders ElectricOverview
+ ElectricDaily back-to-back below the hint card.
氢能 keeps its sub-tabs (richer overview with Top5 + region chart).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The "每 5 分钟更新" copy was inherited from the BI dashboard mock and
no longer matches reality — server cache is 60s TTL.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace front-end mock data with live API backed by:
- tab_energy_hydrogen_bill (66.5K rows) joined with
tab_hydrogen_site (internal stations) and tab_outside_hydrogen_site
(external stations, joined via inner_site_id)
- tab_energy_electricity_bill (4.4K rows, all 龙王路充电站)
New server routes (src/server/routes/energy/):
- GET /api/energy/hydrogen/overview → KPI + Top5 站点 + 区域占比
- GET /api/energy/hydrogen/daily?range=&customer= → 日级 + 站点级下钻
- GET /api/energy/electric/overview → KPI + 本月柱图 (fallback to last
available month if current month has no data)
- GET /api/energy/electric/monthly?customer= → 6 个月分组日级表
Business rules encoded server-side:
- 客户类型: customer_id IS NULL = 羚牛承担, NOT NULL = 外部
- 时区: DATETIME 列字面值是 UTC,分组前 +8h 转成 CST
- 数据清理: hydrogen_time >= 2024-01-01 (排除 1900 年脏数据)
- 站点名 fallback: short_name → name → fixed_station_name → station_name → '未知站点'
- 区域归一化: SUBSTRING_INDEX(city, '-', -1) 取最后一段,去掉 '省'/'市'
让 '四川省-成都市' 和 '成都市' 合并为 '成都'
Component changes:
- All 4 components (HydrogenOverview, HydrogenDaily, ElectricOverview,
ElectricDaily) now use useEffect + fetch with loading/error states
- HydrogenDaily filtering moved to server (range + customer params)
→ drops client-side TODAY constant + isInPick switch
- ElectricOverview chart title is dynamic: shows 'YYYY-MM 每日充电'
when fallback kicks in (current month has no data)
- mock.ts deleted
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Symmetry with hydrogen — both sides now have a 每日/总览 sub-tab pair
- New ElectricOverview (KPI + bar chart) and ElectricDaily (table)
- Sub-tab styling: pill fill (active = blue-50/blue-600) instead of the
underline-style used by parent — clearer visual hierarchy
- Tab order swapped to 每日 → 总览 with 每日 as default (daily ops focus)
- Today KPI: pill moves to absolute top-right corner so today's kwh
reading regains full row width (was getting truncated to "510...")
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
All bars now use the cyan→blue gradient consistently, matching the
electric daily chart. Anomaly information stays available via the
table row tinting and the trend pills below.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the electric-view treatment: a 时段每日加氢量 bar chart sits
between the customer toggle and the table. Bars use the cyan→blue
gradient by default; days where |chainPct| >= 30% render in solid
emerald (positive) or red (negative), giving an at-a-glance view of
anomalous days that's reinforced by the table's row tinting below.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- New 本月每日充电 bar chart (蓝青 gradient) sits between KPI row and
table, fixing the previous "wall of numbers" feel
- Day rows now tint emerald/red when |chainPct| >= 30% (matches hydrogen)
- 环比 pill column now also shows on mobile (was desktop-only)
- Today KPI: pill moves to second line alongside kwh via justify-between
so it no longer gets clipped on narrow viewports
- Day labels in table trimmed to MM-DD (parent month row already shows year)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- mock: derive ELECTRIC_KPI month/today from APR_DAYS so card and table
totals always agree (previously ¥8,437 vs ¥9,151 mismatch)
- overview: Top5 bar chart now shows rank badges (1-5) and inline value
labels at bar ends — readable without hover
- overview: donut "年合计 362.43T" moves into the chart center
(previously below as a separate line, defeating the donut hole)
- daily: rows with |chainPct| ≥ 30% get a tinted background
(green for spikes, red for drops) for at-a-glance abnormal-day spotting
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>