fix(energy): deliver prototype-aligned hydrogen board and acceptance fixes
ci/woodpecker/push/woodpecker Pipeline was successful

Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
This commit is contained in:
kfluous
2026-09-03 22:27:23 +08:00
co-authored by HiFox Agent
parent 5eb38a4b05
commit 6c91a6694a
77 changed files with 30169 additions and 361 deletions
+15 -31
View File
@@ -115,6 +115,7 @@ test("氢能 BI v2 使用独立真实账本合同,并且不让前端拼接旧
assert.equal(calls.length, 3);
assert.match(calls[0].sql, /FROM hydrogen_fuel_ledger/);
assert.match(calls[1].sql, /FROM new_hydrogen_site/);
assert.match(calls[1].sql, /EXISTS\s*\([\s\S]*amount_kg[\s\S]*> 0/);
});
test("氢能 BI v2 下钻在日期、站点、客户、车辆及区域上下文中复用同一过滤口径", async () => {
@@ -124,6 +125,7 @@ test("氢能 BI v2 下钻在日期、站点、客户、车辆及区域上下文
hydrogenPool: {
query: createQueryMock(
[
[{ id: "123" }],
[{ recordCount: 2, kg: 30, cost: 900, revenue: 1000 }],
[
{
@@ -141,25 +143,6 @@ test("氢能 BI v2 下钻在日期、站点、客户、车辆及区域上下文
externalKg: 30,
},
],
[
{
id: 9,
time: "2026-08-18 08:00:00",
orderNo: "H2-9",
stationId: 0,
stationName: "未关联站点",
customerId: 0,
customerName: "未关联客户",
plateNo: "无车牌",
source: "import",
verifyStatus: "VERIFIED",
vehicleId: null,
kg: 30,
unitPrice: 30,
cost: 900,
revenue: 1000,
},
],
],
calls,
),
@@ -182,6 +165,8 @@ test("氢能 BI v2 下钻在日期、站点、客户、车辆及区域上下文
assert.equal(payload.summary.kg, 30);
assert.equal(calls.length, 3);
assert.deepEqual(calls[0].params, ["嘉兴市"]);
assert.match(calls[0].sql, /FROM new_hydrogen_site rs/);
const commonParams = [
"2026-08-18",
"2026-08-18",
@@ -189,27 +174,26 @@ test("氢能 BI v2 下钻在日期、站点、客户、车辆及区域上下文
0,
"未关联客户",
"无车牌",
"嘉兴市",
"123",
];
assert.deepEqual(calls[0].params, commonParams);
assert.deepEqual((calls[1].params as unknown[]).slice(0, -2), commonParams);
assert.deepEqual(calls[1].params, commonParams);
assert.deepEqual((calls[2].params as unknown[]).slice(0, -2), commonParams);
for (const call of calls) {
for (const call of calls.slice(1)) {
assert.match(call.sql, /COALESCE\(b\.station_id, 0\) = \?/);
assert.match(
call.sql,
/COALESCE\(b\.system_customer_id, b\.customer_id, 0\) = \?/,
);
assert.match(call.sql, /COALESCE\(NULLIF\(b\.license_plate/);
assert.match(call.sql, /new_hydrogen_site rs/);
assert.match(call.sql, /b\.station_id IN \(\?\)/);
assert.match(call.sql, /b\.vehicle_id IS NULL/);
assert.match(call.sql, /verify_status/);
}
assert.match(
calls[1].sql,
calls[2].sql,
/GROUP BY DATE_FORMAT\(b\.refuel_time, '%Y-%m-%d'\)/,
);
assert.match(calls[1].sql, /ORDER BY id DESC/);
assert.match(calls[2].sql, /ORDER BY id DESC/);
});
test("氢能 BI v2 利润下钻只保留客户承担订单,并与对客总价使用同一订单集合", async () => {
@@ -268,7 +252,7 @@ test("氢能 BI v2 利润下钻只保留客户承担订单,并与对客总价
const payload = await response.json();
assert.equal(payload.amountScope, "customer");
assert.equal(payload.summary.revenue - payload.summary.cost, 60);
assert.equal(calls.length, 3);
assert.equal(calls.length, 2);
for (const call of calls) {
assert.match(
call.sql,
@@ -473,7 +457,7 @@ test("氢能 BI v2 月度上下文换算为完整自然月并沿用至明细", a
]);
});
test("单站看板保留零业务站点并合并区间现结流水", async () => {
test("单站看板仅保留有加氢记录的站点并合并区间现结流水", async () => {
const calls: QueryCall[] = [];
const cacheCalls: CacheCall[] = [];
const stationBoardApp = new Hono();
@@ -533,7 +517,7 @@ test("单站看板保留零业务站点并合并区间现结流水", async () =>
assert.equal(response.status, 200);
const payload = await response.json();
assert.deepEqual(payload.summary, {
stationCount: 2,
stationCount: 1,
activeStationCount: 1,
totalKg: 100,
totalFee: 3500,
@@ -560,8 +544,8 @@ test("单站看板保留零业务站点并合并区间现结流水", async () =>
},
],
});
assert.equal(payload.stations[1].name, "零业务站");
assert.equal(payload.stations[1].kg, 0);
assert.equal(payload.stations.length, 1);
assert.equal(payload.stations[0].name, "测试加氢站");
assert.deepEqual(payload.stations[0].dailyKg, [
{ date: "2026-08-16", kg: 40 },
{ date: "2026-08-17", kg: 60 },