MsgAlarmMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 left 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="startMonth != null and startMonth != 0">
  66. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  67. </if>
  68. <if test="endMonth != null and endMonth != 0">
  69. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  70. </if>
  71. <if test="alarmType != null and alarmType != ''">
  72. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  73. </if>
  74. <if test="userId != null and userId != ''">
  75. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  76. </if>
  77. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  78. </where>
  79. group by a.alarm_id
  80. </select>
  81. <resultMap id="AlarmStatisticDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDto">
  82. <id column="id" property="id"/>
  83. <result column="alarmId" property="alarmId"/>
  84. <result column="railwayName" property="railwayName"/>
  85. <result column="alarmTime" property="alarmTime"/>
  86. <result column="lineDir" property="lineDir"/>
  87. <result column="lineDirValue" property="lineDirValue"/>
  88. <result column="alarmType" property="alarmType"/>
  89. <result column="alarmTypeValue" property="alarmTypeValue"/>
  90. <result column="alarmMile" property="alarmMile"/>
  91. <result column="beginMile" property="beginMile"/>
  92. <result column="endMile" property="endMile"/>
  93. </resultMap>
  94. <select id="listDto" resultMap="AlarmStatisticDtoResult">
  95. SELECT
  96. a.alarm_id AS alarmId,
  97. a.alarm_time AS alarmTime,
  98. a.alarm_mile AS alarmMile,
  99. a.line_dir AS lineDir,
  100. a.alarm_type AS alarmType,
  101. c.railway_name AS railwayName,
  102. b.begin_mile AS beginMile,
  103. b.end_mile AS endMile
  104. FROM
  105. msg_alarm AS a left join
  106. base_camera_management AS b on a.camera_code=b.camera_code left join
  107. msg_web_push m on a.alarm_id = m.alarm_id left join
  108. base_railway_management c on b.railway_code=c.railway_code
  109. <where>
  110. <if test="railwayCode != null and railwayCode != ''">
  111. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  112. </if>
  113. <if test="startMonth != null and startMonth != 0">
  114. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  115. </if>
  116. <if test="endMonth != null and endMonth != 0">
  117. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  118. </if>
  119. <if test="alarmType != null and alarmType != ''">
  120. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  121. </if>
  122. <if test="userId != null and userId != ''">
  123. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  124. </if>
  125. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  126. </where>
  127. group by a.alarm_id
  128. </select>
  129. <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
  130. <id column="id" property="id"/>
  131. <result column="monthsta" property="monthsta"/>
  132. <result column="frequency" property="frequency"/>
  133. <result column="alarm_type" property="alarmType"/>
  134. </resultMap>
  135. <select id="listDtoMonth" resultMap="AlarmStatisticMonthDtoResult">
  136. SELECT p.monthsta,SUM(p.fre) as frequency
  137. from
  138. (SELECT
  139. MONTH(a.alarm_time) as monthsta,
  140. count(DISTINCT a.alarm_id) as fre
  141. FROM
  142. msg_alarm AS a left join
  143. base_camera_management AS b on a.camera_code=b.camera_code left join
  144. msg_web_push m on a.alarm_id = m.alarm_id left join
  145. base_railway_management c on b.railway_code=c.railway_code
  146. <where>
  147. <if test="railwayCode != null and railwayCode != ''">
  148. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  149. </if>
  150. <if test="startMonth != null and startMonth != 0">
  151. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  152. </if>
  153. <if test="endMonth != null and endMonth != 0">
  154. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  155. </if>
  156. <if test="alarmType != null and alarmType != ''">
  157. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  158. </if>
  159. <if test="userId != null and userId != ''">
  160. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  161. </if>
  162. and YEAR(a.alarm_time) = YEAR(SYSDATE())
  163. </where>
  164. group by a.alarm_id,MONTH(a.alarm_time)) AS p
  165. </select>
  166. <select id="selectCameraCode" parameterType="java.lang.String" resultType="java.util.Map">
  167. select is_lock isLock, max(alarm_time) from msg_alarm where camera_code = #{cameraCode}
  168. </select>
  169. <select id="selectByCameraCode" parameterType="java.lang.String" resultType="com.ozs.service.entity.MsgAlarm">
  170. select *, max(alarm_time) from msg_alarm where camera_code = #{cameraCode}
  171. </select>
  172. <select id="selectMsgAlarmList" resultType="com.ozs.service.entity.MsgAlarm"
  173. parameterType="com.ozs.service.entity.vo.MsgAlarmVo">
  174. SELECT
  175. a.alarm_id AS alarmId,
  176. a.alarm_time AS alarmTime,
  177. a.alarm_mile AS alarmMile,
  178. a.line_dir AS lineDir,
  179. a.alarm_type AS alarmType,
  180. a.camera_code AS cameraCode,
  181. a.id AS id,
  182. a.content AS content,
  183. a.alarm_confidence AS alarmConfidence,
  184. a.alarm_attr AS alarmAttr,
  185. a.image_url AS imageUrl,
  186. a.released_by AS releasedBy,
  187. a.is_lock AS isLock,
  188. a.released_time AS releasedTime
  189. FROM
  190. msg_alarm AS a join
  191. base_camera_management AS b on a.camera_code=b.camera_code
  192. <where>
  193. <if test="railwayCode != null and railwayCode != ''">
  194. and b.railway_code=#{railwayCode}
  195. </if>
  196. <if test="beginMile != null and beginMile != 0">
  197. and b.begin_mile &gt;=#{beginMile}
  198. </if>
  199. <if test="endMile != null and endMile != 0">
  200. and b.end_mile &lt;=#{endMile}
  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. <if test="alarmType != null and alarmType != 0">
  220. and a.alarm_type=#{alarmType}
  221. </if>
  222. <if test="alarmMile != null and alarmMile != 0">
  223. and a.alarm_mile=#{alarmMile}
  224. </if>
  225. <if test="isLock != null and isLock != 0">
  226. and a.is_lock=#{isLock}
  227. </if>
  228. <if test="beginAlarmTime != null and beginAlarmTime != ''">
  229. and date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginAlarmTime},'%Y-%m-%d %H:%i:%S')
  230. </if>
  231. <if test="endAlarmTime != null and endAlarmTime != ''">
  232. AND date_format(a.alarm_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endAlarmTime},'%Y-%m-%d %H:%i:%S')
  233. </if>
  234. </where>
  235. </select>
  236. </mapper>