OtherReceivableMapper.xml 13 KB

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