From 605be0c8702fc7bfe4f7fcdd397c9f0d40722b69 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 09 四月 2026 15:19:43 +0800
Subject: [PATCH] 1.商品档案新增最大限制和最小限制 2.mes空桶/余料回库修复

---
 src/main/resources/mapper/LocDetlMapper.xml |   66 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/LocDetlMapper.xml b/src/main/resources/mapper/LocDetlMapper.xml
index 05b0f54..7c4bc10 100644
--- a/src/main/resources/mapper/LocDetlMapper.xml
+++ b/src/main/resources/mapper/LocDetlMapper.xml
@@ -769,4 +769,70 @@
         ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
     </select>
 
+    <sql id="groupLocWarnStatusCase">
+        case
+            when mm.store_max is null and mm.store_min is null then '鏈缃�'
+            when mm.store_max is not null and isnull(stock.anfme, 0) &gt; mm.store_max then '瓒呬笂闄�'
+            when mm.store_min is not null and isnull(stock.anfme, 0) &lt; mm.store_min then '瓒呬笅闄�'
+            else '姝e父'
+        end
+    </sql>
+
+    <sql id="groupLocListCondition">
+        where 1 = 1
+        and (mm.memo is null or mm.memo != '鎵撳寘涓婄嚎')
+        <if test="matnr != null and matnr != ''">
+            and mm.matnr like '%' + #{matnr} + '%'
+        </if>
+        <if test="maktx != null and maktx != ''">
+            and mm.maktx like '%' + #{maktx} + '%'
+        </if>
+        <if test="specs != null and specs != ''">
+            and mm.specs like '%' + #{specs} + '%'
+        </if>
+        <if test="warnStatus != null and warnStatus != ''">
+            and
+            <include refid="groupLocWarnStatusCase"/>
+            = #{warnStatus}
+        </if>
+    </sql>
+
+    <select id="groupLocList" resultType="com.zy.asrs.entity.param.AbnormalLocDetlParam">
+        select * from
+        (
+            select
+                row_number() over (order by mm.matnr asc) as row_num,
+                mm.matnr as matnr,
+                mm.maktx as maktx,
+                mm.specs as specs,
+                isnull(stock.anfme, 0) as anfme,
+                mm.store_max as storeMax,
+                mm.store_min as storeMin,
+                <include refid="groupLocWarnStatusCase"/> as warnStatus
+            from man_mat mm
+            left join (
+                select
+                    a.matnr,
+                    sum(a.anfme) as anfme
+                from asr_loc_detl a
+                group by a.matnr
+            ) stock on stock.matnr = mm.matnr
+            <include refid="groupLocListCondition"/>
+        ) t
+        where t.row_num between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
+    </select>
+
+    <select id="groupLocListCount" resultType="java.lang.Integer">
+        select count(1)
+        from man_mat mm
+        left join (
+            select
+                a.matnr,
+                sum(a.anfme) as anfme
+            from asr_loc_detl a
+            group by a.matnr
+        ) stock on stock.matnr = mm.matnr
+        <include refid="groupLocListCondition"/>
+    </select>
+
 </mapper>

--
Gitblit v1.9.1