MoneyAccountItemMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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
  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. </resultMap>
  23. <!-- 通用条件列 -->
  24. <sql id="Condition">
  25. <where>
  26. <if test="macId != null and macId != ''">
  27. AND mac_id = #{macId}
  28. </if>
  29. <if test="flowType != null and flowType != ''">
  30. AND flow_type = #{flowType}
  31. </if>
  32. <if test="invoiceId != null and invoiceId != ''">
  33. AND invoice_id = #{invoiceId}
  34. </if>
  35. <if test="amtInflow != null">
  36. AND amt_inflow = #{amtInflow}
  37. </if>
  38. <if test="accDate != null">
  39. AND acc_date = #{accDate}
  40. </if>
  41. <if test="remarks != null and remarks != ''">
  42. AND remarks = #{remarks}
  43. </if>
  44. <if test="makeStaff != null and makeStaff != ''">
  45. AND make_staff = #{makeStaff}
  46. </if>
  47. <if test="makeTime != null">
  48. AND make_time = #{makeTime}
  49. </if>
  50. <if test="flgValid != null">
  51. AND flg_valid = #{flgValid}
  52. </if>
  53. <if test="cpId != null">
  54. AND cp_id = #{cpId}
  55. </if>
  56. </where>
  57. </sql>
  58. <sql id="idsForeach">
  59. <!-- 根据主键itemId批量操作 -->
  60. WHERE item_id in
  61. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  62. #{item}
  63. </foreach>
  64. </sql>
  65. <!-- 查询表t_mst_money_account_item,(条件查询+分页)列表 -->
  66. <select id="selectByCond" resultMap="BaseResultMap">
  67. SELECT
  68. <include refid="Base_Column_List"/>
  69. FROM dkic_b.t_mst_money_account_item
  70. <include refid="Condition"/>
  71. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  72. limit #{end} offset #{start}
  73. </if>
  74. </select>
  75. <!-- 查询表t_mst_money_account_item,(条件查询)个数 -->
  76. <select id="countByCond" resultType="Long">
  77. SELECT
  78. count(1)
  79. FROM dkic_b.t_mst_money_account_item
  80. <include refid="Condition"/>
  81. </select>
  82. <!-- 根据主键查询表t_mst_money_account_item的一行数据 -->
  83. <select id="selectById" resultMap="BaseResultMap">
  84. SELECT
  85. <include refid="Base_Column_List"/>
  86. FROM dkic_b.t_mst_money_account_item
  87. WHERE item_id = #{id}::uuid
  88. </select>
  89. <!-- 根据主键锁定表t_mst_money_account_item的一行数据 -->
  90. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  91. SELECT
  92. <include refid="Base_Column_List"/>
  93. FROM dkic_b.t_mst_money_account_item
  94. WHERE item_id = #{id}::uuid
  95. for update
  96. </select>
  97. <!-- 根据来源Id锁定表t_mst_money_account_item的一行数据 -->
  98. <select id="selectByInvoiceIdForUpdate" resultMap="BaseResultMap">
  99. SELECT
  100. <include refid="Base_Column_List"/>
  101. FROM dkic_b.t_mst_money_account_item
  102. WHERE invoice_id = #{id}::uuid
  103. for update
  104. </select>
  105. <!-- 根据主键锁定表t_mst_money_account_item的多行数据 -->
  106. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM dkic_b.t_mst_money_account_item
  110. <include refid="idsForeach"/>
  111. for update
  112. </select>
  113. <insert id="insertBatch">
  114. insert into dkic_b.t_mst_money_account_item
  115. (
  116. <trim suffixOverrides=",">
  117. mac_id,
  118. flow_type,
  119. invoice_id,
  120. amt_inflow,
  121. acc_date,
  122. remarks,
  123. make_staff,
  124. make_time,
  125. cp_id,
  126. op_app_code,
  127. </trim>
  128. )
  129. values
  130. <foreach collection="list" index="index" item="item" separator=",">
  131. (
  132. <trim suffixOverrides=",">
  133. #{item.macId}::uuid,
  134. #{item.flowType},
  135. #{item.invoiceId}::uuid,
  136. #{item.amtInflow},
  137. #{item.accDate},
  138. #{item.remarks},
  139. #{item.makeStaff}::uuid,
  140. #{item.makeTime},
  141. #{item.cpId},
  142. #{item.opAppCode},
  143. </trim>
  144. )
  145. </foreach>
  146. </insert>
  147. <delete id="deleteByInvoiceId">
  148. DELETE FROM dkic_b.t_mst_money_account_item
  149. WHERE invoice_id = #{id}::uuid;
  150. </delete>
  151. <!-- 查询收款总额 -->
  152. <select id="getSumAmtInflow" resultType="java.util.Map">
  153. SELECT COALESCE(sum(tmmai.amt_inflow), 0) as "sumAmtInflow"
  154. FROM dkic_b.t_mst_money_account_item as tmmai
  155. where tmmai.flg_valid
  156. and tmmai.mac_id = #{id}::uuid
  157. </select>
  158. </mapper>