From 24888c4b2ca2ffc49c4d94aefd6aea32d515b6dd Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期日, 20 四月 2025 14:17:24 +0800
Subject: [PATCH] 分架明细报表修改查询问题

---
 north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml |   61 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml b/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
index e26a46c..e449f52 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
@@ -286,6 +286,67 @@
             `i`.`available_quantity` DESC ;
     </select>
 
+    <!--浣欐枡淇℃伅-->
+    <select id="surplusMaterialsMp">
+        SELECT
+            i.id AS id,
+            '' AS producer,
+            i.quantity AS available_quantity,
+            i.width,
+            i.height,
+            i.thickness,
+            i.colour AS name,
+            i.colour
+        FROM  mm.surplus_materials as i
+        WHERE
+            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
+        ORDER BY
+            i.quantity DESC ;
+    </select>
+
+    <!--搴撳瓨浣欐枡淇℃伅-->
+    <select id="materialStoreSurplusMp">
+        (SELECT
+            i.id AS id,
+            i.producer AS producer,
+            i.available_quantity-i.plan_quantity AS available_quantity,
+            JSON_EXTRACT(s.json, '$.width') AS width,
+            JSON_EXTRACT(s.json, '$.height') AS height,
+            JSON_EXTRACT(s.json, '$.thickness') AS thickness,
+            JSON_EXTRACT(s.json, '$.name') AS name,
+            JSON_EXTRACT(s.json, '$.model') AS model
+        FROM  mm.material_inventory as `i`
+                  LEFT JOIN  mm.material_store  as s ON (
+            (
+                `i`.`material_code` = `s`.`id`
+                )
+            )
+        WHERE
+            (
+                    (`s`.`type` = '鍘熺墖')
+                    AND (`i`.`optimize_state` = 1)
+                    AND (`i`.`available_quantity`-i.plan_quantity > 0)
+                    AND JSON_EXTRACT(s.json, '$.thickness') = #{thickness}
+                    AND JSON_EXTRACT(s.json, '$.model') = #{model}
+                )
+        ORDER BY
+            `i`.`available_quantity` DESC) union
+        (SELECT
+            i.id AS id,
+            '' AS producer,
+            i.quantity AS available_quantity,
+            i.width,
+            i.height,
+            i.thickness,
+            i.colour AS name,
+            i.colour
+        FROM  mm.surplus_materials as i
+        WHERE
+            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
+        ORDER BY
+            i.quantity DESC );
+    </select>
+
 
     <select id="materialStoreOptimizeUse">
         select ms.id AS id,

--
Gitblit v1.8.0