From 802796c22d7d21a6d572cd4c11844e6865521666 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 22 六月 2026 11:53:05 +0800
Subject: [PATCH] 新增库存,采购入库关联供应商,外协入库关联厂家

---
 src/main/resources/mapper/stock/StockInventoryMapper.xml |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 5d6657f..cd3ad3b 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -12,6 +12,9 @@
         <result column="version" property="version"/>
         <result column="locked_quantity" property="lockedQuantity"/>
         <result column="warn_num" property="warnNum"/>
+        <result column="manufacturer_id" property="manufacturerId"/>
+        <result column="source" property="source"/>
+        <result column="supplier_id" property="supplierId"/>
     </resultMap>
     <update id="updateAddStockInventory">
         update stock_inventory
@@ -33,6 +36,12 @@
             </if>
             <if test="ew.source != null and ew.source != ''">
                 source = #{ew.source},
+            </if>
+            <if test="ew.manufacturerId != null">
+                manufacturer_id = #{ew.manufacturerId},
+            </if>
+            <if test="ew.supplierId != null">
+                supplier_id = #{ew.supplierId},
             </if>
             update_time = now()
         </set>
@@ -75,6 +84,9 @@
         si.update_time,
         COALESCE(si.warn_num, 0) as warn_num,
         si.version,
+        si.source,
+        si.manufacturer_id,
+        si.supplier_id,
         (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
         pm.model,
         si.remark,
@@ -118,6 +130,7 @@
         MAX(update_time) as update_time,
         MAX(warn_num) as warn_num,
         MAX(version) as version,
+        MAX(supplier_id) as supplier_id,
         model,
         MAX(remark) as remark,
         unit,
@@ -139,6 +152,7 @@
         si.update_time,
         COALESCE(si.warn_num, 0) as warn_num,
         si.version,
+        si.supplier_id,
         (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
         pm.model,
         si.remark,
@@ -177,6 +191,7 @@
         su.update_time,
         0 as warn_num,
         su.version,
+        null as supplier_id,
         (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
         pm.model,
         su.remark,
@@ -568,7 +583,9 @@
         product_name,
         product_id,
         MAX(manufacturer_id) as manufacturer_id,
+        MAX(supplier_id) as supplier_id,
         MAX(manufacturer_name) as manufacturerName,
+        MAX(supplier_name) as supplierName,
         MAX(qualifiedSource) as qualifiedSource,
         MAX(unQualifiedSource) as unQualifiedSource,
 
@@ -597,7 +614,9 @@
         p.product_name,
         p.id as product_id,
         si.manufacturer_id,
+        si.supplier_id,
         m.name as manufacturer_name,
+        sm.supplier_name as supplier_name,
         si.source as qualifiedSource,
         null as unQualifiedSource,
 
@@ -624,6 +643,7 @@
         left join product_model pm on si.product_model_id = pm.id
         left join product p on pm.product_id = p.id
         left join manufacturer m on si.manufacturer_id = m.id
+        left join supplier_manage sm on si.supplier_id = sm.id
 
         union all
 
@@ -643,8 +663,10 @@
         pm.unit,
         p.product_name,
         p.id as product_id,
-        su.manufacturer_id,
-        m.name as manufacturer_name,
+        null as manufacturer_id,
+        null as supplier_id,
+        null as manufacturer_name,
+        null as supplier_name,
         null as qualifiedSource,
         su.source as unQualifiedSource,
 
@@ -670,7 +692,6 @@
         from stock_uninventory su
         left join product_model pm on su.product_model_id = pm.id
         left join product p on pm.product_id = p.id
-        left join manufacturer m on su.manufacturer_id = m.id
         ) as combined
         <where>
             <if test="ew.productModelId != null and ew.productModelId > 0">
@@ -689,7 +710,9 @@
         product_name,
         product_id,
         manufacturer_id,
-        manufacturer_name
+        supplier_id,
+        manufacturer_name,
+        supplier_name
         order by
         batch_no
     </select>

--
Gitblit v1.9.3