ZengTao
3 天以前 21a76af55c4da5f1999e9dd24690b2449a7a18a7
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
<?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.edgstoragecage.mapper.EdgStorageCageMapper">
 
    <resultMap id="baseMap" type="com.mes.edgstoragecage.entity.EdgStorageCage">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="device_id" property="deviceId" jdbcType="INTEGER"/>
        <result column="slot" property="slot" jdbcType="INTEGER"/>
        <result column="enable_state" property="enableState" jdbcType="INTEGER"/>
        <result column="remain_width" property="remainWidth" jdbcType="INTEGER"/>
    </resultMap>
 
    <update id="resetSlotRemainWidth">
        <foreach collection="list" item="item" separator=";" open="begin" close=";end;">
            update edg_storage_cage set remain_width = #{item.remainWidth} where
            device_id = #{item.deviceId} and slot = #{item.slot}
        </foreach>
    </update>
 
    <select id="getEdgStorageCageBySize" resultMap="baseMap">
        select t.*
        from edg_storage_cage t
                 left join edg_storage_cage_details t1 on t.slot = t1.slot
        where t.device_id = #{deviceId}
          and t1.state = 100
          and t.remain_width >= GREATEST(#{width}, #{height})
          and t1.width = #{width}
          and t1.height = #{height}
          and t.enable_state = 1
        order by abs(t.slot - #{slot})
        limit 1
    </select>
</mapper>