hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
@@ -302,29 +302,49 @@
        order by bsc.device_id, bsc.slot
    </select>
    <select id="queryNeedDispatch" resultType="com.mes.bigstorage.entity.BigStorageCageDetails">
        SELECT * FROM big_storage_cage_details WHERE STATE = 100 AND SLOT = (SELECT SLOT FROM big_storage_cage_details WHERE STATE = 100 AND sequence = 1 order by slot desc LIMIT 1) ORDER BY tempering_feed_sequence
        SELECT *
        FROM big_storage_cage_details
        WHERE STATE = 100
          AND SLOT =
              (SELECT SLOT FROM big_storage_cage_details WHERE STATE = 100 AND sequence = 1 order by slot desc LIMIT 1)
        ORDER BY tempering_feed_sequence
    </select>
    <select id="queryNeedDispatchSlotBySequence" resultType="com.mes.bigstorage.entity.dto.BigStorageSlotDTO">
        with glass_temp as (
        select t.* ,t1.virtual_slot,t1.slot_sequence from big_storage_cage_details t inner join
            select t.*, t1.virtual_slot, t1.slot_sequence
            from big_storage_cage_details t
                     inner join
        big_storage_glass_relation_info t1 on t.engineer_id = t1.engineer_id
        and t.tempering_layout_id = t1.tempering_layout_id
        and t.tempering_feed_sequence = t1.tempering_feed_sequence where t.state = 100
        ),slot_max_temp as (
                     and t.tempering_feed_sequence = t1.tempering_feed_sequence
            where t.state = 100
        )
           , slot_max_temp as (
        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence desc)
        as rn,t.* from glass_temp t where t.device_id in (5,6)
        ) ,slot_max_message as (select * from slot_max_temp where rn =1)
        as rn,t.*
            from glass_temp t
            where t.device_id in (5, 6)
        )
           , slot_max_message as (select * from slot_max_temp where rn = 1)
        ,slot_min_temp as (
        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence) as
        rn,t.* from glass_temp t where t.device_id in (5,6)
        ) ,slot_min_message as (select * from slot_min_temp where rn =1)
        rn,t.*
            from glass_temp t
            where t.device_id in (5, 6)
        )
           , slot_min_message as (select * from slot_min_temp where rn = 1)
        ,result as (
        select t.slot as target_slot ,t1.slot as start_slot from slot_max_message t inner join slot_min_message t1 on
        t.engineer_id = t1.engineer_id and t.tempering_layout_id = t1.tempering_layout_id and t.virtual_slot =
            select t.slot as target_slot, t1.slot as start_slot
            from slot_max_message t
                     inner join slot_min_message t1 on
                    t.engineer_id = t1.engineer_id and t.tempering_layout_id = t1.tempering_layout_id and
                    t.virtual_slot =
        t1.virtual_slot and t.tempering_layout_id = t1.tempering_layout_id and t.tempering_feed_sequence =
        t1.tempering_feed_sequence -1
        )select * from result limit 1
        )
        select *
        from result limit 1
    </select>
    <select id="queryTemperingGlassCountSummary" resultMap="temperingGlassCount">
        with glass_info_temp as (
@@ -382,4 +402,30 @@
        from secondary_summary
        order by engineer_id, films_id, thickness
    </select>
    <select id="queryVerticalSheetCageDetailsList"
            resultType="com.mes.bigstorage.entity.vo.BigCageDetailsVO">
        SELECT t.id,t.device_id,t.slot,t.remain_width ,t.enable_state,t1.engineer_id,
        t1.id as detail_id,t1.device_id as detail_device_id ,t1.slot as
        detail_slot,t1.engineer_id,t1.glass_id,t1.tempering_layout_id,t1.tempering_feed_sequence,
        t1.flow_card_id,t1.layer,t1.width,t1.height,t1.thickness,t1.films_id
        FROM big_storage_cage t
        left join big_storage_cage_details t1 on t.slot = t1.slot
        and t1.state in (100, 102, 103, 104)
        <if test="filmsId != null and filmsId != ''">
            and t1.films_id like CONCAT('%', #{filmsId}, '%')
        </if>
        <if test="flowCardId != null and flowCardId != ''">
            and t1.flow_card_id like CONCAT('%', #{flowCardId}, '%')
        </if>
        <if test="engineerId != null and engineerId != ''">
            and t1.engineer_id like CONCAT('%', #{engineerId}, '%')
        </if>
        <if test="glassId != null and glassId != ''">
            and t1.glass_id like CONCAT('%', #{glassId}, '%')
        </if>
        <if test="thickness != -1">
            and t1.thickness = #{thickness}
        </if>
        order by t.slot
    </select>
</mapper>