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="monthstaString" property="monthstaString"/>
  137. <result column="frequency" property="frequency"/>
  138. <result column="alarm_type" property="alarmType"/>
  139. </resultMap>
  140. <select id="listDtoMonth" resultMap="AlarmStatisticMonthDtoResult">
  141. SELECT p.monthsta as monthsta,sum(p.fre) as frequency,p.monthstaString as monthstaString
  142. from
  143. (SELECT
  144. DATE_FORMAT(a.alarm_time,'%Y年%m月') as monthstaString,
  145. MONTH(a.alarm_time) as monthsta,
  146. count(DISTINCT a.alarm_id) as fre
  147. FROM
  148. msg_alarm AS a inner join
  149. base_camera_management AS b on a.camera_code=b.camera_code left join
  150. msg_web_push m on a.alarm_id = m.alarm_id left join
  151. base_railway_management c on b.railway_code=c.railway_code
  152. <where>
  153. <if test="railwayCode != null and railwayCode != ''">
  154. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  155. </if>
  156. <if test="currentYear != null and currentYear != 0">
  157. and YEAR(a.alarm_time) like UPPER(CONCAT('%',#{currentYear},'%'))
  158. </if>
  159. <if test="currentYear == null or currentYear == ''">
  160. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  161. </if>
  162. <if test="currentMonth != null and currentMonth != 0">
  163. and MONTH(a.alarm_time) =#{currentMonth}
  164. </if>
  165. <if test="alarmType != null and alarmType != ''">
  166. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  167. </if>
  168. <if test="userId != null and userId != ''">
  169. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  170. </if>
  171. </where>
  172. group by a.alarm_id) AS p group by p.monthsta order by p.monthsta
  173. </select>
  174. <select id="listDtoDay" resultMap="AlarmStatisticMonthDtoResult">
  175. SELECT p.daysta as monthsta,sum(p.fre) as frequency,p.daystaString as monthstaString
  176. from
  177. (SELECT
  178. DATE_FORMAT(a.alarm_time,'%Y年%m月%d日') as daystaString,
  179. DAY(a.alarm_time) as daysta,
  180. count(DISTINCT a.alarm_id) as fre
  181. FROM
  182. msg_alarm AS a inner join
  183. base_camera_management AS b on a.camera_code=b.camera_code left join
  184. msg_web_push m on a.alarm_id = m.alarm_id 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="userId != null and userId != ''">
  203. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  204. </if>
  205. </where>
  206. group by a.alarm_id) AS p group by p.daysta order by p.daysta
  207. </select>
  208. <select id="selectCameraCode" parameterType="java.lang.String" resultType="java.lang.Integer">
  209. select is_lock from msg_alarm where camera_code = #{cameraCode} ORDER BY alarm_time DESC LIMIT 1
  210. </select>
  211. <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
  212. select *, max(alarm_time) from msg_alarm where camera_code = #{cameraCode}
  213. </select>
  214. <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarm"
  215. parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
  216. SELECT
  217. a.alarm_id AS alarmId,
  218. a.alarm_time AS alarmTime,
  219. a.alarm_mile AS alarmMile,
  220. a.line_dir AS lineDir,
  221. a.alarm_type AS alarmType,
  222. a.camera_code AS cameraCode,
  223. a.id AS id,
  224. a.content AS content,
  225. a.alarm_confidence AS alarmConfidence,
  226. a.alarm_attr AS alarmAttr,
  227. a.image_url AS imageUrl,
  228. a.released_by AS releasedBy,
  229. a.is_lock AS isLock,
  230. a.released_time AS releasedTime,
  231. a.released_type AS releasedType,
  232. a.released_reason AS releasedReason,
  233. a.remark AS remark
  234. FROM
  235. msg_alarm AS a join
  236. base_camera_management AS b on a.camera_code=b.camera_code
  237. <where>
  238. <if test="railwayCode != null and railwayCode != ''">
  239. and b.railway_code=#{railwayCode}
  240. </if>
  241. <if test="beginMile != null and beginMile != 0">
  242. and b.begin_mile &gt;=#{beginMile}
  243. </if>
  244. <if test="endMile != null and endMile != 0">
  245. and b.end_mile &lt;=#{endMile}
  246. </if>
  247. <if test="!dsFlay">
  248. and
  249. <trim prefix="(" prefixOverrides="or" suffix=")">
  250. <if test="dsUserId != null and dsUserId != ''">
  251. or a.create_by=#{dsUserId}
  252. </if>
  253. <if test="dsDeptId != null and dsDeptId != 0">
  254. or b.dept_id=#{dsDeptId}
  255. </if>
  256. <if test="dsDeptIds != null">
  257. or b.dept_id in
  258. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  259. #{item}
  260. </foreach>
  261. </if>
  262. </trim>
  263. </if>
  264. <if test="alarmType != null and alarmType != 0">
  265. and a.alarm_type=#{alarmType}
  266. </if>
  267. <if test="alarmMile != null and alarmMile != 0">
  268. and a.alarm_mile=#{alarmMile}
  269. </if>
  270. <if test="isLock != null and isLock != 0">
  271. and a.is_lock=#{isLock}
  272. </if>
  273. <if test="lineDir != null and lineDir != 0">
  274. and a.line_dir =#{lineDir}
  275. </if>
  276. <if test="releasedType != null and releasedType != 0">
  277. and a.released_type =#{releasedType}
  278. </if>
  279. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  280. and date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d %H:%i:%S')
  281. </if>
  282. <if test="endAlarmTime != null and endAlarmTime != ''">
  283. AND date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d %H:%i:%S')
  284. </if>
  285. </where>
  286. order by a.alarm_time desc
  287. </select>
  288. <select id="getByAlarmId" resultType="com.ozs.service.entity.MsgAlarm" parameterType="java.lang.String">
  289. select * from msg_alarm where alarm_id = #{alarmId}
  290. </select>
  291. <select id="countMsg" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  292. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code = b.camera_code
  293. <where>
  294. <if test="!dsFlay">
  295. and
  296. <trim prefix="(" prefixOverrides="or" suffix=")">
  297. <if test="dsUserId != null and dsUserId != ''">
  298. or a.create_by = #{dsUserId}
  299. </if>
  300. <if test="dsDeptId != null and dsDeptId != 0">
  301. or b.dept_id = #{dsDeptId}
  302. </if>
  303. <if test="dsDeptIds != null">
  304. or b.dept_id in
  305. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  306. #{item}
  307. </foreach>
  308. </if>
  309. </trim>
  310. </if>
  311. </where>
  312. </select>
  313. <select id="countJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  314. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  315. <where>
  316. is_lock = 1
  317. <if test="!dsFlay">
  318. and
  319. <trim prefix="(" prefixOverrides="or" suffix=")">
  320. <if test="dsUserId != null and dsUserId != ''">
  321. or a.create_by = #{dsUserId}
  322. </if>
  323. <if test="dsDeptId != null and dsDeptId != 0">
  324. or b.dept_id = #{dsDeptId}
  325. </if>
  326. <if test="dsDeptIds != null">
  327. or b.dept_id in
  328. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  329. #{item}
  330. </foreach>
  331. </if>
  332. </trim>
  333. </if>
  334. </where>
  335. </select>
  336. <select id="countWJC" parameterType="com.ozs.service.entity.vo.MsgAlarmVo" resultType="java.lang.Integer">
  337. select count(1) from msg_alarm AS a join base_camera_management AS b on a.camera_code=b.camera_code
  338. <where>
  339. is_lock = 2
  340. <if test="!dsFlay">
  341. and
  342. <trim prefix="(" prefixOverrides="or" suffix=")">
  343. <if test="dsUserId != null and dsUserId != ''">
  344. or a.create_by = #{dsUserId}
  345. </if>
  346. <if test="dsDeptId != null and dsDeptId != 0">
  347. or b.dept_id = #{dsDeptId}
  348. </if>
  349. <if test="dsDeptIds != null">
  350. or b.dept_id in
  351. <foreach item="item" collection="dsDeptIds" separator="," open="(" close=")" index="">
  352. #{item}
  353. </foreach>
  354. </if>
  355. </trim>
  356. </if>
  357. </where>
  358. </select>
  359. </mapper>