DeviceAttributeMapper.xml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.bizmatics.persistence.mapper.DeviceAttributeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.bizmatics.model.DeviceAttribute">
  6. <id column="id" property="id" />
  7. <result column="monitor_device_name" property="monitorDeviceName" />
  8. <result column="loop_meter_address" property="loopMeterAddress" />
  9. <result column="rated_voltage" property="ratedVoltage" />
  10. <result column="rated_current" property="ratedCurrent" />
  11. <result column="current_load_rate" property="currentLoadRate" />
  12. <result column="monitor_device_code" property="monitorDeviceCode" />
  13. <result column="variable_list_id" property="variableListId" />
  14. <result column="creator" property="creator" />
  15. <result column="create_time" property="createTime" />
  16. <result column="quality_analysis" property="qualityAnalysis" />
  17. <result column="status" property="status" />
  18. </resultMap>
  19. <select id="monitorDeviceList" resultType="com.bizmatics.model.vo.MonitorDeviceListVO">
  20. SELECT
  21. a.id,
  22. a.site_name,
  23. a.site_address,
  24. a.user_name,
  25. a.phone,
  26. IF (
  27. b.device_count &lt;&gt; '',
  28. b.device_count,
  29. 0
  30. ) AS device_count
  31. FROM
  32. site AS a
  33. LEFT JOIN (
  34. SELECT
  35. site_id,
  36. COUNT(*) AS device_count
  37. FROM
  38. device_attribute
  39. <where>
  40. status=1
  41. </where>
  42. GROUP BY
  43. site_id
  44. ) AS b ON a.id = b.site_id
  45. <where>
  46. a.enable =1
  47. <if test="siteName != null and siteName !=''">
  48. and a.site_name LIKE CONCAT(CONCAT('%', #{siteName}), '%')
  49. </if>
  50. </where>
  51. <if test="startCurrent != null and size !=0">
  52. LIMIT #{startCurrent},
  53. #{size}
  54. </if>
  55. </select>
  56. </mapper>