AccountMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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.AccountMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. ac.object_id, ac.object_type, ac.receipt, ac.receipt_lock, ac.contract_assets, ac.receivable,
  8. ac.receivable_handle, ac.receivable_waive, ac.receivable_residue, ac.receipt_residue, ac.payment,
  9. ac.pur_estimate, ac.payable, ac.payable_handle, ac.payable_waive, ac.payable_residue,
  10. ac.payment_residue, ac.remarks, ac.flg_valid, ac.cp_id
  11. </sql>
  12. <!-- 通用查询映射结果 -->
  13. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.Account">
  14. <id column="object_id" property="objectId"/>
  15. <result column="object_type" property="objectType"/>
  16. <result column="receipt" property="receipt"/>
  17. <result column="receipt_lock" property="receiptLock"/>
  18. <result column="contract_assets" property="contractAssets"/>
  19. <result column="receivable" property="receivable"/>
  20. <result column="receivable_handle" property="receivableHandle"/>
  21. <result column="receivable_waive" property="receivableWaive"/>
  22. <result column="receivable_residue" property="receivableResidue"/>
  23. <result column="receipt_residue" property="receiptResidue"/>
  24. <result column="payment" property="payment"/>
  25. <result column="pur_estimate" property="purEstimate"/>
  26. <result column="payable" property="payable"/>
  27. <result column="payable_handle" property="payableHandle"/>
  28. <result column="payable_waive" property="payableWaive"/>
  29. <result column="payable_residue" property="payableResidue"/>
  30. <result column="payment_residue" property="paymentResidue"/>
  31. <result column="remarks" property="remarks"/>
  32. <result column="flg_valid" property="flgValid"/>
  33. <result column="cp_id" property="cpId"/>
  34. </resultMap>
  35. <!-- 通用查询映射结果 -->
  36. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.AccountResponse">
  37. <id column="object_id" property="objectId"/>
  38. <result column="object_type" property="objectType"/>
  39. <result column="receipt" property="receipt"/>
  40. <result column="receipt_lock" property="receiptLock"/>
  41. <result column="contract_assets" property="contractAssets"/>
  42. <result column="receivable" property="receivable"/>
  43. <result column="receivable_handle" property="receivableHandle"/>
  44. <result column="receivable_waive" property="receivableWaive"/>
  45. <result column="receivable_residue" property="receivableResidue"/>
  46. <result column="receipt_residue" property="receiptResidue"/>
  47. <result column="payment" property="payment"/>
  48. <result column="pur_estimate" property="purEstimate"/>
  49. <result column="payable" property="payable"/>
  50. <result column="payable_handle" property="payableHandle"/>
  51. <result column="payable_waive" property="payableWaive"/>
  52. <result column="payable_residue" property="payableResidue"/>
  53. <result column="payment_residue" property="paymentResidue"/>
  54. <result column="remarks" property="remarks"/>
  55. <result column="flg_valid" property="flgValid"/>
  56. <result column="cp_id" property="cpId"/>
  57. </resultMap>
  58. <!-- 通用条件列 -->
  59. <sql id="Condition">
  60. <where>
  61. <if test="objectType != null and objectType != ''">
  62. AND object_type = #{objectType}
  63. </if>
  64. <if test="receipt != null">
  65. AND receipt = #{receipt}
  66. </if>
  67. <if test="receiptLock != null">
  68. AND receipt_lock = #{receiptLock}
  69. </if>
  70. <if test="contractAssets != null">
  71. AND contract_assets = #{contractAssets}
  72. </if>
  73. <if test="receivable != null">
  74. AND receivable = #{receivable}
  75. </if>
  76. <if test="receivableHandle != null">
  77. AND receivable_handle = #{receivableHandle}
  78. </if>
  79. <if test="receivableWaive != null">
  80. AND receivable_waive = #{receivableWaive}
  81. </if>
  82. <if test="receivableResidue != null">
  83. AND receivable_residue = #{receivableResidue}
  84. </if>
  85. <if test="receiptResidue != null">
  86. AND receipt_residue = #{receiptResidue}
  87. </if>
  88. <if test="payment != null">
  89. AND payment = #{payment}
  90. </if>
  91. <if test="purEstimate != null">
  92. AND pur_estimate = #{purEstimate}
  93. </if>
  94. <if test="payable != null">
  95. AND payable = #{payable}
  96. </if>
  97. <if test="payableHandle != null">
  98. AND payable_handle = #{payableHandle}
  99. </if>
  100. <if test="payableWaive != null">
  101. AND payable_waive = #{payableWaive}
  102. </if>
  103. <if test="payableResidue != null">
  104. AND payable_residue = #{payableResidue}
  105. </if>
  106. <if test="paymentResidue != null">
  107. AND payment_residue = #{paymentResidue}
  108. </if>
  109. <if test="remarks != null and remarks != ''">
  110. AND remarks = #{remarks}
  111. </if>
  112. <if test="flgValid != null">
  113. AND flg_valid = #{flgValid}
  114. </if>
  115. <if test="cpId != null">
  116. AND cp_id = #{cpId}
  117. </if>
  118. </where>
  119. </sql>
  120. <sql id="idsForeach">
  121. <!-- 根据主键objectId批量操作 -->
  122. WHERE ac.object_id in
  123. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  124. #{item}
  125. </foreach>
  126. </sql>
  127. <!-- 查询表t_mac_account,(条件查询+分页)列表 -->
  128. <select id="selectByCond" resultMap="BaseResultMap">
  129. SELECT
  130. <include refid="Base_Column_List"/>
  131. FROM dkic_b.t_mac_account ac
  132. <include refid="Condition"/>
  133. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  134. limit #{end} offset #{start}
  135. </if>
  136. </select>
  137. <!-- 查询表t_mac_account,(条件查询)个数 -->
  138. <select id="countByCond" resultType="Long">
  139. SELECT
  140. count(1)
  141. FROM dkic_b.t_mac_account ac
  142. <include refid="Condition"/>
  143. </select>
  144. <!-- 根据主键查询表t_mac_account的一行数据 -->
  145. <select id="selectById" resultMap="BaseResultMapResponse">
  146. SELECT
  147. <include refid="Base_Column_List"/>
  148. ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "objectTypeName"
  149. ,tmp.sup_name AS "supplierName"
  150. ,tmc.cus_name as "cusName"
  151. ,tmc.cus_phone as "cusPhone"
  152. FROM dkic_b.t_mac_account ac
  153. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = ac.object_type
  154. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = ac.object_id
  155. left join dkic_b.t_mst_customer tmc on ac.object_id = tmc.cus_id
  156. WHERE ac.object_id = #{objectId}::uuid
  157. </select>
  158. <!-- 根据主键锁定表t_mac_account的一行数据 -->
  159. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  160. SELECT
  161. <include refid="Base_Column_List"/>
  162. FROM dkic_b.t_mac_account ac
  163. WHERE ac.object_id = #{id}::uuid
  164. for update
  165. </select>
  166. <!-- 根据主键锁定表t_mac_account的多行数据 -->
  167. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  168. SELECT
  169. <include refid="Base_Column_List"/>
  170. FROM dkic_b.t_mac_account ac
  171. <include refid="idsForeach"/>
  172. for update
  173. </select>
  174. <insert id="insertBatch">
  175. insert into dkic_b.t_mac_account
  176. (
  177. <trim suffixOverrides=",">
  178. object_type,
  179. receipt,
  180. receipt_lock,
  181. contract_assets,
  182. receivable,
  183. receivable_handle,
  184. receivable_waive,
  185. receivable_residue,
  186. receipt_residue,
  187. payment,
  188. pur_estimate,
  189. payable,
  190. payable_handle,
  191. payable_waive,
  192. payable_residue,
  193. payment_residue,
  194. remarks,
  195. cp_id,
  196. </trim>
  197. )
  198. values
  199. <foreach collection="list" index="index" item="item" separator=",">
  200. (
  201. <trim suffixOverrides=",">
  202. #{item.objectType},
  203. #{item.receipt},
  204. #{item.receiptLock},
  205. #{item.contractAssets},
  206. #{item.receivable},
  207. #{item.receivableHandle},
  208. #{item.receivableWaive},
  209. #{item.receivableResidue},
  210. #{item.receiptResidue},
  211. #{item.payment},
  212. #{item.purEstimate},
  213. #{item.payable},
  214. #{item.payableHandle},
  215. #{item.payableWaive},
  216. #{item.payableResidue},
  217. #{item.paymentResidue},
  218. #{item.remarks},
  219. #{item.cpId},
  220. </trim>
  221. )
  222. </foreach>
  223. </insert>
  224. </mapper>