From 958883d6f4dac68fcbbccadb4e7f87e963eee0e8 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期三, 09 七月 2025 12:32:40 +0800
Subject: [PATCH] 新增盘点提取库存后可以删除明细

---
 zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml |  134 ++++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 68 deletions(-)

diff --git a/zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml b/zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml
index 73e0dc8..b783b20 100644
--- a/zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml
+++ b/zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml
@@ -23,11 +23,17 @@
         <if test="map.maktx!=null and map.maktx!='' ">
             and a.maktx like '%' + #{map.maktx} + '%'
         </if>
+        <if test="map.zpallet!=null and map.zpallet!='' ">
+            and a.zpallet like '%' + #{map.zpallet} + '%'
+        </if>
         <if test="map.batch!=null and map.batch!='' ">
             and a.batch like '%' + #{map.batch} + '%'
         </if>
         <if test="map.anfme!=null and map.anfme!='' ">
             and a.anfme like '%' + #{map.anfme} + '%'
+        </if>
+        <if test="map.owner!=null and map.owner!='' ">
+            and a.owner like '%' + #{map.owner} + '%'
         </if>
         <if test="map.startTime!=null and map.endTime!=null">
             and a.modi_time between #{map.startTime} and #{map.endTime}
@@ -59,77 +65,16 @@
         select
         a.*
         from wms_loc_detl a
-        left join common_loc_mast b on a.loc_no = b.loc_no
+        left join common_loc_mast b on a.loc_no = b.loc_no and a.host_id = b.host_id
         where 1=1
-        <if test="no!=null and no == 1">
-            and b.row1 >= 31
-            and b.row1 &lt;= 32
-        </if>
-        <if test="no!=null and no == 2">
-            and b.row1 >= 2
-            and b.row1 &lt;= 17
-        </if>
-        <if test="no!=null and no == 3">
-            and b.row1 >= 18
-            and b.row1 &lt;= 30
-        </if>
         and a.matnr = #{matnr}
-        and b.bay1 = #{bay}
-        and b.loc_sts = 'F'
-        order by b.row1
-        <if test="orderBy != null and orderBy != '' and orderBy == 'false'">
-            desc
+        <if test="batch!=null and batch!=''">
+            and a.batch = #{batch}
         </if>
-    </select>
-
-    <select id="queryStockPre" resultType="com.zy.asrs.common.domain.dto.QueryStockPreDo">
-        select
-            *
-        from
-            (
-                select
-                    no = 1,
-                    orderBy = 'true',
-                    b.bay1 as bay,
-                    sum(anfme) as count
-                from wms_loc_detl a
-                    left join common_loc_mast b on a.loc_no = b.loc_no
-                where 1=1
-                  and b.loc_sts = 'F'
-                  and a.matnr = #{matnr}
-                  and b.row1 >= 31
-                  and b.row1 &lt;= 32
-                group by b.bay1
-                union
-                select
-                    no = 2,
-                    orderBy = 'true',
-                    b.bay1 as bay,
-                    sum(anfme) as count
-                from wms_loc_detl a
-                    left join common_loc_mast b on a.loc_no = b.loc_no
-                where 1=1
-                  and b.loc_sts = 'F'
-                  and a.matnr = #{matnr}
-                  and b.row1 >= 2
-                  and b.row1 &lt;= 17
-                group by b.bay1
-                union
-                select
-                    no = 3,
-                    orderBy = 'false',
-                    b.bay1 as bay,
-                    sum(anfme) as count
-                from wms_loc_detl a
-                    left join common_loc_mast b on a.loc_no = b.loc_no
-                where 1=1
-                  and b.loc_sts = 'F'
-                  and a.matnr = #{matnr}
-                  and b.row1 >= 18
-                  and b.row1 &lt;= 30
-                group by b.bay1
-            ) a
-        order by no, count desc
+        and b.host_id = #{hostId}
+        and b.loc_sts = 'F'
+        and b.row1 in (1,2,3,4)
+        order by b.row1
     </select>
 
     <select id="selectItem" resultType="com.zy.asrs.common.wms.entity.LocDetl">
@@ -170,7 +115,60 @@
         where 1=1
         and b.loc_sts = 'F'
         and b.host_id = #{map.hostId}
+        and b.row1 in (1,2,3,4)
         <include refid="stockOutCondition"></include>
     </select>
 
+    <select id="getReportStockDto" resultType="com.zy.asrs.common.domain.dto.ReportStockDto">
+        select matnr,batch,sum(anfme) anfme from wms_loc_detl
+        where host_id = #{hostId}
+        group by matnr,batch
+    </select>
+
+    <select id="selectSameDetl" resultType="java.lang.String">
+        SELECT
+            ld.loc_no
+        FROM wms_loc_detl ld
+                 LEFT JOIN common_loc_mast lm ON ld.loc_no = lm.loc_no and ld.host_id = lm.host_id
+                 LEFT JOIN (
+            select
+                loc_no,
+                count(1) as count
+            from wms_loc_detl
+            where 1=1
+            and host_id = #{hostId}
+            group by loc_no
+        ) dual on dual.loc_no = lm.loc_no
+        WHERE 1 = 1
+          AND ld.matnr = #{matnr}
+          <if test="batch">
+              AND ld.batch = #{batch}
+          </if>
+          AND (lm.loc_sts = 'F')
+          AND dual.count = 1
+          AND lm.host_id = #{hostId}
+        ORDER BY lm.modi_time ASC
+    </select>
+
+    <select id="getStockStatisExcel" resultType="com.zy.asrs.common.wms.entity.LocDetl">
+        select
+            ROW_NUMBER() over (order by sum(a.anfme) desc) as row
+        , a.matnr
+             , sum(a.anfme) as anfme
+        from wms_loc_detl a
+        where 1=1
+        group by a.matnr
+    </select>
+
+    <select id="getStock" resultType="com.zy.asrs.common.domain.dto.ReportStockDto">
+        select loc_no as locNo,count(loc_no) as anfme from
+            (select matnr,count(matnr) counts,loc_no
+             from wms_loc_detl where matnr IN
+        <foreach item="item" collection="matnr" open="(" separator="," close=")">
+        #{item, jdbcType=VARCHAR}
+        </foreach> GROUP BY matnr,loc_no) aa
+        GROUP BY aa.loc_no
+        order by anfme desc
+    </select>
+
 </mapper>

--
Gitblit v1.9.1