SensorInfoMapper.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gbd.demp.info.mapper.SensorInfoMapper">
  4. <resultMap id="sensorInfo" type="com.gbd.demp.info.entity.SensorInfo">
  5. <result column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="sensor_id" jdbcType="VARCHAR" property="sensorId"/>
  7. <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
  8. <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
  9. <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
  10. <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
  11. <result column="sensor_name" jdbcType="VARCHAR" property="sensorName"/>
  12. <result column="sensor_unit" jdbcType="VARCHAR" property="sensorUnit"/>
  13. <result column="editable" jdbcType="INTEGER" property="editable"/>
  14. </resultMap>
  15. <sql id="findSensorInfoSql">
  16. SELECT
  17. t.id,
  18. t.sensor_id,
  19. t.device_id,
  20. t1.device_name,
  21. t1.company_id,
  22. t1.company_name,
  23. sensor_name,
  24. sensor_unit,
  25. t2.editable
  26. FROM
  27. t_sensor_info t
  28. LEFT JOIN
  29. t_device_info t1 ON t.device_id = t1.device_id
  30. LEFT JOIN
  31. (SELECT
  32. device_id, sensor_id, editable
  33. FROM
  34. demp.t_device_threshold
  35. WHERE
  36. code = 0) t2 ON t.device_id = t2.device_id
  37. AND t.sensor_id = t2.sensor_id
  38. where 1=1
  39. <if test="sensorInfo.deviceName != null and sensorInfo.deviceName != ''">
  40. AND t1.device_name like CONCAT('%', #{sensorInfo.deviceName}, '%')
  41. </if>
  42. <if test="sensorInfo.companyName != null and sensorInfo.companyName != ''">
  43. AND t1.company_name like CONCAT('%', #{sensorInfo.companyName}, '%')
  44. </if>
  45. <if test="sensorInfo.deviceId != null and sensorInfo.deviceId != ''">
  46. AND t1.device_id =#{sensorInfo.deviceId}
  47. </if>
  48. <if test="sensorInfo.deviceId != null and sensorInfo.deviceId != ''">
  49. AND t1.device_id =#{sensorInfo.deviceId}
  50. </if>
  51. <if test="possession != null and possession != ''">
  52. AND t1.possession = #{possession}
  53. </if>
  54. group by
  55. t.id,
  56. t.sensor_id,
  57. t.device_id,
  58. t.sensor_name,
  59. t.sensor_unit,
  60. t2.editable
  61. </sql>
  62. <select id="findAllSensorInfoPage" resultMap="sensorInfo">
  63. <include refid="findSensorInfoSql"/>
  64. </select>
  65. <delete id="deleteByDeviceId">
  66. delete
  67. from t_sensor_info
  68. where device_id = #{id}
  69. </delete>
  70. </mapper>