OtherReceivableMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.OtherReceivableResponse">
  29. <id column="receivable_id" property="receivableId"/>
  30. <result column="receivable_no" property="receivableNo"/>
  31. <result column="object_type" property="objectType"/>
  32. <result column="object_id" property="objectId" typeHandler="UuidTypeHandler"/>
  33. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  34. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  35. <result column="sum_amt_receivable" property="sumAmtReceivable"/>
  36. <result column="acc_item_id" property="accItemId" typeHandler="UuidTypeHandler"/>
  37. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  38. <result column="remarks" property="remarks"/>
  39. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  40. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  41. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  42. <result column="flg_valid" property="flgValid"/>
  43. <result column="cp_id" property="cpId"/>
  44. </resultMap>
  45. <!-- 通用条件列 -->
  46. <sql id="Condition">
  47. <where>
  48. <if test="receivableNo != null and receivableNo != ''">
  49. AND t.receivable_no LIKE concat('%',my_ex.likequery(#{receivableNo}),'%')
  50. </if>
  51. <if test="objectType != null and objectType != ''">
  52. AND t.object_type = #{objectType}
  53. </if>
  54. <if test="objectId != null and objectId != ''">
  55. AND t.object_id = #{objectId}
  56. </if>
  57. <if test="orgId != null and orgId != ''">
  58. AND t.org_id = #{orgId}
  59. </if>
  60. <if test="staffId != null and staffId != ''">
  61. AND t.staff_id = #{staffId}
  62. </if>
  63. <if test="sumAmtReceivable != null">
  64. AND t.sum_amt_receivable = #{sumAmtReceivable}
  65. </if>
  66. <if test="accItemId != null and accItemId != ''">
  67. AND t.acc_item_id = #{accItemId}
  68. </if>
  69. <if test="accDate != null">
  70. AND t.acc_date = #{accDate}
  71. </if>
  72. <if test="remarks != null and remarks != ''">
  73. AND t.remarks = #{remarks}
  74. </if>
  75. <if test="annexPaths != null and annexPaths != ''">
  76. AND t.annex_paths = #{annexPaths}
  77. </if>
  78. <if test="makeStaff != null and makeStaff != ''">
  79. AND t.make_staff = #{makeStaff}
  80. </if>
  81. <if test="cpId != null">
  82. AND t.cp_id = #{cpId}
  83. </if>
  84. <if test="cusPhone != null and cusPhone != ''">
  85. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  86. </if>
  87. <if test="cusName != null and cusName != ''">
  88. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  89. </if>
  90. <if test="orgIds != null and orgIds.size() > 0">
  91. AND t.org_id =any(#{orgIds, typeHandler=UuidListTypeHandler})
  92. </if>
  93. <if test="staffIds != null and staffIds.size() > 0">
  94. AND t.staff_id =any(#{staffIds, typeHandler=UuidListTypeHandler})
  95. </if>
  96. <if test="makeTimeStart != null and makeTimeEnd != null">
  97. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  98. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  99. </if>
  100. <if test="flgValidList != null and flgValidList.size()>0">
  101. AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  102. </if>
  103. </where>
  104. </sql>
  105. <sql id="idsForeach">
  106. <!-- 根据主键receivableId批量操作 -->
  107. WHERE receivable_id in
  108. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  109. #{item}
  110. </foreach>
  111. </sql>
  112. <!-- 查询表t_mac_other_receivable,(条件查询+分页)列表 -->
  113. <select id="selectByCond" resultMap="BaseResultMapResponse">
  114. SELECT t.receivable_id,
  115. t.receivable_no,
  116. t.object_type,
  117. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "objectTypeName",
  118. t.object_id,
  119. tmc.cus_code as "cusCode",
  120. tmc.cus_name as "cusName",
  121. tmc.cus_phone as "cusPhone",
  122. t.org_id,
  123. tmo.org_name as "orgName",
  124. t.staff_id,
  125. tms.staff_name as "staffName",
  126. t.sum_amt_receivable,
  127. t.acc_item_id,
  128. t.acc_date,
  129. t.remarks,
  130. t.annex_paths,
  131. t.make_staff,
  132. makestaff.staff_name as "makeStaffName",
  133. t.make_time,
  134. t.flg_valid,
  135. t.cp_id
  136. FROM dkic_b.t_mac_other_receivable as t
  137. left join dkic_b.t_mst_customer tmc
  138. on tmc.cus_id = t.object_id and t.object_type in ('对象类型-客户')
  139. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  140. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  141. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  142. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
  143. <include refid="Condition"/>
  144. order by t.op_create_time desc
  145. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  146. limit #{end} offset #{start}
  147. </if>
  148. </select>
  149. <!-- 查询表t_mac_other_receivable,(条件查询)个数 -->
  150. <select id="countByCond" resultType="Long">
  151. SELECT
  152. count(1)
  153. FROM dkic_b.t_mac_other_receivable as t
  154. left join dkic_b.t_mst_customer tmc
  155. on tmc.cus_id = t.object_id and t.object_type in ('对象类型-客户')
  156. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  157. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  158. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  159. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
  160. <include refid="Condition"/>
  161. </select>
  162. <!-- 根据主键查询表t_mac_other_receivable的一行数据 -->
  163. <select id="selectById" resultMap="BaseResultMapResponse">
  164. SELECT t.receivable_id,
  165. t.receivable_no,
  166. t.object_type,
  167. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "objectTypeName",
  168. t.object_id,
  169. tmc.cus_code as "cusCode",
  170. tmc.cus_name as "cusName",
  171. tmc.cus_phone as "cusPhone",
  172. t.org_id,
  173. tmo.org_name as "orgName",
  174. t.staff_id,
  175. tms.staff_name as "staffName",
  176. t.sum_amt_receivable,
  177. t.acc_item_id,
  178. t.acc_date,
  179. t.remarks,
  180. t.annex_paths,
  181. t.make_staff,
  182. makestaff.staff_name as "makeStaffName",
  183. t.make_time,
  184. t.flg_valid,
  185. t.cp_id
  186. FROM dkic_b.t_mac_other_receivable as t
  187. left join dkic_b.t_mst_customer tmc
  188. on tmc.cus_id = t.object_id and t.object_type in ('对象类型-客户')
  189. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  190. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  191. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  192. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.object_type
  193. WHERE receivable_id = #{id}::uuid
  194. </select>
  195. <!-- 根据主键锁定表t_mac_other_receivable的一行数据 -->
  196. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  197. SELECT
  198. <include refid="Base_Column_List"/>
  199. FROM dkic_b.t_mac_other_receivable
  200. WHERE receivable_id = #{id}::uuid
  201. for update
  202. </select>
  203. <!-- 根据主键锁定表t_mac_other_receivable的多行数据 -->
  204. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  205. SELECT
  206. <include refid="Base_Column_List"/>
  207. FROM dkic_b.t_mac_other_receivable
  208. <include refid="idsForeach"/>
  209. for update
  210. </select>
  211. <insert id="insertBatch">
  212. insert into dkic_b.t_mac_other_receivable
  213. (
  214. <trim suffixOverrides=",">
  215. receivable_no,
  216. object_type,
  217. object_id,
  218. org_id,
  219. staff_id,
  220. sum_amt_receivable,
  221. acc_item_id,
  222. acc_date,
  223. remarks,
  224. annex_paths,
  225. make_staff,
  226. make_time,
  227. cp_id,
  228. </trim>
  229. )
  230. values
  231. <foreach collection="list" index="index" item="item" separator=",">
  232. (
  233. <trim suffixOverrides=",">
  234. #{item.receivableNo},
  235. #{item.objectType},
  236. #{item.objectId}::uuid,
  237. #{item.orgId}::uuid,
  238. #{item.staffId}::uuid,
  239. #{item.sumAmtReceivable},
  240. #{item.accItemId}::uuid,
  241. #{item.accDate},
  242. #{item.remarks},
  243. #{item.annexPaths},
  244. #{item.makeStaff}::uuid,
  245. #{item.makeTime},
  246. #{item.cpId},
  247. </trim>
  248. )
  249. </foreach>
  250. </insert>
  251. </mapper>