#
luxiaotao1123
2024-02-01 528d0da19f5fc3f5c78af3c99a1f2cfa914a27dd
zy-asrs-common/src/main/resources/mapper/wms/LocDetlMapper.xml
@@ -59,77 +59,15 @@
        select
        a.*
        from wms_loc_detl a
        left join common_loc_mast b on a.loc_no = b.loc_no
        left join common_loc_mast b on a.loc_no = b.loc_no and a.host_id = b.host_id
        where 1=1
        <if test="no!=null and no == 1">
            and b.row1 >= 31
            and b.row1 &lt;= 32
        </if>
        <if test="no!=null and no == 2">
            and b.row1 >= 2
            and b.row1 &lt;= 17
        </if>
        <if test="no!=null and no == 3">
            and b.row1 >= 18
            and b.row1 &lt;= 30
        </if>
        and a.matnr = #{matnr}
        and b.bay1 = #{bay}
        <if test="batch!=null and batch!=''">
            and a.batch = #{batch}
        </if>
        and b.host_id = #{hostId}
        and b.loc_sts = 'F'
        order by b.row1
        <if test="orderBy != null and orderBy != '' and orderBy == 'false'">
            desc
        </if>
    </select>
    <select id="queryStockPre" resultType="com.zy.asrs.common.domain.dto.QueryStockPreDo">
        select
            *
        from
            (
                select
                    no = 1,
                    orderBy = 'true',
                    b.bay1 as bay,
                    sum(anfme) as count
                from wms_loc_detl a
                    left join common_loc_mast b on a.loc_no = b.loc_no
                where 1=1
                  and b.loc_sts = 'F'
                  and a.matnr = #{matnr}
                  and b.row1 >= 31
                  and b.row1 &lt;= 32
                group by b.bay1
                union
                select
                    no = 2,
                    orderBy = 'true',
                    b.bay1 as bay,
                    sum(anfme) as count
                from wms_loc_detl a
                    left join common_loc_mast b on a.loc_no = b.loc_no
                where 1=1
                  and b.loc_sts = 'F'
                  and a.matnr = #{matnr}
                  and b.row1 >= 2
                  and b.row1 &lt;= 17
                group by b.bay1
                union
                select
                    no = 3,
                    orderBy = 'false',
                    b.bay1 as bay,
                    sum(anfme) as count
                from wms_loc_detl a
                    left join common_loc_mast b on a.loc_no = b.loc_no
                where 1=1
                  and b.loc_sts = 'F'
                  and a.matnr = #{matnr}
                  and b.row1 >= 18
                  and b.row1 &lt;= 30
                group by b.bay1
            ) a
        order by no, count desc
    </select>
    <select id="selectItem" resultType="com.zy.asrs.common.wms.entity.LocDetl">
@@ -179,4 +117,29 @@
        group by matnr,batch
    </select>
    <select id="selectSameDetl" resultType="java.lang.String">
        SELECT
            ld.loc_no
        FROM wms_loc_detl ld
                 LEFT JOIN common_loc_mast lm ON ld.loc_no = lm.loc_no and ld.host_id = lm.host_id
                 LEFT JOIN (
            select
                loc_no,
                count(1) as count
            from wms_loc_detl
            where 1=1
            and host_id = #{hostId}
            group by loc_no
        ) dual on dual.loc_no = lm.loc_no
        WHERE 1 = 1
          AND ld.matnr = #{matnr}
          <if test="batch">
              AND ld.batch = #{batch}
          </if>
          AND (lm.loc_sts = 'F')
          AND dual.count = 1
          AND lm.host_id = #{hostId}
        ORDER BY lm.modi_time ASC
    </select>
</mapper>