From 9f1c36a2ba4e13f9592bbf2e49afd95fd77cadfb Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 01 四月 2026 13:29:55 +0800
Subject: [PATCH] fix:1.仓储物流区分原材料/成品 2.生产订单/报工领料优化

---
 src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java          |    2 
 src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java               |    2 
 src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java                              |    1 
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml                          |    6 ++-
 src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java |    1 
 src/main/resources/mapper/sales/InvoiceLedgerMapper.xml                               |    4 +-
 src/main/resources/mapper/stock/StockInventoryMapper.xml                              |   63 +++++++++++++++++++++----------
 src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml                      |    8 +++-
 8 files changed, 58 insertions(+), 29 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
index f479a16..711fb1c 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -277,7 +277,7 @@
         }
         // 濡傛灉鏈夋暟鎹厛鍔犲簱瀛�
         ProductOrder productOrder = productOrderMapper.selectById(productOrderDto.getId());
-        if (productOrder != null) {
+        if (productOrder.getDrawMaterials() != null) {
             List<DrawMaterialDto> materialDtoList = JSON.parseArray(productOrder.getDrawMaterials(), DrawMaterialDto.class);
             for (DrawMaterialDto drawMaterialDto : materialDtoList) {
                 stockUtils.addStock(drawMaterialDto.getProductModelId(), drawMaterialDto.getRequisitionQty(), null, productOrderDto.getId(),
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index 7175825..61e1dfc 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -246,7 +246,6 @@
                     throw new RuntimeException("鐢熶骇璁㈠崟涓嶅瓨鍦�");
                 }
 
-
                 Product product = productMapper.selectById(productModel.getProductId());
                 QualityInspect qualityInspect = new QualityInspect();
                 qualityInspect.setProductId(product.getId());
diff --git a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
index 625e765..93be0df 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -68,7 +68,7 @@
         if(!"宸插彂璐�".equals(byId.getStatus())){
             SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(byId.getSalesLedgerProductId());
             stockUtils.substractStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(),
-                    StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),null,null
+                    StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(),salesLedgerProduct.getBatchNo(),salesLedgerProduct.getCustomer()
             );
         }
         byId.setExpressNumber(req.getExpressNumber());
diff --git a/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java b/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
index f28c0eb..183f4d5 100644
--- a/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
+++ b/src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
@@ -45,4 +45,5 @@
     private Long productId;      // 浜у搧ID
     private Long parentId;  // 鐖剁骇浜у搧ID
     private Long productModelId;   // 浜у搧鍨嬪彿ID
+    private String productScope;  //浜у搧绫诲瀷
 }
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
index 1446ab6..613f8ff 100644
--- a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -206,7 +206,7 @@
         T1.supplier_name,
         SUM(contract_amount) AS invoiceAmount,
         IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
-        IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
+        IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
         T1.purchase_contract_number,
         T2.payment_date
         FROM purchase_ledger T1
@@ -217,7 +217,11 @@
                 T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
             </if>
         </where>
-        GROUP BY  T1.purchase_contract_number,T2.payment_date
+        GROUP BY
+        T1.supplier_id,
+        T1.supplier_name,
+        T1.purchase_contract_number,
+        T2.payment_date
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml b/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
index 2874f48..3a03588 100644
--- a/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
@@ -115,7 +115,7 @@
             T1.customer_name,
             SUM(contract_amount) AS invoice_total,
             IFNULL( SUM(T2.receipt_payment_amount) , 0 ) AS receipt_payment_amount,
-            IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.receipt_payment_amount),0)),0) AS unReceipt_payment_amount
+            IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.receipt_payment_amount),0)),0) AS unReceipt_payment_amount
         FROM sales_ledger T1
         LEFT JOIN receipt_payment T2 ON T1.id = T2.sales_ledger_id
         <where>
