MsgAlarmMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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.MsgAlarmMapper">
  4. <resultMap id="AlarmStatisticVoResult" type="com.ozs.service.entity.vo.AlarmStatisticVo">
  5. <id column="id" property="id"/>
  6. <result column="alarm_id" property="alarmId"/>
  7. <result column="monthsta" property="monthsta"/>
  8. <result column="frequency" property="frequency"/>
  9. <result column="camera_code" property="cameraCode"/>
  10. <result column="alarm_time" property="alarmTime"/>
  11. <result column="alarm_mile" property="alarmMile"/>
  12. <result column="content" property="content"/>
  13. <result column="alarm_confidence" property="alarmConfidence"/>
  14. <result column="line_dir" property="lineDir"/>
  15. <result column="alarm_type" property="alarmType"/>
  16. <result column="alarm_attr" property="alarmAttr"/>
  17. <result column="image_url" property="imageUrl"/>
  18. <result column="released_by" property="releasedBy"/>
  19. <result column="released_time" property="releasedTime"/>
  20. <result column="is_lock" property="isLock"/>
  21. <association property="baseCameraManagement" javaType="com.ozs.service.entity.BaseCameraManagement">
  22. <id column="id" property="id"/>
  23. <result column="railway_code" property="railwayCode"/>
  24. <result column="railwayName" property="railwayName"/>
  25. <result column="channel" property="channel"/>
  26. <result column="install_mile" property="installMile"/>
  27. <result column="begin_mile" property="beginMile"/>
  28. <result column="end_mile" property="endMile"/>
  29. <result column="install_longitude" property="installLongitude"/>
  30. <result column="install_latitude" property="installLatitude"/>
  31. </association>
  32. </resultMap>
  33. <select id="list" resultMap="AlarmStatisticVoResult">
  34. SELECT
  35. a.alarm_id ,
  36. a.camera_code ,
  37. a.alarm_time ,
  38. a.alarm_mile ,
  39. a.content ,
  40. a.alarm_confidence,
  41. a.line_dir ,
  42. a.alarm_type ,
  43. a.alarm_attr ,
  44. a.image_url ,
  45. a.released_by ,
  46. a.released_time,
  47. a.is_lock ,
  48. b.railway_code AS railway_code,
  49. b.channel AS channel,
  50. b.install_mile AS install_mile,
  51. b.begin_mile AS begin_mile,
  52. b.end_mile AS end_mile,
  53. b.install_longitude AS install_longitude,
  54. b.install_latitude AS install_latitude,
  55. c.railway_name AS railwayName
  56. FROM
  57. msg_alarm AS a inner join
  58. base_camera_management AS b on a.camera_code=b.camera_code left join
  59. msg_web_push m on a.alarm_id = m.alarm_id left join
  60. base_railway_management c on b.railway_code=c.railway_code
  61. <where>
  62. <if test="railwayCode != null and railwayCode != ''">
  63. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  64. </if>
  65. <if test="currentYear != null and currentYear != 0">
  66. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  67. </if>
  68. <if test="currentYear == null or currentYear == ''">
  69. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  70. </if>
  71. <if test="currentMonth != null and currentMonth != 0">
  72. and MONTH(a.alarm_time) =#{currentMonth}
  73. </if>
  74. <if test="alarmType != null and alarmType != ''">
  75. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  76. </if>
  77. <if test="userId != null and userId != ''">
  78. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  79. </if>
  80. </where>
  81. group by a.alarm_id
  82. </select>
  83. <resultMap id="AlarmStatisticDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDto">
  84. <id column="id" property="id"/>
  85. <result column="alarmId" property="alarmId"/>
  86. <result column="railwayName" property="railwayName"/>
  87. <result column="alarmTime" property="alarmTime"/>
  88. <result column="lineDir" property="lineDir"/>
  89. <result column="lineDirValue" property="lineDirValue"/>
  90. <result column="alarmType" property="alarmType"/>
  91. <result column="alarmTypeValue" property="alarmTypeValue"/>
  92. <result column="alarmMile" property="alarmMile"/>
  93. <result column="beginMile" property="beginMile"/>
  94. <result column="endMile" property="endMile"/>
  95. </resultMap>
  96. <select id="listDto" resultMap="AlarmStatisticDtoResult">
  97. SELECT
  98. a.alarm_id AS alarmId,
  99. a.alarm_time AS alarmTime,
  100. a.alarm_mile AS alarmMile,
  101. a.line_dir AS lineDir,
  102. a.alarm_type AS alarmType,
  103. c.railway_name AS railwayName,
  104. b.begin_mile AS beginMile,
  105. b.end_mile AS endMile
  106. FROM
  107. msg_alarm AS a inner join
  108. base_camera_management AS b on a.camera_code=b.camera_code left join
  109. msg_web_push m on a.alarm_id = m.alarm_id left join
  110. base_railway_management c on b.railway_code=c.railway_code
  111. <where>
  112. <if test="railwayCode != null and railwayCode != ''">
  113. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  114. </if>
  115. <if test="currentYear != null and currentYear != 0">
  116. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  117. </if>
  118. <if test="currentYear == null or currentYear == ''">
  119. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  120. </if>
  121. <if test="currentMonth != null and currentMonth != 0">
  122. and MONTH(a.alarm_time) =#{currentMonth}
  123. </if>
  124. <if test="alarmType != null and alarmType != ''">
  125. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  126. </if>
  127. <if test="userId != null and userId != ''">
  128. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  129. </if>
  130. </where>
  131. group by a.alarm_id
  132. </select>
  133. <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
  134. <id column="id" property="id"/>
  135. <result column="monthsta" property="monthsta"/>
  136. <result column="frequency" property="frequency"/>
  137. <result column="alarm_type" property="alarmType"/>
  138. </resultMap>
  139. <select id="listDtoMonth" resultMap="AlarmStatisticMonthDtoResult">
  140. SELECT p.monthsta as monthsta,sum(p.fre) as frequency
  141. from
  142. (SELECT
  143. MONTH(a.alarm_time) as monthsta,
  144. count(DISTINCT a.alarm_id) as fre
  145. FROM
  146. msg_alarm AS a inner join
  147. base_camera_management AS b on a.camera_code=b.camera_code left join
  148. msg_web_push m on a.alarm_id = m.alarm_id left join
  149. base_railway_management c on b.railway_code=c.railway_code
  150. <where>
  151. <if test="railwayCode != null and railwayCode != ''">
  152. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  153. </if>
  154. <if test="currentYear != null and currentYear != 0">
  155. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  156. </if>
  157. <if test="currentYear == null or currentYear == ''">
  158. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  159. </if>
  160. <if test="currentMonth != null and currentMonth != 0">
  161. and MONTH(a.alarm_time) =#{currentMonth}
  162. </if>
  163. <if test="alarmType != null and alarmType != ''">
  164. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  165. </if>
  166. <if test="userId != null and userId != ''">
  167. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  168. </if>
  169. </where>
  170. group by a.alarm_id) AS p group by p.monthsta
  171. </select>
  172. <resultMap id="AlarmStatisticDayDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDayDto">
  173. <id column="id" property="id"/>
  174. <result column="daysta" property="daysta"/>
  175. <result column="frequency" property="frequency"/>
  176. <result column="alarm_type" property="alarmType"/>
  177. </resultMap>
  178. <select id="listDtoDay" resultMap="AlarmStatisticDayDtoResult">
  179. SELECT p.daysta as daysta,sum(p.fre) as frequency
  180. from
  181. (SELECT
  182. DAY(a.alarm_time) as daysta,
  183. count(DISTINCT a.alarm_id) as fre
  184. FROM
  185. msg_alarm AS a inner join
  186. base_camera_management AS b on a.camera_code=b.camera_code left join
  187. msg_web_push m on a.alarm_id = m.alarm_id left join
  188. base_railway_management c on b.railway_code=c.railway_code
  189. <where>
  190. <if test="railwayCode != null and railwayCode != ''">
  191. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  192. </if>
  193. <if test="currentYear != null and currentYear != 0">
  194. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  195. </if>
  196. <if test="currentYear == null or currentYear == ''">
  197. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  198. </if>
  199. <if test="currentMonth != null and currentMonth != 0">
  200. and MONTH(a.alarm_time) =#{currentMonth}
  201. </if>
  202. <if test="alarmType != null and alarmType != ''">
  203. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  204. </if>
  205. <if test="userId != null and userId != ''">
  206. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  207. </if>
  208. </where>
  209. group by a.alarm_id) AS p group by p.daysta
  210. </select>
  211. <select id="selectCameraCode" parameterType="java.lang.String" resultType="java.lang.Integer">
  212. select is_lock from msg_alarm where camera_code = #{cameraCode} ORDER BY alarm_time DESC LIMIT 1
  213. </select>
  214. <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
  215. select *, max(alarm_time) from msg_alarm where camera_code = #{cameraCode}
  216. </select>
  217. <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarm"
  218. parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
  219. SELECT
  220. a.alarm_id AS alarmId,
  221. a.alarm_time AS alarmTime,
  222. a.alarm_mile AS alarmMile,
  223. a.line_dir AS lineDir,
  224. a.alarm_type AS alarmType,
  225. a.camera_code AS cameraCode,
  226. a.id AS id,
  227. a.content AS content,
  228. a.alarm_confidence AS alarmConfidence,
  229. a.alarm_attr AS alarmAttr,
  230. a.image_url AS imageUrl,
  231. a.released_by AS releasedBy,
  232. a.is_lock AS isLock,
  233. a.released_time AS releasedTime,
  234. a.released_type AS releasedType
  235. FROM
  236. msg_alarm AS a join
  237. base_camera_management AS b on a.camera_code=b.camera_code
  238. <where>
  239. <if test="railwayCode != null and railwayCode != ''">
  240. and b.railway_code=#{railwayCode}
  241. </if>
  242. <if test="beginMile != null and beginMile != 0">
  243. and b.begin_mile &gt;=#{beginMile}
  244. </if>
  245. <if test="endMile != null and endMile != 0">
  246. and b.end_mile &lt;=#{endMile}
  247. </if>
  248. <if test="!dsFlay">
  249. and
  250. <trim prefix="(" prefixOverrides="or" suffix=")">
  251. <if test="dsUserId != null and dsUserId != ''">
  252. or a.create_by=#{dsUserId}
  253. </if>
  254. <if test="dsDeptId != null and dsDeptId != 0">
  255. or b.dept_id=#{dsDeptId}
  256. </if>
  257. <if test="dsDeptIds != null">
  258. or b.dept_id in
  259. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  260. #{item}
  261. </foreach>
  262. </if>
  263. </trim>
  264. </if>
  265. <if test="alarmType != null and alarmType != 0">
  266. and a.alarm_type=#{alarmType}
  267. </if>
  268. <if test="alarmMile != null and alarmMile != 0">
  269. and a.alarm_mile=#{alarmMile}
  270. </if>
  271. <if test="isLock != null and isLock != 0">
  272. and a.is_lock=#{isLock}
  273. </if>
  274. <if test="lineDir != null and lineDir != 0">
  275. and a.line_dir =#{lineDir}
  276. </if>
  277. <if test="releasedType != null and releasedType != 0">
  278. and a.released_type =#{releasedType}
  279. </if>
  280. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  281. and date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d %H:%i:%S')
  282. </if>
  283. <if test="endAlarmTime != null and endAlarmTime != ''">
  284. AND date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d %H:%i:%S')
  285. </if>
  286. </where>
  287. order by a.alarm_time desc
  288. </select>
  289. <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarm" parameterType="java.lang.String">
  290. select * from msg_alarm where alarm_id = #{alarmId}
  291. </select>
  292. <select id="countMsg" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  293. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code = b.camera_code
  294. <where>
  295. <if test="!dsFlay">
  296. and
  297. <trim prefix="(" prefixOverrides="or" suffix=")">
  298. <if test="dsUserId != null and dsUserId != ''">
  299. or a.create_by = #{dsUserId}
  300. </if>
  301. <if test="dsDeptId != null and dsDeptId != 0">
  302. or b.dept_id = #{dsDeptId}
  303. </if>
  304. <if test="dsDeptIds != null">
  305. or b.dept_id in
  306. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  307. #{item}
  308. </foreach>
  309. </if>
  310. </trim>
  311. </if>
  312. </where>
  313. </select>
  314. <select id="countJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  315. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  316. <where>
  317. is_lock = 1
  318. <if test="!dsFlay">
  319. and
  320. <trim prefix="(" prefixOverrides="or" suffix=")">
  321. <if test="dsUserId != null and dsUserId != ''">
  322. or a.create_by = #{dsUserId}
  323. </if>
  324. <if test="dsDeptId != null and dsDeptId != 0">
  325. or b.dept_id = #{dsDeptId}
  326. </if>
  327. <if test="dsDeptIds != null">
  328. or b.dept_id in
  329. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  330. #{item}
  331. </foreach>
  332. </if>
  333. </trim>
  334. </if>
  335. </where>
  336. </select>
  337. <select id="countWJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  338. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  339. <where>
  340. is_lock = 2
  341. <if test="!dsFlay">
  342. and
  343. <trim prefix="(" prefixOverrides="or" suffix=")">
  344. <if test="dsUserId != null and dsUserId != ''">
  345. or a.create_by = #{dsUserId}
  346. </if>
  347. <if test="dsDeptId != null and dsDeptId != 0">
  348. or b.dept_id = #{dsDeptId}
  349. </if>
  350. <if test="dsDeptIds != null">
  351. or b.dept_id in
  352. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  353. #{item}
  354. </foreach>
  355. </if>
  356. </trim>
  357. </if>
  358. </where>
  359. </select>
  360. </mapper>