IotDeviceInfoMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.IotDeviceInfoMapper">
  4. <select id="selectDeviceInfoPage" resultType="com.xunmei.iot.vo.deviceInfo.IotDeviceInfoPageVo">
  5. SELECT
  6. d.*,
  7. o.affiliated_area AS firstOrgName,
  8. o.affiliated_bank AS secondOrgName,
  9. o.short_name AS orgName
  10. FROM
  11. iot_device_info d
  12. LEFT JOIN sys_org o ON o.id = d.org_id
  13. where d.deleted = 0
  14. <if test="req.deviceName !=null and req.deviceName !=''">
  15. and d.device_name like concat('%',#{req.deviceName},'%')
  16. </if>
  17. <if test="req.deviceType !=null and req.deviceType !=''">
  18. and d.device_type = #{req.deviceType}
  19. </if>
  20. <if test="req.deviceTypeList != null and req.deviceTypeList.size > 0">
  21. and d.device_type in
  22. <foreach collection="req.deviceTypeList" item="deviceType" open="(" separator="," close=")">
  23. #{deviceType}
  24. </foreach>
  25. </if>
  26. <if test="req.netStatus !=null and req.netStatus !=''">
  27. and d.net_status = #{req.netStatus}
  28. </if>
  29. <choose>
  30. <when test="req.checkSub == false">
  31. and d.org_id=#{req.orgId}
  32. </when>
  33. <otherwise>
  34. and d.org_path like concat(#{req.orgPath},'%')
  35. </otherwise>
  36. </choose>
  37. order by d.device_type asc,d.id desc
  38. </select>
  39. <select id="getDetailById" resultType="com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo">
  40. SELECT
  41. d.*,
  42. (select device_name from iot_device_info i where i.device_code = d.host_code and i.iot_token = d.iot_token) as parentName,
  43. o.affiliated_area AS firstOrgName,
  44. o.affiliated_bank AS secondOrgName,
  45. o.short_name AS orgName,
  46. e.net_address AS deviceAddress,
  47. e.`port` AS devicePort
  48. FROM
  49. iot_device_info d
  50. LEFT JOIN sys_org o ON o.id = d.org_id
  51. LEFT JOIN iot_device_info_extend e ON d.id = e.device_id
  52. where d.deleted = 0 and d.id = #{id}
  53. </select>
  54. <select id="getChildrenInfoList" resultType="com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo">
  55. SELECT
  56. d.*,
  57. o.affiliated_area AS firstOrgName,
  58. o.affiliated_bank AS secondOrgName,
  59. o.short_name AS orgName
  60. FROM
  61. iot_device_info d
  62. LEFT JOIN sys_org o ON o.id = d.org_id
  63. where d.deleted = 0
  64. and d.iot_token = #{iotToken}
  65. and d.host_code = #{hostCode}
  66. <if test="deviceProduct !=null and deviceProduct !=''">
  67. and d.device_product = #{deviceProduct}
  68. </if>
  69. </select>
  70. <select id="getByProductTypes" resultType="com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo">
  71. SELECT
  72. d.id,
  73. d.device_type,
  74. d.device_product,
  75. d.device_code,
  76. d.device_name,
  77. ifnull( s.state, 0 ) AS state
  78. FROM
  79. iot_device_info d
  80. LEFT JOIN iot_device_status s ON d.id = s.device_id
  81. WHERE
  82. d.deleted = 0
  83. and d.org_path like concat(#{orgPath},'%')
  84. <if test="productTypes !=null and productTypes.size()>0">
  85. and d.device_product in
  86. <foreach collection="productTypes" item="item" open="(" separator="," close=")">
  87. #{item}
  88. </foreach>
  89. </if>
  90. </select>
  91. <select id="getByProductTypesAndOrgId" resultType="com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo">
  92. SELECT
  93. d.id,
  94. d.device_type,
  95. d.device_product,
  96. d.device_code,
  97. d.device_name,
  98. ifnull( s.state, 0 ) AS state
  99. FROM
  100. iot_device_info d
  101. LEFT JOIN iot_device_status s ON d.id = s.device_id
  102. WHERE
  103. d.deleted = 0
  104. and d.org_id = #{orgId}
  105. <if test="productTypes !=null and productTypes.size()>0">
  106. and d.device_product in
  107. <foreach collection="productTypes" item="item" open="(" separator="," close=")">
  108. #{item}
  109. </foreach>
  110. </if>
  111. </select>
  112. </mapper>