wuyouming666
2024-07-17 4829439b3c4d52ecee6e9858068552b2f9d8ac79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper">
 
    <resultMap id="bigStorageDTO" type="com.mes.bigstorage.entity.BigStorageDTO">
        <result column="REMAIN_WIDTH" property="width"/>
        <result column="GLASS_COUNT" property="glassCount"/>
    </resultMap>
 
    <select id="querySitToUpGlass" resultType="java.lang.Integer">
        select t.line
        from (
                 select line,
                        COUNT(glass_id)                               as total_count,
                        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 = 0 or target_slot is null)
                 group by line
             ) t
        where t.total_count = t.real_count
    </select>
    <select id="querySitToUpRemainWidth" resultMap="bigStorageDTO">
        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)
             ) T
    </select>
 
</mapper>