#
luxiaotao1123
2024-02-01 528d0da19f5fc3f5c78af3c99a1f2cfa914a27dd
zy-asrs-common/src/main/resources/mapper/wms/PriorMapper.xml
@@ -4,54 +4,21 @@
    <sql id="pageCondition">
        <if test="map.host_id != null and map.host_id != ''">
            and mp0.host_id = #{map.host_id}
            and host_id = #{map.host_id}
        </if>
        <if test="map.matnr != null and map.matnr != ''">
            and mp0.matnr like concat('%',#{map.matnr},'%')
            and matnr like concat('%',#{map.matnr},'%')
        </if>
        <if test="map.maktx != null and map.maktx != ''">
            and mp0.maktx like concat('%',#{map.maktx},'%')
            and maktx like concat('%',#{map.maktx},'%')
        </if>
        <if test="map.node_id != null and map.node_id != ''">
            and mp0.node_id like concat('%',#{map.node_id},'%')
        <if test="map.loc_no != null and map.loc_no != ''">
            and loc_no like concat('%',#{map.loc_no},'%')
        </if>
    </sql>
    <select id="selectSafeStoPage" resultType="com.zy.asrs.common.domain.dto.SafeStoDo">
        select
        mp0.node_id,
        mp0.node_name,
        mp0.matnr,
        mp0.maktx,
        mp0.safe_qua,
        ISNULL(dual.amount, 0) as amount,
        ISNULL((cast(round((dual.amount/(mp0.safe_qua*1.0))*100,2) as varchar)+'%'), '0.00%') as progress,
        case
        when isnull(round((dual.amount/mp0.safe_qua),2),0) >= 1 then 1
        when isnull(round((dual.amount/mp0.safe_qua),2),0) > 0.75 then 2
        else 3
        end as status
        from wms_prior mp0
        left join
        (
        select
        mp.node_id,
        mp.matnr,
        ISNULL(sum(ls.amount), 0) as amount
        from wms_prior mp
        left join
        (
        select
        mld.node_id,
        mn.path,
        mld.matnr,
        sum(mld.anfme) as amount
        from wms_loc_detl mld
        left join wms_node mn on mld.node_id = mn.id
        group by mld.node_id, mld.matnr, mn.path
        ) as ls on ls.matnr = mp.matnr and (ls.node_id = mp.node_id or CHARINDEX(','+cast(mp.node_id as varchar)+',', ','+ls.path+',') > 0)
        group by mp.node_id, mp.matnr
        ) as dual on mp0.node_id = dual.node_id and mp0.matnr = dual.matnr
        select * from wms_prior
        where 1=1
        <include refid="pageCondition"></include>
    </select>