InboundMapper.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  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.InboundMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. into_id
  8. , into_no, into_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
  9. into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty,
  10. return_amt, into_date, remarks, annex_paths, make_staff, make_time,
  11. receivable_id, payable_id, flg_valid, cp_id, op_create_time, op_create_user_id,
  12. op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,wh_id,
  13. into_reason
  14. </sql>
  15. <!-- response通用查询列 -->
  16. <sql id="Base_Column_List_Response">
  17. tpi.into_id, tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id,
  18. tpi.cus_id, tpi.sup_id, tpi.into_status, tpi.intoing_qty, tpi.intoing_amt, tpi.into_qty,
  19. tpi.into_amt, tpi.return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths,
  20. tpi.make_staff, tpi.make_time, tpi.receivable_id, tpi.payable_id, tpi.flg_valid, tpi.cp_id,
  21. tpi.wh_id,tpi.into_reason
  22. </sql>
  23. <!-- 通用查询映射结果 -->
  24. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Inbound">
  25. <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
  26. <result column="into_no" property="intoNo"/>
  27. <result column="into_type" property="intoType"/>
  28. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  29. <result column="from_no" property="fromNo"/>
  30. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  31. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  32. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  33. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  34. <result column="into_status" property="intoStatus"/>
  35. <result column="intoing_qty" property="intoingQty"/>
  36. <result column="intoing_amt" property="intoingAmt"/>
  37. <result column="into_qty" property="intoQty"/>
  38. <result column="into_amt" property="intoAmt"/>
  39. <result column="return_qty" property="returnQty"/>
  40. <result column="return_amt" property="returnAmt"/>
  41. <result column="into_date" property="intoDate" typeHandler="TimestampTypeHandler"/>
  42. <result column="remarks" property="remarks"/>
  43. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  44. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  45. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  46. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  47. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  48. <result column="flg_valid" property="flgValid"/>
  49. <result column="cp_id" property="cpId"/>
  50. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  51. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  52. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  53. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  54. <result column="op_app_code" property="opAppCode"/>
  55. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  56. <result column="op_db_user" property="opDbUser"/>
  57. <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
  58. <result column="wh_id" property="whId"/>
  59. </resultMap>
  60. <!-- response查询映射结果 -->
  61. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
  62. <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
  63. <result column="into_no" property="intoNo"/>
  64. <result column="into_type" property="intoType"/>
  65. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  66. <result column="from_no" property="fromNo"/>
  67. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  68. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  69. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  70. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  71. <result column="into_status" property="intoStatus"/>
  72. <result column="intoing_qty" property="intoingQty"/>
  73. <result column="intoing_amt" property="intoingAmt"/>
  74. <result column="into_qty" property="intoQty"/>
  75. <result column="into_amt" property="intoAmt"/>
  76. <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
  77. <result column="return_qty" property="returnQty"/>
  78. <result column="return_amt" property="returnAmt"/>
  79. <result column="into_date" property="intoDate" typeHandler="TimestampTypeHandler"/>
  80. <result column="remarks" property="remarks"/>
  81. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  82. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  83. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  84. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  85. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  86. <result column="flg_valid" property="flgValid"/>
  87. <result column="cp_id" property="cpId"/>
  88. <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
  89. <result column="into_reason_name" property="intoReasonName" />
  90. <!-- <result column="orgName" property="orgName" />-->
  91. <!-- <result column="staff_name" property="staffName" />-->
  92. <result column="cus_code" property="cusCode" />
  93. <result column="cus_name" property="cusName" />
  94. <result column="cus_phone" property="cusPhone" />
  95. <result column="contact_phone" property="contactPhone" />
  96. <result column="contact_name" property="contactName" />
  97. <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
  98. <result column="address_name" property="addressName"/>
  99. <result column="address_no" property="addressNo"/>
  100. <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
  101. <result column="address_full" property="addressFull"/>
  102. <result column="channel_name" property="channelName" />
  103. <result column="cus_from_name" property="cusFromName" />
  104. <result column="return_address" property="returnAddress" />
  105. </resultMap>
  106. <!-- response明细通用查询列 -->
  107. <sql id="Base_Column_List_Item_Response">
  108. tpi.into_id
  109. , tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id, tpi.cus_id, tpi.sup_id, tpi.into_status, tpi.intoing_qty, tpi.intoing_amt,
  110. tpi.into_qty, tpi.into_amt, tpi.return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths, tpi.make_staff, tpi.make_time,
  111. tpi.receivable_id, tpi.payable_id, tpi.flg_valid, tpi.cp_id
  112. </sql>
  113. <!-- response明细关联明细映射-->
  114. <resultMap id="BaseResultMapItemResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
  115. <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
  116. <result column="into_no" property="intoNo"/>
  117. <result column="into_type" property="intoType"/>
  118. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  119. <result column="from_no" property="fromNo"/>
  120. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  121. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  122. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  123. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  124. <result column="into_status" property="intoStatus"/>
  125. <result column="intoing_qty" property="intoingQty"/>
  126. <result column="intoing_amt" property="intoingAmt"/>
  127. <result column="into_qty" property="intoQty"/>
  128. <result column="into_amt" property="intoAmt"/>
  129. <result column="return_qty" property="returnQty"/>
  130. <result column="return_amt" property="returnAmt"/>
  131. <result column="into_date" property="intoDate" typeHandler="TimestampTypeHandler"/>
  132. <result column="remarks" property="remarks"/>
  133. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  134. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  135. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  136. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  137. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  138. <result column="flg_valid" property="flgValid"/>
  139. <result column="cp_id" property="cpId"/>
  140. <collection property="inboundItemList" resultMap="inboundItemListMap" columnPrefix="list_"/>
  141. </resultMap>
  142. <!-- 关联映射-->
  143. <resultMap id="inboundItemListMap" type="java.util.Map">
  144. <result column="item_id" property="itemId" typeHandler="UuidTypeHandler"/>
  145. <result column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
  146. <result column="into_type" property="intoType"/>
  147. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  148. <result column="from_item_id" property="fromItemId" typeHandler="UuidTypeHandler"/>
  149. <result column="item_index" property="itemIndex"/>
  150. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  151. <result column="item_qty" property="itemQty"/>
  152. <result column="price_into" property="priceInto"/>
  153. <result column="item_amt" property="itemAmt"/>
  154. <result column="non_std_code" property="nonStdCode"/>
  155. <result column="into_status" property="intoStatus"/>
  156. <result column="intoing_qty" property="intoingQty"/>
  157. <result column="intoing_amt" property="intoingAmt"/>
  158. <result column="into_qty" property="intoQty"/>
  159. <result column="into_amt" property="intoAmt"/>
  160. <result column="return_qty" property="returnQty"/>
  161. <result column="return_amt" property="returnAmt"/>
  162. <result column="remarks" property="remarks"/>
  163. <result column="inv_id" property="invId" typeHandler="UuidTypeHandler"/>
  164. <result column="cost_price" property="costPrice"/>
  165. <result column="cost_amt" property="costAmt"/>
  166. <result column="out_qty" property="outQty"/>
  167. <result column="inv_qty" property="invQty"/>
  168. <result column="flg_valid" property="flgValid"/>
  169. <result column="cp_id" property="cpId"/>
  170. <result column="sku_code" property="skuCode"/>
  171. <result column="sku_name" property="skuName"/>
  172. <result column="sku_model" property="skuModel"/>
  173. <result column="price_purchase" property="pricePurchase"/>
  174. <result column="reject_qty" property="rejectQty"/>
  175. <result column="sku_images" property="skuImages" typeHandler="JsonTypeHandler"/>
  176. <result column="usable_qty" property="usableQty"/>
  177. <result column="inv_qty" property="invQty"/>
  178. <result column="outing_qty" property="outingQty"/>
  179. <result column="price_std" property="priceStd"/>
  180. <result column="into_item_id" property="intoItemId"/>
  181. <result column="wh_name" property="whName"/>
  182. <result column="wh_code" property="whCode"/>
  183. </resultMap>
  184. <!-- 通用条件列 -->
  185. <sql id="Condition">
  186. <where>
  187. <if test="intoNo != null and intoNo != ''">
  188. AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
  189. </if>
  190. <if test="intoType != null and intoType != ''">
  191. AND tpi.into_type LIKE concat('%',my_ex.likequery(#{intoType}),'%')
  192. </if>
  193. <if test="intoTypes != null and intoTypes.size()>0">
  194. AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
  195. </if>
  196. <if test="searchText !=null and searchText != ''">
  197. AND (
  198. tpi.into_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  199. or tpi.from_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  200. or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  201. or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  202. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  203. or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  204. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  205. )
  206. </if>
  207. <if test="fromId != null and fromId != ''">
  208. AND tpi.from_id = #{fromId}::uuid
  209. </if>
  210. <if test="fromNo != null and fromNo != ''">
  211. AND tpi.from_no LIKE concat('%',my_ex.likequery(#{fromNo}),'%')
  212. </if>
  213. <if test="orgId != null and orgId != ''">
  214. AND tpi.org_id = #{orgId}::uuid
  215. </if>
  216. <if test="staffId != null and staffId != ''">
  217. AND tpi.staff_id = #{staffId}::uuid
  218. </if>
  219. <if test="cusId != null and cusId != ''">
  220. AND tpi.cus_id = #{cusId}::uuid
  221. </if>
  222. <if test="supId != null and supId != ''">
  223. AND tpi.sup_id = #{supId}::uuid
  224. </if>
  225. <if test="makeStaff != null and makeStaff != ''">
  226. AND tpi.make_staff = #{makeStaff}
  227. </if>
  228. <if test="makeTime != null">
  229. AND tpi.make_time = #{makeTime}
  230. </if>
  231. <if test="receivableId != null and receivableId != ''">
  232. AND tpi.receivable_id = #{receivableId}
  233. </if>
  234. <if test="payableId != null and payableId != ''">
  235. AND tpi.payable_id = #{payableId}
  236. </if>
  237. <if test="flgValid != null">
  238. AND tpi.flg_valid = #{flgValid}
  239. </if>
  240. <if test="cpId != null">
  241. AND tpi.cp_id = #{cpId}
  242. </if>
  243. <if test="cusPhone != null and cusPhone != ''">
  244. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  245. </if>
  246. <if test="cusName != null and cusName != ''">
  247. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  248. </if>
  249. <if test="orgIdList != null and orgIdList.size() > 0">
  250. AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  251. </if>
  252. <if test="staffIdList != null and staffIdList.size() > 0">
  253. AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  254. </if>
  255. <if test="intoDateStart != null and intoDateEnd != null">
  256. AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
  257. AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
  258. </if>
  259. <if test="intoStatusList != null and intoStatusList.size()>0">
  260. AND tpi.into_status =
  261. any(#{intoStatusList, typeHandler= StringListTypeHandler})
  262. </if>
  263. <if test="intoStatus != null and intoStatus != ''">
  264. AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
  265. </if>
  266. <if test="skuModel != null and skuModel!='' ">
  267. and exists (select 1 from dkic_b.t_psi_inbound_item tpii
  268. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
  269. where
  270. tpi.into_id = tpii.into_id
  271. and tpii.flg_valid
  272. AND position(#{skuModel} in tmgs.sku_model) > 0
  273. )
  274. </if>
  275. <if test="skuCode != null and skuCode!='' ">
  276. and exists (select 1 from dkic_b.t_psi_inbound_item tpii
  277. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
  278. where
  279. tpi.into_id = tpii.into_id
  280. and tpii.flg_valid
  281. AND position(#{skuCode} in tmgs.sku_code) > 0
  282. )
  283. </if>
  284. <if test="skuName != null and skuName!='' ">
  285. and exists (select 1 from dkic_b.t_psi_inbound_item tpii
  286. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
  287. where
  288. tpi.into_id = tpii.into_id
  289. and tpii.flg_valid
  290. AND position(#{skuName} in tmgs.sku_name) > 0
  291. )
  292. </if>
  293. </where>
  294. </sql>
  295. <sql id="idsForeach">
  296. <!-- 根据主键intoId批量操作 -->
  297. WHERE into_id in
  298. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  299. #{item}
  300. </foreach>
  301. </sql>
  302. <!-- 查询表t_psi_inbound,(条件查询+分页)列表 tpi.sum_quantity, tpi.sum_amount,-->
  303. <select id="selectByCond" resultMap="BaseResultMapResponse">
  304. SELECT
  305. <include refid="Base_Column_List_Response"/>
  306. ,tmo.org_name AS "orgName",
  307. tmp.sup_name AS "supplierName",
  308. tms.staff_name AS "staffName",
  309. tms.staff_name AS "makeStaffName",
  310. tmw.wh_name as "whName",
  311. tmc.cus_name as "cusName",
  312. tmc.cus_phone as "cusPhone",
  313. tmc.cus_from as "cusFrom",
  314. makestaff.staff_name as "makeStaffName",
  315. sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS "intoTypeName",
  316. sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS "intoStatusName",
  317. tmd.data_value as into_reason_name,
  318. tmp.return_address,
  319. tmp.contact_name AS return_contact_name,
  320. tmp.contact_phone AS return_contact_phone
  321. FROM dkic_b.t_psi_inbound tpi
  322. <include refid="Join_Table"/>
  323. <include refid="Condition"/>
  324. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  325. limit #{end} offset #{start}
  326. </if>
  327. </select>
  328. <!-- 查询表t_psi_inbound,(条件查询)个数 -->
  329. <select id="countByCond" resultType="Long">
  330. SELECT
  331. count(1)
  332. FROM dkic_b.t_psi_inbound tpi
  333. <include refid="Join_Table"/>
  334. <include refid="Condition"/>
  335. </select>
  336. <sql id="Join_Table">
  337. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  338. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  339. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  340. Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
  341. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
  342. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
  343. Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  344. left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
  345. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  346. </sql>
  347. <!-- 根据主键查询表t_psi_inbound的一行数据 -->
  348. <select id="selectById" resultMap="BaseResultMapResponse">
  349. SELECT
  350. <include refid="Base_Column_List_Response"/>
  351. ,tmo.org_name as "orgName"
  352. ,tms.staff_name as "staffName"
  353. ,tms1.staff_name as "makeStaffName"
  354. ,tmp.sup_name as "supplierName"
  355. ,tmw.wh_name as "whName"
  356. ,tmd.data_value as into_reason_name
  357. FROM dkic_b.t_psi_inbound tpi
  358. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  359. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  360. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  361. Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
  362. Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  363. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  364. WHERE tpi.into_id = #{intoId}::uuid
  365. </select>
  366. <!-- 根据主键锁定表t_psi_inbound的一行数据 -->
  367. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  368. SELECT
  369. <include refid="Base_Column_List"/>
  370. FROM dkic_b.t_psi_inbound
  371. WHERE into_id = #{intoId}
  372. for update
  373. </select>
  374. <!-- 根据主键锁定表t_psi_inbound的多行数据 -->
  375. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  376. SELECT
  377. <include refid="Base_Column_List"/>
  378. FROM dkic_b.t_psi_inbound
  379. <include refid="idsForeach"/>
  380. for update
  381. </select>
  382. <insert id="insertBatch">
  383. insert into dkic_b.t_psi_inbound
  384. (
  385. <trim suffixOverrides=",">
  386. into_no,
  387. into_type,
  388. from_id,
  389. from_no,
  390. org_id,
  391. staff_id,
  392. cus_id,
  393. sup_id,
  394. into_status,
  395. intoing_qty,
  396. intoing_amt,
  397. into_qty,
  398. into_amt,
  399. return_qty,
  400. return_amt,
  401. into_date,
  402. remarks,
  403. annex_paths,
  404. make_staff,
  405. make_time,
  406. receivable_id,
  407. payable_id,
  408. cp_id,
  409. op_app_code,
  410. wh_id,
  411. entry_reason,
  412. </trim>
  413. )
  414. values
  415. <foreach collection="list" index="index" item="item" separator=",">
  416. (
  417. <trim suffixOverrides=",">
  418. #{item.intoNo},
  419. #{item.intoType},
  420. #{item.fromId}::uuid,
  421. #{item.fromNo},
  422. #{item.orgId}::uuid,
  423. #{item.staffId}::uuid,
  424. #{item.cusId}::uuid,
  425. #{item.supId}::uuid,
  426. #{item.intoStatus},
  427. #{item.intoingQty},
  428. #{item.intoingAmt},
  429. #{item.intoQty},
  430. #{item.intoAmt},
  431. #{item.returnQty},
  432. #{item.returnAmt},
  433. #{item.intoDate},
  434. #{item.remarks},
  435. #{item.annexPaths},
  436. #{item.makeStaff}::uuid,
  437. #{item.makeTime},
  438. #{item.receivableId}::uuid,
  439. #{item.payableId}::uuid,
  440. #{item.cpId},
  441. #{item.opAppCode},
  442. #{item.whId},
  443. #{item.intoReason}::uuid,
  444. </trim>
  445. )
  446. </foreach>
  447. </insert>
  448. <sql id="Base_Column_List_Item_Response_Join">
  449. tpii
  450. .
  451. item_id
  452. AS list_item_id,
  453. tpii.item_id AS list_into_item_Id,
  454. tpii.into_id AS list_into_id,
  455. tpii.into_type AS list_into_type,
  456. tpii.from_id AS list_from_id,
  457. tpii.from_item_id AS list_from_item_id,
  458. tpii.item_index AS list_item_index,
  459. tpii.sku_id AS list_sku_id,
  460. tpii.price_into AS list_price_into,
  461. tpii.non_std_code AS list_non_std_code,
  462. tpii.into_status AS list_into_status,
  463. tpii.intoing_qty AS list_intoing_qty,
  464. tpii.intoing_amt AS list_intoing_amt,
  465. tpii.into_qty AS list_into_qty,
  466. tpii.into_amt AS list_into_amt,
  467. tpii.return_qty AS list_return_qty,
  468. tpii.return_amt AS list_return_amt,
  469. tpii.remarks AS list_remarks,
  470. tpii.inv_id AS list_inv_id,
  471. tpii.cost_price AS list_cost_price,
  472. tpii.cost_amt AS list_cost_amt,
  473. tpii.out_qty AS list_out_qty,
  474. tpii.inv_qty AS list_inv_qty,
  475. tpii.flg_valid AS list_flg_valids,
  476. tpii.cp_id AS list_cp_id,
  477. tmgs.sku_code AS list_sku_code,
  478. tmgs.sku_name AS list_sku_name,
  479. tmgs.sku_model AS list_sku_model,
  480. tmgs.price_purchase AS list_price_purchase,
  481. tmgs.sku_images AS list_sku_images,
  482. ( tpii.into_qty - tpii.return_qty) AS list_reject_qty,
  483. -- tpit.usable_qty AS list_usable_qty,
  484. -- tpit.inv_qty AS list_inv_qty,
  485. -- tpit.outing_qty AS list_outing_qty
  486. -- ,
  487. tmgs.price_standard AS list_price_std,
  488. tmw.wh_name AS list_wh_name,
  489. tmw.wh_code AS list_wh_code
  490. </sql>
  491. <!-- 查询表t_psi_inbound,(条件查询+分页)列表 -->
  492. <select id="selectInboundAndItem" resultMap="BaseResultMapItemResponse">
  493. SELECT
  494. <include refid="Base_Column_List_Item_Response"/>,
  495. <include refid="Base_Column_List_Item_Response_Join"/>
  496. FROM dkic_b.t_psi_inbound tpi
  497. left join dkic_b.t_psi_inbound_item tpii on tpi.into_id = tpii.into_id
  498. left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpii.wh_id
  499. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
  500. -- left join dkic_b.t_psi_inventory tpit on tpit.sku_id = tpii.sku_id
  501. <include refid="Condition"/>
  502. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  503. limit #{end} offset #{start}
  504. </if>
  505. </select>
  506. <!-- 查询表t_psi_inbound,(条件查询)个数 -->
  507. <select id="selectInboundAndItemCountByCond" resultType="Long">
  508. SELECT
  509. count(1)
  510. FROM dkic_b.t_psi_inbound tpi
  511. left join dkic_b.t_psi_inbound_item tpii on tpi.into_id = tpii.into_id
  512. <include refid="Condition"/>
  513. </select>
  514. <update id="updateAmount" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
  515. update dkic_b.t_psi_inbound
  516. <set>
  517. <if test="returnQty!= null">
  518. return_qty= #{returnQty},
  519. </if>
  520. <if test="returnAmt!= null">
  521. return_amt = #{returnAmt},
  522. </if>
  523. </set>
  524. where into_id = #{intoId}::uuid
  525. </update>
  526. <!-- 根据id查询带出销售退货单数据(采购退货入库办理用)-->
  527. <select id="selectMessageByOtherQuery" resultMap="BaseResultMapResponse">
  528. SELECT
  529. <include refid="Base_Column_List_Response"/>
  530. ,tmo.org_name as "orgName"
  531. ,tms.staff_name as "staffName"
  532. ,tmc.cus_code
  533. ,tmc.cus_name
  534. ,tmc.cus_phone
  535. ,tmc.contact_phone
  536. ,tmc.contact_name
  537. ,tmc.address_area
  538. ,tmc.address_name
  539. ,tmc.address_no
  540. ,tmc.address_gcj02
  541. ,tmc.address_full
  542. ,tmsc.channel_name
  543. ,tmsc.channel_name
  544. ,tmsc.channel_name
  545. ,tmd.data_value as cus_from_name
  546. FROM dkic_b.t_psi_inbound tpi
  547. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  548. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  549. left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
  550. left join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
  551. left join dkic_b.t_mst_dictionary_data tmd on tmc.cus_from = tmd.data_id
  552. <where>
  553. <if test="intoId != null and intoId != ''">
  554. AND tpi.into_id = #{intoId}::uuid
  555. </if>
  556. <if test="intoStatus != null and intoStatus != ''">
  557. AND tpi.into_status = #{intoStatus}
  558. </if>
  559. </where>
  560. </select>
  561. <!-- 入库办理显示字段 -->
  562. <sql id="Base_Column_List_Response_Into">
  563. tpi.into_id,
  564. tpi.into_no,
  565. tpi.into_type,
  566. tpi.from_id,
  567. tpi.from_no,
  568. tpi.org_id,
  569. tpi.staff_id,
  570. tpi.cus_id,
  571. tpi.sup_id,
  572. tpi.into_status,
  573. tpi.intoing_qty,
  574. tpi.intoing_amt,
  575. tpi.into_qty,
  576. tpi.into_amt,
  577. tpi.return_qty,
  578. tpi.return_amt,
  579. tpi.into_date,
  580. tpi.remarks,
  581. tpi.annex_paths,
  582. tpi.make_staff,
  583. tpi.make_time,
  584. tpi.wh_id,
  585. tpi.into_reason
  586. </sql>
  587. <sql id="Base_Column_List_Response_Out">
  588. tpo.out_id as into_id,
  589. tpo.out_no as into_no,
  590. tpo.out_type as into_type,
  591. tpo.from_id,
  592. tpo.from_no,
  593. tpo.org_id,
  594. tpo.staff_id,
  595. tpo.cus_id,
  596. tpo.sup_id,
  597. tpo.out_status,
  598. tpo.outing_qty as intoing_qty,
  599. tpo.outing_amt as intoing_amt,
  600. tpo.out_qty as into_qty,
  601. tpo.out_amt as into_amt,
  602. tpo.return_qty,
  603. tpo.return_amt,
  604. tpo.out_date as into_date,
  605. tpo.remarks,
  606. tpo.annex_paths,
  607. tpo.make_staff,
  608. tpo.make_time,
  609. null as wh_id,
  610. tpo.out_reason as into_reason
  611. </sql>
  612. <!-- 条件查询 web端入库办理用,-->
  613. <select id="selectInbound" resultMap="BaseResultMapResponse">
  614. SELECT
  615. <include refid="Base_Column_List_Response_Into"/>,
  616. tmo.org_name AS "orgName",
  617. tmp.sup_name AS "supplierName",
  618. tms.staff_name AS "staffName",
  619. tms.staff_name AS "makeStaffName",
  620. tmw.wh_name as "whName",
  621. tmc.cus_name as "cusName",
  622. tmc.cus_phone as "cusPhone",
  623. tmc.cus_from as "cusFrom",
  624. makestaff.staff_name as "makeStaffName",
  625. sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS "intoTypeName",
  626. sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS "intoStatusName",
  627. tmd.data_value as into_reason_name
  628. FROM dkic_b.t_psi_inbound tpi
  629. <include refid="Select_Inbound_Join_Table_Into"/>
  630. <where>
  631. <if test="intoTypes != null and intoTypes.size()>0">
  632. AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
  633. </if>
  634. <if test="intoTypes == null || intoTypes.size()==0">
  635. AND (tpi.into_type = '入库类型-其他入库'
  636. or tpi.into_type = '入库类型-采购入库')
  637. </if>
  638. <if test=" intoStatus != null and intoStatus != '' ">
  639. AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
  640. </if>
  641. <if test="intoDateStart != null and intoDateEnd != null">
  642. AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
  643. AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
  644. </if>
  645. </where>
  646. union all
  647. select
  648. <include refid="Base_Column_List_Response_Out"/>,
  649. tmo.org_name AS "orgName",
  650. tmp.sup_name AS "supplierName",
  651. tms.staff_name AS "staffName",
  652. tms.staff_name AS "makeStaffName",
  653. null as "whName",
  654. tmc.cus_name as "cusName",
  655. tmc.cus_phone as "cusPhone",
  656. tmc.cus_from as "cusFrom",
  657. makestaff.staff_name as "makeStaffName",
  658. sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS "intoTypeName",
  659. sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS "intoStatusName",
  660. tmd.data_value as into_reason_name
  661. from dkic_b.t_psi_outbound tpo
  662. <include refid="Select_Inbound_Join_Table_Out"/>
  663. <where>
  664. <if test="intoTypes != null and intoTypes.size()>0">
  665. AND tpo.out_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
  666. </if>
  667. <if test="intoTypes == null || intoTypes.size()==0">
  668. AND tpo.out_type = '出库类型-销退出库'
  669. </if>
  670. <if test="outStatus != null and outStatus != '' ">
  671. AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
  672. </if>
  673. <if test="intoDateStart != null and intoDateEnd != null">
  674. AND tpo.make_time &gt;= #{intoDateStart}::timestamp with time zone
  675. AND tpo.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
  676. </if>
  677. </where>
  678. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  679. limit #{end} offset #{start}
  680. </if>
  681. </select>
  682. <!-- 条件查询 web端入库办理用个数 -->
  683. <select id="selectInboundCond" resultType="Long">
  684. SELECT
  685. count(1) from (
  686. SELECT
  687. <include refid="Base_Column_List_Response_Into"/>,
  688. tmo.org_name AS "orgName",
  689. tmp.sup_name AS "supplierName",
  690. tms.staff_name AS "staffName",
  691. tms.staff_name AS "makeStaffName",
  692. tmw.wh_name as "whName",
  693. tmc.cus_name as "cusName",
  694. tmc.cus_phone as "cusPhone",
  695. tmc.cus_from as "cusFrom",
  696. makestaff.staff_name as "makeStaffName",
  697. sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS "intoTypeName",
  698. sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS "intoStatusName",
  699. tmd.data_value as into_reason_name
  700. FROM dkic_b.t_psi_inbound tpi
  701. <include refid="Select_Inbound_Join_Table_Into"/>
  702. <where>
  703. <if test="intoTypes != null and intoTypes.size()>0">
  704. AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
  705. </if>
  706. <if test="intoTypes == null || intoTypes.size()==0">
  707. AND (tpi.into_type = '入库类型-其他入库'
  708. or tpi.into_type = '入库类型-采购入库')
  709. </if>
  710. <if test="intoStatus != null and intoStatus != '' ">
  711. AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
  712. </if>
  713. <if test="intoDateStart != null and intoDateEnd != null">
  714. AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
  715. AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
  716. </if>
  717. </where>
  718. union all
  719. select
  720. <include refid="Base_Column_List_Response_Out"/>,
  721. tmo.org_name AS "orgName",
  722. tmp.sup_name AS "supplierName",
  723. tms.staff_name AS "staffName",
  724. tms.staff_name AS "makeStaffName",
  725. null as "whName",
  726. tmc.cus_name as "cusName",
  727. tmc.cus_phone as "cusPhone",
  728. tmc.cus_from as "cusFrom",
  729. makestaff.staff_name as "makeStaffName",
  730. sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS "intoTypeName",
  731. sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS "intoStatusName",
  732. tmd.data_value as into_reason_name
  733. from dkic_b.t_psi_outbound tpo
  734. <include refid="Select_Inbound_Join_Table_Out"/>
  735. <where>
  736. <if test="intoTypes != null and intoTypes.size()>0">
  737. AND tpo.out_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
  738. </if>
  739. <if test="intoTypes == null || intoTypes.size()==0">
  740. AND tpo.out_type = '出库类型-销退出库'
  741. </if>
  742. <if test="outStatus != null and outStatus != '' ">
  743. AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
  744. </if>
  745. <if test="intoDateStart != null and intoDateEnd != null">
  746. AND tpo.make_time &gt;= #{intoDateStart}::timestamp with time zone
  747. AND tpo.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
  748. </if>
  749. </where>
  750. ) tt
  751. </select>
  752. <!--入库办理显示入库关联表-->
  753. <sql id="Select_Inbound_Join_Table_Into">
  754. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  755. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  756. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  757. Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
  758. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
  759. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
  760. Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  761. left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
  762. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  763. </sql>
  764. <!--入库办理显示出库关联表-->
  765. <sql id="Select_Inbound_Join_Table_Out">
  766. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
  767. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpo.sup_id
  768. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
  769. Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpo.make_staff
  770. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpo.out_status
  771. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpo.out_type
  772. left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
  773. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpo.out_reason
  774. </sql>
  775. <update id="updateIntoStatus" parameterType="com.dk.mdm.model.pojo.ivt.InboundItem">
  776. update dkic_b.t_psi_inbound
  777. <set>
  778. <if test="intoStatus!= null">
  779. into_status= #{intoStatus},
  780. </if>
  781. </set>
  782. where into_id = #{intoId}::uuid
  783. </update>
  784. <!-- 采购退货用-->
  785. <resultMap id="BaseResultMapInboundReturnResponse" type="com.dk.mdm.model.response.ivt.InboundResponse">
  786. <id column="into_id" property="intoId" typeHandler="UuidTypeHandler"/>
  787. <result column="into_no" property="intoNo"/>
  788. <result column="into_type" property="intoType"/>
  789. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  790. <result column="from_no" property="fromNo"/>
  791. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  792. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  793. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  794. <result column="into_status" property="intoStatus"/>
  795. <result column="intoing_qty" property="intoingQty"/>
  796. <result column="intoing_amt" property="intoingAmt"/>
  797. <result column="into_qty" property="intoQty"/>
  798. <result column="into_amt" property="intoAmt"/>
  799. <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
  800. <result column="return_qty" property="returnQty"/>
  801. <result column="return_amt" property="returnAmt"/>
  802. <result column="into_date" property="intoDate" typeHandler="TimestampTypeHandler"/>
  803. <result column="remarks" property="remarks"/>
  804. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  805. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  806. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  807. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  808. <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
  809. <result column="flg_valid" property="flgValid"/>
  810. <result column="cp_id" property="cpId"/>
  811. <result column="sup_name" property="supName"/>
  812. <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
  813. <result column="into_reason_name" property="intoReasonName" />
  814. <result column="orgName" property="orgName" />
  815. <result column="staff_name" property="staffName" />
  816. <result column="contact_phone" property="contactPhone" />
  817. <result column="contact_name" property="contactName" />
  818. <result column="channel_name" property="channelName" />
  819. <result column="cus_from_name" property="cusFromName" />
  820. <result column="return_address" property="returnAddress" />
  821. </resultMap>
  822. <sql id="Join_Table_Return">
  823. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  824. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  825. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  826. Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
  827. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
  828. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
  829. Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  830. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  831. </sql>
  832. <!-- 采购退货用-->
  833. <select id="selectByInboundReturnCond" resultMap="BaseResultMapInboundReturnResponse">
  834. SELECT
  835. <include refid="Base_Column_List_Response"/>
  836. ,tmo.org_name
  837. ,tmp.sup_name
  838. ,tms.staff_name
  839. ,tmw.wh_name
  840. ,tms1.staff_name as make_staff_name
  841. ,sys.f_get_name_i18n(tdktype.kind_name_i18n, 'zh_CN') AS into_type_name
  842. ,sys.f_get_name_i18n(tdk.kind_name_i18n, 'zh_CN') AS into_status_name
  843. ,tmd.data_value as into_reason_name
  844. ,tmp.return_address
  845. ,tmp.contact_name
  846. ,tmp.contact_phone
  847. FROM dkic_b.t_psi_inbound tpi
  848. <include refid="Join_Table_Return"/>
  849. <include refid="Condition"/>
  850. ORDER BY tpi.op_create_time DESC
  851. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  852. limit #{end} offset #{start}
  853. </if>
  854. </select>
  855. <!--采购退货用 查询表t_psi_inbound,(条件查询)个数 -->
  856. <select id="countByInboundReturnCond" resultType="Long">
  857. SELECT
  858. count(1)
  859. FROM dkic_b.t_psi_inbound tpi
  860. <include refid="Join_Table_Return"/>
  861. <include refid="Condition"/>
  862. </select>
  863. <!-- 查看来源单据,总单加明细 采购退货用-->
  864. <select id="selectInboundReturnById" resultMap="BaseResultMapInboundReturnResponse">
  865. SELECT
  866. <include refid="Base_Column_List_Response"/>
  867. ,tmo.org_name
  868. ,tms.staff_name as staff_name
  869. ,tms1.staff_name as make_staff_name
  870. ,tmp.sup_name
  871. ,tmw.wh_name
  872. ,tmd.data_value as into_reason_name
  873. ,tmp.return_address
  874. ,tmp.contact_name
  875. ,tmp.contact_phone
  876. FROM dkic_b.t_psi_inbound tpi
  877. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  878. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  879. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  880. Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
  881. Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
  882. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  883. WHERE tpi.into_id = #{intoId}::uuid
  884. </select>
  885. </mapper>