zhoushihao
2024-12-02 3345225e1a1c5c9665a948ae612a677ae284431b
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
@@ -99,6 +99,7 @@
                (#{item.glassId}, #{item.targetSlot})
            </foreach>
            )
            and state !=101
        </where>
    </update>
@@ -134,7 +135,9 @@
             details_temp as (
                 select t.engineer_id, t.tempering_layout_id, t.virtual_slot, count(1) as slot_count
                 from big_storage_glass_relation_info t
                          left join big_storage_cage_details t1 on t.glass_id = t1.glass_id
                          left join big_storage_cage_details 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 t1.state = 100
                 group by t.engineer_id, t.tempering_layout_id, t.virtual_slot
             ),
@@ -153,15 +156,19 @@
    <select id="queryNeedDispatchSlot" resultMap="baseSlotSequenceDTO">
        with glass_id_temp as (
            select glass_id
            select engineer_id, tempering_layout_id, tempering_feed_sequence
            from big_storage_glass_relation_info
            where (engineer_id, tempering_layout_id, virtual_slot) =
                  (#{engineerId}, #{temperingLayoutId}, #{virtualSlot})
        )
        select t.slot, max(t1.slot_sequence) as max_sequence, min(t1.slot_sequence) as min_sequence
        select t.slot, max(t1.tempering_feed_sequence) as max_sequence, min(t1.tempering_feed_sequence) as min_sequence
        from big_storage_cage_details t
                 inner join big_storage_glass_relation_info t1 on t.glass_id = t1.glass_id
        where t.glass_id in (select * from glass_id_temp)
                 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.engineer_id, t.tempering_layout_id, t.tempering_feed_sequence) in
              (select engineer_id, tempering_layout_id, tempering_feed_sequence from glass_id_temp)
          and t.state = 100
        group by t.slot
        order by max_sequence
    </select>