DeviceInfoMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.gbd.demp.info.mapper.DeviceInfoMapper">
  4. <resultMap id="deviceInfo" type="com.gbd.demp.info.entity.DeviceInfo">
  5. <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
  6. <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
  7. <result column="device_start_date" jdbcType="DATE" property="deviceStartDate"/>
  8. <result column="industry_code" jdbcType="VARCHAR" property="industryCode"/>
  9. <result column="industry_value" jdbcType="VARCHAR" property="industryValue"/>
  10. <result column="dust_type" jdbcType="VARCHAR" property="dustType"/>
  11. <result column="dust_name" jdbcType="VARCHAR" property="dustName"/>
  12. <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
  13. <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
  14. <result column="device_location" jdbcType="VARCHAR" property="deviceLocation"/>
  15. <result column="possession" jdbcType="VARCHAR" property="possession"/>
  16. <result column="work_time_from" jdbcType="VARCHAR" property="workTimeFrom"/>
  17. <result column="work_time_to" jdbcType="VARCHAR" property="workTimeTo"/>
  18. <result column="longitude" jdbcType="DOUBLE" property="longitude"/>
  19. <result column="latitude" jdbcType="DOUBLE" property="latitude"/>
  20. <result column="editable" jdbcType="INTEGER" property="editable"/>
  21. </resultMap>
  22. <resultMap id="sensorInfo" type="com.gbd.demp.info.entity.SensorInfo">
  23. <result column="id" jdbcType="BIGINT" property="id"/>
  24. <result column="sensor_id" jdbcType="VARCHAR" property="sensorId"/>
  25. <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
  26. <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
  27. <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
  28. <result column="sensor_name" jdbcType="VARCHAR" property="sensorName"/>
  29. <result column="sensor_unit" jdbcType="VARCHAR" property="sensorUnit"/>
  30. </resultMap>
  31. <resultMap id="videoInfo" type="com.gbd.demp.info.entity.VideoInfo">
  32. <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
  33. <result column="company_name" jdbcType="VARCHAR" property="companyName"/>
  34. <result column="detail_name" jdbcType="VARCHAR" property="detailName"/>
  35. <result column="id" jdbcType="VARCHAR" property="id"/>
  36. <result column="place_info" jdbcType="VARCHAR" property="placeInfo"/>
  37. <result column="puid" jdbcType="VARCHAR" property="puid"/>
  38. <result column="show_name" jdbcType="VARCHAR" property="showName"/>
  39. <result column="status" jdbcType="VARCHAR" property="status"/>
  40. <result column="type" jdbcType="VARCHAR" property="type"/>
  41. </resultMap>
  42. <sql id="findDeviceInfoSql">
  43. SELECT
  44. device_id,
  45. device_name,
  46. device_start_date,
  47. t.industry_code,
  48. t1.value industry_value,
  49. t.dust_type,
  50. t2.dust_name,
  51. company_id,
  52. company_name,
  53. device_location,
  54. possession,
  55. work_time_from,
  56. work_time_to,
  57. longitude,
  58. latitude,
  59. editable
  60. FROM
  61. t_device_info t
  62. left join t_code_industry t1 on t.industry_code=t1.code
  63. left join t_code_dust_type t2 on t.dust_type=t2.code
  64. where 1=1
  65. <if test="deviceInfo.deviceId != null and deviceInfo.deviceId != ''">
  66. AND t.device_id = #{deviceInfo.deviceId}
  67. </if>
  68. <if test="deviceInfo.possession != null and deviceInfo.possession != ''">
  69. AND t.possession = #{deviceInfo.possession}
  70. </if>
  71. <if test="deviceInfo.deviceName != null and deviceInfo.deviceName != ''">
  72. AND t.device_name like CONCAT('%', #{deviceInfo.deviceName}, '%')
  73. </if>
  74. <if test="deviceInfo.startTimeFrom != null and deviceInfo.startTimeFrom !=''">
  75. And t.device_start_date &gt; #{deviceInfo.startTimeFrom}
  76. </if>
  77. <if test="deviceInfo.startTimeTo!= null and deviceInfo.startTimeTo !=''">
  78. And t.device_start_date &lt; #{deviceInfo.startTimeTo}
  79. </if>
  80. <if test="deviceInfo.companyId != null and deviceInfo.companyId != ''">
  81. AND t.company_id = #{deviceInfo.companyId}
  82. </if>
  83. <if test="deviceInfo.companyName != null and deviceInfo.companyName != ''">
  84. AND t.company_name like CONCAT('%', #{deviceInfo.companyName}, '%')
  85. </if>
  86. <if test="deviceInfo.editable != null and deviceInfo.editable != 0">
  87. AND t.editable = #{deviceInfo.editable}
  88. </if>
  89. group by
  90. t.device_id,
  91. t.device_name,
  92. t.industry_code,
  93. t.dust_type,
  94. t.company_id,
  95. t.company_name,
  96. t.device_location,
  97. t.possession
  98. </sql>
  99. <sql id="findClickInfoSql">
  100. /*select
  101. tdi.device_id AS deviceId,
  102. tdi.company_name AS companyName,
  103. tdi.device_name AS monitorName,
  104. '0' AS ifShow,
  105. '' AS videoId,
  106. tsv.sensor_id AS sensorId,
  107. tsi.sensor_name AS name,
  108. tsi.sensor_unit AS unit,
  109. tcar.value AS detail,
  110. tld.data_value AS value,
  111. tcar.color AS color,
  112. tvi.detail_name AS videoName,
  113. tvi.puid AS videoCode
  114. from t_sensor_video tsv
  115. left join t_video_info tvi on tvi.id = tsv.video_id
  116. left join t_sensor_info tsi on tsi.sensor_id = tsv.sensor_id and tsi.device_id=tsv.device_id
  117. left join t_device_info tdi on tdi.device_id = tsv.device_id
  118. left join t_live_data tld on tld.sensor_id = tsv.sensor_id and tld.device_id=tsv.device_id
  119. left join t_code_alarm_rules tcar on tcar.code = tld.status
  120. left join t_alarm_event tae on tae.device_id=tsv.device_id and tae.sensor_id=tsv.sensor_id
  121. where 1=1*/
  122. select
  123. tdi.device_id AS deviceId,
  124. tdi.company_name AS companyName,
  125. tdi.device_name AS monitorName,
  126. '0' AS ifShow,
  127. '' AS videoId,
  128. tld.sensor_id AS sensorId,
  129. tsi.sensor_name AS name,
  130. tsi.sensor_unit AS unit,
  131. tcar.value AS detail,
  132. tld.data_value AS value,
  133. tcar.color AS color,
  134. tvi.detail_name AS videoName,
  135. tvi.puid AS videoCode
  136. from t_live_data tld
  137. left join t_sensor_video tsv on tld.sensor_id = tsv.sensor_id and tld.device_id=tsv.device_id
  138. left join t_video_info tvi on tsv.video_id = tvi.id
  139. left join t_sensor_info tsi on tld.sensor_id = tsi.sensor_id and tld.device_id=tsi.device_id
  140. left join t_device_info tdi on tld.device_id = tdi.device_id
  141. left join t_code_alarm_rules tcar on tcar.code = tld.status
  142. left join t_alarm_event tae on tld.device_id=tae.device_id and tld.sensor_id=tae.sensor_id
  143. where 1=1
  144. <!--toto -->
  145. <if test="companyId != null and companyId != ''">
  146. AND tdi.company_id = #{companyId}
  147. </if>
  148. <if test="deviceId != null and deviceId != ''">
  149. AND tdi.device_id = #{deviceId}
  150. </if>
  151. <if test="alarmId != null and alarmId != ''">
  152. AND tae.third_party_id = #{alarmId}
  153. </if>
  154. group by
  155. tdi.device_id
  156. </sql>
  157. <select id="findAllDeviceInfoPage" resultMap="deviceInfo">
  158. <include refid="findDeviceInfoSql"/>
  159. </select>
  160. <update id="setWorkTime">
  161. update t_device_info
  162. set work_time_from=#{from},
  163. work_time_to=#{to}
  164. where device_id = #{id}
  165. </update>
  166. <!-- 2. 监测企业点位信息 -->
  167. <select id="findAll" resultMap="deviceInfo">
  168. select *
  169. from t_device_info
  170. </select>
  171. <!-- 3. 监测图层点击详情 -->
  172. <select id="getMonitorLayerClickMap" resultType="com.gbd.demp.info.vo.DeviceEventVO">
  173. <include refid="findClickInfoSql"/>
  174. </select>
  175. <update id="unlockEdit">
  176. update t_device_info
  177. set editable=1
  178. where device_id = #{id}
  179. </update>
  180. <select id="getCompanys" resultType="java.util.HashMap">
  181. SELECT company_id value,company_name label FROM t_device_info
  182. where 1=1
  183. <if test="possession != null and possession != ''">
  184. AND possession = #{possession}
  185. </if>
  186. group by company_id,company_name
  187. </select>
  188. </mapper>