From 186505641e95a73bac6cf3ddfe640acb3d06de6d Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 26 三月 2021 09:09:28 +0800
Subject: [PATCH] #

---
 src/main/resources/mapper/PriorMapper.xml |   61 +++++++++++++++++++++++++-----
 1 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/src/main/resources/mapper/PriorMapper.xml b/src/main/resources/mapper/PriorMapper.xml
index c3e8e23..1dc19d2 100644
--- a/src/main/resources/mapper/PriorMapper.xml
+++ b/src/main/resources/mapper/PriorMapper.xml
@@ -24,23 +24,62 @@
 
     </resultMap>
 
+
+    <sql id="pageCondition">
+        <if test="loc_no != null and loc_no != ''">
+            and mld.loc_no like concat('%',#{loc_no},'%')
+        </if>
+        <if test="matnr != null and matnr != ''">
+            and mld.matnr like concat('%',#{matnr},'%')
+        </if>
+        <if test="maktx != null and maktx != ''">
+            and mld.maktx like concat('%',#{maktx},'%')
+        </if>
+        <if test="startTime!=null and endTime!=null">
+            and mld.update_time between #{startTime} and #{endTime}
+        </if>
+    </sql>
+
     <select id="selectSafeStoPage" resultType="zy.cloud.wms.manager.entity.SafeStoDo">
+        select * from
+        (
+            select
+            ROW_NUMBER() over (order by mp.create_time desc) as row,
+            mp.node_id,
+            mp.matnr,
+            mp.safe_qua,
+            ls.amount,
+            (cast(round((ls.amount/(mp.safe_qua*1.0))*100,2) as varchar)+'%') as pe
+            from man_prior mp
+            inner join
+            (
+                select
+                node_id,
+                matnr,
+                sum(anfme) as amount
+                from man_loc_detl
+                group by node_id, matnr
+            ) as ls on ls.node_id = mp.node_id and ls.matnr = mp.matnr
+            where 1=1
+            <include refid="pageCondition"></include>
+       ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
+    </select>
+
+    <select id="selectSafeStoPageCount" resultType="java.lang.Integer">
         select
-        mp.node_id,
-        mp.matnr,
-        mp.safe_qua,
-        ls.amount,
-        (cast(round((ls.amount/(mp.safe_qua*1.0))*100,2) as varchar)+'%') as pe
+        count(1) as count
         from man_prior mp
         inner join
         (
-            select
-            node_id,
-            matnr,
-            sum(anfme) as amount
-            from man_loc_detl
-            group by node_id, matnr
+        select
+        node_id,
+        matnr,
+        sum(anfme) as amount
+        from man_loc_detl
+        group by node_id, matnr
         ) as ls on ls.node_id = mp.node_id and ls.matnr = mp.matnr
+        where 1=1
+        <include refid="pageCondition"></include>
     </select>
 
 </mapper>

--
Gitblit v1.9.1