MsgAlarmMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 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 * from msg_alarm where camera_code = #{cameraCode} order by alarm_time desc limit 1
  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. a.released_reason AS releasedReason,
  236. a.remark AS remark
  237. FROM
  238. msg_alarm AS a join
  239. base_camera_management AS b on a.camera_code=b.camera_code
  240. <where>
  241. <if test="railwayCode != null and railwayCode != ''">
  242. and b.railway_code=#{railwayCode}
  243. </if>
  244. <if test="beginMile != null and beginMile != 0">
  245. and b.begin_mile &gt;=#{beginMile}
  246. </if>
  247. <if test="endMile != null and endMile != 0">
  248. and b.end_mile &lt;=#{endMile}
  249. </if>
  250. <if test="!dsFlay">
  251. and
  252. <trim prefix="(" prefixOverrides="or" suffix=")">
  253. <if test="dsUserId != null and dsUserId != ''">
  254. or a.create_by=#{dsUserId}
  255. </if>
  256. <if test="dsDeptId != null and dsDeptId != 0">
  257. or b.dept_id=#{dsDeptId}
  258. </if>
  259. <if test="dsDeptIds != null">
  260. or b.dept_id in
  261. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  262. #{item}
  263. </foreach>
  264. </if>
  265. </trim>
  266. </if>
  267. <if test="alarmType != null and alarmType != 0">
  268. and a.alarm_type=#{alarmType}
  269. </if>
  270. <if test="alarmMile != null and alarmMile != 0">
  271. and a.alarm_mile=#{alarmMile}
  272. </if>
  273. <if test="isLock != null and isLock != 0">
  274. and a.is_lock=#{isLock}
  275. </if>
  276. <if test="lineDir != null and lineDir != 0">
  277. and a.line_dir =#{lineDir}
  278. </if>
  279. <if test="releasedType != null and releasedType != 0">
  280. and a.released_type =#{releasedType}
  281. </if>
  282. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  283. and date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d %H:%i:%S')
  284. </if>
  285. <if test="endAlarmTime != null and endAlarmTime != ''">
  286. AND date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d %H:%i:%S')
  287. </if>
  288. </where>
  289. order by a.alarm_time desc
  290. </select>
  291. <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarm" parameterType="java.lang.String">
  292. select * from msg_alarm where alarm_id = #{alarmId}
  293. </select>
  294. <select id="countMsg" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  295. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code = b.camera_code
  296. <where>
  297. <if test="!dsFlay">
  298. and
  299. <trim prefix="(" prefixOverrides="or" suffix=")">
  300. <if test="dsUserId != null and dsUserId != ''">
  301. or a.create_by = #{dsUserId}
  302. </if>
  303. <if test="dsDeptId != null and dsDeptId != 0">
  304. or b.dept_id = #{dsDeptId}
  305. </if>
  306. <if test="dsDeptIds != null">
  307. or b.dept_id in
  308. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  309. #{item}
  310. </foreach>
  311. </if>
  312. </trim>
  313. </if>
  314. </where>
  315. </select>
  316. <select id="countJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  317. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  318. <where>
  319. is_lock = 1
  320. <if test="!dsFlay">
  321. and
  322. <trim prefix="(" prefixOverrides="or" suffix=")">
  323. <if test="dsUserId != null and dsUserId != ''">
  324. or a.create_by = #{dsUserId}
  325. </if>
  326. <if test="dsDeptId != null and dsDeptId != 0">
  327. or b.dept_id = #{dsDeptId}
  328. </if>
  329. <if test="dsDeptIds != null">
  330. or b.dept_id in
  331. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  332. #{item}
  333. </foreach>
  334. </if>
  335. </trim>
  336. </if>
  337. </where>
  338. </select>
  339. <select id="countWJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  340. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  341. <where>
  342. is_lock = 2
  343. <if test="!dsFlay">
  344. and
  345. <trim prefix="(" prefixOverrides="or" suffix=")">
  346. <if test="dsUserId != null and dsUserId != ''">
  347. or a.create_by = #{dsUserId}
  348. </if>
  349. <if test="dsDeptId != null and dsDeptId != 0">
  350. or b.dept_id = #{dsDeptId}
  351. </if>
  352. <if test="dsDeptIds != null">
  353. or b.dept_id in
  354. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  355. #{item}
  356. </foreach>
  357. </if>
  358. </trim>
  359. </if>
  360. </where>
  361. </select>
  362. </mapper>