MsgAlarmMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" 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. base_railway_management c on b.railway_code=c.railway_code
  47. <where>
  48. <if test="railwayCode != null and railwayCode != ''">
  49. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  50. </if>
  51. <if test="currentYear != null and currentYear != 0">
  52. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  53. </if>
  54. <if test="currentYear == null or currentYear == ''">
  55. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  56. </if>
  57. <if test="currentMonth != null and currentMonth != 0">
  58. and MONTH(a.alarm_time) =#{currentMonth}
  59. </if>
  60. <if test="alarmType != null and alarmType != ''">
  61. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  62. </if>
  63. <if test="!dsFlay">
  64. and
  65. <trim prefix="(" prefixOverrides="or" suffix=")">
  66. <if test="dsUserId != null and dsUserId != ''">
  67. or a.create_by=#{dsUserId}
  68. </if>
  69. <if test="dsDeptId != null and dsDeptId != 0">
  70. or b.dept_id=#{dsDeptId}
  71. </if>
  72. <if test="dsDeptIds != null">
  73. or b.dept_id in
  74. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  75. #{item}
  76. </foreach>
  77. </if>
  78. </trim>
  79. </if>
  80. </where>
  81. group by a.alarm_id order by a.alarm_time desc
  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="cameraCode" property="cameraCode"/>
  87. <result column="alarmTime" property="alarmTime"/>
  88. <result column="alarmMile" property="alarmMile"/>
  89. <result column="content" property="content"/>
  90. <result column="alarmConfidence" property="alarmConfidence"/>
  91. <result column="lineDir" property="lineDir"/>
  92. <result column="alarmType" property="alarmType"/>
  93. <result column="alarmAttr" property="alarmAttr"/>
  94. <result column="imageUrl" property="imageUrl"/>
  95. <result column="releasedBy" property="releasedBy"/>
  96. <result column="releasedTime" property="releasedTime"/>
  97. <result column="releasedReason" property="releasedReason"/>
  98. <result column="releasedType" property="releasedType"/>
  99. <result column="railwayName" property="railwayName"/>
  100. <result column="remark" property="remark"/>
  101. <result column="isLock" property="isLock"/>
  102. </resultMap>
  103. <select id="listDto" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticDtoResult">
  104. SELECT
  105. a.alarm_id AS alarmId,
  106. a.camera_code AS cameraCode,
  107. a.alarm_time AS alarmTime,
  108. a.alarm_mile AS alarmMile,
  109. a.content AS content,
  110. a.alarm_confidence AS alarmConfidence,
  111. a.line_dir AS lineDir,
  112. a.alarm_type AS alarmType,
  113. a.alarm_attr AS alarmAttr,
  114. a.image_url AS imageUrl,
  115. a.released_by AS releasedBy,
  116. a.released_time AS releasedTime,
  117. a.released_reason AS releasedReason,
  118. a.released_type AS releasedType,
  119. c.railway_name AS railwayName,
  120. a.remark AS remark,
  121. a.is_lock AS isLock
  122. FROM
  123. msg_alarm AS a inner join
  124. base_camera_management AS b on a.camera_code=b.camera_code left join
  125. base_railway_management c on b.railway_code=c.railway_code
  126. <where>
  127. <if test="railwayCode != null and railwayCode != ''">
  128. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  129. </if>
  130. <if test="currentYear != null and currentYear != 0">
  131. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  132. </if>
  133. <if test="currentYear == null or currentYear == ''">
  134. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  135. </if>
  136. <if test="currentMonth != null and currentMonth != 0">
  137. and MONTH(a.alarm_time) =#{currentMonth}
  138. </if>
  139. <if test="alarmType != null and alarmType != ''">
  140. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  141. </if>
  142. <if test="ids != null and ids.size>0">
  143. and a.id in
  144. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  145. #{items}
  146. </foreach>
  147. </if>
  148. <if test="!dsFlay">
  149. and
  150. <trim prefix="(" prefixOverrides="or" suffix=")">
  151. <if test="dsUserId != null and dsUserId != ''">
  152. or a.create_by=#{dsUserId}
  153. </if>
  154. <if test="dsDeptId != null and dsDeptId != 0">
  155. or b.dept_id=#{dsDeptId}
  156. </if>
  157. <if test="dsDeptIds != null">
  158. or b.dept_id in
  159. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  160. #{item}
  161. </foreach>
  162. </if>
  163. </trim>
  164. </if>
  165. </where>
  166. group by a.alarm_id order by a.alarm_time desc
  167. </select>
  168. <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
  169. <id column="id" property="id"/>
  170. <result column="monthsta" property="monthsta"/>
  171. <result column="monthstaString" property="monthstaString"/>
  172. <result column="frequency" property="frequency"/>
  173. <result column="alarm_type" property="alarmType"/>
  174. </resultMap>
  175. <select id="listDtoMonth" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticMonthDtoResult">
  176. SELECT p.monthsta as monthsta,sum(p.fre) as frequency,p.monthstaString as monthstaString
  177. from
  178. (SELECT
  179. DATE_FORMAT(a.alarm_time,'%Y年%m月') as monthstaString,
  180. MONTH(a.alarm_time) as monthsta,
  181. count(DISTINCT a.alarm_id) as fre
  182. FROM
  183. msg_alarm AS a inner join
  184. base_camera_management AS b on a.camera_code=b.camera_code left join
  185. base_railway_management c on b.railway_code=c.railway_code
  186. <where>
  187. <if test="railwayCode != null and railwayCode != ''">
  188. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  189. </if>
  190. <if test="currentYear != null and currentYear != 0">
  191. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  192. </if>
  193. <if test="currentYear == null or currentYear == ''">
  194. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  195. </if>
  196. <if test="currentMonth != null and currentMonth != 0">
  197. and MONTH(a.alarm_time) =#{currentMonth}
  198. </if>
  199. <if test="alarmType != null and alarmType != ''">
  200. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  201. </if>
  202. <if test="!dsFlay">
  203. and
  204. <trim prefix="(" prefixOverrides="or" suffix=")">
  205. <if test="dsUserId != null and dsUserId != ''">
  206. or a.create_by=#{dsUserId}
  207. </if>
  208. <if test="dsDeptId != null and dsDeptId != 0">
  209. or b.dept_id=#{dsDeptId}
  210. </if>
  211. <if test="dsDeptIds != null">
  212. or b.dept_id in
  213. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  214. #{item}
  215. </foreach>
  216. </if>
  217. </trim>
  218. </if>
  219. </where>
  220. group by a.alarm_id) AS p group by p.monthsta order by p.monthsta
  221. </select>
  222. <select id="listDtoDay" parameterType="com.ozs.service.entity.vo.AlarmStatisticResVo" resultMap="AlarmStatisticMonthDtoResult">
  223. SELECT p.daysta as monthsta,sum(p.fre) as frequency,p.daystaString as monthstaString
  224. from
  225. (SELECT
  226. DATE_FORMAT(a.alarm_time,'%Y年%m月%d日') as daystaString,
  227. DAY(a.alarm_time) as daysta,
  228. count(DISTINCT a.alarm_id) as fre
  229. FROM
  230. msg_alarm AS a inner join
  231. base_camera_management AS b on a.camera_code=b.camera_code left join
  232. base_railway_management c on b.railway_code=c.railway_code
  233. <where>
  234. <if test="railwayCode != null and railwayCode != ''">
  235. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  236. </if>
  237. <if test="currentYear != null and currentYear != 0">
  238. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  239. </if>
  240. <if test="currentYear == null or currentYear == ''">
  241. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  242. </if>
  243. <if test="currentMonth != null and currentMonth != 0">
  244. and MONTH(a.alarm_time) =#{currentMonth}
  245. </if>
  246. <if test="alarmType != null and alarmType != ''">
  247. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  248. </if>
  249. <if test="!dsFlay">
  250. and
  251. <trim prefix="(" prefixOverrides="or" suffix=")">
  252. <if test="dsUserId != null and dsUserId != ''">
  253. or a.create_by=#{dsUserId}
  254. </if>
  255. <if test="dsDeptId != null and dsDeptId != 0">
  256. or b.dept_id=#{dsDeptId}
  257. </if>
  258. <if test="dsDeptIds != null">
  259. or b.dept_id in
  260. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  261. #{item}
  262. </foreach>
  263. </if>
  264. </trim>
  265. </if>
  266. </where>
  267. group by a.alarm_id) AS p group by p.daysta order by p.daysta
  268. </select>
  269. <select id="selectCameraCode" parameterType="java.lang.String" resultType="java.lang.Integer">
  270. select is_lock
  271. from msg_alarm
  272. where camera_code = #{cameraCode}
  273. ORDER BY alarm_time DESC LIMIT 1
  274. </select>
  275. <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
  276. select *
  277. from msg_alarm
  278. where camera_code = #{cameraCode}
  279. order by alarm_time desc limit 1
  280. </select>
  281. <select id="selectMsgAlarmListHome" resultType="com.ozs.service.entity.MsgAlarm"
  282. parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
  283. SELECT
  284. a.alarm_id AS alarmId,
  285. a.alarm_time AS alarmTime,
  286. a.alarm_mile AS alarmMile,
  287. a.line_dir AS lineDir,
  288. a.alarm_type AS alarmType,
  289. a.camera_code AS cameraCode,
  290. a.id AS id,
  291. a.content AS content,
  292. a.alarm_confidence AS alarmConfidence,
  293. a.alarm_attr AS alarmAttr,
  294. a.image_url AS imageUrl,
  295. a.released_by AS releasedBy,
  296. a.is_lock AS isLock,
  297. a.released_time AS releasedTime,
  298. a.released_type AS releasedType,
  299. a.released_reason AS releasedReason,
  300. a.remark AS remark,
  301. COUNT(CASE WHEN a.is_lock = 2 THEN 1 END) OVER() AS unlockNum
  302. FROM msg_alarm AS a
  303. join base_camera_management AS b on a.camera_code=b.camera_code
  304. join base_railway_management AS l on b.railway_code=l.railway_code
  305. <where>
  306. <if test="railwayCode != null and railwayCode != ''">
  307. concat(l.railway_name,l.railway_code)
  308. like concat("%",#{railwayCode},"%")
  309. </if>
  310. <if test="beginMile != null and beginMile != 0">
  311. and b.begin_mile &gt;=#{beginMile}
  312. </if>
  313. <if test="endMile != null and endMile != 0">
  314. and b.end_mile &lt;=#{endMile}
  315. </if>
  316. <if test="ids != null and ids.size>0">
  317. and a.id in
  318. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  319. #{items}
  320. </foreach>
  321. </if>
  322. <if test="!dsFlay">
  323. and
  324. <trim prefix="(" prefixOverrides="or" suffix=")">
  325. <if test="dsUserId != null and dsUserId != ''">
  326. or a.create_by=#{dsUserId}
  327. </if>
  328. <if test="dsDeptId != null and dsDeptId != 0">
  329. or b.dept_id=#{dsDeptId}
  330. </if>
  331. <if test="dsDeptIds != null">
  332. or b.dept_id in
  333. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  334. #{item}
  335. </foreach>
  336. </if>
  337. </trim>
  338. </if>
  339. <if test="alarmType != null and alarmType != 0">
  340. and a.alarm_type=#{alarmType}
  341. </if>
  342. <if test="alarmMile != null and alarmMile != 0">
  343. and a.alarm_mile=#{alarmMile}
  344. </if>
  345. <if test="isLock != null and isLock != 0">
  346. and a.is_lock=#{isLock}
  347. </if>
  348. <if test="lineDir != null and lineDir != 0">
  349. and a.line_dir =#{lineDir}
  350. </if>
  351. <if test="releasedType != null and releasedType != 0">
  352. and a.released_type =#{releasedType}
  353. </if>
  354. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  355. and date_format(a.alarm_time,'%Y-%m-%d') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d')
  356. </if>
  357. <if test="endAlarmTime != null and endAlarmTime != ''">
  358. AND date_format(a.alarm_time,'%Y-%m-%d') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d')
  359. </if>
  360. </where>
  361. order by a.is_lock desc, a.alarm_time desc
  362. </select>
  363. <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarm"
  364. parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
  365. SELECT
  366. a.alarm_id AS alarmId,
  367. a.alarm_time AS alarmTime,
  368. a.alarm_mile AS alarmMile,
  369. a.line_dir AS lineDir,
  370. a.alarm_type AS alarmType,
  371. a.camera_code AS cameraCode,
  372. a.id AS id,
  373. a.content AS content,
  374. a.alarm_confidence AS alarmConfidence,
  375. a.alarm_attr AS alarmAttr,
  376. a.image_url AS imageUrl,
  377. a.released_by AS releasedBy,
  378. a.is_lock AS isLock,
  379. a.released_time AS releasedTime,
  380. a.released_type AS releasedType,
  381. a.released_reason AS releasedReason,
  382. a.remark AS remark
  383. FROM
  384. msg_alarm AS a join
  385. base_camera_management AS b on a.camera_code=b.camera_code join
  386. base_railway_management AS l on b.railway_code=l.railway_code
  387. <where>
  388. <if test="railwayCode != null and railwayCode != ''">
  389. concat(l.railway_name,l.railway_code)
  390. like concat("%",#{railwayCode},"%")
  391. </if>
  392. <if test="beginMile != null and beginMile != 0">
  393. and b.begin_mile &gt;=#{beginMile}
  394. </if>
  395. <if test="endMile != null and endMile != 0">
  396. and b.end_mile &lt;=#{endMile}
  397. </if>
  398. <if test="ids != null and ids.size>0">
  399. and a.id in
  400. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  401. #{items}
  402. </foreach>
  403. </if>
  404. <if test="!dsFlay">
  405. and
  406. <trim prefix="(" prefixOverrides="or" suffix=")">
  407. <if test="dsUserId != null and dsUserId != ''">
  408. or a.create_by=#{dsUserId}
  409. </if>
  410. <if test="dsDeptId != null and dsDeptId != 0">
  411. or b.dept_id=#{dsDeptId}
  412. </if>
  413. <if test="dsDeptIds != null">
  414. or b.dept_id in
  415. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  416. #{item}
  417. </foreach>
  418. </if>
  419. </trim>
  420. </if>
  421. <if test="alarmType != null and alarmType != 0">
  422. and a.alarm_type=#{alarmType}
  423. </if>
  424. <if test="railwayType != null and railwayType != 0">
  425. and l.railway_type=#{railwayType}
  426. </if>
  427. <if test="alarmMile != null and alarmMile != 0">
  428. and a.alarm_mile=#{alarmMile}
  429. </if>
  430. <if test="isLock != null and isLock != 0">
  431. and a.is_lock=#{isLock}
  432. </if>
  433. <if test="lineDir != null and lineDir != 0">
  434. and a.line_dir =#{lineDir}
  435. </if>
  436. <if test="releasedType != null and releasedType != 0">
  437. and a.released_type =#{releasedType}
  438. </if>
  439. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  440. and date_format(a.alarm_time,'%Y-%m-%d') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d')
  441. </if>
  442. <if test="endAlarmTime != null and endAlarmTime != ''">
  443. AND date_format(a.alarm_time,'%Y-%m-%d') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d')
  444. </if>
  445. </where>
  446. order by a.alarm_time desc
  447. </select>
  448. <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarm" parameterType="java.lang.String">
  449. select *
  450. from msg_alarm
  451. where alarm_id = #{alarmId}
  452. </select>
  453. <select id="countMsg" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  454. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code = b.camera_code
  455. <where>
  456. <if test="!dsFlay">
  457. and
  458. <trim prefix="(" prefixOverrides="or" suffix=")">
  459. <if test="dsUserId != null and dsUserId != ''">
  460. or a.create_by = #{dsUserId}
  461. </if>
  462. <if test="dsDeptId != null and dsDeptId != 0">
  463. or b.dept_id = #{dsDeptId}
  464. </if>
  465. <if test="dsDeptIds != null">
  466. or b.dept_id in
  467. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  468. #{item}
  469. </foreach>
  470. </if>
  471. </trim>
  472. </if>
  473. </where>
  474. </select>
  475. <select id="countJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  476. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  477. <where>
  478. is_lock = 1
  479. <if test="!dsFlay">
  480. and
  481. <trim prefix="(" prefixOverrides="or" suffix=")">
  482. <if test="dsUserId != null and dsUserId != ''">
  483. or a.create_by = #{dsUserId}
  484. </if>
  485. <if test="dsDeptId != null and dsDeptId != 0">
  486. or b.dept_id = #{dsDeptId}
  487. </if>
  488. <if test="dsDeptIds != null">
  489. or b.dept_id in
  490. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  491. #{item}
  492. </foreach>
  493. </if>
  494. </trim>
  495. </if>
  496. </where>
  497. </select>
  498. <select id="countWJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  499. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  500. <where>
  501. is_lock = 2
  502. <if test="!dsFlay">
  503. and
  504. <trim prefix="(" prefixOverrides="or" suffix=")">
  505. <if test="dsUserId != null and dsUserId != ''">
  506. or a.create_by = #{dsUserId}
  507. </if>
  508. <if test="dsDeptId != null and dsDeptId != 0">
  509. or b.dept_id = #{dsDeptId}
  510. </if>
  511. <if test="dsDeptIds != null">
  512. or b.dept_id in
  513. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  514. #{item}
  515. </foreach>
  516. </if>
  517. </trim>
  518. </if>
  519. </where>
  520. </select>
  521. <select id="queryAlarmInfoByAfterTenMinute" resultType="com.ozs.service.entity.MsgAlarm">
  522. SELECT a.id as id,
  523. a.alarm_id AS alarmId,
  524. a.alarm_time AS alarmTime,
  525. a.alarm_mile AS alarmMile,
  526. a.line_dir AS lineDir,
  527. a.alarm_type AS alarmType,
  528. a.camera_code AS cameraCode,
  529. a.content AS content,
  530. a.alarm_confidence AS alarmConfidence,
  531. a.alarm_attr AS alarmAttr,
  532. a.image_url AS imageUrl,
  533. a.released_by AS releasedBy,
  534. a.is_lock AS isLock,
  535. a.released_time AS releasedTime,
  536. a.released_type AS releasedType,
  537. a.released_url AS releasedUrl,
  538. a.released_reason AS releasedReason,
  539. a.remark AS remark
  540. from msg_alarm AS a
  541. where a.is_lock = 2
  542. and a.released_url is null
  543. and a.alarm_time &lt;= DATE_SUB(NOW(), INTERVAL 10 MINUTE)
  544. </select>
  545. <select id="selectAlarmStatistics" resultType="java.util.HashMap">
  546. SELECT
  547. SUM(CASE WHEN rm.railway_type = 1 THEN 1 ELSE 0 END) AS highAlarmCount,
  548. SUM(CASE WHEN rm.railway_type &lt;&gt; 1 THEN 1 ELSE 0 END) AS puAlarmCount,
  549. SUM(CASE WHEN am.is_lock = 2 AND rm.railway_type = 1 THEN 1 ELSE 0 END) AS highUnresolvedCount,
  550. SUM(CASE WHEN am.is_lock = 2 AND rm.railway_type &lt;&gt; 1 THEN 1 ELSE 0 END) AS puUnresolvedCount
  551. FROM
  552. msg_alarm am
  553. JOIN
  554. base_camera_management cm ON am.camera_code = cm.camera_code
  555. JOIN
  556. base_railway_management rm ON cm.railway_code = rm.railway_code
  557. <where>
  558. am.is_lock IN (1, 2)
  559. <if test="ids != null and ids.size>0">
  560. and a.id in
  561. <foreach item="items" collection="ids" separator="," open="(" close=")" index="">
  562. #{items}
  563. </foreach>
  564. </if>
  565. <if test="!dsFlay">
  566. and
  567. <trim prefix="(" prefixOverrides="or" suffix=")">
  568. <if test="dsUserId != null and dsUserId != ''">
  569. or am.create_by=#{dsUserId}
  570. </if>
  571. <if test="dsDeptId != null and dsDeptId != 0">
  572. or cm.dept_id=#{dsDeptId}
  573. </if>
  574. <if test="dsDeptIds != null">
  575. or cm.dept_id in
  576. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  577. #{item}
  578. </foreach>
  579. </if>
  580. </trim>
  581. </if>
  582. </where>
  583. </select>
  584. </mapper>