TEarlyWarningMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.TEarlyWarningMapper">
  6. <resultMap type="TEarlyWarning" id="TEarlyWarningResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="state" column="state"/>
  10. <result property="type" column="type"/>
  11. <result property="content" column="content"/>
  12. <result property="eventRecord" column="event_record"/>
  13. <result property="location" column="location"/>
  14. <result property="lng" column="lng"/>
  15. <result property="lat" column="lat"/>
  16. <result property="createTime" column="create_time"/>
  17. <result property="updateTime" column="update_time"/>
  18. <result property="facilityId" column="facility_id"/>
  19. <result property="deviceIdCode" column="device_id_code"/>
  20. <result property="alarmId" column="alarm_id"/>
  21. <result property="typeDesc" column="type_desc" />
  22. </resultMap>
  23. <sql id="selectTEarlyWarningVo">
  24. select id,
  25. user_id,
  26. state,
  27. type,
  28. content,
  29. event_record,
  30. location,
  31. lng,
  32. lat,
  33. create_time,
  34. update_time,
  35. facility_id,
  36. device_id_code,
  37. alarm_id,
  38. type_desc
  39. from t_early_warning
  40. </sql>
  41. <select id="selectTEarlyWarningByAlarmId" parameterType="long" resultMap="TEarlyWarningResult">
  42. <include refid="selectTEarlyWarningVo"/>
  43. where alarm_id = #{alarmId}
  44. </select>
  45. <select id="selectTEarlyWarningList" parameterType="TEarlyWarning" resultMap="TEarlyWarningResult">
  46. <include refid="selectTEarlyWarningVo"/>
  47. <where>
  48. <if test="userId != null ">and user_id = #{userId}</if>
  49. <if test="state != null ">and state = #{state}</if>
  50. <if test="type != null ">and type = #{type}</if>
  51. <if test="content != null and content != ''">and content = #{content}</if>
  52. <if test="eventRecord != null and eventRecord != ''">and event_record = #{eventRecord}</if>
  53. <if test="location != null and location != ''">and location = #{location}</if>
  54. <if test="lng != null ">and lng = #{lng}</if>
  55. <if test="lat != null ">and lat = #{lat}</if>
  56. <if test="facilityId != null ">and facility_id = #{facilityId}</if>
  57. <if test="deviceIdCode != null and deviceIdCode != ''">and device_id_code = #{deviceIdCode}</if>
  58. <if test="alarmId != null ">and alarm_id = #{alarmId}</if>
  59. <if test="typeDesc != null and typeDesc != ''"> and type_desc = #{typeDesc}</if>
  60. </where>
  61. </select>
  62. <select id="selectTEarlyWarningById" parameterType="Long" resultMap="TEarlyWarningResult">
  63. <include refid="selectTEarlyWarningVo"/>
  64. where id = #{id}
  65. </select>
  66. <select id="selectTEarlyWarningList_SOS" resultType="com.ruoyi.system.domain.TEarlyWarning">
  67. select a.id,
  68. a.user_id,
  69. a.state,
  70. a.state as solve_status,
  71. a.type,
  72. a.type as alarm_type,
  73. a.content ,
  74. a.event_record,
  75. a.event_record as msg,
  76. a.location,
  77. a.location as address_desc,
  78. a.lng,
  79. a.lat,
  80. a.lng as gps_long,
  81. a.lat as gps_lat,
  82. a.create_time as createTime,
  83. a.update_time,
  84. a.facility_id,
  85. a.device_id_code,
  86. a.device_id_code as deviceIdCode,
  87. a.alarm_id,
  88. a.type_desc as typeDesc,
  89. a.type_desc as alarmMsg,
  90. b.name,
  91. b.tel_one,
  92. c.id as service_id,
  93. c.store_name,
  94. d.device_model
  95. from t_early_warning a
  96. left join t_user_profile b on a.user_id = b.id
  97. left join t_service_manage c on b.serviceid = c.id
  98. left join t_device_list d on a.device_id_code = d.device_id
  99. <where>
  100. <if test="type != null ">and a.type = #{type}</if>
  101. <if test="name != null ">and b.name = #{name}</if>
  102. <if test="solve_status != null ">and a.state = #{solve_status}</if>
  103. </where>
  104. </select>
  105. <select id="selectTEarlyWarningList_HEALTHSOLVE" resultType="com.ruoyi.system.domain.TEarlyWarning">
  106. select a.id,
  107. a.user_id,
  108. a.state,
  109. a.state as solve_status,
  110. a.type,
  111. a.type as alarm_type,
  112. a.content as alarmMsg,
  113. a.event_record,
  114. a.event_record as msg,
  115. a.location,
  116. a.location as address_desc,
  117. a.lng,
  118. a.lat,
  119. a.lng as gps_long,
  120. a.lat as gps_lat,
  121. a.create_time as createTime,
  122. a.update_time,
  123. a.facility_id,
  124. a.device_id_code,
  125. a.device_id_code as deviceIdCode,
  126. a.alarm_id,
  127. a.type_desc,
  128. b.name,
  129. b.tel_one,
  130. c.id as service_id,
  131. c.store_name,
  132. d.device_model
  133. from t_early_warning a
  134. left join t_user_profile b on a.user_id = b.id
  135. left join t_service_manage c on b.serviceid = c.id
  136. left join t_device_list d on a.device_id_code = d.device_id
  137. <where>
  138. and a.type &gt;= 22
  139. and a.type &lt;= 25
  140. <if test="name != null ">and b.name = #{name}</if>
  141. <if test="solve_status != null ">and a.state = #{solve_status}</if>
  142. </where>
  143. </select>
  144. <select id="selectTEarlyWarningList_OTHERSOLVE" resultType="com.ruoyi.system.domain.TEarlyWarning">
  145. select a.id,
  146. a.user_id,
  147. a.state,
  148. a.state as solve_status,
  149. a.type,
  150. a.type as alarm_type,
  151. a.content as alarmMsg,
  152. a.event_record,
  153. a.event_record as msg,
  154. a.location,
  155. a.location as address_desc,
  156. a.lng,
  157. a.lat,
  158. a.lng as gps_long,
  159. a.lat as gps_lat,
  160. a.create_time as createTime,
  161. a.update_time,
  162. a.facility_id,
  163. a.device_id_code,
  164. a.device_id_code as deviceIdCode,
  165. a.alarm_id,
  166. a.type_desc,
  167. b.name,
  168. b.tel_one,
  169. c.id as service_id,
  170. c.store_name,
  171. d.device_model
  172. from t_early_warning a
  173. left join t_user_profile b on a.user_id = b.id
  174. left join t_service_manage c on b.serviceid = c.id
  175. left join t_device_list d on a.device_id_code = d.device_id
  176. <where>
  177. and a.type != 16
  178. and a.type != 21
  179. and a.type != 22
  180. and a.type != 23
  181. and a.type != 24
  182. and a.type != 25
  183. <if test="name != null ">and b.name = #{name}</if>
  184. <if test="solve_status != null ">and a.state = #{solve_status}</if>
  185. </where>
  186. </select>
  187. <select id="selectTEarlyWarningCompletedCountByType" parameterType="Integer" resultType="java.lang.Integer">
  188. SELECT COUNT(*)
  189. FROM t_early_warning
  190. WHERE type = #{type}
  191. AND state = 1;
  192. </select>
  193. <select id="selectTEarlyWarningUnCompletedCountByType" parameterType="Integer" resultType="java.lang.Integer">
  194. SELECT COUNT(*)
  195. FROM t_early_warning
  196. WHERE type = #{type}
  197. AND state = 0;
  198. </select>
  199. <select id="selectTEarlyWarningUnCompletedPercentageByType" parameterType="Integer" resultType="java.lang.Double">
  200. SELECT (COUNT(CASE WHEN state = 1 THEN 0 END) / COUNT(*) * 100)
  201. FROM t_early_warning
  202. WHERE type = #{type}
  203. </select>
  204. <select id="selectTEarlyWarningUnCompletedPercentageByAllType" resultType="java.lang.Double">
  205. SELECT (COUNT(CASE WHEN state = 1 THEN 0 END) / COUNT(*) * 100)
  206. FROM t_early_warning
  207. </select>
  208. <insert id="insertTEarlyWarning" parameterType="TEarlyWarning" useGeneratedKeys="true" keyProperty="id">
  209. insert into t_early_warning
  210. <trim prefix="(" suffix=")" suffixOverrides=",">
  211. <if test="userId != null">user_id,</if>
  212. <if test="state != null">state,</if>
  213. <if test="type != null">type,</if>
  214. <if test="content != null">content,</if>
  215. <if test="eventRecord != null">event_record,</if>
  216. <if test="location != null">location,</if>
  217. <if test="lng != null">lng,</if>
  218. <if test="lat != null">lat,</if>
  219. <if test="createTime != null">create_time,</if>
  220. <if test="updateTime != null">update_time,</if>
  221. <if test="facilityId != null">facility_id,</if>
  222. <if test="deviceIdCode != null">device_id_code,</if>
  223. <if test="alarmId != null">alarm_id,</if>
  224. <if test="typeDesc != null">type_desc,</if>
  225. </trim>
  226. <trim prefix="values (" suffix=")" suffixOverrides=",">
  227. <if test="userId != null">#{userId},</if>
  228. <if test="state != null">#{state},</if>
  229. <if test="type != null">#{type},</if>
  230. <if test="content != null">#{content},</if>
  231. <if test="eventRecord != null">#{eventRecord},</if>
  232. <if test="location != null">#{location},</if>
  233. <if test="lng != null">#{lng},</if>
  234. <if test="lat != null">#{lat},</if>
  235. <if test="createTime != null">#{createTime},</if>
  236. <if test="updateTime != null">#{updateTime},</if>
  237. <if test="facilityId != null">#{facilityId},</if>
  238. <if test="deviceIdCode != null">#{deviceIdCode},</if>
  239. <if test="alarmId != null">#{alarmId},</if>
  240. <if test="typeDesc != null">#{typeDesc},</if>
  241. </trim>
  242. </insert>
  243. <update id="updateTEarlyWarning" parameterType="TEarlyWarning">
  244. update t_early_warning
  245. <trim prefix="SET" suffixOverrides=",">
  246. <if test="userId != null">user_id = #{userId},</if>
  247. <if test="state != null">state = #{state},</if>
  248. <if test="type != null">type = #{type},</if>
  249. <if test="content != null">content = #{content},</if>
  250. <if test="eventRecord != null">event_record = #{eventRecord},</if>
  251. <if test="location != null">location = #{location},</if>
  252. <if test="lng != null">lng = #{lng},</if>
  253. <if test="lat != null">lat = #{lat},</if>
  254. <if test="createTime != null">create_time = #{createTime},</if>
  255. <if test="updateTime != null">update_time = #{updateTime},</if>
  256. <if test="facilityId != null">facility_id = #{facilityId},</if>
  257. <if test="deviceIdCode != null">device_id_code = #{deviceIdCode},</if>
  258. <if test="alarmId != null">alarm_id = #{alarmId},</if>
  259. <if test="typeDesc != null">type_desc = #{typeDesc},</if>
  260. </trim>
  261. where id = #{id}
  262. </update>
  263. <delete id="deleteTEarlyWarningById" parameterType="Long">
  264. delete
  265. from t_early_warning
  266. where id = #{id}
  267. </delete>
  268. <delete id="deleteTEarlyWarningByIds" parameterType="String">
  269. delete from t_early_warning where id in
  270. <foreach item="id" collection="array" open="(" separator="," close=")">
  271. #{id}
  272. </foreach>
  273. </delete>
  274. </mapper>