Newer
Older
huludao / src / main / resources / mapper / DeviceAlarmMapper.xml
<?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.newfiber.api.pc.dao.DeviceAlarmMapper">
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.entity.DeviceAlarm">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="alarm_type" jdbcType="TINYINT" property="alarmType" />
    <result column="alarm_name" jdbcType="VARCHAR" property="alarmName" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="alarm_desc" jdbcType="VARCHAR" property="alarmDesc" />
    <result column="record_time" jdbcType="TIMESTAMP" property="recordTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="site_no" jdbcType="VARCHAR" property="siteNo" />
    <result column="device_type" jdbcType="TINYINT" property="deviceType" />
    <result column="lon" jdbcType="VARCHAR" property="lon" />
    <result column="lat" jdbcType="VARCHAR" property="lat" />
  </resultMap>
  <sql id="Base_Column_List">
    id, alarm_type, alarm_name,name, address, alarm_desc, record_time, create_time,status,site_no,device_type,lon,lat
  </sql>

  <select id="selectAlarmCount"  resultType="com.newfiber.api.pc.model.entity.DeviceAlarmCountDto">
   SELECT alarm_type as alarmType,alarm_name as alarmName,count(0) as count FROM `device_alarm`
    where create_time >= #{startTime}
    and create_time &lt; #{endTime} and status = 1
    group by alarm_type
  </select>

    <update id="updateAlarm"  >
    update `device_alarm` set status = 2 where alarm_type = #{alarmType} and site_no = #{siteNo}
    <if test="deviceType != null">
        and device_type = #{deviceType}
    </if>
  </update>

  <update id="updateDeviceById"  >
    update `device_alarm` set status = 2 where id = #{id}
  </update>
</mapper>