IotDeviceMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.middle.platform.manage.biz.mapper.IotDeviceMapper">
  4. <resultMap id="BaseResultMap" type="com.middle.platform.manage.biz.entity.IotDevice">
  5. <!--@mbg.generated-->
  6. <!--@Table iot_device-->
  7. <id column="id" jdbcType="BIGINT" property="id"/>
  8. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  9. <result column="name" jdbcType="VARCHAR" property="name"/>
  10. <result column="sn" jdbcType="VARCHAR" property="sn"/>
  11. <result column="guid" jdbcType="VARCHAR" property="guid"/>
  12. <result column="subtitle" jdbcType="VARCHAR" property="subtitle"/>
  13. <result column="lon" jdbcType="DECIMAL" property="lon"/>
  14. <result column="lat" jdbcType="DECIMAL" property="lat"/>
  15. <result column="address" jdbcType="VARCHAR" property="address"/>
  16. <result column="online_time" jdbcType="TIMESTAMP" property="onlineTime"/>
  17. <result column="status" jdbcType="TINYINT" property="status"/>
  18. <result column="enable_flag" jdbcType="TINYINT" property="enableFlag"/>
  19. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  20. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  21. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  22. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  23. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  24. <result column="delete_time" jdbcType="TIMESTAMP" property="deleteTime"/>
  25. <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
  26. </resultMap>
  27. <sql id="Base_Column_List">
  28. <!--@mbg.generated-->
  29. id,
  30. product_id,
  31. `name`,
  32. sn,
  33. guid,
  34. subtitle,
  35. lon,
  36. lat,
  37. address,
  38. online_time,
  39. `status`,
  40. enable_flag,
  41. remark,
  42. create_by,
  43. create_time,
  44. update_by,
  45. update_time,
  46. delete_time,
  47. del_flag
  48. </sql>
  49. <select id="queryByProduct" resultType="java.lang.Long">
  50. select count(1)
  51. from iot_device id
  52. <where>
  53. id.product_id = #{id,jdbcType=BIGINT}
  54. </where>
  55. </select>
  56. <!-- <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">-->
  57. <!-- select *-->
  58. <!-- from iot_device id-->
  59. <!-- <where>-->
  60. <!-- <if test="keywords != null and keywords != ''">-->
  61. <!-- and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')-->
  62. <!-- </if>-->
  63. <!-- </where>-->
  64. <!-- </select>-->
  65. <select id="queryTotalNumberOfDevices" resultType="int">
  66. select count(id) as num
  67. from iot_device
  68. <where>
  69. del_flag = 0
  70. and enable_flag = 1
  71. </where>
  72. </select>
  73. <select id="queryOnlineEquipment" resultType="int">
  74. select count(id) as num
  75. from iot_device
  76. <where>
  77. del_flag = 0
  78. and status = 1
  79. and enable_flag = 1
  80. </where>
  81. </select>
  82. <select id="queryTypeStatistics" resultType="com.middle.platform.manage.biz.domain.vo.TypeStatisticsVo">
  83. select ide.*,
  84. ipr.title projectTitle
  85. from iot_device ide
  86. left join iot_project_device ipd on ipd.device_id = ide.id
  87. left join iot_project ipr on ipr.id = ipd.project_id
  88. <where>
  89. ide.del_flag = 0
  90. and ide.enable_flag = 1
  91. <if test="deviceId != null">
  92. and ide.id = #{deviceId,jdbcType=BIGINT}
  93. </if>
  94. <if test="productId != null">
  95. and ipd.product_id = #{productId,jdbcType=BIGINT}
  96. </if>
  97. </where>
  98. </select>
  99. <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">
  100. select id.*, ip.name as productName
  101. from iot_device id
  102. inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
  103. <where>
  104. <if test="keywords != null and keywords != ''">
  105. and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
  106. </if>
  107. <if test="productId != null">
  108. and id.product_id = #{productId,jdbcType=BIGINT}
  109. </if>
  110. and id.del_flag = 0
  111. </where>
  112. </select>
  113. <select id="count" resultType="java.util.Map">
  114. select count(case when id.status = 1 then 1 end) online,
  115. count(case when id.status = 0 then 1 end) offline
  116. from iot_device id
  117. <where>
  118. <if test="productId != null">
  119. and id.product_id = #{productId,jdbcType=BIGINT}
  120. </if>
  121. and id.del_flag = 0
  122. </where>
  123. </select>
  124. <select id="detail" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceDetailVo">
  125. select id.id,
  126. id.name,
  127. id.sn,
  128. id.guid,
  129. id.subtitle,
  130. id.lat,
  131. id.lon,
  132. id.address,
  133. id.online_time,
  134. id.status,
  135. id.enable_flag,
  136. id.remark,
  137. id.create_time,
  138. id.create_by,
  139. id.update_time,
  140. id.update_by,
  141. ip.code productCode,
  142. ip.name productName,
  143. ip.secret,
  144. ip.node_type nodeType,
  145. ip.network_type networkType,
  146. ip.report_protocol reportProtocol,
  147. ip.data_format dataFormat,
  148. ip.auth_type authType,
  149. ip.vendors,
  150. ip.tag
  151. from iot_device id
  152. inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
  153. where id.id = #{id,jdbcType=BIGINT}
  154. and id.del_flag = 0
  155. </select>
  156. <select id="query" resultType="com.middle.platform.manage.biz.domain.vo.ProductDeviceDto">
  157. select id.id,
  158. id.sn,
  159. ip.code
  160. from iot_device id
  161. inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
  162. <where>
  163. <if test="id != null">
  164. and id.id = #{id,jdbcType=BIGINT}
  165. </if>
  166. and id.del_flag = 0
  167. </where>
  168. </select>
  169. <select id="deviceCache" resultType="com.middle.platform.manage.api.pojo.DeviceVo">
  170. select id.id,
  171. ip.id productId,
  172. id.sn,
  173. ip.code
  174. from iot_device id
  175. inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
  176. <where>
  177. <if test="guid != null and guid != ''">
  178. and id.guid = #{guid,jdbcType=VARCHAR}
  179. </if>
  180. and id.enable_flag = 1
  181. and id.del_flag = 0
  182. </where>
  183. </select>
  184. </mapper>