wu
2024-12-23 164cb74e2c471321caf9c4870de846cf08ca5f6c
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageFeedTaskMapper.xml
@@ -15,17 +15,31 @@
                        SUM(case task_state when 2 then 1 else 0 end) as real_count
                 from big_storage_cage_feed_task
                 where task_state in (1, 2)
                   and target_slot is null
                   and deleted = 0
                   and (target_slot = 0 or target_slot is null)
                 group by line
                 HAVING  DATEDIFF(SECOND, max(create_time), GETDATE()) + 45 > 40 or SUM(case task_state when 2 then 1 else 0 end)>1
             ) t
        where t.total_count = t.real_count
        order by real_count desc,line desc
    </select>
    <select id="querySitToUpRemainWidth" resultMap="bigStorageDTO">
        SELECT cast(5000 - sum(width + 20) as INT) as REMAIN_WIDTH,
               count(glass_id)                     as GLASS_COUNT
        FROM big_storage_cage_feed_task
        WHERE line = #{line}
          AND task_state in (1, 2)
        SELECT CAST
                   (5000 - SUM(MAX_LENGTH + #{glassGap}) AS INT) AS REMAIN_WIDTH,
               COUNT(GLASS_ID)                                   AS GLASS_COUNT
        FROM (
                 SELECT GLASS_ID,
                        CASE
                            WHEN WIDTH >= HEIGHT THEN
                                WIDTH
                            ELSE HEIGHT
                            END MAX_LENGTH
                 FROM BIG_STORAGE_CAGE_FEED_TASK
                 WHERE LINE = #{line}
                   AND TASK_STATE IN (1, 2)
                   and deleted = 0
             ) T
    </select>
</mapper>