MsgAlarmMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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="channel" property="channel"/>
  25. <result column="install_mile" property="installMile"/>
  26. <result column="begin_mile" property="beginMile"/>
  27. <result column="end_mile" property="endMile"/>
  28. <result column="install_longitude" property="installLongitude"/>
  29. <result column="install_latitude" property="installLatitude"/>
  30. </association>
  31. </resultMap>
  32. <select id="list" resultMap="AlarmStatisticVoResult">
  33. SELECT
  34. a.alarm_id ,
  35. a.camera_code ,
  36. a.alarm_time ,
  37. a.alarm_mile ,
  38. a.content ,
  39. a.alarm_confidence,
  40. a.line_dir ,
  41. a.alarm_type ,
  42. a.alarm_attr ,
  43. a.image_url ,
  44. a.released_by ,
  45. a.released_time,
  46. a.is_lock ,
  47. b.railway_code AS railway_code,
  48. b.channel AS channel,
  49. b.install_mile AS install_mile,
  50. b.begin_mile AS begin_mile,
  51. b.end_mile AS end_mile,
  52. b.install_longitude AS install_longitude,
  53. b.install_latitude AS install_latitude
  54. FROM
  55. msg_alarm AS a left join
  56. base_camera_management AS b on a.camera_code=b.camera_code left join
  57. msg_web_push m on a.alarm_id = m.alarm_id
  58. <where>
  59. <if test="railwayCode != null and railwayCode != ''">
  60. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  61. </if>
  62. <if test="startMonth != null and startMonth != 0">
  63. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  64. </if>
  65. <if test="endMonth != null and endMonth != 0">
  66. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  67. </if>
  68. <if test="alarmType != null and alarmType != ''">
  69. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  70. </if>
  71. <if test="userId != null and userId != ''">
  72. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  73. </if>
  74. </where>
  75. group by a.alarm_id
  76. </select>
  77. <select id="listMonth" resultMap="AlarmStatisticVoResult">
  78. SELECT
  79. a.alarm_id ,
  80. MONTH(a.alarm_time) as monthsta,
  81. count(DISTINCT a.alarm_id) as frequency,
  82. a.camera_code ,
  83. a.alarm_time ,
  84. a.alarm_mile ,
  85. a.content ,
  86. a.alarm_confidence,
  87. a.line_dir ,
  88. a.alarm_type ,
  89. a.alarm_attr ,
  90. a.image_url ,
  91. a.released_by ,
  92. a.released_time,
  93. a.is_lock ,
  94. b.railway_code AS railway_code,
  95. b.channel AS channel,
  96. b.install_mile AS install_mile,
  97. b.begin_mile AS begin_mile,
  98. b.end_mile AS end_mile,
  99. b.install_longitude AS install_longitude,
  100. b.install_latitude AS install_latitude
  101. FROM
  102. msg_alarm AS a left join
  103. base_camera_management AS b on a.camera_code=b.camera_code left join
  104. msg_web_push m on a.alarm_id = m.alarm_id
  105. <where>
  106. <if test="railwayCode != null and railwayCode != ''">
  107. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  108. </if>
  109. <if test="startMonth != null and startMonth != 0">
  110. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  111. </if>
  112. <if test="endMonth != null and endMonth != 0">
  113. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  114. </if>
  115. <if test="alarmType != null and alarmType != ''">
  116. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  117. </if>
  118. <if test="userId != null and userId != ''">
  119. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  120. </if>
  121. </where>
  122. group by a.alarm_id,MONTH(a.alarm_time)
  123. </select>
  124. <resultMap id="AlarmStatisticDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticDto">
  125. <id column="id" property="id"/>
  126. <result column="alarmId" property="alarmId"/>
  127. <result column="railwayName" property="railwayName"/>
  128. <result column="alarmTime" property="alarmTime"/>
  129. <result column="lineDir" property="lineDir"/>
  130. <result column="lineDirValue" property="lineDirValue"/>
  131. <result column="alarmType" property="alarmType"/>
  132. <result column="alarmTypeValue" property="alarmTypeValue"/>
  133. <result column="alarmMile" property="alarmMile"/>
  134. <result column="beginMile" property="beginMile"/>
  135. <result column="endMile" property="endMile"/>
  136. </resultMap>
  137. <select id="listDto" resultMap="AlarmStatisticDtoResult">
  138. SELECT
  139. a.alarm_id AS alarmId,
  140. a.alarm_time AS alarmTime,
  141. a.alarm_mile AS alarmMile,
  142. a.line_dir AS lineDir,
  143. a.alarm_type AS alarmType,
  144. c.railway_name AS railwayName,
  145. b.begin_mile AS beginMile,
  146. b.end_mile AS endMile
  147. FROM
  148. msg_alarm AS a left 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="startMonth != null and startMonth != 0">
  157. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  158. </if>
  159. <if test="endMonth != null and endMonth != 0">
  160. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  161. </if>
  162. <if test="alarmType != null and alarmType != ''">
  163. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  164. </if>
  165. <if test="userId != null and userId != ''">
  166. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  167. </if>
  168. </where>
  169. group by a.alarm_id
  170. </select>
  171. <resultMap id="AlarmStatisticMonthDtoResult" type="com.ozs.service.entity.vo.AlarmStatisticMonthDto">
  172. <id column="id" property="id"/>
  173. <result column="alarmId" property="alarmId"/>
  174. <result column="railwayName" property="railwayName"/>
  175. <result column="alarmType" property="alarmType"/>
  176. <result column="alarmTime" property="alarmTime"/>
  177. <result column="monthsta" property="monthsta"/>
  178. <result column="frequency" property="frequency"/>
  179. </resultMap>
  180. <select id="listDtoMonth" resultMap="AlarmStatisticMonthDtoResult">
  181. SELECT
  182. a.alarm_id AS alarmId,
  183. MONTH(a.alarm_time) as monthsta,
  184. count(DISTINCT a.alarm_id) as frequency,
  185. a.alarm_type AS alarmType,
  186. a.alarm_time AS alarmTime,
  187. c.railway_name AS railwayName
  188. FROM
  189. msg_alarm AS a left join
  190. base_camera_management AS b on a.camera_code=b.camera_code left join
  191. msg_web_push m on a.alarm_id = m.alarm_id left join
  192. base_railway_management c on b.railway_code=c.railway_code
  193. <where>
  194. <if test="railwayCode != null and railwayCode != ''">
  195. and UPPER(b.railway_code) like UPPER(CONCAT('%',#{railwayCode},'%'))
  196. </if>
  197. <if test="startMonth != null and startMonth != 0">
  198. <![CDATA[and MONTH(a.alarm_time) >=#{startMonth}]]>
  199. </if>
  200. <if test="endMonth != null and endMonth != 0">
  201. <![CDATA[and MONTH(a.alarm_time) <=#{endMonth}]]>
  202. </if>
  203. <if test="alarmType != null and alarmType != ''">
  204. and UPPER(a.alarm_type) like UPPER(CONCAT('%',#{alarmType},'%'))
  205. </if>
  206. <if test="userId != null and userId != ''">
  207. and UPPER(m.receive_by) like UPPER(CONCAT('%',#{userId},'%'))
  208. </if>
  209. </where>
  210. group by a.alarm_id,MONTH(a.alarm_time)
  211. </select>
  212. </mapper>