TDeviceAlarmMapper.xml 7.27 KB
Newer Older
1 2 3 4 5 6 7 8
<?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.zehong.system.mapper.TDeviceAlarmMapper">
    
    <resultMap type="TDeviceAlarm" id="TDeviceAlarmResult">
        <result property="alarmId"    column="alarm_id"    />
9 10
        <result property="deviceId"    column="device_id"    />
        <result property="deviceType"    column="device_type"    />
11 12 13 14 15 16 17 18 19 20 21
        <result property="orderId"    column="order_id"    />
        <result property="alarmType"    column="alarm_type"    />
        <result property="alarmValue"    column="alarm_value"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="dealStatus"    column="deal_status"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTDeviceAlarmVo">
22
        select alarm_id, device_id, device_type, order_id, alarm_type, alarm_value, start_time, end_time, deal_status, update_time, create_time from t_device_alarm
23 24
    </sql>

王晓倩's avatar
王晓倩 committed
25
    <select id="selectTDeviceAlarmList" parameterType="DeviceAlarmForm" resultMap="TDeviceAlarmResult">
26
        <include refid="selectTDeviceAlarmVo"/>
王晓倩's avatar
王晓倩 committed
27 28 29
        <where>
            <if test="startTime1 != null "> and start_time &gt;= #{startTime1}</if>
            <if test="endTime1 != null "> and start_time &lt;= #{endTime1}</if>
30 31
            <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if>
            <if test="dealStatus != null  and dealStatus != ''"> and deal_status = #{dealStatus}</if>
32
            AND is_del = '0'
33
        </where>
耿迪迪's avatar
耿迪迪 committed
34
        ORDER BY create_time DESC 
35
    </select>
王晓倩's avatar
王晓倩 committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

    <select id="selectTDeviceAlarmByPipeCode" parameterType="DeviceAlarmForm" resultMap="TDeviceAlarmResult">
        select t.alarm_id, t.device_id, t.device_type, t.order_id, t.alarm_type, t.alarm_value, t.start_time, t.end_time, t.deal_status, t.update_time, t.create_time
        from t_device_alarm t
        left join t_pipe p on t.device_id = p.pipe_id
        <where>
            <if test="deviceCode != null "> and p.pipe_code like concat('%',#{deviceCode},'%')</if>
            <if test="startTime1 != null "> and t.start_time &gt;= #{startTime1}</if>
            <if test="endTime1 != null "> and t.start_time &lt;= #{endTime1}</if>
            <if test="alarmType != null  and alarmType != ''"> and t.alarm_type = #{alarmType}</if>
            <if test="dealStatus != null  and dealStatus != ''"> and t.deal_status = #{dealStatus}</if>
        </where>
        ORDER BY create_time DESC
    </select>

    <select id="selectTDeviceAlarmByDeviceCode" parameterType="DeviceAlarmForm" resultMap="TDeviceAlarmResult">
        select t.alarm_id, t.device_id, t.device_type, t.order_id, t.alarm_type, t.alarm_value, t.start_time, t.end_time, t.deal_status, t.update_time, t.create_time
        from t_device_alarm t
        left join t_device_info d on t.device_id = d.device_id
        <where>
            <if test="deviceCode != null "> and d.device_code like concat('%',#{deviceCode},'%')</if>
            <if test="startTime1 != null "> and t.start_time &gt;= #{startTime1}</if>
            <if test="endTime1 != null "> and t.start_time &lt;= #{endTime1}</if>
            <if test="alarmType != null  and alarmType != ''"> and t.alarm_type = #{alarmType}</if>
            <if test="dealStatus != null  and dealStatus != ''"> and t.deal_status = #{dealStatus}</if>
        </where>
        ORDER BY create_time DESC
    </select>

王晓倩's avatar
王晓倩 committed
65
    <select id="selectTDeviceAlarmById" parameterType="int" resultMap="TDeviceAlarmResult">
66 67 68 69 70 71 72
        <include refid="selectTDeviceAlarmVo"/>
        where alarm_id = #{alarmId}
    </select>
        
    <insert id="insertTDeviceAlarm" parameterType="TDeviceAlarm" useGeneratedKeys="true" keyProperty="alarmId">
        insert into t_device_alarm
        <trim prefix="(" suffix=")" suffixOverrides=",">
73 74
            <if test="deviceId != null">device_id,</if>
            <if test="deviceType != null">device_type,</if>
75 76 77 78 79 80 81 82 83 84
            <if test="orderId != null">order_id,</if>
            <if test="alarmType != null">alarm_type,</if>
            <if test="alarmValue != null">alarm_value,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="dealStatus != null">deal_status,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
85 86
            <if test="deviceId != null">#{deviceId},</if>
            <if test="deviceType != null">#{deviceType},</if>
87 88 89 90 91 92 93 94 95 96 97 98 99 100
            <if test="orderId != null">#{orderId},</if>
            <if test="alarmType != null">#{alarmType},</if>
            <if test="alarmValue != null">#{alarmValue},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="dealStatus != null">#{dealStatus},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTDeviceAlarm" parameterType="TDeviceAlarm">
        update t_device_alarm
        <trim prefix="SET" suffixOverrides=",">
101 102
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="deviceType != null">device_type = #{deviceType},</if>
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="alarmType != null">alarm_type = #{alarmType},</if>
            <if test="alarmValue != null">alarm_value = #{alarmValue},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="dealStatus != null">deal_status = #{dealStatus},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where alarm_id = #{alarmId}
    </update>

    <delete id="deleteTDeviceAlarmById" parameterType="Long">
        delete from t_device_alarm where alarm_id = #{alarmId}
    </delete>

    <delete id="deleteTDeviceAlarmByIds" parameterType="String">
        delete from t_device_alarm where alarm_id in 
        <foreach item="alarmId" collection="array" open="(" separator="," close=")">
            #{alarmId}
        </foreach>
    </delete>
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

    <select id="selectAlarmDevice" resultMap="TDeviceAlarmResult">
        SELECT
            alarm_id,
            device_id,
            device_type,
            order_id,
            alarm_type,
            alarm_value,
            start_time,
            end_time,
            deal_status,
            update_time,
            create_time
        FROM
            t_device_alarm
        WHERE
          end_time IS NULL

    </select>
jianqian's avatar
jianqian committed
145 146 147 148 149
    <select id="selectAddressByOrderId" resultType="java.lang.String">
        SELECT IFNULL(d.device_addr,"") AS address FROM t_device_alarm t
        LEFT JOIN t_device_info d ON t.device_id = d.device_id
        WHERE order_id = #{orderId}
    </select>
150
</mapper>