ChecklistHazardRiskMeasureMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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.ChecklistHazardRiskMeasureMapper">
  4. <resultMap id="BaseResultMap" type="com.zhyc.xps.aqpt.entity.ChecklistHazardRiskMeasure">
  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="risk_id" property="riskId" jdbcType="BIGINT"/>
  9. <result column="measure_id" property="measureId" jdbcType="BIGINT"/>
  10. <result column="measure_content" property="measureContent" jdbcType="VARCHAR"/>
  11. <result column="measure_reference" property="measureReference" jdbcType="VARCHAR"/>
  12. <result column="measure_desc" property="measureDesc" jdbcType="VARCHAR"/>
  13. <result column="measure_type_id" property="measureTypeId" jdbcType="BIGINT"/>
  14. </resultMap>
  15. <resultMap id="RiskMeasureDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardRiskMeasureDto" extends="BaseResultMap">
  16. <result column="measure_type_title" property="measureTypeTitle" jdbcType="VARCHAR"/>
  17. </resultMap>
  18. <resultMap id="ChecklistDetailsDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistDetailsDto" extends="RiskMeasureDtoMap">
  19. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
  20. <result column="risk_code" property="riskCode" jdbcType="VARCHAR"/>
  21. <result column="risk_source" property="riskSource" jdbcType="VARCHAR"/>
  22. <result column="risk_reason" property="riskReason" jdbcType="VARCHAR"/>
  23. <result column="risk_consequence" property="riskConsequence" jdbcType="VARCHAR"/>
  24. <result column="risk_level" property="riskLevel" jdbcType="BIGINT" />
  25. <result column="ctrl_level_title" property="ctrlLevelTitle" jdbcType="VARCHAR"/>
  26. <result column="measure_type_title" property="measureTypeTitle" jdbcType="VARCHAR"/>
  27. </resultMap>
  28. <sql id="RiskMeasureDto_Cols">
  29. A.oc_id,
  30. A.checklist_id,
  31. A.hazard_id,
  32. A.risk_id,
  33. A.measure_id,
  34. A.measure_content,
  35. A.measure_desc,
  36. A.measure_type_id,
  37. B.measure_type_title,
  38. A.measure_reference
  39. </sql>
  40. <!--根据ID获取信息-->
  41. <select id="getById" resultMap="RiskMeasureDtoMap">
  42. SELECT
  43. <include refid="RiskMeasureDto_Cols"/>
  44. FROM checklist_hazard_risk_measure AS A
  45. LEFT JOIN measure_type AS B ON(A.measure_type_id = B.measure_type_id)
  46. WHERE 1 = 1 AND A.deleted_flag = 0
  47. <if test="ocId != null">
  48. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  49. </if>
  50. <if test="checklistId != null">
  51. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  52. </if>
  53. <if test="hazardId != null">
  54. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  55. </if>
  56. <if test="riskId != null">
  57. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  58. </if>
  59. <if test="measureId != null">
  60. AND A.measure_id = #{measureId ,jdbcType=BIGINT}
  61. </if>
  62. </select>
  63. <!--分页查询信息-->
  64. <select id="getByPage" parameterType="java.util.Map" resultMap="RiskMeasureDtoMap">
  65. SELECT
  66. <include refid="RiskMeasureDto_Cols"/>
  67. FROM checklist_hazard_risk_measure AS A
  68. LEFT JOIN measure_type AS B ON(A.measure_type_id = B.measure_type_id)
  69. WHERE 1 = 1 AND A.deleted_flag = 0
  70. <if test="ocId != null">
  71. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  72. </if>
  73. <if test="checklistId != null">
  74. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  75. </if>
  76. <if test="hazardId != null">
  77. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  78. </if>
  79. <if test="riskId != null">
  80. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  81. </if>
  82. <if test="keywords != null and keywords != ''">
  83. AND A.measure_content like "%"#{keywords}"%"
  84. </if>
  85. ORDER BY A.measure_id ASC
  86. </select>
  87. <select id="getByList" parameterType="java.util.Map" resultMap="RiskMeasureDtoMap">
  88. SELECT
  89. <include refid="RiskMeasureDto_Cols"/>
  90. FROM checklist_hazard_risk_measure AS A
  91. LEFT JOIN measure_type AS B ON(A.measure_type_id = B.measure_type_id)
  92. WHERE A.deleted_flag = 0
  93. <if test="ocId != null">
  94. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  95. </if>
  96. <if test="checklistId != null">
  97. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  98. </if>
  99. <if test="hazardId != null">
  100. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  101. </if>
  102. <if test="riskId != null">
  103. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  104. </if>
  105. <if test="keywords != null and keywords != ''">
  106. AND A.measure_content like "%"#{keywords}"%"
  107. </if>
  108. <if test="ctrlLevelId != null">
  109. AND EXISTS (
  110. SELECT
  111. *
  112. FROM checklist_hazard_risk AS C
  113. WHERE C.deleted_flag = 0
  114. AND A.oc_id = C.oc_id
  115. AND A.checklist_id = C.checklist_id
  116. AND A.hazard_id = C.hazard_id
  117. AND A.risk_id = C.risk_id
  118. <![CDATA[
  119. AND C.ctrl_level_id <= #{ctrlLevelId ,jdbcType=BIGINT}
  120. ]]>
  121. )
  122. </if>
  123. <if test="riskPointId != null">
  124. AND EXISTS (
  125. SELECT
  126. *
  127. FROM ent_risk_point_hazard AS D
  128. WHERE D.deleted_flag = 0
  129. AND A.oc_id = D.oc_id
  130. AND A.checklist_id = D.checklist_id
  131. AND A.hazard_id = D.hazard_id
  132. AND D.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  133. )
  134. </if>
  135. ORDER BY A.measure_id ASC
  136. </select>
  137. <!--检查表预览-->
  138. <select id="getChecklistDataById" resultMap="ChecklistDetailsDtoMap" >
  139. SELECT
  140. A.checklist_id,
  141. A.hazard_id,
  142. B.hazard_title,
  143. A.risk_id,
  144. C.risk_code,
  145. C.risk_source,
  146. C.risk_reason,
  147. C.risk_consequence,
  148. C.risk_level,
  149. C.ctrl_level_id,
  150. D.ctrl_level_title,
  151. A.measure_id,
  152. E.measure_type_title,
  153. A.measure_content,
  154. A.measure_reference,
  155. A.measure_desc
  156. FROM checklist_hazard_risk_measure A
  157. LEFT JOIN checklist_hazard B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  158. LEFT JOIN checklist_hazard_risk C ON ( A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id )
  159. LEFT JOIN ent_ctrl_level D ON ( C.oc_id = D.oc_id AND C.ctrl_level_id = D.ctrl_level_id )
  160. LEFT JOIN measure_type E ON ( A.measure_type_id = E.measure_type_id)
  161. WHERE A.deleted_flag = 0
  162. <if test="ocId != null">
  163. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  164. </if>
  165. <if test="checklistId !=null">
  166. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  167. </if>
  168. ORDER BY A.checklist_id, A.hazard_id, A.risk_id, A.measure_type_id
  169. </select>
  170. <!--检查表预览-->
  171. <select id="getChecklistDataByCtrlLevel" resultMap="ChecklistDetailsDtoMap" >
  172. SELECT
  173. A.checklist_id,
  174. A.hazard_id,
  175. B.hazard_title,
  176. A.risk_id,
  177. C.risk_code,
  178. C.risk_source,
  179. C.risk_reason,
  180. C.risk_consequence,
  181. C.risk_level,
  182. C.ctrl_level_id,
  183. D.ctrl_level_title,
  184. A.measure_id,
  185. E.measure_type_title,
  186. A.measure_content,
  187. A.measure_reference,
  188. A.measure_desc
  189. FROM checklist_hazard_risk_measure A
  190. LEFT JOIN checklist_hazard B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  191. LEFT JOIN checklist_hazard_risk C ON ( A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id )
  192. LEFT JOIN ent_ctrl_level D ON ( C.oc_id = D.oc_id AND C.ctrl_level_id = D.ctrl_level_id )
  193. LEFT JOIN measure_type E ON ( A.measure_type_id = E.measure_type_id)
  194. WHERE A.deleted_flag = 0
  195. <if test="ocId != null">
  196. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  197. </if>
  198. <if test="checklistId !=null">
  199. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  200. </if>
  201. <if test="ctrlLevelId !=null">
  202. AND C.ctrl_level_id &lt;= #{ctrlLevelId ,jdbcType=BIGINT}
  203. </if>
  204. ORDER BY A.checklist_id, A.hazard_id, A.risk_id, A.measure_type_id
  205. </select>
  206. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazardRiskMeasure">
  207. INSERT INTO checklist_hazard_risk_measure
  208. <trim prefix="(" suffix=")" suffixOverrides=",">
  209. <if test="ocId != null">
  210. oc_id,
  211. </if>
  212. <if test="checklistId != null">
  213. checklist_id,
  214. </if>
  215. <if test="hazardId != null">
  216. hazard_id,
  217. </if>
  218. <if test="riskId != null">
  219. risk_id,
  220. </if>
  221. <if test="measureId != null">
  222. measure_id,
  223. </if>
  224. <if test="measureContent != null">
  225. measure_content,
  226. </if>
  227. <if test="measureDesc != null">
  228. measure_desc,
  229. </if>
  230. <if test="measureReference != null">
  231. measure_reference,
  232. </if>
  233. <if test="measureTypeId != null">
  234. measure_type_id,
  235. </if>
  236. <if test="createdBy != null">
  237. created_by,
  238. </if>
  239. <if test="createdAt != null">
  240. created_at,
  241. </if>
  242. </trim>
  243. <trim prefix="values (" suffix=")" suffixOverrides=",">
  244. <if test="ocId != null">
  245. #{ocId ,jdbcType=BIGINT},
  246. </if>
  247. <if test="checklistId != null">
  248. #{checklistId ,jdbcType=BIGINT},
  249. </if>
  250. <if test="hazardId != null">
  251. #{hazardId ,jdbcType=BIGINT},
  252. </if>
  253. <if test="riskId != null">
  254. #{riskId ,jdbcType=BIGINT},
  255. </if>
  256. <if test="measureId != null">
  257. #{measureId ,jdbcType=BIGINT},
  258. </if>
  259. <if test="measureContent != null">
  260. #{measureContent ,jdbcType=VARCHAR},
  261. </if>
  262. <if test="measureDesc != null">
  263. #{measureDesc ,jdbcType=VARCHAR},
  264. </if>
  265. <if test="measureReference != null">
  266. #{measureReference ,jdbcType=VARCHAR},
  267. </if>
  268. <if test="measureTypeId != null">
  269. #{measureTypeId ,jdbcType=BIGINT},
  270. </if>
  271. <if test="createdBy != null">
  272. #{createdBy ,jdbcType=BIGINT},
  273. </if>
  274. <if test="createdAt != null">
  275. #{createdAt ,jdbcType=TIMESTAMP},
  276. </if>
  277. </trim>
  278. </insert>
  279. <!--更新-->
  280. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazardRiskMeasure">
  281. UPDATE checklist_hazard_risk_measure
  282. <trim suffixOverrides=",">
  283. <set>
  284. <if test="measureContent != null and measureContent != ''">
  285. measure_content = #{measureContent, jdbcType=VARCHAR},
  286. </if>
  287. <if test="measureDesc != null and measureDesc != ''">
  288. measure_desc = #{measureDesc, jdbcType=VARCHAR},
  289. </if>
  290. <if test="measureReference != null">
  291. measure_reference = #{measureReference ,jdbcType=VARCHAR},
  292. </if>
  293. <if test="measureTypeId != null ">
  294. measure_type_id = #{measureTypeId, jdbcType=BIGINT},
  295. </if>
  296. <if test="updatedBy != null ">
  297. updated_by = #{updatedBy ,jdbcType=BIGINT},
  298. </if>
  299. <if test="updatedAt != null">
  300. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  301. </if>
  302. </set>
  303. </trim>
  304. WHERE 1 = 1
  305. <if test="ocId != null">
  306. AND oc_id = #{ocId ,jdbcType=BIGINT}
  307. </if>
  308. <if test="checklistId != null">
  309. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  310. </if>
  311. <if test="hazardId != null">
  312. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  313. </if>
  314. <if test="riskId != null">
  315. AND risk_id = #{riskId ,jdbcType=BIGINT}
  316. </if>
  317. <if test="measureId != null">
  318. AND measure_id = #{measureId ,jdbcType=BIGINT}
  319. </if>
  320. </update>
  321. <!--删除-->
  322. <update id="delete" parameterType="java.util.Map">
  323. UPDATE checklist_hazard_risk_measure
  324. <trim suffixOverrides=",">
  325. <set>
  326. <if test="deletedFlag != null">
  327. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  328. </if>
  329. <if test="deletedTime != null">
  330. deleted_time = #{deletedTime,jdbcType=VARCHAR},
  331. </if>
  332. <if test="deletedBy != null">
  333. deleted_by = #{deletedBy,jdbcType=BIGINT},
  334. </if>
  335. </set>
  336. </trim>
  337. WHERE 1 = 1
  338. <if test="ocId != null">
  339. AND oc_id = #{ocId ,jdbcType=BIGINT}
  340. </if>
  341. <if test="checklistId != null">
  342. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  343. </if>
  344. <if test="hazardId != null">
  345. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  346. </if>
  347. <if test="riskId != null">
  348. AND risk_id = #{riskId ,jdbcType=BIGINT}
  349. </if>
  350. <if test="measureId != null">
  351. AND measure_id = #{measureId ,jdbcType=BIGINT}
  352. </if>
  353. </update>
  354. </mapper>