ChecklistHazardMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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.zhyc.xps.aqpt.mapper.ChecklistHazardMapper">
  4. <resultMap id="HazardDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardDto" >
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  7. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  8. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
  9. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR"/>
  10. <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR"/>
  11. <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR"/>
  12. <result column="hazard_cat_id" property="hazardCatId" jdbcType="BIGINT" />
  13. <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT" />
  14. <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR"/>
  15. <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT" />
  16. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  17. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  18. <result column="root_id" property="rootId" jdbcType="BIGINT" />
  19. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
  20. <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
  21. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
  22. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
  23. <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
  24. </resultMap>
  25. <sql id="HazardDto_Cols">
  26. A.oc_id,
  27. A.checklist_id,
  28. A.hazard_id,
  29. A.hazard_title,
  30. A.hazard_code,
  31. A.hazard_image,
  32. A.hazard_desc,
  33. B.hazard_type_title,
  34. A.hazard_type_id,
  35. A.hazard_level,
  36. A.parent_id,
  37. A.is_fixed,
  38. A.root_id,
  39. A.node_left,
  40. A.node_right,
  41. A.node_level,
  42. A.is_leaf,
  43. A.sort_no
  44. </sql>
  45. <!--根据ID获取信息-->
  46. <select id="getById" resultMap="HazardDtoMap">
  47. SELECT
  48. <include refid="HazardDto_Cols"/>
  49. FROM checklist_hazard AS A
  50. LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
  51. WHERE 1 = 1 AND A.deleted_flag = 0
  52. <if test="ocId != null">
  53. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  54. </if>
  55. <if test="checklistId != null">
  56. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  57. </if>
  58. <if test="hazardId != null">
  59. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  60. </if>
  61. </select>
  62. <!--根据ID获取信息-->
  63. <select id="getChecklistHazardById" resultMap="HazardDtoMap">
  64. SELECT
  65. <include refid="HazardDto_Cols"/>
  66. FROM checklist_hazard AS A
  67. LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
  68. WHERE 1 = 1 AND A.deleted_flag = 0
  69. <if test="checklistId != null">
  70. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  71. </if>
  72. <if test="hazardId != null">
  73. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  74. </if>
  75. </select>
  76. <!--分页查询角色信息-->
  77. <select id="getByPage" parameterType="java.util.Map" resultMap="HazardDtoMap">
  78. SELECT
  79. <include refid="HazardDto_Cols"/>
  80. FROM checklist_hazard AS A
  81. LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
  82. WHERE 1 = 1 AND A.deleted_flag = 0
  83. <if test="ocId != null">
  84. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  85. </if>
  86. <if test="keywords != null and keywords != ''">
  87. and A.hazard_title like "%"#{keywords}"%"
  88. </if>
  89. <if test="hazardTypeId != null">
  90. AND A.hazard_type_id = #{hazardTypeId ,jdbcType=BIGINT}
  91. </if>
  92. <if test="hazardLevel != null and hazardLevel > 0">
  93. AND A.hazard_level = #{hazardLevel ,jdbcType=BIGINT}
  94. </if>
  95. <if test="nodeLeft != null and nodeRight != null">
  96. <![CDATA[
  97. AND A.node_left > #{nodeLeft ,jdbcType=BIGINT}
  98. AND A.node_right < #{nodeRight ,jdbcType=BIGINT}
  99. ]]>
  100. </if>
  101. <if test="checklistId != null">
  102. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  103. </if>
  104. <if test="parentId != null and parentId > 0">
  105. AND A.parent_id = #{parentId ,jdbcType=BIGINT}
  106. </if>
  107. ORDER BY A.hazard_code ASC, A.sort_no ASC
  108. </select>
  109. <!-- Get List -->
  110. <select id="getByList" parameterType="java.util.Map" resultMap="HazardDtoMap">
  111. SELECT
  112. <include refid="HazardDto_Cols"/>
  113. FROM checklist_hazard AS A
  114. LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
  115. WHERE 1 = 1 AND A.deleted_flag = 0
  116. <if test="ocId != null">
  117. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  118. </if>
  119. <if test="keywords != null and keywords != ''">
  120. and A.hazard_title like "%"#{keywords}"%"
  121. </if>
  122. <if test="hazardTypeId != null">
  123. AND A.hazard_type_id = #{hazardTypeId ,jdbcType=BIGINT}
  124. </if>
  125. <if test="hazardLevel != null and hazardLevel > 0">
  126. AND A.hazard_level = #{hazardLevel ,jdbcType=BIGINT}
  127. </if>
  128. <if test="nodeLeft != null and nodeRight != null">
  129. <![CDATA[
  130. AND A.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  131. AND A.node_right <= #{nodeRight ,jdbcType=BIGINT}
  132. ]]>
  133. </if>
  134. <if test="ctrlLevelId != null">
  135. AND EXISTS (
  136. SELECT
  137. *
  138. FROM checklist_hazard_risk AS C
  139. WHERE C.deleted_flag = 0
  140. AND A.oc_id = C.oc_id
  141. AND A.checklist_id = C.checklist_id
  142. AND A.hazard_id = C.hazard_id
  143. <![CDATA[
  144. AND C.ctrl_level_id <= #{ctrlLevelId ,jdbcType=BIGINT}
  145. ]]>
  146. )
  147. </if>
  148. <if test="riskPointId != null">
  149. AND EXISTS (
  150. SELECT
  151. *
  152. FROM ent_risk_point_hazard AS D
  153. WHERE D.deleted_flag = 0
  154. AND A.oc_id = D.oc_id
  155. AND A.checklist_id = D.checklist_id
  156. AND A.hazard_id = D.hazard_id
  157. AND D.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  158. )
  159. </if>
  160. <if test="waitingTaskId != null">
  161. AND EXISTS (
  162. SELECT
  163. *
  164. FROM check_task_doing AS D
  165. WHERE 1 = 1
  166. AND A.oc_id = D.oc_id
  167. AND A.hazard_id = D.hazard_id
  168. AND D.task_id = #{waitingTaskId ,jdbcType=BIGINT}
  169. )
  170. </if>
  171. <if test="handledTaskId != null">
  172. AND EXISTS (
  173. SELECT
  174. *
  175. FROM check_record AS D
  176. WHERE 1 = 1
  177. AND A.oc_id = D.oc_id
  178. AND A.hazard_id = D.hazard_id
  179. AND D.task_id = #{handledTaskId ,jdbcType=BIGINT}
  180. )
  181. </if>
  182. <if test="checklistId != null">
  183. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  184. </if>
  185. <if test="parentId != null and parentId > 0">
  186. AND A.parent_id = #{parentId ,jdbcType=BIGINT}
  187. </if>
  188. ORDER BY A.hazard_code ASC, A.sort_no ASC
  189. </select>
  190. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazard">
  191. INSERT INTO checklist_hazard
  192. <trim prefix="(" suffix=")" suffixOverrides=",">
  193. <if test="ocId != null">
  194. oc_id,
  195. </if>
  196. <if test="checklistId != null">
  197. checklist_id,
  198. </if>
  199. <if test="hazardId != null">
  200. hazard_id,
  201. </if>
  202. <if test="hazardTitle != null and hazardTitle != ''">
  203. hazard_title,
  204. </if>
  205. <if test="hazardCode != null and hazardCode != ''">
  206. hazard_code,
  207. </if>
  208. <if test="hazardImage != null and hazardImage != ''">
  209. hazard_image,
  210. </if>
  211. <if test="hazardDesc != null and hazardDesc != ''">
  212. hazard_desc,
  213. </if>
  214. <if test="hazardCatId != null">
  215. hazard_cat_id,
  216. </if>
  217. <if test="hazardTypeId != null">
  218. hazard_type_id,
  219. </if>
  220. <if test="isFixed != null">
  221. is_fixed,
  222. </if>
  223. <if test="parentId != null">
  224. parent_id,
  225. </if>
  226. <if test="rootId != null">
  227. root_id,
  228. </if>
  229. <if test="nodeLeft != null">
  230. node_left,
  231. </if>
  232. <if test="nodeRight != null">
  233. node_right,
  234. </if>
  235. <if test="nodeLevel != null">
  236. node_level,
  237. </if>
  238. <if test="isLeaf != null">
  239. is_leaf,
  240. </if>
  241. <if test="sortNo != null">
  242. sort_no,
  243. </if>
  244. <if test="createdBy != null">
  245. created_by,
  246. </if>
  247. <if test="createdAt != null">
  248. created_at,
  249. </if>
  250. </trim>
  251. <trim prefix="values (" suffix=")" suffixOverrides=",">
  252. <if test="ocId != null">
  253. #{ocId ,jdbcType=BIGINT},
  254. </if>
  255. <if test="checklistId != null">
  256. #{checklistId ,jdbcType=BIGINT},
  257. </if>
  258. <if test="hazardId != null">
  259. #{hazardId ,jdbcType=BIGINT},
  260. </if>
  261. <if test="hazardTitle != null and hazardTitle != ''">
  262. #{hazardTitle ,jdbcType=VARCHAR},
  263. </if>
  264. <if test="hazardCode != null and hazardCode != ''">
  265. #{hazardCode ,jdbcType=VARCHAR},
  266. </if>
  267. <if test="hazardImage != null and hazardImage != ''">
  268. #{hazardImage ,jdbcType=VARCHAR},
  269. </if>
  270. <if test="hazardDesc != null and hazardDesc != ''">
  271. #{hazardDesc ,jdbcType=VARCHAR},
  272. </if>
  273. <if test="hazardCatId != null">
  274. #{hazardCatId ,jdbcType=BIGINT},
  275. </if>
  276. <if test="hazardTypeId != null">
  277. #{hazardTypeId ,jdbcType=BIGINT},
  278. </if>
  279. <if test="isFixed != null">
  280. #{isFixed ,jdbcType=BIGINT},
  281. </if>
  282. <if test="parentId != null">
  283. #{parentId ,jdbcType=BIGINT},
  284. </if>
  285. <if test="rootId != null">
  286. #{rootId ,jdbcType=BIGINT},
  287. </if>
  288. <if test="nodeLeft != null">
  289. #{nodeLeft ,jdbcType=BIGINT},
  290. </if>
  291. <if test="nodeRight != null">
  292. #{nodeRight ,jdbcType=BIGINT},
  293. </if>
  294. <if test="nodeLevel != null">
  295. #{nodeLevel ,jdbcType=BIGINT},
  296. </if>
  297. <if test="isLeaf != null">
  298. #{isLeaf ,jdbcType=BIGINT},
  299. </if>
  300. <if test="sortNo != null">
  301. #{sortNo ,jdbcType=BIGINT},
  302. </if>
  303. <if test="createdBy != null">
  304. #{createdBy ,jdbcType=BIGINT},
  305. </if>
  306. <if test="createdAt != null">
  307. #{createdAt ,jdbcType=TIMESTAMP},
  308. </if>
  309. </trim>
  310. </insert>
  311. <!--更新-->
  312. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazard">
  313. UPDATE checklist_hazard
  314. <trim suffixOverrides=",">
  315. <set>
  316. <if test="hazardTitle != null and hazardTitle != ''">
  317. hazard_title = #{hazardTitle, jdbcType=VARCHAR},
  318. </if>
  319. <if test="hazardCode != null and hazardCode != ''">
  320. hazard_code = #{hazardCode, jdbcType=VARCHAR},
  321. </if>
  322. <if test="hazardImage != null and hazardImage != ''">
  323. hazard_image = #{hazardImage, jdbcType=VARCHAR},
  324. </if>
  325. <if test="hazardDesc != null and hazardDesc != ''">
  326. hazard_desc = #{hazardDesc, jdbcType=VARCHAR},
  327. </if>
  328. <if test="hazardCatId != null ">
  329. hazard_cat_id = #{hazardCatId, jdbcType=BIGINT},
  330. </if>
  331. <if test="isLeaf != null">
  332. is_leaf = #{isLeaf ,jdbcType=BIGINT},
  333. </if>
  334. <if test="sortNo != null">
  335. sort_no = #{sortNo ,jdbcType=BIGINT},
  336. </if>
  337. <if test="updatedBy != null ">
  338. updated_by = #{updatedBy ,jdbcType=BIGINT},
  339. </if>
  340. <if test="updatedAt != null">
  341. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  342. </if>
  343. </set>
  344. </trim>
  345. WHERE 1 = 1
  346. <if test="ocId != null">
  347. AND oc_id = #{ocId ,jdbcType=BIGINT}
  348. </if>
  349. <if test="checklistId != null">
  350. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  351. </if>
  352. <if test="hazardId != null">
  353. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  354. </if>
  355. </update>
  356. <!--删除-->
  357. <update id="delete" parameterType="java.util.Map">
  358. UPDATE checklist_hazard
  359. <trim suffixOverrides=",">
  360. <set>
  361. <if test="deletedFlag != null">
  362. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  363. </if>
  364. <if test="deletedTime != null">
  365. deleted_time = #{deletedTime ,jdbcType=DATE},
  366. </if>
  367. <if test="deletedBy != null">
  368. deleted_by = #{deletedBy,jdbcType=BIGINT},
  369. </if>
  370. </set>
  371. </trim>
  372. WHERE 1 = 1
  373. <if test="ocId != null">
  374. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  375. </if>
  376. <if test="checklistId != null">
  377. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  378. </if>
  379. <if test="hazardId != null">
  380. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  381. </if>
  382. <if test="nodeLeft != null and nodeRight != null">
  383. <![CDATA[
  384. AND node_left >= #{nodeLeft ,jdbcType=BIGINT}
  385. AND node_right <= #{nodeRight ,jdbcType=BIGINT}
  386. ]]>
  387. </if>
  388. </update>
  389. </mapper>