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
<?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 is null
                 group by line
             ) t
        where t.total_count = t.real_count
    </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>
 
</mapper>