MacTransferMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.MacTransferMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. trf_id, trf_no, trf_type, org_id, staff_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.MacTransfer">
  11. <id column="trf_id" property="trfId"/>
  12. <result column="trf_no" property="trfNo"/>
  13. <result column="trf_type" property="trfType"/>
  14. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  15. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  16. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  17. <result column="remarks" property="remarks"/>
  18. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  19. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  20. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  21. <result column="flg_valid" property="flgValid"/>
  22. <result column="cp_id" property="cpId"/>
  23. </resultMap>
  24. <!-- 通用查询映射结果 -->
  25. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.MacTransferResponse">
  26. <id column="trf_id" property="trfId"/>
  27. <result column="trf_no" property="trfNo"/>
  28. <result column="trf_type" property="trfType"/>
  29. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  30. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  31. <result column="acc_date" property="accDate" typeHandler="TimestampTypeHandler"/>
  32. <result column="remarks" property="remarks"/>
  33. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  34. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  35. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  36. <result column="flg_valid" property="flgValid"/>
  37. <result column="cp_id" property="cpId"/>
  38. </resultMap>
  39. <!-- 通用条件列 -->
  40. <sql id="Condition">
  41. <where>
  42. <if test="trfNo != null and trfNo != ''">
  43. AND t.trf_no LIKE concat('%',my_ex.likequery(#{trfNo}),'%')
  44. </if>
  45. <if test="trfType != null">
  46. AND t.trf_type = #{trfType}
  47. </if>
  48. <if test="orgId != null and orgId != ''">
  49. AND org_id = #{orgId}
  50. </if>
  51. <if test="staffId != null and staffId != ''">
  52. AND staff_id = #{staffId}
  53. </if>
  54. <if test="accDate != null">
  55. AND t.acc_date = #{accDate}
  56. </if>
  57. <if test="remarks != null and remarks != ''">
  58. AND t.remarks LIKE concat('%',my_ex.likequery(#{remarks}),'%')
  59. </if>
  60. <if test="annexPaths != null and annexPaths != ''">
  61. AND t.annex_paths = #{annexPaths}
  62. </if>
  63. <if test="makeStaff != null and makeStaff != ''">
  64. AND t.make_staff = #{makeStaff}
  65. </if>
  66. <if test="cpId != null">
  67. AND t.cp_id = #{cpId}
  68. </if>
  69. <if test="orgIdList != null and orgIdList.size() > 0">
  70. AND t.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  71. </if>
  72. <if test="staffIdList != null and staffIdList.size() > 0">
  73. AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  74. </if>
  75. <if test="makeTimeStart != null and makeTimeEnd != null">
  76. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  77. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  78. </if>
  79. <if test="flgValidList != null and flgValidList.size()>0">
  80. AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  81. </if>
  82. </where>
  83. </sql>
  84. <sql id="idsForeach">
  85. <!-- 根据主键trfId批量操作 -->
  86. WHERE trf_id in
  87. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  88. #{item}
  89. </foreach>
  90. </sql>
  91. <!-- 查询表t_mac_transfer,(条件查询+分页)列表 -->
  92. <select id="selectByCond" resultMap="BaseResultMapResponse">
  93. SELECT t.trf_id,
  94. t.trf_no,
  95. t.trf_type,
  96. case when t.trf_type = 0 then '期初' else '转账' end as "trfTypeName",
  97. t.org_id,
  98. t.staff_id,
  99. t.acc_date,
  100. t.remarks,
  101. t.annex_paths,
  102. t.make_staff,
  103. t.make_time,
  104. t.flg_valid,
  105. t.cp_id,
  106. tmo.org_name as "orgName",
  107. tms.staff_name as "staffName",
  108. makestaff.staff_name as "makeStaffName"
  109. FROM dkic_b.t_mac_transfer as t
  110. left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
  111. left join dkic_b.t_mst_staff tms on t.staff_id = tms.staff_id
  112. left join dkic_b.t_mst_staff as makestaff on t.make_staff = makestaff.staff_id
  113. <include refid="Condition"/>
  114. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  115. limit #{end} offset #{start}
  116. </if>
  117. </select>
  118. <!-- 查询表t_mac_transfer,(条件查询)个数 -->
  119. <select id="countByCond" resultType="Long">
  120. SELECT count(1)
  121. FROM dkic_b.t_mac_transfer as t
  122. left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
  123. left join dkic_b.t_mst_staff tms on t.staff_id = tms.staff_id
  124. left join dkic_b.t_mst_staff as makestaff on t.make_staff = makestaff.staff_id
  125. <include refid="Condition"/>
  126. </select>
  127. <!-- 根据主键查询表t_mac_transfer的一行数据 -->
  128. <select id="selectById" resultMap="BaseResultMapResponse">
  129. SELECT t.trf_id,
  130. t.trf_no,
  131. t.trf_type,
  132. case when t.trf_type = 0 then '期初' else '转账' end as "trfTypeName",
  133. t.org_id,
  134. t.staff_id,
  135. t.acc_date,
  136. t.remarks,
  137. t.annex_paths,
  138. t.make_staff,
  139. t.make_time,
  140. t.flg_valid,
  141. t.cp_id,
  142. tmo.org_name as "orgName",
  143. tms.staff_name as "staffName",
  144. makestaff.staff_name as "makeStaffName"
  145. FROM dkic_b.t_mac_transfer as t
  146. left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
  147. left join dkic_b.t_mst_staff tms on t.staff_id = tms.staff_id
  148. left join dkic_b.t_mst_staff as makestaff on t.make_staff = makestaff.staff_id
  149. WHERE trf_id = #{id}::uuid
  150. </select>
  151. <!-- 根据主键锁定表t_mac_transfer的一行数据 -->
  152. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  153. SELECT
  154. <include refid="Base_Column_List"/>
  155. FROM dkic_b.t_mac_transfer
  156. WHERE trf_id = #{id}::uuid
  157. for update
  158. </select>
  159. <!-- 根据主键锁定表t_mac_transfer的多行数据 -->
  160. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  161. SELECT
  162. <include refid="Base_Column_List"/>
  163. FROM dkic_b.t_mac_transfer
  164. <include refid="idsForeach"/>
  165. for update
  166. </select>
  167. <insert id="insertBatch">
  168. insert into dkic_b.t_mac_transfer
  169. (
  170. <trim suffixOverrides=",">
  171. trf_no,
  172. trf_type,
  173. org_id,
  174. staff_id,
  175. acc_date,
  176. remarks,
  177. annex_paths,
  178. make_staff,
  179. make_time,
  180. cp_id,
  181. op_app_code,
  182. </trim>
  183. )
  184. values
  185. <foreach collection="list" index="index" item="item" separator=",">
  186. (
  187. <trim suffixOverrides=",">
  188. #{item.trfNo},
  189. #{item.trfType},
  190. #{item.orgId}::uuid,
  191. #{item.staffId}::uuid,
  192. #{item.accDate},
  193. #{item.remarks},
  194. #{item.annexPaths},
  195. #{item.makeStaff}::uuid,
  196. #{item.makeTime},
  197. #{item.cpId},
  198. #{item.opAppCode},
  199. </trim>
  200. )
  201. </foreach>
  202. </insert>
  203. </mapper>