ChecklistHazardRiskPositionMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.ChecklistHazardRiskPositionMapper">
  4. <resultMap id="BaseResultMap" type="com.zhyc.xps.aqpt.entity.ChecklistHazardRiskPosition">
  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="position_id" property="positionId" jdbcType="BIGINT"/>
  10. </resultMap>
  11. <resultMap id="ChecklistHazardRiskPositionDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardRiskPositionDto" extends="BaseResultMap">
  12. <result column="position_name" property="positionName" jdbcType="VARCHAR"/>
  13. </resultMap>
  14. <sql id="EntRiskCtrlPositionDto_Cols">
  15. A.oc_id,
  16. A.checklist_id,
  17. A.hazard_id,
  18. A.risk_id,
  19. A.position_id,
  20. B.position_name
  21. </sql>
  22. <select id="getByList" parameterType="java.util.Map" resultMap="ChecklistHazardRiskPositionDtoMap">
  23. SELECT
  24. <include refid="EntRiskCtrlPositionDto_Cols"/>
  25. FROM checklist_hazard_risk_position AS A
  26. LEFT JOIN s_position AS B ON (A.oc_id = B.oc_id AND A.position_id = B.position_id)
  27. WHERE 1 = 1
  28. <if test="ocId != null">
  29. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  30. </if>
  31. <if test="checklistId != null">
  32. AND A.checklist_id = #{checklistId,jdbcType=BIGINT}
  33. </if>
  34. <if test="hazardId != null">
  35. AND A.hazard_id = #{hazardId,jdbcType=BIGINT}
  36. </if>
  37. <if test="riskId != null">
  38. AND A.risk_id = #{riskId,jdbcType=BIGINT}
  39. </if>
  40. ORDER BY A.position_id ASC
  41. </select>
  42. <select id="getByListWithDef" parameterType="java.util.Map" resultMap="ChecklistHazardRiskPositionDtoMap">
  43. SELECT
  44. A.oc_id,
  45. A.position_id,
  46. A.position_name,
  47. B.hazard_id,
  48. B.risk_id,
  49. A.created_by,
  50. A.created_at,
  51. A.updated_by,
  52. A.updated_at
  53. FROM s_position AS A
  54. LEFT JOIN (
  55. SELECT
  56. *
  57. FROM checklist_hazard_risk_position AS C
  58. WHERE 1 = 1
  59. <if test="ocId != null">
  60. AND C.oc_id = #{ocId ,jdbcType=BIGINT}
  61. </if>
  62. <if test="checklistId != null">
  63. AND C.checklist_id = #{checklistId,jdbcType=BIGINT}
  64. </if>
  65. <if test="hazardId != null">
  66. AND C.hazard_id = #{hazardId ,jdbcType=BIGINT}
  67. </if>
  68. <if test="riskId != null">
  69. AND C.risk_id = #{riskId ,jdbcType=BIGINT}
  70. </if>
  71. ) AS B ON (A.oc_id = B.oc_id AND A.position_id = B.position_id)
  72. WHERE 1 = 1 AND A.deleted_flag = 0
  73. <if test="ocId != null">
  74. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  75. </if>
  76. ORDER BY A.position_id ASC
  77. </select>
  78. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazardRiskPosition">
  79. INSERT INTO checklist_hazard_risk_position
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="ocId != null">
  82. oc_id,
  83. </if>
  84. <if test="checklistId != null">
  85. checklist_id,
  86. </if>
  87. <if test="hazardId != null">
  88. hazard_id,
  89. </if>
  90. <if test="riskId != null">
  91. risk_id,
  92. </if>
  93. <if test="positionId != null">
  94. position_id,
  95. </if>
  96. </trim>
  97. <trim prefix="values (" suffix=")" suffixOverrides=",">
  98. <if test="ocId != null">
  99. #{ocId ,jdbcType=BIGINT},
  100. </if>
  101. <if test="checklistId != null">
  102. #{checklistId,jdbcType=BIGINT},
  103. </if>
  104. <if test="hazardId != null">
  105. #{hazardId ,jdbcType=BIGINT},
  106. </if>
  107. <if test="riskId != null">
  108. #{riskId ,jdbcType=BIGINT},
  109. </if>
  110. <if test="positionId != null">
  111. #{positionId ,jdbcType=BIGINT},
  112. </if>
  113. </trim>
  114. </insert>
  115. <!--删除-->
  116. <delete id="delete" parameterType="java.util.Map">
  117. DELETE FROM checklist_hazard_risk_position
  118. WHERE 1 = 1
  119. <if test="ocId != null">
  120. AND oc_id = #{ocId ,jdbcType=BIGINT}
  121. </if>
  122. <if test="checklistId != null">
  123. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  124. </if>
  125. <if test="hazardId != null">
  126. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  127. </if>
  128. <if test="riskId != null">
  129. AND risk_id = #{riskId ,jdbcType=BIGINT}
  130. </if>
  131. <if test="positionId != null">
  132. AND position_id = #{positionId ,jdbcType=BIGINT}
  133. </if>
  134. </delete>
  135. </mapper>