@@ -123,7 +123,7 @@
                 T1.customer_name LIKE CONCAT ('%',#{invoiceLedgerDto.searchText},'%')
             </if>
         </where>
-        GROUP BY T1.customer_name
+        GROUP BY T1.customer_id, T1.customer_name
     </select>
 
     <select id="invoiceLedgerProductInfo" resultType="com.ruoyi.sales.dto.InvoiceRegistrationProductDto">
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 73026c8..d336e60 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -127,8 +127,10 @@
         <if test="req.productCategory != null and req.productCategory != ''">
             AND slp.product_category = #{req.productCategory}
         </if>
-        <!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
-        GROUP BY slp.product_category
+        GROUP BY
+        slp.product_category,
+        slp.specification_model,
+        sl.supplier_name
         <!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
         ORDER BY slp.product_category
     </select>
diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 21bc11e..d592b11 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -52,29 +52,52 @@
         where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
     </update>
     <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
-        select si.id,
+        SELECT
+        si.id,
         si.qualitity,
-        COALESCE(si.locked_quantity, 0) as locked_quantity,
+        COALESCE(si.locked_quantity, 0) AS locked_quantity,
         si.product_model_id,
         si.create_time,
         si.update_time,
-        COALESCE(si.warn_num, 0) as warn_num,
+        COALESCE(si.warn_num, 0) AS warn_num,
         si.version,
-        (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
+        (si.qualitity - COALESCE(si.locked_quantity, 0)) AS un_locked_quantity,
         pm.model,
         si.remark,
         pm.unit,
-        pm.uid_no as uidNo,
+        pm.uid_no AS uidNo,
         p.product_name,
         si.batch_no,
         si.customer
-        from stock_inventory si
-        left join product_model pm on si.product_model_id = pm.id
-        left join product p on pm.product_id = p.id
-        where 1 = 1
-        <if test="ew.productName != null and ew.productName !=''">
-            and p.product_name like concat('%',#{ew.productName},'%')
-        </if>
+        FROM
+        stock_inventory si
+        LEFT JOIN product_model pm ON si.product_model_id = pm.id
+        LEFT JOIN product p ON pm.product_id = p.id
+        LEFT JOIN product p1 ON p.parent_id = p1.id
+        <where>
+            <if test="ew.productName != null and ew.productName != ''">
+                AND p.product_name LIKE CONCAT('%', #{ew.productName}, '%')
+            </if>
+            <if test="ew.model != null and ew.model != ''">
+                AND pm.model LIKE CONCAT('%', #{ew.model}, '%')
+            </if>
+            <if test="ew.uidNo != null and ew.uidNo != ''">
+                AND pm.uid_no LIKE CONCAT('%', #{ew.uidNo}, '%')
+            </if>
+            <if test="ew.batchNo != null and ew.batchNo != ''">
+                AND si.batch_no LIKE CONCAT('%', #{ew.batchNo}, '%')
+            </if>
+            <if test="ew.productScope != null and ew.productScope != ''">
+                <choose>
+                    <when test="ew.productScope == '鎴愬搧'">
+                        AND p1.product_name = #{ew.productScope}
+                    </when>
+                    <otherwise>
+                        AND p1.product_name != '鎴愬搧'
+                    </otherwise>
+                </choose>
+            </if>
+        </where>
     </select>
     <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
         select si.qualitity,
@@ -283,14 +306,14 @@
         LEFT JOIN product_model pm ON si.product_model_id = pm.id
         LEFT JOIN product p ON pm.product_id = p.id
         LEFT JOIN product p1 ON p1.id = p.parent_id
-        WHERE
-            p1.product_name = '鍘熸潗鏂�';
-        <if test="ew.batchNo != null and ew.batchNo !=''">
-            and si.batch_no like concat('%',#{ew.batchNo},'%')
-        </if>
-        <if test="ew.customer != null and ew.customer !=''">
-            and si.customer like concat('%',#{ew.customer},'%')
-        </if>
+        <where>
+            <if test="ew.batchNo != null and ew.batchNo !=''">
+                and si.batch_no like concat('%',#{ew.batchNo},'%')
+            </if>
+            <if test="ew.customer != null and ew.customer !=''">
+                and si.customer like concat('%',#{ew.customer},'%')
+            </if>
+        </where>
     </select>
 
     <select id="getStockInventoryAll" resultType="com.ruoyi.stock.dto.StockInventoryDto">

--
Gitblit v1.9.3