From 7d45b1aa345be565648f9ae01cd200631eb008a2 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 18 三月 2026 13:30:53 +0800
Subject: [PATCH] 生产计划的下发状态逻辑调整+能耗统计查询sql优化
---
src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml b/src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml
index 32f2f40..50f4e2f 100644
--- a/src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml
+++ b/src/main/resources/mapper/energy/EnergyConsumptionDetailMapper.xml
@@ -41,7 +41,9 @@
</where>
</select>
<select id="calculateEnergy" resultType="java.util.Map">
- select SUM(ecd.dosage) totalEnergyConsumption,
+ select COALESCE(t.totalEnergyConsumption, 0) AS totalEnergyConsumption,
+ COALESCE(t.totalEnergyCost, 0) AS totalEnergyCost
+ from (select SUM(ecd.dosage) totalEnergyConsumption,
SUM(ecd.dosage * e.unit_price) totalEnergyCost
from energy_consumption_detail ecd
left join energy e on ecd.energy_id = e.id
@@ -49,6 +51,7 @@
<if test="c.type != null and c.type != ''">
and ecd.type =#{c.type}
</if>
+ )t
</select>
<select id="energyConsumptionTypeProportion"
resultType="com.ruoyi.energy.dto.EnergyConsumptionTypeDto">
--
Gitblit v1.9.3