EntRiskPointChecklistMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.EntRiskPointChecklistMapper">
  4. <resultMap id="RiskPointChecklistDtoMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointChecklistDto" >
  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="remark" property="remark" jdbcType="VARCHAR" />
  9. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  10. <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
  11. <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
  12. <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
  13. </resultMap>
  14. <resultMap id="ChecklistDtoMap" type="com.zhyc.xps.common.dto.ChecklistDto">
  15. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--单位ID-->
  16. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" /><!--清单ID-->
  17. <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
  18. <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
  19. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  20. <result column="checklist_desc" property="checklistDesc" jdbcType="VARCHAR" />
  21. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  22. <result column="issued_at" property="issuedAt" jdbcType="TIMESTAMP"/>
  23. <result column="author" property="author" jdbcType="VARCHAR" />
  24. <result column="status" property="status" jdbcType="BIGINT" />
  25. <result column="version" property="version" jdbcType="VARCHAR" />
  26. <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
  27. <result column="issued_account_id" property="issuedAccountId" jdbcType="BIGINT" />
  28. <result column="issued_account_name" property="issuedAccountName" jdbcType="VARCHAR" />
  29. </resultMap>
  30. <sql id="RiskPointChecklistDto_Cols">
  31. A.oc_id,
  32. A.risk_point_id,
  33. A.checklist_id,
  34. B.checklist_title,
  35. B.checklist_type_id,
  36. B.checklist_cat_id,
  37. C.checklist_cat_title,
  38. A.remark
  39. </sql>
  40. <!--分页查询信息-->
  41. <select id="getByPage" parameterType="java.util.Map" resultMap="RiskPointChecklistDtoMap">
  42. SELECT
  43. <include refid="RiskPointChecklistDto_Cols"/>
  44. FROM ent_risk_point_checklist AS A
  45. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  46. LEFT JOIN checklist_cat AS C ON (B.oc_id = C.oc_id AND B.checklist_cat_id = C.checklist_cat_id)
  47. WHERE 1 = 1 AND A.deleted_flag = 0
  48. <if test="ocId != null">
  49. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  50. </if>
  51. <if test="riskPointId != null">
  52. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  53. </if>
  54. <if test="checklistId != null">
  55. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  56. </if>
  57. <if test="keywords != null and keywords != ''">
  58. and B.checklist_title like "%"#{keywords}"%"
  59. </if>
  60. ORDER BY checklist_id ASC
  61. </select>
  62. <!--基于ID获取信息-->
  63. <select id="getById" parameterType="java.util.Map" resultMap="RiskPointChecklistDtoMap">
  64. SELECT
  65. <include refid="RiskPointChecklistDto_Cols"/>
  66. FROM ent_risk_point_checklist AS A
  67. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  68. LEFT JOIN checklist_cat AS C ON (B.oc_id = C.oc_id AND B.checklist_cat_id = C.checklist_cat_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="riskPointId != null">
  74. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  75. </if>
  76. <if test="checklistId != null">
  77. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  78. </if>
  79. </select>
  80. <!--查询信息-->
  81. <select id="getByList" parameterType="java.util.Map" resultMap="RiskPointChecklistDtoMap">
  82. SELECT
  83. <include refid="RiskPointChecklistDto_Cols"/>
  84. FROM ent_risk_point_checklist AS A
  85. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  86. LEFT JOIN checklist_cat AS C ON (B.oc_id = C.oc_id AND B.checklist_cat_id = C.checklist_cat_id)
  87. WHERE 1 = 1 AND A.deleted_flag = 0
  88. <if test="ocId != null">
  89. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  90. </if>
  91. <if test="riskPointId != null">
  92. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  93. </if>
  94. <if test="keywords != null and keywords != ''">
  95. and B.checklist_title like "%"#{keywords}"%"
  96. </if>
  97. ORDER BY A.checklist_id ASC
  98. </select>
  99. <!--INSERT-->
  100. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointChecklist">
  101. INSERT INTO ent_risk_point_checklist
  102. <trim prefix="(" suffix=")" suffixOverrides=",">
  103. <if test="ocId != null">
  104. oc_id,
  105. </if>
  106. <if test="riskPointId != null">
  107. risk_point_id,
  108. </if>
  109. <if test="checklistId != null">
  110. checklist_id,
  111. </if>
  112. <if test="createdBy != null">
  113. created_by,
  114. </if>
  115. <if test="createdAt != null">
  116. created_at,
  117. </if>
  118. </trim>
  119. <trim prefix="values (" suffix=")" suffixOverrides=",">
  120. <if test="ocId != null">
  121. #{ocId ,jdbcType=BIGINT},
  122. </if>
  123. <if test="riskPointId != null">
  124. #{riskPointId ,jdbcType=BIGINT},
  125. </if>
  126. <if test="checklistId != null">
  127. #{checklistId ,jdbcType=BIGINT},
  128. </if>
  129. <if test="createdBy != null">
  130. #{createdBy ,jdbcType=BIGINT},
  131. </if>
  132. <if test="createdAt != null">
  133. #{createdAt ,jdbcType=TIMESTAMP},
  134. </if>
  135. </trim>
  136. </insert>
  137. <!--删除-->
  138. <delete id="delete" parameterType="java.util.Map">
  139. DELETE FROM ent_risk_point_checklist
  140. WHERE 1 = 1
  141. <if test="ocId != null">
  142. AND oc_id = #{ocId ,jdbcType=BIGINT}
  143. </if>
  144. <if test="riskPointCatId != null">
  145. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  146. </if>
  147. <if test="checklistId != null">
  148. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  149. </if>
  150. </delete>
  151. <!--查询信息-->
  152. <select id="getSelectByPage" parameterType="java.util.Map" resultMap="ChecklistDtoMap">
  153. SELECT
  154. A.oc_id,
  155. A.checklist_id,
  156. A.checklist_cat_id,
  157. A.checklist_type_id,
  158. B.checklist_cat_title,
  159. A.checklist_desc,
  160. A.checklist_title,
  161. A.is_fixed,
  162. C.account_name AS issued_account_name,
  163. A.issued_by AS issued_account_id,
  164. A.issued_at,
  165. A.author,
  166. A.status,
  167. A.version
  168. FROM checklist AS A
  169. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  170. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  171. WHERE 1 = 1 AND A.deleted_flag = 0
  172. AND NOT EXISTS (
  173. SELECT
  174. *
  175. FROM ent_risk_point_checklist AS D
  176. WHERE A.oc_id = D.oc_id AND A.checklist_id = D.checklist_id AND D.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  177. )
  178. <if test="ocId != null">
  179. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  180. </if>
  181. <if test="keywords != null and keywords != ''">
  182. and A.checklist_title like "%"#{keywords}"%"
  183. </if>
  184. ORDER BY A.checklist_id ASC
  185. </select>
  186. </mapper>