RecPayItemMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.RecPayItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id , rp_id, mac_id, amt_rec, amt_pay, acc_item_id, acc_date, remarks, make_staff, make_time, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.RecPayItem">
  11. <id column="item_id" property="itemId"/>
  12. <result column="rp_id" property="rpId" typeHandler="UuidTypeHandler"/>
  13. <result column="mac_id" property="macId" typeHandler="UuidTypeHandler"/>
  14. <result column="amt_rec" property="amtRec"/>
  15. <result column="amt_pay" property="amtPay"/>
  16. <result column="acc_item_id" property="accItemId"/>
  17. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  18. <result column="remarks" property="remarks"/>
  19. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  20. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  21. <result column="flg_valid" property="flgValid"/>
  22. <result column="cp_id" property="cpId"/>
  23. </resultMap>
  24. <!-- Response查询映射结果 -->
  25. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.RecPayItemResponse">
  26. <id column="item_id" property="itemId"/>
  27. <result column="rp_id" property="rpId" typeHandler="UuidTypeHandler"/>
  28. <result column="mac_id" property="macId" typeHandler="UuidTypeHandler"/>
  29. <result column="amt_rec" property="amtRec"/>
  30. <result column="amt_pay" property="amtPay"/>
  31. <result column="acc_item_id" property="accItemId"/>
  32. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  33. <result column="remarks" property="remarks"/>
  34. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  35. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  36. <result column="flg_valid" property="flgValid"/>
  37. <result column="cp_id" property="cpId"/>
  38. <result column="macReceiptCode" property="macReceiptCode"/>
  39. <result column="macTypeName" property="macTypeName"/>
  40. </resultMap>
  41. <!-- 通用条件列 -->
  42. <sql id="Condition">
  43. <where>
  44. <if test="rpId != null and rpId != ''">
  45. AND t.rp_id = #{rpId}::uuid
  46. </if>
  47. <if test="macId != null and macId != ''">
  48. AND t.mac_id = #{macId}
  49. </if>
  50. <if test="amtRec != null">
  51. AND t.amt_rec = #{amtRec}
  52. </if>
  53. <if test="amtPay != null">
  54. AND t.amt_pay = #{amtPay}
  55. </if>
  56. <if test="accItemId != null">
  57. AND t.acc_item_id = #{accItemId}
  58. </if>
  59. <if test="accDate != null">
  60. AND t.acc_date = #{accDate}
  61. </if>
  62. <if test="remarks != null and remarks != ''">
  63. AND t.remarks = #{remarks}
  64. </if>
  65. <if test="makeStaff != null and makeStaff != ''">
  66. AND t.make_staff = #{makeStaff}
  67. </if>
  68. <if test="makeTime != null">
  69. AND t.make_time = #{makeTime}
  70. </if>
  71. <if test="flgValid != null">
  72. AND t.flg_valid = #{flgValid}
  73. </if>
  74. <if test="cpId != null">
  75. AND t.cp_id = #{cpId}
  76. </if>
  77. </where>
  78. </sql>
  79. <sql id="idsForeach">
  80. <!-- 根据主键itemId批量操作 -->
  81. WHERE item_id in
  82. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  83. #{item}
  84. </foreach>
  85. </sql>
  86. <!-- 查询表t_mac_rec_pay_item,(条件查询+分页)列表 -->
  87. <select id="selectByCond" resultMap="BaseResultMapResponse">
  88. SELECT t.item_id,
  89. t.rp_id,
  90. t.mac_id,
  91. tmma.mac_name as "macName",
  92. tmma.mac_receipt_code as "macReceiptCode",
  93. dd.data_value AS "macTypeName",
  94. t.amt_rec,
  95. t.amt_pay,
  96. t.acc_item_id,
  97. t.acc_date,
  98. t.remarks,
  99. t.make_staff,
  100. t.make_time,
  101. t.flg_valid,
  102. t.cp_id
  103. FROM dkic_b.t_mac_rec_pay_item as t
  104. inner join dkic_b.t_mst_money_account tmma on tmma.mac_id = t.mac_id
  105. left join dkic_b.t_mst_dictionary_data as dd on tmma.mac_type = dd.data_id
  106. <include refid="Condition"/>
  107. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  108. limit #{end} offset #{start}
  109. </if>
  110. </select>
  111. <!-- 查询表t_mac_rec_pay_item,(条件查询)个数 -->
  112. <select id="countByCond" resultType="Long">
  113. SELECT
  114. count(1)
  115. FROM dkic_b.t_mac_rec_pay_item as t
  116. inner join dkic_b.t_mst_money_account tmma on tmma.mac_id = t.mac_id
  117. <include refid="Condition"/>
  118. </select>
  119. <!-- 根据主键查询表t_mac_rec_pay_item的一行数据 -->
  120. <select id="selectById" resultMap="BaseResultMap">
  121. SELECT
  122. <include refid="Base_Column_List"/>
  123. FROM dkic_b.t_mac_rec_pay_item
  124. WHERE item_id = #{id}::uuid
  125. </select>
  126. <!-- 根据主键锁定表t_mac_rec_pay_item的一行数据 -->
  127. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  128. SELECT
  129. <include refid="Base_Column_List"/>
  130. FROM dkic_b.t_mac_rec_pay_item
  131. WHERE item_id = #{id}::uuid
  132. for update
  133. </select>
  134. <!-- 根据主键锁定表t_mac_rec_pay_item的多行数据 -->
  135. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  136. SELECT
  137. <include refid="Base_Column_List"/>
  138. FROM dkic_b.t_mac_rec_pay_item
  139. <include refid="idsForeach"/>
  140. for update
  141. </select>
  142. <insert id="insertBatch">
  143. insert into dkic_b.t_mac_rec_pay_item
  144. (
  145. <trim suffixOverrides=",">
  146. rp_id,
  147. mac_id,
  148. amt_rec,
  149. amt_pay,
  150. acc_item_id,
  151. acc_date,
  152. remarks,
  153. make_staff,
  154. make_time,
  155. cp_id,
  156. op_app_code,
  157. </trim>
  158. )
  159. values
  160. <foreach collection="list" index="index" item="item" separator=",">
  161. (
  162. <trim suffixOverrides=",">
  163. #{item.rpId}::uuid,
  164. #{item.macId}::uuid,
  165. #{item.amtRec},
  166. #{item.amtPay},
  167. #{item.accItemId},
  168. #{item.accDate},
  169. #{item.remarks},
  170. #{item.makeStaff}::uuid,
  171. #{item.makeTime},
  172. #{item.cpId},
  173. #{item.opAppCode},
  174. </trim>
  175. )
  176. </foreach>
  177. </insert>
  178. <!-- 根据主键锁定表t_psi_out_return_item的多行数据 -->
  179. <select id="selectByZIdForUpdate" resultMap="BaseResultMap">
  180. SELECT
  181. <include refid="Base_Column_List"/>
  182. FROM dkic_b.t_mac_rec_pay_item
  183. WHERE rp_id = #{id}::uuid
  184. for update
  185. </select>
  186. <delete id="deleteById">
  187. DELETE FROM dkic_b.t_mac_rec_pay_item
  188. WHERE item_id = #{id}::uuid;
  189. </delete>
  190. </mapper>