EntRiskPointHazardMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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.EntRiskPointHazardMapper">
  4. <resultMap id="RiskPointHazardDtoMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointHazardDto" >
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
  7. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  8. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  9. <result column="status" property="status" jdbcType="BIGINT" />
  10. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR" />
  11. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR" />
  12. <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR" />
  13. <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR" />
  14. <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT" />
  15. <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR" />
  16. <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT" />
  17. </resultMap>
  18. <sql id="RiskPointHazardDto_Cols">
  19. A.oc_id,
  20. A.risk_point_id,
  21. A.checklist_id,
  22. A.hazard_id,
  23. A.status,
  24. B.hazard_title,
  25. B.hazard_code,
  26. B.hazard_image,
  27. B.hazard_desc,
  28. B.hazard_type_id,
  29. C.hazard_type_title,
  30. B.hazard_level
  31. </sql>
  32. <!--基于ID查询-->
  33. <select id="getById" resultMap="RiskPointHazardDtoMap">
  34. SELECT
  35. <include refid="RiskPointHazardDto_Cols"/>
  36. FROM ent_risk_point_hazard AS A
  37. LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  38. LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
  39. WHERE 1 = 1 AND A.deleted_flag = 0
  40. <if test="ocId != null">
  41. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  42. </if>
  43. <if test="checklistId != null">
  44. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  45. </if>
  46. <if test="hazardId != null">
  47. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  48. </if>
  49. <if test="status != null">
  50. AND A.status = #{status ,jdbcType=BIGINT}
  51. </if>
  52. <if test="riskPointId != null">
  53. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  54. </if>
  55. </select>
  56. <!--分页查询-->
  57. <select id="getByPage" parameterType="java.util.Map" resultMap="RiskPointHazardDtoMap">
  58. SELECT
  59. <include refid="RiskPointHazardDto_Cols"/>
  60. FROM ent_risk_point_hazard AS A
  61. LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  62. LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
  63. WHERE 1 = 1 AND A.deleted_flag = 0
  64. <if test="ocId != null">
  65. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  66. </if>
  67. <if test="riskPointId != null">
  68. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  69. </if>
  70. <if test="status != null">
  71. AND A.status = #{status ,jdbcType=BIGINT}
  72. </if>
  73. <if test="checklistId != null">
  74. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  75. </if>
  76. <if test="keywords != null and keywords != ''">
  77. AND B.hazard_title LIKE "%"#{keywords}"%"
  78. </if>
  79. ORDER BY A.risk_point_id ASC
  80. </select>
  81. <!--列表查询-->
  82. <select id="getByList" parameterType="java.util.Map" resultMap="RiskPointHazardDtoMap">
  83. SELECT
  84. <include refid="RiskPointHazardDto_Cols"/>
  85. FROM ent_risk_point_hazard AS A
  86. LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  87. LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
  88. WHERE 1 = 1 AND A.deleted_flag = 0
  89. <if test="ocId != null">
  90. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  91. </if>
  92. <if test="riskPointId != null">
  93. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  94. </if>
  95. <if test="checklistId != null">
  96. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  97. </if>
  98. <if test="hazardId != null">
  99. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  100. </if>
  101. <if test="keywords != null and keywords != ''">
  102. AND B.hazard_title LIKE "%"#{keywords}"%"
  103. </if>
  104. <if test="status != null">
  105. AND A.status = #{status,jdbcType=BIGINT}
  106. </if>
  107. ORDER BY A.risk_point_id ASC
  108. </select>
  109. <!--新增-->
  110. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointHazard">
  111. INSERT INTO ent_risk_point_hazard
  112. <trim prefix="(" suffix=")" suffixOverrides=",">
  113. <if test="ocId != null">
  114. oc_id,
  115. </if>
  116. <if test="riskPointId != null">
  117. risk_point_id,
  118. </if>
  119. <if test="checklistId != null">
  120. checklist_id,
  121. </if>
  122. <if test="hazardId != null">
  123. hazard_id,
  124. </if>
  125. <if test="status != null">
  126. status,
  127. </if>
  128. <if test="createdBy != null">
  129. created_by,
  130. </if>
  131. <if test="createdAt != null">
  132. created_at,
  133. </if>
  134. </trim>
  135. <trim prefix="values (" suffix=")" suffixOverrides=",">
  136. <if test="ocId != null">
  137. #{ocId ,jdbcType=BIGINT},
  138. </if>
  139. <if test="riskPointId != null">
  140. #{riskPointId ,jdbcType=BIGINT},
  141. </if>
  142. <if test="checklistId != null">
  143. #{checklistId ,jdbcType=BIGINT},
  144. </if>
  145. <if test="hazardId != null">
  146. #{hazardId ,jdbcType=BIGINT},
  147. </if>
  148. <if test="status != null">
  149. #{status ,jdbcType=BIGINT},
  150. </if>
  151. <if test="createdBy != null">
  152. #{createdBy ,jdbcType=BIGINT},
  153. </if>
  154. <if test="createdAt != null">
  155. #{createdAt ,jdbcType=TIMESTAMP},
  156. </if>
  157. </trim>
  158. </insert>
  159. <!--更新-->
  160. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointHazard">
  161. UPDATE ent_risk_point_hazard
  162. <trim suffixOverrides=",">
  163. <set>
  164. <if test="status != null ">
  165. is_enabled = #{status, jdbcType=BIGINT},
  166. </if>
  167. <if test="updatedBy != null ">
  168. updated_by = #{updatedBy ,jdbcType=BIGINT},
  169. </if>
  170. <if test="updatedAt != null">
  171. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  172. </if>
  173. </set>
  174. </trim>
  175. WHERE 1 = 1
  176. <if test="ocId != null">
  177. AND oc_id = #{ocId ,jdbcType=BIGINT}
  178. </if>
  179. <if test="riskPointId != null">
  180. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  181. </if>
  182. <if test="hazardId != null">
  183. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  184. </if>
  185. </update>
  186. <!--删除-->
  187. <delete id="delete" parameterType="java.util.Map">
  188. DELETE from ent_risk_point_hazard
  189. WHERE 1 = 1
  190. <if test="ocId != null">
  191. AND oc_id = #{ocId ,jdbcType=BIGINT}
  192. </if>
  193. <if test="riskPointId != null">
  194. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  195. </if>
  196. <if test="checklistId != null">
  197. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  198. </if>
  199. <if test="hazardId != null">
  200. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  201. </if>
  202. </delete>
  203. <resultMap id="HazardDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardDto" >
  204. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  205. <result column="checklist_id" property="checklistId" jdbcType="BIGINT"/>
  206. <result column="hazard_id" property="hazardId" jdbcType="BIGINT"/>
  207. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
  208. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR"/>
  209. <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR"/>
  210. <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR"/>
  211. <result column="hazard_cat_id" property="hazardCatId" jdbcType="BIGINT"/>
  212. <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT"/>
  213. <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR"/>
  214. <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT"/>
  215. <result column="parent_id" property="parentId" jdbcType="BIGINT"/>
  216. <result column="is_fixed" property="isFixed" jdbcType="BIGINT"/>
  217. <result column="root_id" property="rootId" jdbcType="BIGINT"/>
  218. <result column="node_left" property="nodeLeft" jdbcType="BIGINT"/>
  219. <result column="node_right" property="nodeRight" jdbcType="BIGINT"/>
  220. <result column="node_level" property="nodeLevel" jdbcType="BIGINT"/>
  221. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT"/>
  222. </resultMap>
  223. <select id="getSelectByList" parameterType="java.util.Map" resultMap="HazardDtoMap">
  224. SELECT
  225. A.oc_id,
  226. A.checklist_id,
  227. A.hazard_id,
  228. A.hazard_title,
  229. A.hazard_code,
  230. A.hazard_image,
  231. A.hazard_desc,
  232. B.hazard_type_title,
  233. A.hazard_type_id,
  234. A.hazard_level,
  235. A.parent_id,
  236. A.is_fixed,
  237. A.root_id,
  238. A.node_left,
  239. A.node_right,
  240. A.node_level,
  241. A.is_leaf
  242. FROM checklist_hazard AS A
  243. LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
  244. WHERE 1 = 1 AND A.deleted_flag = 0
  245. AND NOT EXISTS (
  246. SELECT
  247. *
  248. FROM ent_risk_point_hazard AS C
  249. WHERE A.oc_id = C.oc_id
  250. AND A.checklist_id = C.checklist_id
  251. AND A.hazard_id = C.hazard_id
  252. AND C.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  253. )
  254. <if test="checklistId != null">
  255. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  256. </if>
  257. <if test="hazardTypeId != null">
  258. AND A.hazard_type_id = #{hazardTypeId ,jdbcType=BIGINT}
  259. </if>
  260. <if test="keywords != null and keywords != ''">
  261. AND A.hazard_title LIKE "%"#{keywords}"%"
  262. </if>
  263. ORDER BY A.hazard_id ASC
  264. </select>
  265. </mapper>