DeviceDataDimMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.zcxk.smartcity.data.access.dao.DeviceDataDimMapper">
  5. <sql id="where">
  6. <where>
  7. <if test="params.device_no != null and params.device_no != ''">
  8. and device_no = #{params.deviceNo}
  9. </if>
  10. <if test="params.site_id != null and params.site_id != ''">
  11. and site_id = #{params.siteId}
  12. </if>
  13. <if test="params.sys_id != null and params.sys_id != ''">
  14. and sys_id = #{params.sysId}
  15. </if>
  16. <if test="params.building_id != null and params.building_id != ''">
  17. and building_id = #{params.buildingId}
  18. </if>
  19. <if test="params.floor != null and params.floor != ''">
  20. and floor = #{params.floor}
  21. </if>
  22. <if test="params.location != null and params.location != ''">
  23. and location = #{params.location}
  24. </if>
  25. <if test="params.send_date != null and params.send_date != ''">
  26. and send_date = #{params.sendDate}
  27. </if>
  28. <if test="params.measuring_id != null and params.measuring_id != ''">
  29. and measuring_id = #{params.measuringId}
  30. </if>
  31. <if test="params.measuring_code != null and params.measuring_code != ''">
  32. and measuring_code = #{params.measuringCode}
  33. </if>
  34. <if test="params.measuring_data != null and params.measuring_data != ''">
  35. and measuring_data = #{params.measuringData}
  36. </if>
  37. <if test="params.send_time != null and params.send_time != ''">
  38. and send_time = #{params.sendTime}
  39. </if>
  40. <if test="params.create_by != null and params.create_by != ''">
  41. and create_by = #{params.createBy}
  42. </if>
  43. <if test="params.date_create != null and params.date_create != ''">
  44. and date_create = #{params.dateCreate}
  45. </if>
  46. </where>
  47. </sql>
  48. <select id="count" resultType="int">
  49. select count(1) from sc_device_data_dim t
  50. <include refid="where" />
  51. </select>
  52. <select id="list" resultType="DeviceDataDim">
  53. select * from sc_device_data_dim t
  54. <include refid="where" />
  55. ${params.orderBy}
  56. limit #{offset}, #{limit}
  57. </select>
  58. <update id="update">
  59. update sc_device_data_dim t
  60. <set>
  61. <if test="device_no != null">
  62. device_no = #{deviceNo},
  63. </if>
  64. <if test="site_id != null">
  65. site_id = #{siteId},
  66. </if>
  67. <if test="sys_id != null">
  68. sys_id = #{sysId},
  69. </if>
  70. <if test="building_id != null">
  71. building_id = #{buildingId},
  72. </if>
  73. <if test="floor != null">
  74. floor = #{floor},
  75. </if>
  76. <if test="location != null">
  77. location = #{location},
  78. </if>
  79. <if test="send_date != null">
  80. send_date = #{sendDate},
  81. </if>
  82. <if test="measuring_id != null">
  83. measuring_id = #{measuringId},
  84. </if>
  85. <if test="measuring_code != null">
  86. measuring_code = #{measuringCode},
  87. </if>
  88. <if test="measuring_data != null">
  89. measuring_data = #{measuringData},
  90. </if>
  91. <if test="send_time != null">
  92. send_time = #{sendTime},
  93. </if>
  94. <if test="create_by != null">
  95. create_by = #{createBy},
  96. </if>
  97. <if test="date_create != null">
  98. date_create = #{dateCreate},
  99. </if>
  100. </set>
  101. where t.id = #{id}
  102. </update>
  103. <sql id="Base_Column_List">
  104. device_id,
  105. device_no,
  106. site_id,
  107. sys_id,
  108. building_id,
  109. floor,
  110. location,
  111. send_date,
  112. measuring_id,
  113. measuring_code,
  114. measuring_data,
  115. measuring_unit,
  116. send_time,
  117. create_by,
  118. date_create
  119. </sql>
  120. <select id="getDeviceDataBetweenDate" resultType="com.zcxk.smartcity.data.access.entity.DeviceDataDim">
  121. select
  122. <include refid="Base_Column_List" />
  123. from
  124. sc_device_data_dim
  125. where device_id = #{deviceId,jdbcType=BIGINT}
  126. and send_time > #{beginTime,jdbcType=TIMESTAMP}
  127. and send_time <![CDATA[ < ]]> #{endTime,jdbcType=TIMESTAMP}
  128. </select>
  129. <select id="getDeviceDataByTime" resultType="java.util.HashMap">
  130. SELECT
  131. dd.measuring_code as measuringCode,
  132. md.measuring_name as measuringName,
  133. measuring_data as measuringData,
  134. dd.measuring_unit as measuringUnit,
  135. tmp.data_name as measuringDataDesc
  136. FROM
  137. sc_device_data_dim dd
  138. LEFT JOIN sc_tpl_measuring_desc md on (dd.measuring_id = md.measuring_id and md.device_type = #{deviceTypeId} )
  139. LEFT JOIN (
  140. SELECT
  141. device_type,
  142. measuring_id ,
  143. measuring_code,
  144. measuring_name,
  145. measuring_unit,
  146. data_value,
  147. data_name
  148. FROM
  149. sc_tpl_measuring_desc md
  150. LEFT JOIN sc_tpl_measuring_data_def mdd ON ( md.id = mdd.measuring_desc )
  151. WHERE
  152. md.device_type = #{deviceTypeId}
  153. ) tmp ON ( dd.measuring_id = tmp.measuring_id AND dd.measuring_data = tmp.data_value )
  154. WHERE
  155. device_id = #{deviceId,jdbcType=BIGINT}
  156. AND send_time = #{sendTime,jdbcType=TIMESTAMP}
  157. </select>
  158. </mapper>