OtherPayableItemMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.dk.mdm.mapper.mac.OtherPayableItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id, payable_id, payable_type, qty_payable, amt_payable, remarks, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.OtherPayableItem">
  11. <id column="item_id" property="itemId"/>
  12. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  13. <result column="payable_type" property="payableType" typeHandler="UuidTypeHandler"/>
  14. <result column="qty_payable" property="qtyPayable"/>
  15. <result column="amt_payable" property="amtPayable"/>
  16. <result column="remarks" property="remarks"/>
  17. <result column="flg_valid" property="flgValid"/>
  18. <result column="cp_id" property="cpId"/>
  19. </resultMap>
  20. <!-- 通用查询映射结果 -->
  21. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.OtherPayableItemResponse">
  22. <id column="item_id" property="itemId"/>
  23. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  24. <result column="payable_type" property="payableType" typeHandler="UuidTypeHandler"/>
  25. <result column="qty_payable" property="qtyPayable"/>
  26. <result column="amt_payable" property="amtPayable"/>
  27. <result column="remarks" property="remarks"/>
  28. <result column="flg_valid" property="flgValid"/>
  29. <result column="cp_id" property="cpId"/>
  30. </resultMap>
  31. <!-- 通用条件列 -->
  32. <sql id="Condition">
  33. <where>
  34. <if test="payableId != null and payableId != ''">
  35. AND t.payable_id = #{payableId}::uuid
  36. </if>
  37. <if test="payableType != null and payableType != ''">
  38. AND t.payable_type = #{payableType}
  39. </if>
  40. <if test="qtyPayable != null">
  41. AND t.qty_payable = #{qtyPayable}
  42. </if>
  43. <if test="amtPayable != null">
  44. AND t.amt_payable = #{amtPayable}
  45. </if>
  46. <if test="remarks != null and remarks != ''">
  47. AND t.remarks = #{remarks}
  48. </if>
  49. <if test="flgValid != null">
  50. AND t.flg_valid = #{flgValid}
  51. </if>
  52. <if test="cpId != null">
  53. AND t.cp_id = #{cpId}
  54. </if>
  55. </where>
  56. </sql>
  57. <sql id="idsForeach">
  58. <!-- 根据主键itemId批量操作 -->
  59. WHERE item_id in
  60. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  61. #{item}
  62. </foreach>
  63. </sql>
  64. <!-- 查询表t_mac_other_payable_item,(条件查询+分页)列表 -->
  65. <select id="selectByCond" resultMap="BaseResultMapResponse">
  66. SELECT t.item_id,
  67. t.payable_id,
  68. t.payable_type,
  69. tmda.data_value as "payableTypeName",
  70. t.qty_payable,
  71. t.amt_payable,
  72. t.remarks,
  73. t.flg_valid,
  74. t.cp_id
  75. FROM dkic_b.t_mac_other_payable_item as t
  76. LEFT JOIN dkic_b.t_mst_dictionary_data as tmda ON tmda.data_id = t.payable_type
  77. <include refid="Condition"/>
  78. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  79. limit #{end} offset #{start}
  80. </if>
  81. </select>
  82. <!-- 查询表t_mac_other_payable_item,(条件查询)个数 -->
  83. <select id="countByCond" resultType="Long">
  84. SELECT count(1)
  85. FROM dkic_b.t_mac_other_payable_item as t
  86. LEFT JOIN dkic_b.t_mst_dictionary_data as tmda ON tmda.data_id = t.payable_type
  87. <include refid="Condition"/>
  88. </select>
  89. <!-- 根据主键查询表t_mac_other_payable_item的一行数据 -->
  90. <select id="selectById" resultMap="BaseResultMapResponse">
  91. SELECT
  92. <include refid="Base_Column_List"/>
  93. FROM dkic_b.t_mac_other_payable_item
  94. WHERE item_id = #{id}::uuid
  95. </select>
  96. <!-- 根据主表主键锁定表t_psi_outbound_item的多行数据 -->
  97. <select id="selectByZIdForUpdate" resultMap="BaseResultMap">
  98. SELECT
  99. <include refid="Base_Column_List"/>
  100. FROM dkic_b.t_mac_other_payable_item
  101. WHERE payable_id = #{id}::uuid
  102. for update
  103. </select>
  104. <!-- 根据主键锁定表t_mac_other_payable_item的一行数据 -->
  105. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  106. SELECT
  107. <include refid="Base_Column_List"/>
  108. FROM dkic_b.t_mac_other_payable_item
  109. WHERE item_id = #{id}::uuid
  110. for update
  111. </select>
  112. <!-- 根据主键锁定表t_mac_other_payable_item的多行数据 -->
  113. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  114. SELECT
  115. <include refid="Base_Column_List"/>
  116. FROM dkic_b.t_mac_other_payable_item
  117. <include refid="idsForeach"/>
  118. for update
  119. </select>
  120. <insert id="insertBatch">
  121. insert into dkic_b.t_mac_other_payable_item
  122. (
  123. <trim suffixOverrides=",">
  124. payable_id,
  125. payable_type,
  126. qty_payable,
  127. amt_payable,
  128. remarks,
  129. cp_id,
  130. op_app_code,
  131. </trim>
  132. )
  133. values
  134. <foreach collection="list" index="index" item="item" separator=",">
  135. (
  136. <trim suffixOverrides=",">
  137. #{item.payableId}::uuid,
  138. #{item.payableType}::uuid,
  139. #{item.qtyPayable},
  140. #{item.amtPayable},
  141. #{item.remarks},
  142. #{item.cpId},
  143. #{item.opAppCode},
  144. </trim>
  145. )
  146. </foreach>
  147. </insert>
  148. <delete id="deleteById">
  149. DELETE
  150. FROM dkic_b.t_mac_other_payable_item
  151. WHERE item_id = #{id}::uuid;
  152. </delete>
  153. </mapper>