MoneyAccountItemMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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.mst.MoneyAccountItemMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. item_id, mac_id, flow_type, invoice_id, amt_inflow, acc_date, remarks, make_staff, make_time, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.MoneyAccountItem">
  11. <id column="item_id" property="itemId"/>
  12. <result column="mac_id" property="macId" typeHandler="UuidTypeHandler"/>
  13. <result column="flow_type" property="flowType"/>
  14. <result column="invoice_id" property="invoiceId" typeHandler="UuidTypeHandler"/>
  15. <result column="amt_inflow" property="amtInflow"/>
  16. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  17. <result column="remarks" property="remarks"/>
  18. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  19. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  20. <result column="flg_valid" property="flgValid"/>
  21. <result column="cp_id" property="cpId"/>
  22. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  23. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  24. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  25. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  26. <result column="op_app_code" property="opAppCode"/>
  27. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  28. <result column="op_db_user" property="opDbUser"/>
  29. </resultMap>
  30. <!-- 通用条件列 -->
  31. <sql id="Condition">
  32. <where>
  33. <if test="macId != null and macId != ''">
  34. AND mac_id = #{macId}
  35. </if>
  36. <if test="flowType != null and flowType != ''">
  37. AND flow_type = #{flowType}
  38. </if>
  39. <if test="invoiceId != null and invoiceId != ''">
  40. AND invoice_id = #{invoiceId}
  41. </if>
  42. <if test="amtInflow != null">
  43. AND amt_inflow = #{amtInflow}
  44. </if>
  45. <if test="accDate != null">
  46. AND acc_date = #{accDate}
  47. </if>
  48. <if test="remarks != null and remarks != ''">
  49. AND remarks = #{remarks}
  50. </if>
  51. <if test="makeStaff != null and makeStaff != ''">
  52. AND make_staff = #{makeStaff}
  53. </if>
  54. <if test="makeTime != null">
  55. AND make_time = #{makeTime}
  56. </if>
  57. <if test="flgValid != null">
  58. AND flg_valid = #{flgValid}
  59. </if>
  60. <if test="cpId != null">
  61. AND cp_id = #{cpId}
  62. </if>
  63. <if test="opCreateTime != null">
  64. AND op_create_time = #{opCreateTime}
  65. </if>
  66. <if test="opCreateUserId != null and opCreateUserId != ''">
  67. AND op_create_user_id = #{opCreateUserId}
  68. </if>
  69. <if test="opUpdateTime != null">
  70. AND op_update_time = #{opUpdateTime}
  71. </if>
  72. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  73. AND op_update_user_id = #{opUpdateUserId}
  74. </if>
  75. <if test="opAppCode != null and opAppCode != ''">
  76. AND op_app_code = #{opAppCode}
  77. </if>
  78. <if test="opTimestamp != null">
  79. AND op_timestamp = #{opTimestamp}
  80. </if>
  81. <if test="opDbUser != null and opDbUser != ''">
  82. AND op_db_user = #{opDbUser}
  83. </if>
  84. </where>
  85. </sql>
  86. <sql id="idsForeach">
  87. <!-- 根据主键itemId批量操作 -->
  88. WHERE item_id in
  89. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  90. #{item}
  91. </foreach>
  92. </sql>
  93. <!-- 查询表t_mst_money_account_item,(条件查询+分页)列表 -->
  94. <select id="selectByCond" resultMap="BaseResultMap">
  95. SELECT
  96. <include refid="Base_Column_List"/>
  97. FROM t_mst_money_account_item
  98. <include refid="Condition"/>
  99. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  100. limit #{end} offset #{start}
  101. </if>
  102. </select>
  103. <!-- 查询表t_mst_money_account_item,(条件查询)个数 -->
  104. <select id="countByCond" resultType="Long">
  105. SELECT
  106. count(1)
  107. FROM t_mst_money_account_item
  108. <include refid="Condition"/>
  109. </select>
  110. <!-- 根据主键查询表t_mst_money_account_item的一行数据 -->
  111. <select id="selectById" resultMap="BaseResultMap">
  112. SELECT
  113. <include refid="Base_Column_List"/>
  114. FROM t_mst_money_account_item
  115. WHERE item_id = #{itemId}::uuid
  116. </select>
  117. <!-- 根据主键锁定表t_mst_money_account_item的一行数据 -->
  118. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  119. SELECT
  120. <include refid="Base_Column_List"/>
  121. FROM t_mst_money_account_item
  122. WHERE item_id = #{id}::uuid
  123. for update
  124. </select>
  125. <!-- 根据主键锁定表t_mst_money_account_item的多行数据 -->
  126. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  127. SELECT
  128. <include refid="Base_Column_List"/>
  129. FROM t_mst_money_account_item
  130. <include refid="idsForeach"/>
  131. for update
  132. </select>
  133. <insert id="insertBatch">
  134. insert into t_mst_money_account_item
  135. (
  136. <trim suffixOverrides=",">
  137. mac_id,
  138. flow_type,
  139. invoice_id,
  140. amt_inflow,
  141. acc_date,
  142. remarks,
  143. make_staff,
  144. make_time,
  145. cp_id,
  146. op_app_code,
  147. </trim>
  148. )
  149. values
  150. <foreach collection="list" index="index" item="item" separator=",">
  151. (
  152. <trim suffixOverrides=",">
  153. #{item.macId}::uuid,
  154. #{item.flowType},
  155. #{item.invoiceId}::uuid,
  156. #{item.amtInflow},
  157. #{item.accDate},
  158. #{item.remarks},
  159. #{item.makeStaff}::uuid,
  160. #{item.makeTime},
  161. #{item.cpId},
  162. #{item.opAppCode},
  163. </trim>
  164. )
  165. </foreach>
  166. </insert>
  167. <delete id="deleteByInvoiceId">
  168. DELETE FROM dkic_b.t_mst_money_account_item
  169. WHERE invoice_id = #{id}::uuid;
  170. </delete>
  171. <!-- 查询收款总额 -->
  172. <select id="getSumAmtInflow" resultType="java.util.Map">
  173. SELECT COALESCE(sum(tmmai.amt_inflow), 0) as "sumAmtInflow"
  174. FROM dkic_b.t_mst_money_account_item as tmmai
  175. where tmmai.flg_valid
  176. and tmmai.mac_id = #{id}::uuid
  177. </select>
  178. </mapper>