From 6be17495cd29ba8b28af35da7ba171cbc0d61c21 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 12 六月 2026 14:18:49 +0800
Subject: [PATCH] 根据单个员工计算工资

---
 src/main/resources/mapper/stock/StockUninventoryMapper.xml |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockUninventoryMapper.xml b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
index fbdb322..b484666 100644
--- a/src/main/resources/mapper/stock/StockUninventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -39,6 +39,8 @@
         su.type,
         COALESCE(su.locked_quantity, 0) as locked_quantity,
         su.product_model_id,
+        p.id as product_id,
+        su.batch_no,
         su.create_time,
         su.update_time,
         su.version,
@@ -64,6 +66,9 @@
             </if>
             <if test="ew.type != null and ew.type != ''">
                 type = #{ew.type},
+            </if>
+            <if test="ew.source != null and ew.source != ''">
+                source = #{ew.source},
             </if>
             update_time = now()
         </set>
@@ -239,6 +244,42 @@
         order by su.batch_no
     </select>
 
+    <select id="getWasteByModelId" resultType="com.ruoyi.stock.dto.StockUninventoryDto">
+        select
+            su.id,
+            su.batch_no,
+            COALESCE(su.locked_quantity, 0) as locked_quantity,
+            (su.qualitity - IFNULL(sd.qualitity, 0)) as qualitity,
+            p.product_name,
+            pm.model,
+            pm.unit,
+            su.product_model_id
+        from stock_uninventory su
+        left join (
+            select
+                sor.product_model_id,
+                sor.batch_no,
+                sum(spd.quantity) as qualitity
+            from shipping_product_detail spd
+            inner join stock_out_record sor
+                on sor.record_id = spd.shipping_info_id
+               and sor.record_type = '13'
+               and sor.type = '1'
+               and sor.approval_status in (0, 3)
+               and sor.product_model_id = spd.product_model_id
+               and (sor.batch_no = spd.batch_no or (sor.batch_no is null and spd.batch_no is null))
+            where spd.stock_type = 'waste'
+            group by sor.product_model_id, sor.batch_no
+        ) sd on sd.product_model_id = su.product_model_id
+            and (sd.batch_no = su.batch_no or (sd.batch_no is null and su.batch_no is null))
+        left join product_model pm on su.product_model_id = pm.id
+        left join product p on pm.product_id = p.id
+        where su.product_model_id = #{productModelId}
+          and su.type = 'waste'
+          and su.qualitity > IFNULL(sd.qualitity, 0)
+        order by su.batch_no
+    </select>
+
     <select id="selectPendingOutQuantity" resultType="java.math.BigDecimal">
         SELECT IFNULL(SUM(sor.stock_out_num), 0)
         FROM stock_out_record sor

--
Gitblit v1.9.3