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>
This commit is contained in:
kkfluous
2026-04-29 17:52:03 +08:00
parent 355c45a2e4
commit 5493e27e49
3 changed files with 55 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { ChevronRight } from 'lucide-react';
import { ChevronRight, Plug } from 'lucide-react';
import { motion, AnimatePresence } from 'motion/react';
import TrendBadge from './TrendBadge';
import { fetchElectricMonthly } from './api';
@@ -48,7 +48,27 @@ export default function ElectricDaily() {
))}
</div>
{/* 外部数据对接中 友好空状态 */}
{customer === 'external' && months !== null && months.length === 0 && (
<motion.div
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-2xl border border-slate-100 shadow-sm px-6 py-12 flex flex-col items-center text-center"
>
<div className="w-14 h-14 rounded-2xl bg-blue-50 flex items-center justify-center mb-3 relative">
<Plug size={22} className="text-blue-500" />
<span className="absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-blue-400 animate-ping" />
<span className="absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-blue-500" />
</div>
<div className="text-sm font-bold text-slate-700 mb-1"></div>
<div className="text-[11px] text-slate-400 max-w-[260px] leading-relaxed">
线
</div>
</motion.div>
)}
{/* 月份分组表 */}
{!(customer === 'external' && months !== null && months.length === 0) && (
<div className="bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden">
<div className="grid grid-cols-[1fr_auto_auto_auto] md:grid-cols-[1fr_120px_140px_120px] gap-2 px-3 py-2 bg-slate-50 text-[11px] font-bold text-slate-500">
<span> / </span>
@@ -122,6 +142,7 @@ export default function ElectricDaily() {
);
})}
</div>
)}
</div>
);
}

View File

@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react';
import { ChevronRight } from 'lucide-react';
import { ChevronRight, Plug } from 'lucide-react';
import { motion, AnimatePresence } from 'motion/react';
import { BarChart, Bar, XAxis, YAxis, ResponsiveContainer, Cell, Tooltip } from 'recharts';
import TrendBadge from './TrendBadge';
@@ -75,6 +75,25 @@ export default function HydrogenDaily() {
))}
</div>
{/* 外部数据对接中 友好空状态 */}
{customer === 'external' && rows !== null && rows.length === 0 && (
<motion.div
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-2xl border border-slate-100 shadow-sm px-6 py-12 flex flex-col items-center text-center"
>
<div className="w-14 h-14 rounded-2xl bg-blue-50 flex items-center justify-center mb-3 relative">
<Plug size={22} className="text-blue-500" />
<span className="absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-blue-400 animate-ping" />
<span className="absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-blue-500" />
</div>
<div className="text-sm font-bold text-slate-700 mb-1"></div>
<div className="text-[11px] text-slate-400 max-w-[260px] leading-relaxed">
线
</div>
</motion.div>
)}
{/* 时段加氢量柱图 */}
{trendData.length > 0 && (
<div className="bg-white rounded-2xl border border-slate-100 shadow-sm p-4">
@@ -116,7 +135,8 @@ export default function HydrogenDaily() {
</div>
)}
{/* 表格 */}
{/* 表格(外部空数据时不渲染,由上方友好空状态替代) */}
{!(customer === 'external' && rows !== null && rows.length === 0) && (
<div className="bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden">
{/* 表头 */}
<div className="grid grid-cols-[1fr_auto_auto] md:grid-cols-[1fr_140px_120px_120px] gap-2 px-3 py-2 bg-slate-50 text-[11px] font-bold text-slate-500">
@@ -193,6 +213,7 @@ export default function HydrogenDaily() {
);
})}
</div>
)}
</div>
);
}