From 7aac0b821663de152ef665a030ebbef1d34b41f2 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 16 四月 2025 11:31:20 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml |  105 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml b/north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml
index 1cfa8bc..0a1965e 100644
--- a/north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml
+++ b/north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml
@@ -538,6 +538,10 @@
         delete from mm.material_log where operation_order_number=#{materialOutboundId}
     </delete>
 
+    <delete id="deleteMaterialLogById" >
+        delete from mm.material_log where id=#{id}
+    </delete>
+
     <delete id="deleteReturningWarehouseDetail" >
         delete from mm.returning_warehouse_detail where returning_id=#{returningId}
     </delete>
@@ -583,11 +587,11 @@
     </select>
 
     <select id="getMaterialInventoryCount" >
-        select count(*) from mm.material_inventory where  material_code=#{materialCode} and date_of_manufacture=#{dateOfManufacture}
+        select * from mm.material_inventory where  material_code=#{materialCode} and date_of_manufacture=#{dateOfManufacture}
     </select>
 
     <select id="getMaterialInventoryCountNull" >
-        select count(*) from mm.material_inventory where  material_code=#{materialCode} and date_of_manufacture is null
+        select * from mm.material_inventory where  material_code=#{materialCode} and date_of_manufacture is null
     </select>
 
     <select id="getMaterialInventoryCountId" >
@@ -779,7 +783,21 @@
         update mm.material_inventory set inventory_quantity=inventory_quantity+#{materialInventory.inventoryQuantity},
                                          available_quantity=available_quantity+#{materialInventory.inventoryQuantity},
                                          total_area=single_piece_area*inventory_quantity
-        where  material_code=#{materialCode}
+        where  material_code=#{materialCode} and date_of_manufacture is null
+    </update>
+
+    <update id="updateMaterialInventoryOut" >
+        update mm.material_inventory set inventory_quantity=inventory_quantity-#{quantity},
+                                         available_quantity=available_quantity-#{quantity},
+                                         total_area=single_piece_area*inventory_quantity
+        where  material_code=#{materialCode} and date_of_manufacture=#{dateOfManufacture}
+    </update>
+
+    <update id="updateMaterialInventoryNullOut" >
+        update mm.material_inventory set inventory_quantity=inventory_quantity-#{quantity},
+                                         available_quantity=available_quantity-#{quantity},
+                                         total_area=single_piece_area*inventory_quantity
+        where  material_code=#{materialCode} and date_of_manufacture is null
     </update>
 
     <update id="updateMaterialInventoryReturning" >
@@ -1131,5 +1149,86 @@
         select project_no from pp.optimize_use where id=#{useId};
     </select>
 
+    <select id="getOptimizeOutboundReport">
+        SELECT
+            ml.operation_order_number,
+            ml.project_no,
+            ml.inventory_id,
+            ml.material_name,
+            ml.unit,
+            ml.width,
+            ml.height,
+            ml.thickness,
+            ml.quantity,
+            round(ml.width*ml.height*ml.quantity/1000000,2) as area,
+            ou.use_count,
+            ou.not_use_count,
+            ml.operator,
+            ml.operate_time
 
+        FROM
+            mm.material_log AS ml
+                LEFT JOIN pp.optimize_use AS ou ON ou.project_no = ml.project_no
+                AND ou.raw_stock_code = ml.inventory_id
+        WHERE
+            ou.project_no IS NOT NULL
+            	AND date( ml.operate_time )>= #{startDate} and date(ml.operate_time) &lt;= #{endDate}
+            and ml.operate_type=#{type}
+
+        <if test="materialLog.operationOrderNumber != null and materialLog.operationOrderNumber != ''">
+            and ml.operation_order_number regexp #{materialLog.operationOrderNumber}
+        </if>
+        <if test="materialLog.useCount != null and materialLog.useCount != ''">
+            and ou.use_count regexp #{materialLog.useCount}
+        </if>
+        <if test="materialLog.quantity != null and materialLog.quantity != ''">
+            and ml.quantity regexp #{materialLog.quantity}
+        </if>
+        <if test="materialLog.width != null and materialLog.width != ''">
+            and  ml.width regexp  REGEXP_REPLACE(#{materialLog.width},'\\.0+$','')
+        </if>
+        <if test="materialLog.height != null and materialLog.height != ''">
+            and  ml.height regexp  REGEXP_REPLACE(#{materialLog.height},'\\.0+$','')
+        </if>
+        <if test="materialLog.thickness != null and materialLog.thickness != ''">
+            and  ml.thickness regexp  REGEXP_REPLACE(#{materialLog.thickness},'\\.0+$','')
+        </if>
+
+        <if test="materialLog.inventoryId != null and materialLog.inventoryId != ''">
+            and  ml.inventory_id regexp  #{materialLog.inventoryId}
+        </if>
+
+        <if test="materialLog.materialName != null and materialLog.materialName != ''">
+            and  ml.material_name regexp  #{materialLog.materialName}
+        </if>
+        <if test="materialLog.producer != null and materialLog.producer != ''">
+            and  ml.producer regexp  #{materialLog.producer}
+        </if>
+        <if test="materialLog.unit != null and materialLog.unit != ''">
+            and  ml.unit regexp  #{materialLog.unit}
+        </if>
+        <if test="materialLog.operator != null and materialLog.operator != ''">
+            and  ml.operator regexp  #{materialLog.operator}
+        </if>
+        <if test="materialLog.remarks != null and materialLog.remarks != ''">
+            and ml.remarks regexp #{materialLog.remarksr}
+        </if>
+        order by ml.id desc
+        limit #{offset},#{pageSize};
+    </select>
+
+    <select id="getOptimizeOutboundReportTotal">
+        SELECT
+            CEILING(count(ml.id)/#{pageSize}) as 'pageTotal',
+                count(ml.id) as 'total'
+
+        FROM
+            mm.material_log AS ml
+                LEFT JOIN pp.optimize_use AS ou ON ou.project_no = ml.project_no
+                AND ou.raw_stock_code = ml.inventory_id
+        WHERE
+            ou.project_no IS NOT NULL
+          AND date( ml.operate_time )>= #{startDate} and date(ml.operate_time) &lt;= #{endDate}
+          and ml.operate_type=#{type}
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0