AccountItemMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.AccountItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id, acc_item_type, object_id, org_id, staff_id, biznis_type, biznis_id, biznis_no, acc_date, rec_status, amt_rec, amt_pay, amt_should, amt_handle, amt_waive, amt_residue, remarks, make_staff, make_time, flg_valid
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.AccountItem">
  11. <id column="item_id" property="itemId"/>
  12. <result column="acc_item_type" property="accItemType"/>
  13. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  14. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  15. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  16. <result column="biznis_type" property="biznisType"/>
  17. <result column="biznis_id" property="biznisId" typeHandler="UuidTypeHandler"/>
  18. <result column="biznis_no" property="biznisNo"/>
  19. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  20. <result column="rec_status" property="recStatus"/>
  21. <result column="amt_rec" property="amtRec"/>
  22. <result column="amt_pay" property="amtPay"/>
  23. <result column="amt_should" property="amtShould"/>
  24. <result column="amt_handle" property="amtHandle"/>
  25. <result column="amt_waive" property="amtWaive"/>
  26. <result column="amt_residue" property="amtResidue"/>
  27. <result column="remarks" property="remarks"/>
  28. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  29. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  30. <result column="flg_valid" property="flgValid"/>
  31. <result column="cp_id" property="cpId"/>
  32. </resultMap>
  33. <!-- 通用条件列 -->
  34. <sql id="Condition">
  35. <where>
  36. <if test="accItemType != null and accItemType != ''">
  37. AND acc_item_type = #{accItemType}
  38. </if>
  39. <if test="objectId != null and objectId != ''">
  40. AND object_id = #{objectId}
  41. </if>
  42. <if test="orgId != null and orgId != ''">
  43. AND org_id = #{orgId}
  44. </if>
  45. <if test="staffId != null and staffId != ''">
  46. AND staff_id = #{staffId}
  47. </if>
  48. <if test="biznisType != null and biznisType != ''">
  49. AND biznis_type = #{biznisType}
  50. </if>
  51. <if test="biznisId != null and biznisId != ''">
  52. AND biznis_id = #{biznisId}
  53. </if>
  54. <if test="biznisNo != null and biznisNo != ''">
  55. AND biznis_no = #{biznisNo}
  56. </if>
  57. <if test="accDate != null">
  58. AND acc_date = #{accDate}
  59. </if>
  60. <if test="recStatus != null and recStatus != ''">
  61. AND rec_status = #{recStatus}
  62. </if>
  63. <if test="amtRec != null">
  64. AND amt_rec = #{amtRec}
  65. </if>
  66. <if test="amtPay != null">
  67. AND amt_pay = #{amtPay}
  68. </if>
  69. <if test="amtShould != null">
  70. AND amt_should = #{amtShould}
  71. </if>
  72. <if test="amtHandle != null">
  73. AND amt_handle = #{amtHandle}
  74. </if>
  75. <if test="amtWaive != null">
  76. AND amt_waive = #{amtWaive}
  77. </if>
  78. <if test="amtResidue != null">
  79. AND amt_residue = #{amtResidue}
  80. </if>
  81. <if test="remarks != null and remarks != ''">
  82. AND remarks = #{remarks}
  83. </if>
  84. <if test="makeStaff != null and makeStaff != ''">
  85. AND make_staff = #{makeStaff}
  86. </if>
  87. <if test="makeTime != null">
  88. AND make_time = #{makeTime}
  89. </if>
  90. <if test="flgValid != null">
  91. AND flg_valid = #{flgValid}
  92. </if>
  93. <if test="cpId != null">
  94. AND cp_id = #{cpId}
  95. </if>
  96. <if test="opCreateTime != null">
  97. AND op_create_time = #{opCreateTime}
  98. </if>
  99. <if test="opCreateUserId != null and opCreateUserId != ''">
  100. AND op_create_user_id = #{opCreateUserId}
  101. </if>
  102. <if test="opUpdateTime != null">
  103. AND op_update_time = #{opUpdateTime}
  104. </if>
  105. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  106. AND op_update_user_id = #{opUpdateUserId}
  107. </if>
  108. <if test="opAppCode != null and opAppCode != ''">
  109. AND op_app_code = #{opAppCode}
  110. </if>
  111. <if test="opTimestamp != null">
  112. AND op_timestamp = #{opTimestamp}
  113. </if>
  114. <if test="opDbUser != null and opDbUser != ''">
  115. AND op_db_user = #{opDbUser}
  116. </if>
  117. </where>
  118. </sql>
  119. <sql id="idsForeach">
  120. <!-- 根据主键itemId批量操作 -->
  121. WHERE item_id in
  122. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  123. #{item}
  124. </foreach>
  125. </sql>
  126. <!-- 查询表t_mac_account_item,(条件查询+分页)列表 -->
  127. <select id="selectByCond" resultMap="BaseResultMap">
  128. SELECT
  129. <include refid="Base_Column_List"/>
  130. FROM dkic_b.t_mac_account_item
  131. <include refid="Condition"/>
  132. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  133. limit #{end} offset #{start}
  134. </if>
  135. </select>
  136. <!-- 查询表t_mac_account_item,(条件查询)个数 -->
  137. <select id="countByCond" resultType="Long">
  138. SELECT
  139. count(1)
  140. FROM dkic_b.t_mac_account_item
  141. <include refid="Condition"/>
  142. </select>
  143. <!-- 根据主键查询表t_mac_account_item的一行数据 -->
  144. <select id="selectById" resultMap="BaseResultMap">
  145. SELECT
  146. <include refid="Base_Column_List"/>
  147. FROM dkic_b.t_mac_account_item
  148. WHERE item_id = #{itemId}::uuid
  149. </select>
  150. <!-- 根据主键锁定表t_mac_account_item的一行数据 -->
  151. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  152. SELECT
  153. <include refid="Base_Column_List"/>
  154. FROM dkic_b.t_mac_account_item
  155. WHERE item_id = #{id}::uuid
  156. for update
  157. </select>
  158. <!-- 根据主键锁定表t_mac_account_item的多行数据 -->
  159. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  160. SELECT
  161. <include refid="Base_Column_List"/>
  162. FROM dkic_b.t_mac_account_item
  163. <include refid="idsForeach"/>
  164. for update
  165. </select>
  166. <insert id="insertBatch">
  167. insert into dkic_b.t_mac_account_item
  168. (
  169. <trim suffixOverrides=",">
  170. acc_item_type,
  171. object_id,
  172. org_id,
  173. staff_id,
  174. biznis_type,
  175. biznis_id,
  176. biznis_no,
  177. acc_date,
  178. rec_status,
  179. amt_rec,
  180. amt_pay,
  181. amt_should,
  182. amt_handle,
  183. amt_waive,
  184. amt_residue,
  185. remarks,
  186. make_staff,
  187. make_time,
  188. cp_id,
  189. op_app_code,
  190. </trim>
  191. )
  192. values
  193. <foreach collection="list" index="index" item="item" separator=",">
  194. (
  195. <trim suffixOverrides=",">
  196. #{item.accItemType},
  197. #{item.objectId}::uuid,
  198. #{item.orgId}::uuid,
  199. #{item.staffId}::uuid,
  200. #{item.biznisType},
  201. #{item.biznisId}::uuid,
  202. #{item.biznisNo},
  203. #{item.accDate},
  204. #{item.recStatus},
  205. #{item.amtRec},
  206. #{item.amtPay},
  207. #{item.amtShould},
  208. #{item.amtHandle},
  209. #{item.amtWaive},
  210. #{item.amtResidue},
  211. #{item.remarks},
  212. #{item.makeStaff}::uuid,
  213. #{item.makeTime},
  214. #{item.cpId},
  215. #{item.opAppCode},
  216. </trim>
  217. )
  218. </foreach>
  219. </insert>
  220. <!-- 查询收款总额 -->
  221. <select id="getSumAmtRec" resultType="java.util.Map">
  222. SELECT sum(tmai.amt_rec) as "sumAmtRec"
  223. FROM dkic_b.t_mac_account_item as tmai
  224. where tmai.flg_valid
  225. and tmai.object_id = #{id}::uuid
  226. </select>
  227. <delete id="deleteById">
  228. DELETE FROM dkic_b.t_mac_account_item
  229. WHERE item_id = #{id}::uuid;
  230. </delete>
  231. </mapper>