自动化立体仓库 - WMS系统
#
yxFwq
2025-11-12 3059d50796c6b497b930933e9d9d2c5a812bb3c7
src/main/resources/mapper/LocMastMapper.xml
@@ -16,6 +16,9 @@
        <result column="lev1" property="lev1" />
        <result column="full_plt" property="fullPlt" />
        <result column="loc_type" property="locType" />
        <result column="loc_type1" property="locType1" />
        <result column="loc_type2" property="locType2" />
        <result column="loc_type3" property="locType3" />
        <result column="out_enable" property="outEnable" />
        <result column="io_time" property="ioTime" />
        <result column="first_time" property="firstTime" />
@@ -30,9 +33,156 @@
        <result column="inv_wh" property="invWh" />
        <result column="mk" property="mk" />
        <result column="barcode" property="barcode" />
        <result column="Pdc_type" property="PdcType" />
        <result column="ctn_no" property="ctnNo" />
    </resultMap>
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMapError" type="com.zy.asrs.entity.param.ErrorDeviceParam">
        <result column="category" property="category" />
        <result column="equipmentNo" property="equipmentNo" />
        <result column="categoryOther" property="categoryOther" />
        <result column="equipmentNoOther" property="equipmentNoOther" />
        <result column="errorM" property="errorM" />
    </resultMap>
    <select id="queryFreeLocMast" resultMap="BaseResultMap">
        select top 1 *
        from asr_loc_mast
        where row1=#{row}
        and loc_sts='O'
        <if test="locType1 != null">
            and loc_type1 = #{locType1}
        </if>
        order by loc_sts desc ,lev1 asc,bay1 asc
    </select>
<!--    库位为F但没有明细-->
    <select id="asrLocMastNotInDetl1" resultMap="BaseResultMap">
        SELECT a.*
        FROM asr_loc_mast AS a
                 LEFT JOIN asr_loc_detl AS b ON a.loc_no = b.loc_no
        WHERE a.loc_sts = 'F'
          AND b.loc_no IS NULL
    </select>
<!--    库位为SRQP但没有工作档案-->
    <select id="asrLocMastNotInDetl2" resultMap="BaseResultMap">
        SELECT a.*
        FROM asr_loc_mast AS a
        WHERE a.loc_sts IN ('S','R','Q','P')
          AND NOT EXISTS (
            SELECT 1
            FROM asr_wrk_mast AS d
            WHERE a.loc_no = d.loc_no OR a.loc_no = d.source_loc_no
          )
        order by a.loc_no
    </select>
    <!--    库位为F\D但存在工作档案-->
    <select id="asrLocMastNotInDetl3" resultMap="BaseResultMap">
        SELECT a.*
        FROM asr_loc_mast AS a
        WHERE a.loc_sts IN ('F','D')
          AND EXISTS (
            SELECT 1
            FROM asr_wrk_mast AS d
            WHERE a.loc_no = d.loc_no OR a.loc_no = d.source_loc_no
        )
        order by a.loc_no
    </select>
    <!--    深浅库位不一致-->
    <select id="adjacentLocMast" resultMap="BaseResultMapError">
        SELECT
            a.loc_no AS category,
            a.loc_sts AS equipmentNo,
            neighbor.loc_no AS categoryOther,
            neighbor.loc_sts AS equipmentNoOther,
            '深浅库位不一致' AS errorM
        FROM
            asr_loc_mast AS a
                JOIN
            asr_loc_mast AS neighbor ON
                a.bay1 = neighbor.bay1 AND
                a.lev1 = neighbor.lev1 AND
                (
                    (a.row1 = 1 AND neighbor.row1 = 2) OR
                    (a.row1 = 2 AND neighbor.row1 = 1) OR
                    (a.row1 = 3 AND neighbor.row1 = 4) OR
                    (a.row1 = 4 AND neighbor.row1 = 3) OR
                    (a.row1 = 5 AND neighbor.row1 = 6) OR
                    (a.row1 = 6 AND neighbor.row1 = 5) OR
                    (a.row1 = 7 AND neighbor.row1 = 8) OR
                    (a.row1 = 8 AND neighbor.row1 = 7)
                    )
        WHERE
            a.row1 IN (2,3,6,7)
          AND NOT (
            a.loc_sts = neighbor.loc_sts OR
            (a.loc_sts IN ('F', 'D') AND neighbor.loc_sts IN ('F', 'D'))
            )
    </select>
    <select id="queryShallowLocFMast" resultMap="BaseResultMap">
        select * from asr_loc_mast
        where 1=1
        and loc_no in (
         select
         concat(
         (
         case
         when left(loc_no, 2) = '01' then '02'
         when left(loc_no, 2) = '04' then '03'
         when left(loc_no, 2) = '05' then '06'
         when left(loc_no, 2) = '08' then '07'
         when left(loc_no, 2) = '09' then '10'
         when left(loc_no, 2) = '12' then '11'
         when left(loc_no, 2) = '13' then '14'
         when left(loc_no, 2) = '16' then '15'
         when left(loc_no, 2) = '17' then '18'
         when left(loc_no, 2) = '20' then '19'
         end)
         , right(loc_no, 5)) as shallowLocNo
         from asr_loc_mast
         where 1=1
         and loc_sts = 'O'
         and row1 in (1,4,5,8,9,12,13,16,17,20)
        )
        and (loc_sts = 'F' or loc_sts = 'D') and crn_no = #{crnNo}
    </select>
    <select id="selectLocByLocStsPakInF1" resultMap="BaseResultMap">
        SELECT top 1 * FROM [dbo].[asr_loc_mast] WHERE loc_no in
        <foreach collection="locNos" item="locNo" index="index" open="(" close=")" separator=",">
            #{locNo}
        </foreach>
        AND loc_sts not in ('O') order by row1
    </select>
    <select id="selectLocByLocStsPakInF2" resultMap="BaseResultMap">
        SELECT top 1 * FROM [dbo].[asr_loc_mast] WHERE loc_no in
        <foreach collection="locNos" item="locNo" index="index" open="(" close=")" separator=",">
            #{locNo}
        </foreach>
        AND loc_sts not in ('O') order by row1 desc
    </select>
    <select id="selectLocByLocStsPakInO1" resultMap="BaseResultMap">
        SELECT top 1 * FROM [dbo].[asr_loc_mast] WHERE loc_no in
        <foreach collection="locNos" item="locNo" index="index" open="(" close=")" separator=",">
            #{locNo}
        </foreach>
        AND loc_sts in ('O') order by row1 desc
    </select>
    <select id="selectLocByLocStsPakInO2" resultMap="BaseResultMap">
        SELECT top 1 * FROM [dbo].[asr_loc_mast] WHERE loc_no in
        <foreach collection="locNos" item="locNo" index="index" open="(" close=")" separator=",">
            #{locNo}
        </foreach>
        AND loc_sts in ('O') order by row1
    </select>
</mapper>