BaseCameraManagementMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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.ozs.service.mapper.BaseCameraManagementMapper">
  4. <select id="selectCameraManagementList" resultType="com.ozs.service.entity.BaseCameraManagement" parameterType="com.ozs.service.entity.vo.BaseCameraManagementVo">
  5. SELECT
  6. a.id AS id,
  7. a.camera_code AS cameraCode,
  8. a.railway_code AS railwayCode,
  9. a.channel AS channel,
  10. a.dept_id AS deptId,
  11. a.line_dir AS lineDir,
  12. a.install_mile AS installMile,
  13. a.begin_mile AS beginMile,
  14. a.end_mile AS endMile,
  15. a.install_longitude AS installLongitude,
  16. a.install_latitude AS installLatitude,
  17. a.card_num AS cardNum,
  18. a.start_recording AS startRecording,
  19. a.task_id AS taskId,
  20. a.create_time AS createTime,
  21. a.remark AS remark,
  22. a.version_id AS versionId,
  23. a.version_num AS versionNum,
  24. a.version_name AS versionName,
  25. a.last_version_num AS lastVersionNum,
  26. a.measure_point_name AS measurePointName,
  27. a.camera_sn AS cameraSn,
  28. r.railway_type AS railwayType,
  29. man.is_disable AS isDisable
  30. FROM
  31. base_camera_management a join base_railway_management r
  32. on a.railway_code=r.railway_code
  33. LEFT JOIN base_device_dynamic_management AS man ON a.camera_code = man.camera_code
  34. <where>
  35. <if test="railwayCode != null and railwayCode != ''">
  36. and a.railway_code=#{railwayCode}
  37. </if>
  38. <if test="isDisable != null and isDisable != 0">
  39. and man.is_disable=#{isDisable}
  40. </if>
  41. <if test="cameraCode != null and cameraCode != ''">
  42. and a.camera_code like concat('%', #{cameraCode}, '%')
  43. </if>
  44. <if test="lineDir != null and lineDir != 0">
  45. and a.line_dir =#{lineDir}
  46. </if>
  47. <if test="deptId != null and deptId != 0">
  48. and a.dept_id =#{deptId}
  49. </if>
  50. <if test="beginMile != null and beginMile != 0">
  51. and a.install_mile &gt;=#{beginMile}
  52. </if>
  53. <if test="endMile != null and endMile != 0">
  54. and a.install_mile &lt;=#{endMile}
  55. </if>
  56. <if test="installMile != null and installMile != 0">
  57. and a.install_mile =#{installMile}
  58. </if>
  59. <if test="railwayType != null and railwayType != 0">
  60. and r.railway_type =#{railwayType}
  61. </if>
  62. <if test="ids != null and ids.size>0">
  63. and a.id in
  64. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  65. #{items}
  66. </foreach>
  67. </if>
  68. <if test="!dsFlay">
  69. and
  70. <trim prefix="(" prefixOverrides="or" suffix=")">
  71. <if test="dsUserId != null and dsUserId != ''">
  72. or a.create_by=#{dsUserId}
  73. </if>
  74. <if test="dsDeptId != null and dsDeptId != 0">
  75. or a.dept_id=#{dsDeptId}
  76. </if>
  77. <if test="dsDeptIds != null">
  78. or a.dept_id in
  79. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  80. #{item}
  81. </foreach>
  82. </if>
  83. </trim>
  84. </if>
  85. </where>
  86. ORDER BY
  87. CONVERT (r.railway_name USING gbk),a.install_mile
  88. </select>
  89. <select id="countCamera" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  90. select count(id) from base_camera_management
  91. <where>
  92. <if test="!dsFlay">
  93. and
  94. <trim prefix="(" prefixOverrides="or" suffix=")">
  95. <if test="dsUserId != null and dsUserId != ''">
  96. or create_by = #{dsUserId}
  97. </if>
  98. <if test="dsDeptId != null and dsDeptId != 0">
  99. or dept_id = #{dsDeptId}
  100. </if>
  101. <if test="dsDeptIds != null">
  102. or dept_id in
  103. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  104. #{item}
  105. </foreach>
  106. </if>
  107. </trim>
  108. </if>
  109. </where>
  110. </select>
  111. <select id="getCameraChannelByAlarmId" resultType="java.util.Map">
  112. select b.channel,
  113. b.camera_code as cameraCode,
  114. ma.is_lock as isLock,
  115. ma.released_time as releasedTime,
  116. ma.alarm_time as alarmTime
  117. from msg_alarm ma
  118. left join
  119. base_camera_management b on ma.camera_code = b.camera_code
  120. where ma.alarm_id = #{alarmId}
  121. </select>
  122. <select id="deviceStatePage" resultType="com.ozs.service.entity.vo.DeviceStateResp" parameterType="com.ozs.service.entity.vo.DeviceStateResp">
  123. SELECT
  124. ca.install_mile AS installMile,
  125. ca.measure_point_name AS measurePointName,
  126. ra.railway_name AS railwayName,
  127. ra.railway_type AS railwayType,
  128. de.dept_name AS deptName,
  129. CASE
  130. line_dir
  131. WHEN 1 THEN
  132. '上行'
  133. WHEN 2 THEN
  134. '下行'
  135. WHEN 3 THEN
  136. '上下行'
  137. END AS lineDir,
  138. CASE
  139. man.is_disable
  140. WHEN 1 THEN
  141. '正常'
  142. WHEN 2 THEN
  143. '故障'
  144. END AS isDisable,
  145. man.electricity,
  146. ca.camera_code AS cameraCode,
  147. ca.camera_sn AS cameraSn,
  148. man.update_time AS updateTime,
  149. man.heart_time AS heartTime
  150. FROM
  151. base_camera_management AS ca
  152. LEFT JOIN base_railway_management AS ra ON ca.railway_code = ra.railway_code
  153. LEFT JOIN sys_dept AS de ON ca.dept_id = de.dept_id
  154. LEFT JOIN base_device_dynamic_management AS man ON ca.camera_code = man.camera_code
  155. <where>
  156. <if test="railwayCode != null and railwayCode != ''">
  157. and ca.railway_code=#{railwayCode}
  158. </if>
  159. <if test="isDisable != null and isDisable != ''">
  160. and man.is_disable=#{isDisable}
  161. </if>
  162. <if test="electricity != null and electricity != ''">
  163. and man.electricity &lt;=#{electricity}
  164. </if>
  165. <if test="lineDir != null and lineDir != 0">
  166. and ca.line_dir =#{lineDir}
  167. </if>
  168. <if test="railwayType != null and railwayType != 0">
  169. and ra.railway_type =#{railwayType}
  170. </if>
  171. <if test="deptId != null and deptId != 0">
  172. and ca.dept_id =#{deptId}
  173. </if>
  174. <if test="!dsFlay">
  175. and
  176. <trim prefix="(" prefixOverrides="or" suffix=")">
  177. <if test="dsUserId != null and dsUserId != ''">
  178. or ca.create_by=#{dsUserId}
  179. </if>
  180. <if test="dsDeptId != null and dsDeptId != 0">
  181. or ca.dept_id=#{dsDeptId}
  182. </if>
  183. <if test="dsDeptIds != null">
  184. or ca.dept_id in
  185. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  186. #{item}
  187. </foreach>
  188. </if>
  189. </trim>
  190. </if>
  191. </where>
  192. ORDER BY man.is_disable DESC,
  193. man.heart_time DESC
  194. </select>
  195. <select id="alarmCountSort" resultType="com.ozs.service.entity.vo.AlarmCountSortVo">
  196. SELECT COUNT(m.camera_code) AS cameraCount,c.camera_code AS cameraCode,c.measure_point_name AS measurePointName
  197. FROM msg_alarm m JOIN base_camera_management c ON m.camera_code=c.camera_code
  198. <where>
  199. <if test="ids != null and ids.size>0">
  200. and c.id in
  201. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  202. #{items}
  203. </foreach>
  204. </if>
  205. <if test="!dsFlay">
  206. and
  207. <trim prefix="(" prefixOverrides="or" suffix=")">
  208. <if test="dsUserId != null and dsUserId != ''">
  209. or c.create_by=#{dsUserId}
  210. </if>
  211. <if test="dsDeptId != null and dsDeptId != 0">
  212. or c.dept_id=#{dsDeptId}
  213. </if>
  214. <if test="dsDeptIds != null">
  215. or c.dept_id in
  216. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  217. #{item}
  218. </foreach>
  219. </if>
  220. </trim>
  221. </if>
  222. </where>
  223. GROUP BY m.camera_code
  224. ORDER BY cameraCount DESC
  225. </select>
  226. <select id="cameraManagementList" resultType="com.ozs.service.entity.BaseCameraManagement" parameterType="com.ozs.service.entity.vo.BaseCameraManagementVo">
  227. SELECT DISTINCT
  228. a.id AS id,
  229. a.camera_code AS cameraCode,
  230. a.railway_code AS railwayCode,
  231. a.channel AS channel,
  232. a.dept_id AS deptId,
  233. a.line_dir AS lineDir,
  234. a.install_mile AS installMile,
  235. a.begin_mile AS beginMile,
  236. a.end_mile AS endMile,
  237. a.install_longitude AS installLongitude,
  238. a.install_latitude AS installLatitude,
  239. a.card_num AS cardNum,
  240. a.start_recording AS startRecording,
  241. a.task_id AS taskId,
  242. a.create_time AS createTime,
  243. a.remark AS remark,
  244. a.version_id AS versionId,
  245. a.version_num AS versionNum,
  246. a.version_name AS versionName,
  247. a.last_version_num AS lastVersionNum,
  248. a.measure_point_name AS measurePointName,
  249. a.camera_sn AS cameraSn,
  250. r.railway_type AS railwayType,
  251. man.is_disable AS isDisable
  252. FROM
  253. base_camera_management a join base_railway_management r
  254. on a.railway_code=r.railway_code
  255. LEFT JOIN base_device_dynamic_management AS man ON a.camera_code = man.camera_code
  256. LEFT JOIN msg_alarm AS msg ON a.camera_code = msg.camera_code
  257. <where>
  258. <if test="railwayCode != null and railwayCode != ''">
  259. and a.railway_code=#{railwayCode}
  260. </if>
  261. <if test="isDisable != null and isDisable != 0">
  262. and man.is_disable=#{isDisable}
  263. </if>
  264. <if test="cameraCode != null and cameraCode != ''">
  265. and a.camera_code like concat('%', #{cameraCode}, '%')
  266. </if>
  267. <if test="lineDir != null and lineDir != 0">
  268. and a.line_dir =#{lineDir}
  269. </if>
  270. <if test="deptId != null and deptId != 0">
  271. and a.dept_id =#{deptId}
  272. </if>
  273. <if test="beginMile != null and beginMile != 0">
  274. and a.install_mile &gt;=#{beginMile}
  275. </if>
  276. <if test="endMile != null and endMile != 0">
  277. and a.install_mile &lt;=#{endMile}
  278. </if>
  279. <if test="installMile != null and installMile != 0">
  280. and a.install_mile =#{installMile}
  281. </if>
  282. <if test="railwayType != null and railwayType != 0">
  283. and r.railway_type =#{railwayType}
  284. </if>
  285. <if test="ids != null and ids.size>0">
  286. and a.id in
  287. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  288. #{items}
  289. </foreach>
  290. </if>
  291. <if test="!dsFlay">
  292. and
  293. <trim prefix="(" prefixOverrides="or" suffix=")">
  294. <if test="dsUserId != null and dsUserId != ''">
  295. or a.create_by=#{dsUserId}
  296. </if>
  297. <if test="dsDeptId != null and dsDeptId != 0">
  298. or a.dept_id=#{dsDeptId}
  299. </if>
  300. <if test="dsDeptIds != null">
  301. or a.dept_id in
  302. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  303. #{item}
  304. </foreach>
  305. </if>
  306. </trim>
  307. </if>
  308. </where>
  309. ORDER BY
  310. a.install_longitude,man.is_disable,msg.is_lock
  311. </select>
  312. </mapper>