AccountMapper.xml 11 KB

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