Commit Graph

28 Commits

Author SHA1 Message Date
kkfluous
23a7722583 chore(energy): 氢能总览删除「我方/客户产生」副统计
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
年加氢量、年加氢费 卡片移除以下副信息:
  - 我方 XXX
  - 客户产生 XXX

只保留主标题与大数字。其他卡片(累计羚牛承担、本月/今日)保持不变。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 20:04:56 +08:00
kkfluous
213037c2ac fix(energy): 氢能 Top5 排名圆点左侧被 SVG 视窗切掉
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
之前 cx=-178 + YAxis.width=190 + margin.left=0:
  Y 轴线 pivot 在 chart x=190;圆点 abs x=12,半径 9 → 左缘 abs x=3
  紧贴 SVG viewBox 左边界,渲染时被切掉一半。

新值:margin.left=12,YAxis.width=188,circle cx=-172,text x=-154
  pivot=200,圆点 abs x=28,左缘=19,离左边界 19px 缓冲,圆点完整可见。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 20:03:24 +08:00
kkfluous
3efa701395 feat(energy): 氢能总览加载骨架屏,缓解 1-2s 初始等待
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
之前数据回来前只显示一行「加载中…」纯文本,1-2 秒等待体感差。
新增 HydrogenOverviewSkeleton:
  - 4 张 KPI 卡占位(含标题/数值/副信息行)
  - Top5 横向条形图占位(5 行 圆点 + 站名 + 渐变条 + 数值)
  - 区域占比环 + 图例占位
  - 底部蓝色脉冲点 +「正在加载氢能总览…」
全部用 animate-pulse,结构与真实页面保持一致,避免回填时跳动。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 20:00:48 +08:00
kkfluous
e775acb8fe fix(energy): 氢能 Top5 排名圆点与站名重叠修复
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
YAxis 宽度 170→190,圆点 cx 从 -158 → -178,文字 x 从 -144 → -160。
间距从 14px 拉到 18px+,避免在窄屏上圆点压住站名首字。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:59:37 +08:00
kkfluous
c788dd4577 fix(energy): 单价直接取 MAX(cost_price),不重算不返 null
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
之前用 MIN=MAX...ELSE NULL 判定,再 NULLIF 排零,遇到「1 笔 0 元免费单 + 多笔 35 元正价单」
仍可能误判混合,最终页面显示「—」(如佛山豪汇石油加氢站)。

按业务约定:单价就是订单上记录的成本价,不做"统一性"判定,也不返 null。
改用 MAX(b.cost_price):
  - 自然忽略 0 元免费/赠送单(被正价 max 掉)
  - 同价组等于原价
  - 极少数真正混合价组也展示该日付出过的最高单价(仍是订单上的真实数字)

回退类型:HydrogenStationRow.pricePerKg 重新固定为 number。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:56:26 +08:00
kkfluous
3851335843 fix(energy): 氢能单价不再加权,混合价组显示「—」并修复 hydrogen_time 歧义
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- pricePerKg 改为 CASE WHEN MIN=MAX THEN MIN ELSE NULL,
  同价组返回原价(无小数误读),混合价组返回 null
- 类型 HydrogenStationRow.pricePerKg: number | null
- 前端 mobile/desktop 两处展示在 null 时显示「—」
- 修复 ER_NON_UNIQ_ERROR:tab_import_hydrogen_order 也有 hydrogen_time 字段,
  把 SELECT/ORDER BY 中 ${HYDROGEN_LOCAL} 替换为显式 b.hydrogen_time 限定
- 实测:712 个站点-日组中 682 个同价直接显示原价,30 个混合显示「—」

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:51:41 +08:00
kkfluous
9a20a7cb79 refactor(energy): 电能仅展示充电量,电/氢 daily 表格统一列宽
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 电能去掉「充电费用(元)」列,只保留 月份/日期 | 充电量(度) | 环比
  原列宽 auto+auto+auto 在窄屏会挤压重叠
- 改用固定 minmax(0,1fr)/120/88(移动)和 1fr/160/120(桌面)
- 氢能 daily 同步统一列宽:1fr/120/88(移动)和 1fr/140/140/120(桌面)
- 单价表头改为「单价 (元/Kg)」全展示,移动端站点行价格作为副信息缩小展示

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:37:26 +08:00
kkfluous
d1d79f1c7c feat(energy): 电能统计切到 bi_ele_charge_record,外部数据接通
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- /api/energy/electric/overview & /electric/monthly 不再读 tab_energy_electricity_bill
- 改读 bi_ele_charge_record:kwh/fee/start_time
- 外部/我司用 vehicle_kind 区分(external/internal)
- 电能默认 customer 由 'external' 改 'lingniu',与导入页约定一致
- ElectricDaily 移除「数据对接中…」友好空状态(外部已有数据)

