自动化立体仓库 - WMS系统
Junjie
2023-05-24 64126dfd00ed90af484fbf7b173e00fcebc4f9fa
src/main/resources/mapper/LocDetlMapper.xml
@@ -78,6 +78,8 @@
        update asr_loc_detl
        set anfme = #{anfme}
        , modi_time = getdate()
        , manu = #{manu}
        , memo = #{memo}
        where 1=1
        and loc_no = #{locNo}
        and matnr = #{matnr}
@@ -94,19 +96,44 @@
        <if test="maktx!=null and maktx!='' ">
            and a.maktx like '%' + #{maktx} + '%'
        </if>
        <if test="specs!=null and specs!='' ">
            and a.specs like '%' + #{specs} + '%'
        </if>
        <if test="anfme!=null and anfme!='' ">
            and a.anfme like '%' + #{anfme} + '%'
        </if>
        <if test="zpallet!=null and zpallet!='' ">
            and a.zpallet like '%' + #{zpallet} + '%'
        </if>
        <if test="manu!=null and manu!='' ">
            and a.manu like '%' + #{manu} + '%'
        </if>
        <if test="startTime!=null and endTime!=null">
            and a.modi_time between #{startTime} and #{endTime}
        </if>
    </sql>
    <sql id="groupListCondition">
        <if test="matnr!=null and matnr!='' ">
            and matnr like '%' + #{matnr} + '%'
        </if>
        <if test="maktx!=null and maktx!='' ">
            and maktx like '%' + #{maktx} + '%'
        </if>
        <if test="specs!=null and specs!='' ">
            and specs like '%' + #{specs} + '%'
        </if>
        <if test="batch!=null and batch!='' ">
            and batch like '%' + #{batch} + '%'
        </if>
    </sql>
    <select id="getStockOutPage" resultMap="BaseResultMap">
        select * from
        (
            select
            ROW_NUMBER() over (order by a.appe_time,a.matnr,a.loc_no) as row,
            ROW_NUMBER() over (order by a.loc_no,a.appe_time,a.matnr) as row,
            a.*
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
@@ -140,6 +167,21 @@
         ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
    </select>
    <select id="getStockStatis2" resultType="com.zy.asrs.entity.LocDetl">
        select * from
        (
        select
        ROW_NUMBER() over (order by sum(a.anfme),a.batch desc) as row
        , a.matnr
        , a.batch
        , sum(a.anfme) as anfme
        from asr_loc_detl a
        where 1=1
        <include refid="stockOutCondition"></include>
        group by a.matnr,a.batch
        ) 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
        (
@@ -157,9 +199,10 @@
        ROW_NUMBER() over (order by sum(a.anfme) desc) as row
        , a.matnr
        , sum(a.anfme) as anfme
        , a.specs
        from asr_loc_detl a
        where 1=1
        group by a.matnr
        group by a.matnr, a.specs
    </select>
    <select id="selectPakoutByRule" resultMap="BaseResultMap">
@@ -199,78 +242,138 @@
        (
            select
            no = 1,
            orderBy = 'false',
            b.bay1 as bay,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 1
            and b.row1 &lt;= 3
            group by b.bay1
            union
            select
            no = 2,
            orderBy = 'true',
            b.bay1,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 4
            and b.row1 &lt;= 7
            group by b.bay1
            union
            select
            no = 3,
            orderBy = 'false',
            b.bay1,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 8
            and b.row1 &lt;= 11
            group by b.bay1
            union
            select
            no = 4,
            orderBy = 'true',
            b.bay1,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 12
            and b.row1 &lt;= 14
            group by b.bay1
            union
            select
            no = 5,
            orderBy = 'false',
            b.bay1,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 15
            and b.row1 &lt;= 18
            group by b.bay1
            union
            select
            no = 6,
            orderBy = 'true',
            b.bay1,
            count(1) as count
            sum(anfme) as count
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            and b.loc_sts = 'F' and b.frozen != 1
            and a.manu is null
            and a.matnr = #{matnr}
            <choose>
                <when test="batch != null and batch != ''">
                    and a.batch = #{batch}
                </when>
                <otherwise>
                    and (a.batch IS NULL OR a.batch = '')
                </otherwise>
            </choose>
            and b.row1 >= 19
            and b.row1 &lt;= 21
            group by b.bay1
@@ -331,9 +434,20 @@
            </if>
        )
        and a.matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and a.batch = #{batch}
            </when>
            <otherwise>
                and (a.batch IS NULL OR a.batch = '')
            </otherwise>
        </choose>
        and b.bay1 = #{bay}
        and b.loc_sts = 'F'
        order by b.row1 asc
        and b.loc_sts = 'F' and b.frozen != 1
        order by b.row1
        <if test="orderBy != null and orderBy != '' and orderBy == 'false'">
            desc
        </if>
    </select>
    <select id="queryStockAnfme" resultType="java.lang.Double">
@@ -367,5 +481,37 @@
            batch LIKE '%[a-z]%'
    </select>
    <select id="selectSameDetl" resultType="java.lang.String">
        SELECT
        ld.loc_no
        FROM asr_loc_detl ld
        LEFT JOIN asr_loc_mast lm ON ld.loc_no = lm.loc_no
        LEFT JOIN (
            select
            loc_no,
            count(1) as count
            from asr_loc_detl
            where 1=1
            group by loc_no
        ) dual on dual.loc_no = lm.loc_no
        WHERE 1 = 1
        AND ld.matnr = #{matnr}
        AND (lm.row1 >= #{start} AND lm.row1 &lt;= #{end})
        AND (lm.loc_sts = 'F')
        AND dual.count = 1
        ORDER BY lm.modi_time ASC
    </select>
    <select id="selectSumByMatnr" resultType="java.lang.Double">
        select sum(anfme) FROM asr_loc_detl WHERE matnr = #{matnr}
    </select>
    <select id="selectGroupPage" resultMap="BaseResultMap" parameterType="java.util.Map">
        SELECT  *  FROM [dbo].[asr_loc_detl_group] WHERE 1 = 1
        <include refid="groupListCondition"></include>
    </select>
    <select id="selectByLocNo" resultMap="BaseResultMap">
        SELECT * FROM asr_loc_detl WHERE loc_no = #{locNo}
    </select>
</mapper>