From d3fa2fd4d62f499fb601ca204a8720464a16becb Mon Sep 17 00:00:00 2001 From: kkfluous Date: Wed, 29 Apr 2026 20:28:52 +0800 Subject: [PATCH] =?UTF-8?q?revert(energy):=20=E5=8F=96=E6=B6=88=20GF=5FHEC?= =?UTF-8?q?RI=5FBILL=20=E8=BF=87=E6=BB=A4=EF=BC=8C=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按用户要求恢复全量统计:移除 4 处 GF 过滤子句和相关常量。 现在 GF_HECRI_BILL 历史订单会与 JQ 新订单一同计入。 Co-Authored-By: Claude Opus 4.7 (1M context) --- src/server/routes/energy/index.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/server/routes/energy/index.ts b/src/server/routes/energy/index.ts index ae102e1..75c7a67 100644 --- a/src/server/routes/energy/index.ts +++ b/src/server/routes/energy/index.ts @@ -22,10 +22,6 @@ function customerClause(field: string, customer: CustomerKind): string { type Range = 'today' | 'thisWeek' | 'thisMonth' | 'thisQuarter' | 'last7' | 'last30'; -// 全局过滤 GF_HECRI_BILL 前缀的加氢订单(旧系统遗留单据,已被 JQ 新单号体系替代) -const GF_EXCLUDE_CLAUSE = `b.bill_code NOT LIKE 'GF\\_HECRI\\_BILL%' ESCAPE '\\\\'`; -const GF_EXCLUDE_CLAUSE_NO_ALIAS = `bill_code NOT LIKE 'GF\\_HECRI\\_BILL%' ESCAPE '\\\\'`; - function rangeClause(localExpr: string, range: Range): string { switch (range) { case 'today': return `DATE(${localExpr}) = CURDATE()`; @@ -68,7 +64,7 @@ app.get('/hydrogen/overview', async (c) => { SUM(CASE WHEN truck_id IS NOT NULL THEN cost_expense ELSE 0 END) AS lingniuBornFee FROM tab_energy_hydrogen_bill - WHERE is_deleted = 0 AND hydrogen_time >= ? AND ${GF_EXCLUDE_CLAUSE_NO_ALIAS}`, + WHERE is_deleted = 0 AND hydrogen_time >= ?`, [HYDROGEN_MIN_DATE], ); const k = kpiRows[0] ?? {}; @@ -103,7 +99,6 @@ app.get('/hydrogen/overview', async (c) => { WHERE b.is_deleted = 0 AND b.hydrogen_time >= ? AND YEAR(DATE_ADD(b.hydrogen_time, INTERVAL 8 HOUR)) = YEAR(CURDATE()) - AND ${GF_EXCLUDE_CLAUSE} GROUP BY b.hydrogen_station_id ORDER BY kg DESC LIMIT 5`, @@ -129,7 +124,6 @@ app.get('/hydrogen/overview', async (c) => { WHERE b.is_deleted = 0 AND b.hydrogen_time >= ? AND YEAR(DATE_ADD(b.hydrogen_time, INTERVAL 8 HOUR)) = YEAR(CURDATE()) - AND ${GF_EXCLUDE_CLAUSE} ) r GROUP BY region ORDER BY kg DESC`, @@ -167,7 +161,6 @@ app.get('/hydrogen/daily', async (c) => { `b.hydrogen_time >= '${HYDROGEN_MIN_DATE}'`, rangeClause(`b.hydrogen_time + INTERVAL 8 HOUR`, range), customerClause('b.truck_id', customer), - GF_EXCLUDE_CLAUSE, ].join(' AND '); // 站点级聚合(每日 × 每站)。前端组装成 day → stations