MsgAlarmMapper.xml 16 KB

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