MsgAlarmMapper.xml 18 KB

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