From 51889b97a85b070cbb80a5bb2893149c80448d5d Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: 星期二, 30 十二月 2025 16:31:15 +0800
Subject: [PATCH] #导出优化

---
 src/main/resources/mapper/LocDetlMapper.xml |   74 +++++++++++++++++++++++++++++--------
 1 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/src/main/resources/mapper/LocDetlMapper.xml b/src/main/resources/mapper/LocDetlMapper.xml
index aada17d..d32628d 100644
--- a/src/main/resources/mapper/LocDetlMapper.xml
+++ b/src/main/resources/mapper/LocDetlMapper.xml
@@ -358,7 +358,22 @@
             and a.standby3 like '%' + #{standby3} + '%'
         </if>
         <if test="boxType3!=null and boxType3!='' ">
-            and a.boxType3 like '%' + #{boxType3} + '%'
+            and a.box_type3 like '%' + #{boxType3} + '%'
+        </if>
+    </sql>
+
+    <sql id="stockOutCondition1">
+        <if test="matnr!=null and matnr!='' ">
+            and a.matnr like '%' + #{matnr} + '%'
+        </if>
+        <if test="standby1!=null and standby1!='' ">
+            and a.standby1 like '%' + #{standby1} + '%'
+        </if>
+        <if test="standby2!=null and standby2!='' ">
+            and a.standby2 like '%' + #{standby2} + '%'
+        </if>
+        <if test="boxType3!=null and boxType3!='' ">
+            and a.box_type3 like '%' + #{boxType3} + '%'
         </if>
     </sql>
 
@@ -386,21 +401,48 @@
         <include refid="stockOutCondition"></include>
     </select>
 
-    <select id="getStockStatis" resultType="com.zy.asrs.entity.LocDetl">
-        select * from
-        (
-            select
-            ROW_NUMBER() over (order by sum(a.anfme) desc) as row
-            , a.matnr
-            , a.batch
-            , a.standby1
-            , a.standby2
-            , sum(a.anfme) as anfme
-            from asr_loc_detl a
-            where 1=1
-            <include refid="stockOutCondition"></include>
-            group by a.matnr, a.batch, a.standby1, a.standby2
-         ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
+    <select id="getStockStatis" resultMap="BaseResultMap">
+        SELECT * FROM (
+            SELECT
+                ROW_NUMBER() OVER (ORDER BY SUM(a.anfme) DESC) AS row,
+                a.matnr,
+                a.batch,
+                a.standby1,
+                a.standby2,
+                MAX(a.box_type3) AS box_type3,  -- 鍏抽敭锛氱敤 MAX 閬垮厤 null 鎴栦笉纭畾鎬�
+                SUM(a.anfme) AS anfme
+                FROM asr_loc_detl a
+                WHERE 1=1
+                <include refid="stockOutCondition"/>
+                GROUP BY
+                a.matnr,
+                a.batch,
+                a.standby1,
+                a.standby2,
+                a.box_type3  -- 淇濈暀锛屽洜涓轰笟鍔¢渶瑕佹寜閲囪喘鍗曞尯鍒�
+            ) t
+        WHERE t.row BETWEEN ((#{pageNumber}-1)*#{pageSize}+1) AND (#{pageNumber}*#{pageSize})
+    </select>
+
+    <!-- 搴撳瓨缁熻瀵煎嚭锛氬叏閲忔眹鎬绘暟鎹紙涓嶅垎椤碉級 -->
+    <select id="selectStockStatisExport" resultMap="BaseResultMap">
+        SELECT
+        a.matnr,
+        a.batch,
+        a.standby1,
+        a.standby2,
+        MAX(a.box_type3) AS box_type3,
+        SUM(a.anfme) AS anfme
+        FROM asr_loc_detl a
+        WHERE 1=1
+        <include refid="stockOutCondition1"/>
+        GROUP BY
+        a.matnr,
+        a.batch,
+        a.standby1,
+        a.standby2,
+        a.box_type3
+        ORDER BY SUM(a.anfme) DESC
     </select>
 
     <select id="getStockStatisCount" parameterType="java.util.Map" resultType="java.lang.Integer">

--
Gitblit v1.9.1