自动化立体仓库 - WMS系统
1
zhang
2025-10-20 00860b3f449e5b3289f2809c199dd56ec75d46e3
src/main/resources/mapper/LocDetlMapper.xml
@@ -48,11 +48,11 @@
    <sql id="batchSeq">
        <choose>
            <when test="batch != null and batch != ''">
            <when test="batch != null">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
                and (batch IS NULL)
            </otherwise>
        </choose>
    </sql>
@@ -100,6 +100,15 @@
        <if test="startTime!=null and endTime!=null">
            and a.modi_time between #{startTime} and #{endTime}
        </if>
        <if test="batch!=null and batch!='' ">
            and a.batch=#{batch}
        </if>
        <if test="crnNo!=null and crnNo!='' ">
            and b.crn_no=#{crnNo}
        </if>
        <if test="zpallet!=null and zpallet!='' ">
            and a.zpallet like '%' + #{zpallet} + '%'
        </if>
    </sql>
    <select id="getStockOutPage" resultMap="BaseResultMap">
@@ -129,28 +138,44 @@
    <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
            , sum(a.anfme) as anfme
            from asr_loc_detl a
            where 1=1
            <include refid="stockOutCondition"></include>
            group by a.matnr
         ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
        select
        ROW_NUMBER() over (order by sum(a.anfme) desc) as row
        , a.matnr
        , sum(a.anfme) as anfme
        from asr_loc_detl a
        where 1=1
        <!-- 动态添加规格和类型的条件 -->
        <if test="specs != null and specs != ''">
            AND a.specs = #{specs}
        </if>
        <if test="brand != null and brand != ''">
            AND a.brand = #{brand}
        </if>
        <include refid="stockOutCondition"></include>
        group by a.matnr
        ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
    </select>
    <select id="getStockStatisCount" parameterType="java.util.Map" resultType="java.lang.Integer">
     select count(1) as count from
        select count(1) as count from
        (
        select
        a.matnr
        from asr_loc_detl a
        where 1=1
        <!-- 动态添加规格和类型的条件 -->
        <if test="specs != null and specs != ''">
            AND a.specs = #{specs}
        </if>
        <if test="brand != null and brand != ''">
            AND a.brand = #{brand}
        </if>
        <include refid="stockOutCondition"></include>
        group by a.matnr
     ) b
        ) b
    </select>
    <select id="getStockStatisExcel" resultType="com.zy.asrs.entity.LocDetl">
        select
@@ -207,11 +232,11 @@
<!--                and (a.batch IS NULL OR a.batch = '')-->
<!--            </otherwise>-->
<!--        </choose>-->
        <if test="batch != null and batch != ''">
        <if test="batch != null">
            and a.batch = #{batch}
        </if>
        <if test="orderNo != null and orderNo != ''">
            and a.orderNo = #{orderNo}
            and a.order_no = #{orderNo}
        </if>
        <if test="locNos != null and locNos.size > 0">
@@ -291,11 +316,39 @@
    <select id="queryStockTotal" resultType="com.zy.asrs.entity.result.StockVo">
        select
        matnr,
        maktx,
        specs,
        batch,
        count(anfme) as count
        from asr_loc_detl
        where 1=1
        group by matnr,batch
        group by matnr,maktx,specs,batch
    </select>
    <select id="sum" resultType="java.lang.Integer">
        SELECT SUM(anfme) FROM asr_loc_detl
    </select>
    <select id="unreason" resultMap="BaseResultMap">
        SELECT
            *
        FROM
            [dbo].[asr_loc_detl]
        WHERE
            DATALENGTH( batch ) != 11 or
            batch LIKE '%[a-z]%'
    </select>
    <select id="selectLocDetlSumQty" resultType="double">
        select SUM(anfme) anfme
        from asr_loc_detl
        where loc_no=#{locNo}
    </select>
    <select id="getBomQyt" resultType="double">
        select SUM(anfme) anfme
        from asr_loc_detl
        where bom_code = #{bomCode}
        and matnr = #{matnr}
    </select>
</mapper>