OutboundMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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.ivt.OutboundMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. out_id, out_no, out_type, from_id, from_no, org_id, staff_id, cus_id, sup_id, out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, out_date, remarks, annex_paths, make_staff, make_time, receivable_id, payable_id, flg_valid, cp_id
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Outbound">
  11. <id column="out_id" property="outId"/>
  12. <result column="out_no" property="outNo"/>
  13. <result column="out_type" property="outType"/>
  14. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  15. <result column="from_no" property="fromNo"/>
  16. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  17. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  18. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  19. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  20. <result column="out_status" property="outStatus"/>
  21. <result column="outing_qty" property="outingQty"/>
  22. <result column="outing_amt" property="outingAmt"/>
  23. <result column="out_qty" property="outQty"/>
  24. <result column="out_amt" property="outAmt"/>
  25. <result column="return_qty" property="returnQty"/>
  26. <result column="return_amt" property="returnAmt"/>
  27. <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
  28. <result column="remarks" property="remarks"/>
  29. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  30. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  31. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  32. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  33. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  34. <result column="flg_valid" property="flgValid"/>
  35. <result column="cp_id" property="cpId"/>
  36. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  37. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  38. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  39. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  40. <result column="op_app_code" property="opAppCode"/>
  41. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  42. <result column="op_db_user" property="opDbUser"/>
  43. </resultMap>
  44. <!-- 通用查询映射结果 -->
  45. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.OutboundResponse">
  46. <id column="out_id" property="outId"/>
  47. <result column="out_no" property="outNo"/>
  48. <result column="out_type" property="outType"/>
  49. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  50. <result column="from_no" property="fromNo"/>
  51. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  52. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  53. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  54. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  55. <result column="out_status" property="outStatus"/>
  56. <result column="outing_qty" property="outingQty"/>
  57. <result column="outing_amt" property="outingAmt"/>
  58. <result column="out_qty" property="outQty"/>
  59. <result column="out_amt" property="outAmt"/>
  60. <result column="return_qty" property="returnQty"/>
  61. <result column="return_amt" property="returnAmt"/>
  62. <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
  63. <result column="remarks" property="remarks"/>
  64. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  65. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  66. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  67. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  68. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  69. <result column="flg_valid" property="flgValid"/>
  70. <result column="cp_id" property="cpId"/>
  71. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  72. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  73. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  74. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  75. <result column="op_app_code" property="opAppCode"/>
  76. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  77. <result column="op_db_user" property="opDbUser"/>
  78. </resultMap>
  79. <!-- 通用条件列 -->
  80. <sql id="Condition">
  81. <where>
  82. <if test="outNo != null and outNo != ''">
  83. AND t.out_no = #{outNo}
  84. </if>
  85. <if test="outType != null and outType != ''">
  86. AND t.out_type = #{outType}
  87. </if>
  88. <if test="fromId != null and fromId != ''">
  89. AND t.from_id = #{fromId}
  90. </if>
  91. <if test="fromNo != null and fromNo != ''">
  92. AND t.from_no = #{fromNo}
  93. </if>
  94. <if test="orgId != null and orgId != ''">
  95. AND t.org_id = #{orgId}
  96. </if>
  97. <if test="staffId != null and staffId != ''">
  98. AND t.staff_id = #{staffId}
  99. </if>
  100. <if test="cusId != null and cusId != ''">
  101. AND t.cus_id = #{cusId}
  102. </if>
  103. <if test="supId != null and supId != ''">
  104. AND t.sup_id = #{supId}
  105. </if>
  106. <if test="outStatus != null and outStatus != ''">
  107. AND t.out_status = #{outStatus}
  108. </if>
  109. <if test="outingQty != null">
  110. AND t.outing_qty = #{outingQty}
  111. </if>
  112. <if test="outingAmt != null">
  113. AND t.outing_amt = #{outingAmt}
  114. </if>
  115. <if test="outQty != null">
  116. AND t.out_qty = #{outQty}
  117. </if>
  118. <if test="outAmt != null">
  119. AND t.out_amt = #{outAmt}
  120. </if>
  121. <if test="returnQty != null">
  122. AND t.return_qty = #{returnQty}
  123. </if>
  124. <if test="returnAmt != null">
  125. AND t.return_amt = #{returnAmt}
  126. </if>
  127. <if test="outDate != null">
  128. AND t.out_date = #{outDate}
  129. </if>
  130. <if test="remarks != null and remarks != ''">
  131. AND t.remarks = #{remarks}
  132. </if>
  133. <if test="annexPaths != null and annexPaths != ''">
  134. AND t.annex_paths = #{annexPaths}
  135. </if>
  136. <if test="makeStaff != null and makeStaff != ''">
  137. AND t.make_staff = #{makeStaff}
  138. </if>
  139. <if test="makeTime != null">
  140. AND t.make_time = #{makeTime}
  141. </if>
  142. <if test="receivableId != null and receivableId != ''">
  143. AND t.receivable_id = #{receivableId}
  144. </if>
  145. <if test="payableId != null and payableId != ''">
  146. AND t.payable_id = #{payableId}
  147. </if>
  148. <if test="flgValid != null">
  149. AND t.flg_valid = #{flgValid}
  150. </if>
  151. <if test="cpId != null">
  152. AND t.cp_id = #{cpId}
  153. </if>
  154. </where>
  155. </sql>
  156. <sql id="idsForeach">
  157. <!-- 根据主键outId批量操作 -->
  158. WHERE out_id in
  159. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  160. #{item}
  161. </foreach>
  162. </sql>
  163. <!-- 查询表t_psi_outbound,(条件查询+分页)列表 -->
  164. <select id="selectByCond" resultMap="BaseResultMapResponse">
  165. SELECT t.out_id,
  166. t.out_no,
  167. t.out_type,
  168. t.from_id,
  169. t.from_no,
  170. t.from_no as "orderNo",
  171. t.org_id,
  172. tmo.org_name as "orgName",
  173. t.staff_id,
  174. tms.staff_name as "staffName",
  175. t.cus_id,
  176. tmc.cus_code as "cusCode",
  177. tmc.cus_name as "cusName",
  178. tmc.cus_phone as "cusPhone",
  179. tmc.cus_from as "cusFrom",
  180. tmc.contact_phone as "contactPhone",
  181. tmc.address_full as "addressFull",
  182. tmdd.data_value as "cusFromName",
  183. t.sup_id,
  184. t.out_status,
  185. sys.f_get_name_i18n(tdk1.kind_name_i18n, 'zh_CN') as "outStatusName",
  186. t.outing_qty,
  187. t.outing_amt,
  188. t.out_qty,
  189. t.out_amt,
  190. t.return_qty,
  191. t.return_amt,
  192. t.out_date,
  193. t.remarks,
  194. t.annex_paths,
  195. t.make_staff,
  196. makestaff.staff_name as "makeStaffName",
  197. t.make_time,
  198. t.receivable_id,
  199. t.payable_id,
  200. t.flg_valid,
  201. t.cp_id
  202. FROM t_psi_outbound as t
  203. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  204. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  205. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  206. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  207. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  208. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  209. <include refid="Condition"/>
  210. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  211. limit #{end} offset #{start}
  212. </if>
  213. </select>
  214. <!-- 查询表t_psi_outbound,(条件查询)个数 -->
  215. <select id="countByCond" resultType="Long">
  216. SELECT
  217. count(1)
  218. FROM t_psi_outbound as t
  219. <include refid="Condition"/>
  220. </select>
  221. <!-- 根据主键查询表t_psi_outbound的一行数据 -->
  222. <select id="selectById" resultMap="BaseResultMap">
  223. SELECT
  224. <include refid="Base_Column_List"/>
  225. FROM t_psi_outbound
  226. WHERE out_id = #{outId}::uuid
  227. </select>
  228. <!-- 根据主键锁定表t_psi_outbound的一行数据 -->
  229. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  230. SELECT
  231. <include refid="Base_Column_List"/>
  232. FROM t_psi_outbound
  233. WHERE out_id = #{outId}
  234. for update
  235. </select>
  236. <!-- 根据主键锁定表t_psi_outbound的多行数据 -->
  237. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  238. SELECT
  239. <include refid="Base_Column_List"/>
  240. FROM t_psi_outbound
  241. <include refid="idsForeach"/>
  242. for update
  243. </select>
  244. <insert id="insertBatch">
  245. insert into t_psi_outbound
  246. (
  247. <trim suffixOverrides=",">
  248. out_no,
  249. out_type,
  250. from_id,
  251. from_no,
  252. org_id,
  253. staff_id,
  254. order_id,
  255. order_no,
  256. into_return_id,
  257. into_return_no,
  258. cus_id,
  259. sup_id,
  260. out_status,
  261. outing_qty,
  262. outing_amt,
  263. out_qty,
  264. out_amt,
  265. return_qty,
  266. return_amt,
  267. out_date,
  268. remarks,
  269. annex_paths,
  270. make_staff,
  271. make_time,
  272. receivable_id,
  273. payable_id,
  274. cp_id,
  275. op_app_code,
  276. </trim>
  277. )
  278. values
  279. <foreach collection="list" index="index" item="item" separator=",">
  280. (
  281. <trim suffixOverrides=",">
  282. #{item.outNo},
  283. #{item.outType},
  284. #{item.fromId}::uuid,
  285. #{item.fromNo},
  286. #{item.orgId}::uuid,
  287. #{item.staffId}::uuid,
  288. #{item.cusId}::uuid,
  289. #{item.supId}::uuid,
  290. #{item.outStatus},
  291. #{item.outingQty},
  292. #{item.outingAmt},
  293. #{item.outQty},
  294. #{item.outAmt},
  295. #{item.returnQty},
  296. #{item.returnAmt},
  297. #{item.outDate},
  298. #{item.remarks},
  299. #{item.annexPaths},
  300. #{item.makeStaff}::uuid,
  301. #{item.makeTime},
  302. #{item.receivableId}::uuid,
  303. #{item.payableId}::uuid,
  304. #{item.cpId},
  305. #{item.opAppCode},
  306. </trim>
  307. )
  308. </foreach>
  309. </insert>
  310. </mapper>