AlertMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.aqpt.mapper.AlertMapper">
  5. <resultMap id="AlertDtoResultMap" type="com.zhyc.xps.aqpt.dto.AlertDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--单位ID-->
  7. <result column="alert_id" property="alertId" jdbcType="BIGINT" /><!--预警ID-->
  8. <result column="alert_type_id" property="alertTypeId" jdbcType="BIGINT" />
  9. <result column="alert_title" property="alertTitle" jdbcType="VARCHAR" />
  10. <result column="alert_desc" property="alertDesc" jdbcType="VARCHAR" />
  11. <result column="alert_time" property="alertTime" jdbcType="TIMESTAMP"/>
  12. <result column="alert_source" property="alertSource" jdbcType="BIGINT" />
  13. <result column="alert_code" property="alertCode" jdbcType="VARCHAR" />
  14. <result column="alert_level" property="alertLevel" jdbcType="BIGINT" />
  15. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
  16. <result column="risk_point_title" property="riskPointTitle" jdbcType="VARCHAR" />
  17. <result column="handle_time" property="handleTime" jdbcType="TIMESTAMP"/>
  18. <result column="handle_act" property="handleAct" jdbcType="BIGINT" />
  19. <result column="status" property="status" jdbcType="BIGINT" />
  20. <result column="alert_reason" property="alertReason" jdbcType="VARCHAR" />
  21. <result column="handle_measure" property="handleMeasure" jdbcType="VARCHAR" />
  22. <result column="handle_group_id" property="handleGroupId" jdbcType="BIGINT" /><!--当前责任人部门ID-->
  23. <result column="handle_position_id" property="handlePositionId" jdbcType="BIGINT" /><!--当前责任人岗位ID-->
  24. <result column="handle_account_id" property="handleAccountId" jdbcType="BIGINT" /><!--当前责任人账号ID-->
  25. <result column="handle_group_name" property="handleGroupName" jdbcType="VARCHAR" /><!--当前责任人部门名称-->
  26. <result column="handle_position_name" property="handlePositionName" jdbcType="VARCHAR" /><!--当前责任人岗位名称-->
  27. <result column="handle_account_name" property="handleAccountName" jdbcType="VARCHAR" /><!--当前责任人账号名称-->
  28. <result column="wf_def_id" property="wfDefId" jdbcType="BIGINT" />
  29. <result column="wf_ins_id" property="wfInsId" jdbcType="BIGINT" />
  30. <result column="cur_activity_ins_id" property="curActivityInsId" jdbcType="BIGINT" />
  31. <result column="cur_activity_code" property="curActivityCode" jdbcType="VARCHAR" />
  32. <result column="cur_activity_title" property="curActivityTitle" jdbcType="VARCHAR" />
  33. <result column="cur_activity_begin_time" property="curActivityBeginTime" jdbcType="TIMESTAMP"/>
  34. <result column="cur_form_code" property="curFormCode" jdbcType="VARCHAR" />
  35. <result column="cur_group_id" property="curGroupId" jdbcType="BIGINT" />
  36. <result column="cur_position_id" property="curPositionId" jdbcType="BIGINT" />
  37. <result column="cur_account_id" property="curAccountId" jdbcType="BIGINT" />
  38. <result column="cur_group_name" property="curGroupName" jdbcType="VARCHAR" />
  39. <result column="cur_position_name" property="curPositionName" jdbcType="VARCHAR" />
  40. <result column="cur_account_name" property="curAccountName" jdbcType="VARCHAR" />
  41. </resultMap>
  42. <sql id="AlertDto_Cols">
  43. A.oc_id,
  44. A.alert_id,
  45. A.alert_type_id,
  46. A.alert_code,
  47. A.alert_desc,
  48. A.alert_title,
  49. A.alert_time,
  50. A.alert_source,
  51. A.alert_level,
  52. A.handle_time,
  53. A.handle_act,
  54. A.alert_reason,
  55. A.handle_measure,
  56. A.risk_point_id,
  57. G.risk_point_title,
  58. A.handle_account_id,
  59. A.handle_account_name,
  60. A.handle_position_id,
  61. A.handle_position_name,
  62. A.handle_group_id,
  63. A.handle_group_name,
  64. A.status,
  65. W.wf_def_id,
  66. W.wf_ins_id,
  67. W.cur_activity_title,
  68. W.cur_activity_code,
  69. W.cur_form_code,
  70. W.cur_activity_ins_id,
  71. W.cur_group_id,
  72. W.cur_activity_begin_time,
  73. W.cur_group_id,
  74. W.cur_group_name,
  75. W.cur_position_id,
  76. W.cur_position_name,
  77. W.cur_account_id,
  78. W.cur_account_name
  79. </sql>
  80. <!--基于ID查询-->
  81. <select id="getById" resultMap="AlertDtoResultMap">
  82. SELECT
  83. <include refid="AlertDto_Cols"/>
  84. FROM alert AS A
  85. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id )
  86. LEFT JOIN ent_risk_point AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.risk_point_id )
  87. LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.alert_id = W.wf_ins_id )
  88. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND A.deleted_flag = 0
  89. AND A.alert_id = #{alertId ,jdbcType=BIGINT}
  90. </select>
  91. <!--列表查询-->
  92. <select id="getByList" parameterType="java.util.Map" resultMap="AlertDtoResultMap">
  93. SELECT
  94. <include refid="AlertDto_Cols"/>
  95. FROM alert AS A
  96. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id )
  97. LEFT JOIN ent_risk_point AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.risk_point_id )
  98. LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.alert_id = W.wf_ins_id )
  99. WHERE A.oc_id = #{ocId, jdbcType=BIGINT} AND A.deleted_flag = 0
  100. <if test="alertId !=null">
  101. AND A.alert_id = #{alertId ,jdbcType=BIGINT}
  102. </if>
  103. <if test="keywords != null and keywords != ''">
  104. AND A.alert_title like "%"#{keywords}"%"
  105. </if>
  106. <if test="alertTypeId != null">
  107. AND A.alert_type_id = #{alertTypeId ,jdbcType=BIGINT}
  108. </if>
  109. <if test="status != null">
  110. AND A.status = #{status ,jdbcType=BIGINT}
  111. </if>
  112. <if test="alertTime != null">
  113. AND DATE_FORMAT(A.alert_time,'%Y-%m-%d') = #{alertTime}
  114. </if>
  115. <if test="year != null">
  116. AND YEAR(A.alert_time) = #{year}
  117. </if>
  118. <if test="month != null">
  119. AND MONTH(A.alert_time) = #{month}
  120. </if>
  121. <if test="startDate != null and endDate != null">
  122. AND A.alert_time BETWEEN #{startDate} and #{endDate}
  123. </if>
  124. <if test="nodeLeft != null and nodeRight != null">
  125. <![CDATA[
  126. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  127. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  128. ]]>
  129. </if>
  130. ORDER BY A.alert_time DESC
  131. </select>
  132. <!--分页查询-->
  133. <select id="getByPage" parameterType="java.util.Map" resultMap="AlertDtoResultMap">
  134. SELECT
  135. <include refid="AlertDto_Cols"/>
  136. FROM alert AS A
  137. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id )
  138. LEFT JOIN ent_risk_point AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.risk_point_id )
  139. LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.alert_id = W.wf_ins_id )
  140. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND A.deleted_flag = 0
  141. <if test="alertId !=null">
  142. AND A.alert_id = #{alertId ,jdbcType=BIGINT}
  143. </if>
  144. <if test="alertLevel != null">
  145. AND A.alert_level = #{alertLevel, jdbcType=BIGINT}
  146. </if>
  147. <if test="keywords != null and keywords != ''">
  148. AND A.alert_title like "%"#{keywords}"%"
  149. </if>
  150. <if test="alertTypeId != null">
  151. AND A.alert_type_id = #{alertTypeId ,jdbcType=BIGINT}
  152. </if>
  153. <if test="status != null">
  154. AND A.status = #{status ,jdbcType=BIGINT}
  155. </if>
  156. <if test="day != null">
  157. AND date_format(A.alert_time, '%Y-%m-%d') = #{day}
  158. </if>
  159. <if test="startDate != null and endDate != null">
  160. AND A.alert_time BETWEEN #{startDate} and #{endDate}
  161. </if>
  162. <if test="alertTime != null">
  163. AND DATE_FORMAT(A.alert_time,'%Y-%m-%d') = #{alertTime}
  164. </if>
  165. <if test="year != null">
  166. AND YEAR(A.alert_time) = #{year}
  167. </if>
  168. <if test="month != null">
  169. AND MONTH(A.alert_time) = #{month}
  170. </if>
  171. <if test="nodeLeft != null and nodeRight != null">
  172. <![CDATA[
  173. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  174. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  175. ]]>
  176. </if>
  177. ORDER BY A.alert_time DESC
  178. </select>
  179. <select id="getAlertByRiskPointId" resultType="com.zhyc.xps.aqpt.dto.AlertDto">
  180. select A.alert_id
  181. FROM alert AS A
  182. where A.deleted_flag=0
  183. <if test="ocId != null">
  184. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  185. </if>
  186. <if test="riskPointId !=null">
  187. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  188. </if>
  189. <if test="alertSource !=null">
  190. AND A.alert_source = #{alertSource ,jdbcType=BIGINT}
  191. </if>
  192. LIMIT 1
  193. </select>
  194. <!--Create-->
  195. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.Alert">
  196. INSERT INTO alert
  197. <trim prefix="(" suffix=")" suffixOverrides=",">
  198. <if test="ocId != null">
  199. oc_id,
  200. </if>
  201. <if test="alertId != null">
  202. alert_id,
  203. </if>
  204. <if test="alertTypeId != null">
  205. alert_type_id,
  206. </if>
  207. <if test="alertTitle != null and alertTitle!=''">
  208. alert_title,
  209. </if>
  210. <if test="alertDesc != null and alertDesc != ''">
  211. alert_desc,
  212. </if>
  213. <if test="status != null">
  214. status,
  215. </if>
  216. <if test="alertLevel != null">
  217. alert_level,
  218. </if>
  219. <if test="alertCode != null and alertCode != ''">
  220. alert_code,
  221. </if>
  222. <if test="alertTime != null">
  223. alert_time,
  224. </if>
  225. <if test="alertSource != null">
  226. alert_source,
  227. </if>
  228. <if test="riskPointId != null">
  229. risk_point_id,
  230. </if>
  231. <if test="handleTime != null">
  232. handle_time,
  233. </if>
  234. <if test="handleAct != null">
  235. handle_act,
  236. </if>
  237. <if test="alertReason != null">
  238. alert_reason,
  239. </if>
  240. <if test="handleMeasure != null">
  241. handle_measure,
  242. </if>
  243. <if test="handleGroupId != null">
  244. handle_group_id,
  245. </if>
  246. <if test="handlePositionId != null">
  247. handle_position_id,
  248. </if>
  249. <if test="handleAccountId != null">
  250. handle_account_id,
  251. </if>
  252. <if test="createdBy != null">
  253. created_by,
  254. </if>
  255. <if test="createdAt != null">
  256. created_at,
  257. </if>
  258. </trim>
  259. <trim prefix="values (" suffix=")" suffixOverrides=",">
  260. <if test="ocId != null">
  261. #{ocId ,jdbcType=BIGINT},
  262. </if>
  263. <if test="alertId != null">
  264. #{alertId ,jdbcType=BIGINT},
  265. </if>
  266. <if test="alertTypeId != null">
  267. #{alertTypeId ,jdbcType=BIGINT},
  268. </if>
  269. <if test="alertTitle != null and alertTitle!=''">
  270. #{alertTitle ,jdbcType=VARCHAR},
  271. </if>
  272. <if test="alertDesc != null and alertDesc != ''">
  273. #{alertDesc ,jdbcType=VARCHAR},
  274. </if>
  275. <if test="status != null">
  276. #{status ,jdbcType=BIGINT},
  277. </if>
  278. <if test="alertLevel != null">
  279. #{alertLevel ,jdbcType=BIGINT},
  280. </if>
  281. <if test="alertCode != null and alertCode != ''">
  282. #{alertCode ,jdbcType=VARCHAR},
  283. </if>
  284. <if test="alertTime != null">
  285. #{alertTime ,jdbcType=TIMESTAMP},
  286. </if>
  287. <if test="alertSource != null">
  288. #{alertSource ,jdbcType=BIGINT},
  289. </if>
  290. <if test="riskPointId != null">
  291. #{riskPointId ,jdbcType=BIGINT},
  292. </if>
  293. <if test="handleTime != null">
  294. #{handleTime ,jdbcType=TIMESTAMP},
  295. </if>
  296. <if test="handleAct != null">
  297. #{handleAct ,jdbcType=BIGINT},
  298. </if>
  299. <if test="alertReason != null">
  300. #{alertReason ,jdbcType=VARCHAR},
  301. </if>
  302. <if test="handleMeasure != null">
  303. #{handleMeasure ,jdbcType=VARCHAR},
  304. </if>
  305. <if test="handleGroupId != null">
  306. #{handleGroupId ,jdbcType=BIGINT},
  307. </if>
  308. <if test="handlePositionId != null">
  309. #{handlePositionId ,jdbcType=BIGINT},
  310. </if>
  311. <if test="handleAccountId != null">
  312. #{handleAccountId ,jdbcType=BIGINT},
  313. </if>
  314. <if test="createdBy != null">
  315. #{createdBy ,jdbcType=BIGINT},
  316. </if>
  317. <if test="createdAt != null">
  318. #{createdAt ,jdbcType=TIMESTAMP},
  319. </if>
  320. </trim>
  321. </insert>
  322. <!--更新-->
  323. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.Alert">
  324. UPDATE alert
  325. <trim suffixOverrides=",">
  326. <set>
  327. <if test="alertTypeId != null">
  328. alert_type_id = #{alertTypeId ,jdbcType=BIGINT},
  329. </if>
  330. <if test="alertTitle != null">
  331. alert_title =#{alertTitle ,jdbcType=VARCHAR},
  332. </if>
  333. <if test="alertDesc != null and alertDesc != ''">
  334. alert_desc = #{alertDesc ,jdbcType=VARCHAR},
  335. </if>
  336. <if test="status != null">
  337. status = #{status ,jdbcType=BIGINT},
  338. </if>
  339. <if test="alertLevel != null">
  340. alert_level = #{alertLevel ,jdbcType=BIGINT},
  341. </if>
  342. <if test="alertCode != null and alertCode != ''">
  343. alert_code = #{alertCode ,jdbcType=VARCHAR},
  344. </if>
  345. <if test="alertTime != null">
  346. alert_time = #{alertTime ,jdbcType=TIMESTAMP},
  347. </if>
  348. <if test="alertSource != null">
  349. alert_source = #{alertSource ,jdbcType=BIGINT},
  350. </if>
  351. <if test="riskPointId != null">
  352. risk_point_id = #{riskPointId ,jdbcType=BIGINT},
  353. </if>
  354. <if test="handleTime != null">
  355. handle_time = #{handleTime ,jdbcType=TIMESTAMP},
  356. </if>
  357. <if test="handleAct != null">
  358. handle_act = #{handleAct ,jdbcType=BIGINT},
  359. </if>
  360. <if test="alertReason != null">
  361. handle_reason = #{alertReason ,jdbcType=VARCHAR},
  362. </if>
  363. <if test="handleMeasure != null">
  364. handle_measure = #{handleMeasure ,jdbcType=VARCHAR},
  365. </if>
  366. <if test="handleGroupId != null">
  367. handle_group_id = #{handleGroupId ,jdbcType=BIGINT},
  368. </if>
  369. <if test="handlePositionId != null">
  370. handle_position_id = #{handlePositionId ,jdbcType=BIGINT},
  371. </if>
  372. <if test="handleAccountId != null">
  373. handle_account_id = #{handleAccountId ,jdbcType=BIGINT},
  374. </if>
  375. <if test="updatedBy != null">
  376. updated_by = #{updatedBy ,jdbcType=BIGINT},
  377. </if>
  378. <if test="updatedAt != null">
  379. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  380. </if>
  381. </set>
  382. </trim>
  383. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND alert_id = #{alertId, jdbcType=BIGINT}
  384. </update>
  385. <!--删除 -->
  386. <update id="delete" parameterType="java.util.Map">
  387. UPDATE alert
  388. <trim suffixOverrides=",">
  389. <set>
  390. <if test="deletedBy != null">
  391. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  392. </if>
  393. <if test="deletedAt != null">
  394. deleted_at = #{deletedAt ,jdbcType=DATE},
  395. </if>
  396. <if test="deletedFlag != null">
  397. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  398. </if>
  399. </set>
  400. </trim>
  401. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND deleted_flag = 0
  402. <if test="alertId != null ">
  403. AND alert_id = #{alertId ,jdbcType=BIGINT}
  404. </if>
  405. </update>
  406. </mapper>