From 0474a145d356ad5f539b05ddc74129b73fe60b41 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 30 三月 2022 11:11:12 +0800
Subject: [PATCH] #

---
 src/main/resources/mapper/LocDetlMapper.xml |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/LocDetlMapper.xml b/src/main/resources/mapper/LocDetlMapper.xml
index 0ef2eaa..be017a9 100644
--- a/src/main/resources/mapper/LocDetlMapper.xml
+++ b/src/main/resources/mapper/LocDetlMapper.xml
@@ -26,6 +26,44 @@
         <result column="appe_time" property="appeTime" />
     </resultMap>
 
+    <sql id="batchSeq">
+        <choose>
+            <when test="batch != null and batch != ''">
+                and batch = #{batch}
+            </when>
+            <otherwise>
+                and (batch IS NULL OR batch = '')
+            </otherwise>
+        </choose>
+    </sql>
+
+    <select id="selectItem" resultMap="BaseResultMap">
+        select top 1 *
+        from asr_loc_detl
+        where 1=1
+        and loc_no = #{locNo}
+        and matnr = #{matnr}
+        <include refid="batchSeq"></include>
+    </select>
+
+    <delete id="deleteItem">
+        delete from asr_loc_detl
+        where 1=1
+        and loc_no = #{locNo}
+        and matnr = #{matnr}
+        <include refid="batchSeq"></include>
+    </delete>
+
+    <update id="updateAnfme">
+        update asr_loc_detl
+        set anfme = #{anfme}
+        , modi_time = getdate()
+        where 1=1
+        and loc_no = #{locNo}
+        and matnr = #{matnr}
+        <include refid="batchSeq"></include>
+    </update>
+
     <sql id="stockOutCondition">
         <if test="loc_no!=null and loc_no!='' ">
             and a.loc_no like '%' + #{loc_no} + '%'
@@ -144,15 +182,21 @@
         where 1=1
         and b.loc_sts = 'F'
         and a.matnr = #{matnr}
-        <if test="batch != null and batch != ''">
-            and a.batch = #{batch}
-        </if>
+        <choose>
+            <when test="batch != null and batch != ''">
+                and a.batch = #{batch}
+            </when>
+            <otherwise>
+                and (a.batch IS NULL OR a.batch = '')
+            </otherwise>
+        </choose>
         <if test="orderNo != null and orderNo != ''">
             and a.orderNo = #{orderNo}
         </if>
         order by
         DATEPART(yyyy,a.modi_time),DATEPART(mm,a.modi_time),DATEPART(dd,a.modi_time)
         desc,
+        NEWID(),
         case
         when (left(a.loc_no, 2) = '01') then 0
         when (left(a.loc_no, 2) = '02') then 1
@@ -207,4 +251,13 @@
         desc
     </select>
 
+    <select id="queryStockAnfme" resultType="java.lang.Double">
+        select sum(anfme) as count from man_loc_detl
+         where 1=1
+         and matnr = #{matnr}
+        <if test="batch != null and batch != ''">
+            and batch = #{batch}
+        </if>
+    </select>
+
 </mapper>

--
Gitblit v1.9.1