| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?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.gbd.demp.info.mapper.SensorInfoMapper">
- <resultMap id="sensorInfo" type="com.gbd.demp.info.entity.SensorInfo">
- <result column="id" jdbcType="BIGINT" property="id"/>
- <result column="sensor_id" jdbcType="VARCHAR" property="sensorId"/>
- <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
- <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
- <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
- <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
- <result column="sensor_name" jdbcType="VARCHAR" property="sensorName"/>
- <result column="sensor_unit" jdbcType="VARCHAR" property="sensorUnit"/>
- <result column="editable" jdbcType="INTEGER" property="editable"/>
- </resultMap>
- <sql id="findSensorInfoSql">
- SELECT
- t.id,
- t.sensor_id,
- t.device_id,
- t1.device_name,
- t1.company_id,
- t1.company_name,
- sensor_name,
- sensor_unit,
- t2.editable
- FROM
- t_sensor_info t
- LEFT JOIN
- t_device_info t1 ON t.device_id = t1.device_id
- LEFT JOIN
- (SELECT
- device_id, sensor_id, editable
- FROM
- demp.t_device_threshold
- WHERE
- code = 0) t2 ON t.device_id = t2.device_id
- AND t.sensor_id = t2.sensor_id
- where 1=1
- <if test="sensorInfo.deviceName != null and sensorInfo.deviceName != ''">
- AND t1.device_name like CONCAT('%', #{sensorInfo.deviceName}, '%')
- </if>
- <if test="sensorInfo.companyName != null and sensorInfo.companyName != ''">
- AND t1.company_name like CONCAT('%', #{sensorInfo.companyName}, '%')
- </if>
- <if test="sensorInfo.deviceId != null and sensorInfo.deviceId != ''">
- AND t1.device_id =#{sensorInfo.deviceId}
- </if>
- <if test="sensorInfo.deviceId != null and sensorInfo.deviceId != ''">
- AND t1.device_id =#{sensorInfo.deviceId}
- </if>
- <if test="possession != null and possession != ''">
- AND t1.possession = #{possession}
- </if>
- group by
- t.id,
- t.sensor_id,
- t.device_id,
- t.sensor_name,
- t.sensor_unit,
- t2.editable
- </sql>
- <select id="findAllSensorInfoPage" resultMap="sensorInfo">
- <include refid="findSensorInfoSql"/>
- </select>
- <delete id="deleteByDeviceId">
- delete
- from t_sensor_info
- where device_id = #{id}
- </delete>
- </mapper>
|