MoneyAccountMapper.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.MoneyAccountMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. mac_id, mac_code, mac_name, mac_type, balance, display_no, flg_default, mac_receipt_code, remarks, 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. <sql id="Base_Column_List_">
  10. tmma.mac_id, tmma.mac_code, tmma.mac_name, tmma.mac_type, tmma.balance, tmma.display_no, tmma.flg_default, tmma.mac_receipt_code, tmma.remarks, tmma.flg_valid, tmma.cp_id, tmma.op_create_time, tmma.op_create_user_id, tmma.op_update_time, tmma.op_update_user_id, tmma.op_app_code, tmma.op_timestamp, tmma.op_db_user
  11. </sql>
  12. <!-- 通用查询映射结果 -->
  13. <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.MoneyAccountResponse">
  14. <id column="mac_id" property="macId"/>
  15. <result column="mac_code" property="macCode"/>
  16. <result column="mac_name" property="macName"/>
  17. <result column="mac_type" property="macType" typeHandler="UuidTypeHandler"/>
  18. <result column="balance" property="balance"/>
  19. <result column="display_no" property="displayNo"/>
  20. <result column="flg_default" property="flgDefault"/>
  21. <result column="mac_receipt_code" property="macReceiptCode"/>
  22. <result column="remarks" property="remarks"/>
  23. <result column="flg_valid" property="flgValid"/>
  24. <result column="cp_id" property="cpId"/>
  25. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  26. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  27. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  28. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  29. <result column="op_app_code" property="opAppCode"/>
  30. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  31. <result column="op_db_user" property="opDbUser"/>
  32. </resultMap>
  33. <!-- 通用条件列 -->
  34. <sql id="Condition">
  35. <where>
  36. <if test="macCode != null and macCode != ''">
  37. AND ma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
  38. </if>
  39. <if test="macName != null and macName != ''">
  40. AND ma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
  41. </if>
  42. <if test="remarks != null and remarks != ''">
  43. AND ma.remarks = LIKE concat('%',my_ex.likequery(#{remarks}),'%')
  44. </if>
  45. <if test="cpId != null">
  46. AND ma.cp_id = #{cpId}
  47. </if>
  48. <if test="opTimestamp != null">
  49. AND ma.op_timestamp = #{opTimestamp}
  50. </if>
  51. <if test="flgValidList != null and flgValidList.size>0">
  52. AND ma.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  53. </if>
  54. <if test="flgValid != null ">
  55. AND ma.flg_valid = #{flgValid}
  56. </if>
  57. <if test="macTypeList != null and macTypeList.size() > 0">
  58. AND ma.mac_Type =any(#{macTypeList, typeHandler=UuidListTypeHandler})
  59. </if>
  60. </where>
  61. </sql>
  62. <!-- 查询表t_mst_money_account,(条件查询+分页)列表 -->
  63. <select id="selectByCond" resultMap="BaseResultMap">
  64. SELECT ma.mac_Type,ma.mac_code,ma.mac_name,ma.remarks
  65. ,ma.cp_id,ma.flg_valid
  66. ,dd.data_value AS "macTypeName"
  67. ,ma.mac_id,ma.balance,ma.display_no
  68. FROM dkic_b.t_mst_money_account ma
  69. left join dkic_b.t_mst_dictionary_data dd on ma.mac_type=dd.data_id
  70. <include refid="Condition"/>
  71. </select>
  72. <!-- 查询表t_mst_money_account,(条件查询)个数 -->
  73. <select id="countByCond" resultType="Long">
  74. SELECT
  75. count(1)
  76. FROM dkic_b.t_mst_money_account ma
  77. <include refid="Condition"/>
  78. </select>
  79. <!-- 王英杰 2024年3月6日 微信小程序用 -->
  80. <select id="wxSelectByCond" resultType="java.util.Map">
  81. SELECT T
  82. .*
  83. FROM
  84. (
  85. SELECT
  86. tmdd.data_id AS "macId",
  87. null AS "macType",
  88. null AS "macCode",
  89. tmdd.data_value AS "macName",
  90. null AS "Remarks",
  91. 'true' AS "flgValid",
  92. null AS "macTypeName",
  93. null AS "macId",
  94. null AS "balance",
  95. null AS "displayNo"
  96. FROM
  97. dkic_b.t_mst_dictionary_data tmdd
  98. WHERE
  99. tmdd.dict_code = '账户类别' UNION ALL
  100. SELECT
  101. ma.mac_id AS "macId",
  102. ma.mac_Type as "macType",
  103. ma.mac_code AS "macCode",
  104. ma.mac_name AS "macName",
  105. ma.remarks AS "Remarks",
  106. ma.flg_valid AS "flgValid",
  107. dd.data_value AS "macTypeName",
  108. ma.mac_id AS "macId",
  109. ma.balance AS "balance",
  110. ma.display_no AS "displayNo"
  111. FROM
  112. dkic_b.t_mst_money_account ma
  113. LEFT JOIN dkic_b.t_mst_dictionary_data dd ON ma.mac_type = dd.data_id
  114. <include refid="Condition"/>
  115. ) T
  116. <where>
  117. <if test="searchText !=null">
  118. AND T."macName" LIKE concat('%', #{searchText}, '%')
  119. </if>
  120. </where>
  121. </select>
  122. <!-- 王英杰 2024年3月6日 微信小程序用 -->
  123. <select id="wxCountByCond" resultType="Long">
  124. SELECT
  125. count(1)
  126. FROM
  127. (
  128. SELECT
  129. null AS "macType",
  130. tmdd.data_value AS "macCode",
  131. null AS "macName",
  132. null AS "Remarks",
  133. null AS "flgValid",
  134. null AS "macTypeName",
  135. null AS "macId",
  136. null AS "balance",
  137. null AS "displayNo"
  138. FROM
  139. dkic_b.t_mst_dictionary_data tmdd
  140. WHERE
  141. tmdd.dict_code = '账户类别' UNION ALL
  142. SELECT
  143. ma.mac_Type as "macType",
  144. ma.mac_code AS "macCode",
  145. ma.mac_name AS "macName",
  146. ma.remarks AS "Remarks",
  147. ma.flg_valid AS "flgValid",
  148. dd.data_value AS "macTypeName",
  149. ma.mac_id AS "macId",
  150. ma.balance AS "balance",
  151. ma.display_no AS "displayNo"
  152. FROM
  153. dkic_b.t_mst_money_account ma
  154. LEFT JOIN dkic_b.t_mst_dictionary_data dd ON ma.mac_type = dd.data_id
  155. <include refid="Condition"/>
  156. ) T
  157. <where>
  158. <if test="searchText !=null">
  159. AND T."macName" LIKE concat('%', #{searchText}, '%')
  160. </if>
  161. </where>
  162. </select>
  163. <!-- 根据主键查询表t_mst_money_account的一行数据 -->
  164. <select id="selectById" resultMap="BaseResultMap">
  165. SELECT
  166. <include refid="Base_Column_List_"/>
  167. ,tmdd.data_value AS "macTypeName"
  168. FROM dkic_b.t_mst_money_account tmma
  169. left join dkic_b.t_mst_dictionary_data tmdd on tmma.mac_type=tmdd.data_id
  170. WHERE tmma.mac_id = #{macId}::uuid
  171. </select>
  172. <select id="selectDisplayNo" resultType="Integer">
  173. SELECT MAX(display_no) + 1 FROM dkic_b.t_mst_money_account ma
  174. WHERE ma.cp_id = #{cpId}
  175. </select>
  176. <!-- 根据主键锁定表t_mst_money_account的一行数据 -->
  177. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  178. SELECT
  179. <include refid="Base_Column_List"/>
  180. FROM t_mst_money_account
  181. WHERE mac_id = #{id}::uuid
  182. for update
  183. </select>
  184. </mapper>