自动化立体仓库 - WMS系统
#
18516761980
2022-03-26 03816e2c16bb0a2fd7a9958e030456e7feeba75a
src/main/resources/mapper/LocDetlMapper.xml
@@ -5,15 +5,17 @@
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.LocDetl">
        <result column="loc_no" property="locNo" />
        <result column="matnr" property="matnr" />
        <result column="lgnum" property="lgnum" />
        <result column="tbnum" property="tbnum" />
        <result column="tbpos" property="tbpos" />
        <result column="zmatid" property="zmatid" />
        <result column="maktx" property="maktx" />
        <result column="werks" property="werks" />
        <result column="anfme" property="anfme" />
        <result column="altme" property="altme" />
        <result column="mat_no" property="matNo" />
        <result column="mat_name" property="matName" />
        <result column="specs" property="specs" />
        <result column="size" property="size" />
        <result column="color" property="color" />
        <result column="weight" property="weight" />
        <result column="supplier" property="supplier" />
        <result column="warehouse" property="warehouse" />
        <result column="brand" property="brand" />
        <result column="qty" property="qty" />
        <result column="unit" property="unit" />
        <result column="zpallet" property="zpallet" />
        <result column="bname" property="bname" />
        <result column="memo" property="memo" />
@@ -21,23 +23,65 @@
        <result column="modi_time" property="modiTime" />
        <result column="appe_user" property="appeUser" />
        <result column="appe_time" property="appeTime" />
        <result column="all_qty" property="allQty"/>
        <result column="all_weight" property="allWeight"/>
        <result column="source" property="source" />
        <result column="vendor" property="vendor" />
        <result column="qty_box" property="qtyBox"/>
        <result column="str3" property="str3" />
        <result column="str4" property="str4" />
        <result column="str5" property="str5"/>
    </resultMap>
    <select id="getStockOutPage" parameterType="java.util.Map" resultMap="BaseResultMap">
    <sql id="stockOutCondition">
        <if test="loc_no!=null and loc_no!='' ">
            and a.loc_no like '%' + #{loc_no} + '%'
        </if>
        <if test="mat_no!=null and mat_no!='' ">
            and a.mat_no like '%' + #{mat_no} + '%'
        </if>
        <if test="mat_name!=null and mat_name!='' ">
            and a.mat_name like '%' + #{mat_name} + '%'
        </if>
        <if test="str3!=null and str3!=''" >
            and a.str3 like '%'+#{str3}+'%'
        </if>
        <if test="qty!=null and qty!='' ">
            and a.qty = #{qty}
        </if>
        <if test="altme!=null and altme!='' ">
            and a.unit like '%' + #{unit} + '%'
        </if>
        <if test="startTime!=null and endTime!=null">
            and a.modi_time between #{startTime} and #{endTime}
        </if>
    </sql>
    <sql id="stockOutCondition1">
    <if test="mat_no!=null and mat_no!='' ">
        and mat_no like '%' + #{mat_no} + '%'
    </if>
    <if test="mat_name!=null and mat_name!='' ">
        and mat_name like '%' + #{mat_name} + '%'
    </if>
    <if test="str3!=null and str3!=''" >
        and str3 like '%'+#{str3}+'%'
    </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.appe_time,a.mat_no,a.loc_no) as row,
            a.*
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_type = 'F'
            <if test="loc_no!=null and loc_no!='' ">
                and a.loc_no like '%' + #{loc_no} + '%'
            </if>
            and b.loc_sts = 'F'
            <include refid="stockOutCondition"></include>
        ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
        order by supplier,modi_time,loc_no
    </select>
    <select id="getStockOutPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
@@ -46,6 +90,68 @@
        from asr_loc_detl a
        left join asr_loc_mast b on a.loc_no = b.loc_no
        where 1=1
        and b.loc_type = 'F'
        and b.loc_sts = 'F'
        <include refid="stockOutCondition"></include>
    </select>
    <select id="selectLocDetlList" resultMap="BaseResultMap">
        select a.*
        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 a.mat_no= #{mat_no}
        order by a.appe_time
    </select>
    <select id="selectLocDetlSumQty" resultType="double">
        select SUM(qty) qty
        from asr_loc_detl
        where loc_no=#{locNo}
    </select>
    <select id="getStockStatis" resultMap="BaseResultMap">
<!--        select a.mat_name,a.mat_no,a.supplier,a.str3,sum(a.qty) qty  from-->
<!--        (-->
<!--        select-->
<!--        ROW_NUMBER() over (order by c.appe_time,c.mat_no,c.loc_no) as row,-->
<!--        c.*-->
<!--        from asr_loc_detl c-->
<!--        ) a where a.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})-->
<!--         <include refid="stockOutCondition"></include>-->
<!--        group by a.mat_no,a.mat_name,a.supplier,a.str3-->
        select * from
        (
        select ROW_NUMBER() over (order by a.mat_no) as row,
        a.mat_name,a.mat_no,a.supplier,a.str3,sum(a.qty) qty  from
        (
        select
        mat_name,mat_no,supplier,str3,qty
        from asr_loc_detl c
        where 1=1
        <include refid="stockOutCondition1"></include>
        ) a
        group by a.mat_no,a.mat_name,a.supplier,a.str3
        ) d
        where 1=1
        and row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
    </select>
    <select id="getStockStatisCount" resultType="integer">
        select
        count(1)
        from asr_loc_detl a
    </select>
    <select id="getStockStatisExcel" resultMap="BaseResultMap">
     select
        ROW_NUMBER() over (order by a.mat_no, sum(a.qty) desc) as row
        , a.mat_no, a.mat_name,a.supplier
        , sum(a.qty) as qty
        from asr_loc_detl a
        where 1=1
        group by a.mat_no,a.mat_name,a.supplier
    </select>
<!--    <select id="getStockSum" resultMap="BaseResultMap">-->
<!--        select mat_no,mat_name,sum(qty) qty  from asr_loc_detl-->
<!--        group by mat_no,mat_name-->
<!--    </select>-->
</mapper>