ele 导入页同步收紧:
- 命中系统车辆=internal,未命中(含车牌为空)一律 external
- 移除 unknown 分类、KPI 卡、批次列、过滤按钮、UploadResult 字段
- 历史 unknown 行已 UPDATE 为 external

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 19:11:52 +08:00
kkfluous
d8189329ac chore(energy): 羚牛 tab 置前并默认选中(氢能/电能一致)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- HydrogenDaily/ElectricDaily 默认 customer 改为 'lingniu'
- segmented control 顺序改为 ['lingniu', 'external']
- 进入页面立刻看到我司数据,避免空状态首屏

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 18:53:22 +08:00
kkfluous
e2d04db06d chore(energy): 重新放开电能 tab
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 取消之前的临时屏蔽,恢复氢能/电能两个顶部 tab
- 电能内部已和氢能同时支持 truck_id 区分外部/我司,外部空数据会展示「数据对接中…」

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 18:52:11 +08:00
kkfluous
5493e27e49 feat(energy): 用 truck_id 区分外部/我司,外部数据空时给友好提示
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 后端 customerClause 改为基于 truck_id:外部=IS NULL,我司=IS NOT NULL
- KPI 内联条件(ourYearKg/Fee、customerYearKg、lingniuBornKg/Fee)同步切换为 truck_id
- 调用方 /hydrogen/daily 与 /electric/monthly 改传 b.truck_id / truck_id
- 当前外部账单 truck_id 尚未对接,HydrogenDaily/ElectricDaily 在 customer=external 且无数据时
  改展示「数据对接中…」友好状态(插头图标 + 蓝色脉冲),替代「暂无数据」

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 17:52:03 +08:00
kkfluous
e0c609168e chore(energy): 恢复能源管理入口,仅隐藏电能 tab
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 重新启用 EnergyModule 作为侧边栏入口
- EnergyModule 内部隐藏「电能」tab,只保留「氢能」(保留 Electric* 代码)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 15:25:37 +08:00
kkfluous
d1acdafa7e refactor(energy): merge electric overview into a single page
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>
2026-04-29 09:04:26 +08:00
kkfluous
c3b43837fb fix(energy): update hint text to match real 1m cache TTL
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>
2026-04-29 09:02:41 +08:00
kkfluous
9a4f1945d9 feat(energy): connect to real DB (lingniu_prod)
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>
2026-04-28 16:42:37 +08:00
kkfluous
7de2d1ecd5 refactor(energy): split electric view into 总览/每日 sub-tabs
- 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>
2026-04-28 12:39:05 +08:00
kkfluous
42ec6e1c01 refactor(energy): drop anomaly coloring on hydrogen daily bars
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>
2026-04-28 12:33:43 +08:00
kkfluous
313325553d feat(energy): hydrogen daily — period bar chart with anomaly coloring
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>
2026-04-28 12:32:40 +08:00
kkfluous
d9b9ff495e feat(energy): electric view — daily bar chart + anomaly tint + mobile 环比
- 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>
2026-04-28 12:05:11 +08:00
kkfluous
bdd039a2c4 refactor(energy): visual polish + KPI/table self-consistency
- 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>
2026-04-28 12:01:13 +08:00
kkfluous
2a92d991b0 fix(energy): bump KPI text-3xl to lg breakpoint to avoid landscape wrap
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:46:15 +08:00
kkfluous
ccf76cba79 feat(energy): electric view with mini KPI + month grouping
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:39:55 +08:00
kkfluous
a40fd2be34 feat(energy): hydrogen daily table with station drilldown
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:33:52 +08:00
kkfluous
c8a1e8506e fix(energy): widen Top5 YAxis to prevent station name truncation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:29:45 +08:00
kkfluous
dc1f0326fc feat(energy): hydrogen overview Top5 bar + region donut
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:27:38 +08:00
kkfluous
e6880cba17 feat(energy): hydrogen overview KPI cards (4-card grid)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:20:32 +08:00
kkfluous
09b9862f1f feat(energy): add module shell, register in nav
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:15:55 +08:00
kkfluous
deb2f2d5da feat(energy): add types and mock data for new module
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:07:04 +08:00