<?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.casic.dao.AlarmMapper"> <select id="getAlarmRecord" resultType="Map"> SELECT ar.id,ar.devcode AS devcode,DATE_FORMAT(ALARM_TIME,'%Y-%m-%d %H:%i:%s') AS "alarmTime",ALARM_VALUE AS dataValue FROM alarm_records ar JOIN (SELECT * FROM bus_device WHERE DEVICE_TYPE=#{deviceType} ) bd ON ar.devcode=bd.devcode WHERE status='1' <if test="devcode != null and devcode !='' "> and bd.devcode = #{devcode} </if> ORDER BY ALARM_TIME LIMIT #{currentIndex},#{pageSize} </select> <select id="getAlarmTotalRecord" resultType="Integer"> SELECT count(*) FROM alarm_records ar JOIN ( SELECT * FROM bus_device WHERE DEVICE_TYPE=#{deviceType}) bd ON ar.devcode=bd.devcode WHERE status='1' <if test="devcode != null and devcode !='' "> and bd.devcode = #{devcode} </if> </select> <update id="excuteAlramBatchCancel"> update alarm_records set status='2' WHERE devcode in ( SELECT devcode FROM bus_device WHERE DEVICE_TYPE=#{deviceType} <if test="devcode != null and devcode !='' "> and devcode = #{devcode} </if> ) </update> <update id="excuteJobBatchCancel"> update alarm_job set JOB_STATUS='4' WHERE devcode in( SELECT devcode FROM bus_device WHERE DEVICE_TYPE=#{deviceType} <if test="devcode != null and devcode !='' "> and devcode = #{devcode} </if> ) </update> <select id="getDeviceByDevcode" resultType="String"> SELECT ID FROM bus_device bd WHERE bd.device_type=#{deviceType} <if test="devcode != null and devcode !='' "> and devcode = #{devcode} </if> </select> <select id="getDeviceDevcode" resultType="String"> SELECT devcode FROM bus_device bd WHERE bd.device_type=#{deviceType} limit 1 </select> </mapper>