OtherReceivableMapper.xml 6.4 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.mac.OtherReceivableMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. receivable_id, receivable_no, object_type, object_id, org_id, staff_id, sum_amt_receivable, acc_item_id, acc_date, remarks, annex_paths, make_staff, make_time, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mac.OtherReceivable">
  11. <id column="receivable_id" property="receivableId"/>
  12. <result column="receivable_no" property="receivableNo"/>
  13. <result column="object_type" property="objectType"/>
  14. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  15. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  16. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  17. <result column="sum_amt_receivable" property="sumAmtReceivable"/>
  18. <result column="acc_item_id" property="accItemId" typeHandler="UuidTypeHandler"/>
  19. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  20. <result column="remarks" property="remarks"/>
  21. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  22. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  23. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  24. <result column="flg_valid" property="flgValid"/>
  25. <result column="cp_id" property="cpId"/>
  26. </resultMap>
  27. <!-- 通用条件列 -->
  28. <sql id="Condition">
  29. <where>
  30. <if test="receivableNo != null and receivableNo != ''">
  31. AND receivable_no = #{receivableNo}
  32. </if>
  33. <if test="objectType != null and objectType != ''">
  34. AND object_type = #{objectType}
  35. </if>
  36. <if test="objectId != null and objectId != ''">
  37. AND object_id = #{objectId}
  38. </if>
  39. <if test="orgId != null and orgId != ''">
  40. AND org_id = #{orgId}
  41. </if>
  42. <if test="staffId != null and staffId != ''">
  43. AND staff_id = #{staffId}
  44. </if>
  45. <if test="sumAmtReceivable != null">
  46. AND sum_amt_receivable = #{sumAmtReceivable}
  47. </if>
  48. <if test="accItemId != null and accItemId != ''">
  49. AND acc_item_id = #{accItemId}
  50. </if>
  51. <if test="accDate != null">
  52. AND acc_date = #{accDate}
  53. </if>
  54. <if test="remarks != null and remarks != ''">
  55. AND remarks = #{remarks}
  56. </if>
  57. <if test="annexPaths != null and annexPaths != ''">
  58. AND annex_paths = #{annexPaths}
  59. </if>
  60. <if test="makeStaff != null and makeStaff != ''">
  61. AND make_staff = #{makeStaff}
  62. </if>
  63. <if test="makeTime != null">
  64. AND make_time = #{makeTime}
  65. </if>
  66. <if test="flgValid != null">
  67. AND flg_valid = #{flgValid}
  68. </if>
  69. <if test="cpId != null">
  70. AND cp_id = #{cpId}
  71. </if>
  72. </where>
  73. </sql>
  74. <sql id="idsForeach">
  75. <!-- 根据主键receivableId批量操作 -->
  76. WHERE receivable_id in
  77. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  78. #{item}
  79. </foreach>
  80. </sql>
  81. <!-- 查询表t_mac_other_receivable,(条件查询+分页)列表 -->
  82. <select id="selectByCond" resultMap="BaseResultMap">
  83. SELECT
  84. <include refid="Base_Column_List"/>
  85. FROM t_mac_other_receivable
  86. <include refid="Condition"/>
  87. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  88. limit #{end} offset #{start}
  89. </if>
  90. </select>
  91. <!-- 查询表t_mac_other_receivable,(条件查询)个数 -->
  92. <select id="countByCond" resultType="Long">
  93. SELECT
  94. count(1)
  95. FROM t_mac_other_receivable
  96. <include refid="Condition"/>
  97. </select>
  98. <!-- 根据主键查询表t_mac_other_receivable的一行数据 -->
  99. <select id="selectById" resultMap="BaseResultMap">
  100. SELECT
  101. <include refid="Base_Column_List"/>
  102. FROM t_mac_other_receivable
  103. WHERE receivable_id = #{receivableId}::uuid
  104. </select>
  105. <!-- 根据主键锁定表t_mac_other_receivable的一行数据 -->
  106. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM t_mac_other_receivable
  110. WHERE receivable_id = #{id}::uuid
  111. for update
  112. </select>
  113. <!-- 根据主键锁定表t_mac_other_receivable的多行数据 -->
  114. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  115. SELECT
  116. <include refid="Base_Column_List"/>
  117. FROM t_mac_other_receivable
  118. <include refid="idsForeach"/>
  119. for update
  120. </select>
  121. <insert id="insertBatch">
  122. insert into t_mac_other_receivable
  123. (
  124. <trim suffixOverrides=",">
  125. receivable_no,
  126. object_type,
  127. object_id,
  128. org_id,
  129. staff_id,
  130. sum_amt_receivable,
  131. acc_item_id,
  132. acc_date,
  133. remarks,
  134. annex_paths,
  135. make_staff,
  136. make_time,
  137. cp_id,
  138. </trim>
  139. )
  140. values
  141. <foreach collection="list" index="index" item="item" separator=",">
  142. (
  143. <trim suffixOverrides=",">
  144. #{item.receivableNo},
  145. #{item.objectType},
  146. #{item.objectId}::uuid,
  147. #{item.orgId}::uuid,
  148. #{item.staffId}::uuid,
  149. #{item.sumAmtReceivable},
  150. #{item.accItemId}::uuid,
  151. #{item.accDate},
  152. #{item.remarks},
  153. #{item.annexPaths},
  154. #{item.makeStaff}::uuid,
  155. #{item.makeTime},
  156. #{item.cpId},
  157. </trim>
  158. )
  159. </foreach>
  160. </insert>
  161. </mapper>