From 7e84848f0ea65411bdc9f27e5fa9d714157d032a Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 05 二月 2026 17:24:20 +0800
Subject: [PATCH] 生产统计

---
 src/main/resources/mapper/production/ProductionProductMainMapper.xml |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductionProductMainMapper.xml b/src/main/resources/mapper/production/ProductionProductMainMapper.xml
index 9c3bf3d..fee9cdc 100644
--- a/src/main/resources/mapper/production/ProductionProductMainMapper.xml
+++ b/src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -115,4 +115,30 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="queryProductInputAndOutput" resultType="Hashmap">
+        select *
+        from (select p.product_name      as productName,
+                     pm.model            as model,
+                     pm.unit             as unit,
+                     temp.inputQuantity  as inputQuantity,
+                     temp.outputQuantity as outputQuantity
+              from (select product_model_id,
+                           coalesce(sum(inputQuantity), 0)  as inputQuantity,
+                           coalesce(sum(outputQuantity), 0) as outputQuantity
+                    from ((select product_model_id, coalesce(sum(quantity), 0) as inputQuantity, 0 as outputQuantity
+                           from production_product_input
+                           where create_time &gt;= #{ew.startTime}
+                             and create_time &lt; #{ew.endTime}
+                           group by product_model_id)
+                          union all
+                          (select product_model_id, 0 as inputQuantity, coalesce(sum(quantity), 0) as outputQuantity
+                           from production_product_output
+                           where create_time &gt;= #{ew.startTime}
+                             and create_time &lt; #{ew.endTime}
+                           group by product_model_id)) t
+                    group by product_model_id) temp
+                       left join product_model pm on temp.product_model_id = pm.id
+                       left join product p on pm.product_id = p.id) tmp
+    </select>
 </mapper>

--
Gitblit v1.9.3