DiagnoseThresholdChMapper.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.xunmei.iot.mapper.DiagnoseThresholdChMapper">
  4. <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo">
  5. select c.* from
  6. (
  7. select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
  8. (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
  9. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
  10. from iot_device_info s
  11. inner join iot_device_info dvs on dvs.iot_token = s.iot_token
  12. and dvs.device_product = s.device_product and dvs.device_code = s.host_code
  13. and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
  14. where s.deleted=0 and s.enable=0 and s.device_type = 2
  15. <if test="request.orgId!= null">
  16. and s.org_id=#{request.orgId}
  17. </if>
  18. <if test="request.orgPath!= null">
  19. and s.org_path like CONCAT(#{request.orgPath}, '%')
  20. </if>
  21. <if test="request.deviceName != null and request.deviceName!= ''">
  22. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  23. </if>
  24. order by s.host_code ,cast(s.device_code as signed)
  25. ) c where 1=1
  26. <choose>
  27. <when test=" request.state == null">
  28. </when>
  29. <when test=" request.state == 0">
  30. and c.threshold_codes is null
  31. </when>
  32. <otherwise>
  33. and c.threshold_codes is not null
  34. </otherwise>
  35. </choose>
  36. <choose>
  37. <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
  38. and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
  39. </when>
  40. <otherwise>
  41. </otherwise>
  42. </choose>
  43. </select>
  44. <select id="selectAllDiagnoseThreshold" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold">
  45. select * from iot_device_diagnose_threshold
  46. </select>
  47. <select id="selectBindCount" resultType="java.lang.Integer">
  48. select count(1) from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
  49. </select>
  50. </mapper>