OutboundMapper.xml 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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,
  8. out_status, sys.f_remove_zero(outing_qty) as outing_qty, outing_amt,
  9. sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as return_qty, return_amt,
  10. out_date, remarks, annex_paths, make_staff, make_time, receivable_id,
  11. flg_valid, cp_id,out_reason,flg_auto_handle,flg_handle_setting
  12. </sql>
  13. <sql id="Base_Column_List_Response">
  14. tpo.out_id, tpo.out_no, tpo.out_type, tpo.from_id, tpo.from_no, tpo.org_id, tpo.staff_id,
  15. tpo.cus_id, tpo.sup_id, tpo.out_status, sys.f_remove_zero(tpo.outing_qty) as outing_qty, tpo.outing_amt,
  16. sys.f_remove_zero(tpo.out_qty) as out_qty, tpo.out_amt,
  17. sys.f_remove_zero(tpo.return_qty) as return_qty, tpo.return_amt, tpo.out_date, tpo.remarks, tpo.annex_paths, tpo.make_staff,
  18. tpo.make_time, tpo.receivable_id, tpo.flg_valid, tpo.cp_id,tpo.out_reason,
  19. tpo.flg_auto_handle,tpo.flg_handle_setting
  20. </sql>
  21. <!-- 通用查询映射结果 -->
  22. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.Outbound">
  23. <id column="out_id" property="outId"/>
  24. <result column="out_no" property="outNo"/>
  25. <result column="out_type" property="outType"/>
  26. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  27. <result column="from_no" property="fromNo"/>
  28. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  29. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  30. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  31. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  32. <result column="out_status" property="outStatus"/>
  33. <result column="outing_qty" property="outingQty"/>
  34. <result column="outing_amt" property="outingAmt"/>
  35. <result column="out_qty" property="outQty"/>
  36. <result column="out_amt" property="outAmt"/>
  37. <result column="return_qty" property="returnQty"/>
  38. <result column="return_amt" property="returnAmt"/>
  39. <result column="out_date" property="outDate" 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="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  45. <result column="flg_valid" property="flgValid"/>
  46. <result column="cp_id" property="cpId"/>
  47. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  48. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  49. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  50. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  51. <result column="op_app_code" property="opAppCode"/>
  52. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  53. <result column="op_db_user" property="opDbUser"/>
  54. <result column="out_reason" property="outReason" typeHandler="UuidTypeHandler"/>
  55. <result column="flg_auto_handle" property="flgAutoHandle"/>
  56. <result column="flg_handle_setting" property="flgHandleSetting"/>
  57. </resultMap>
  58. <!-- 通用查询映射结果 -->
  59. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.ivt.OutboundResponse">
  60. <id column="out_id" property="outId"/>
  61. <result column="out_no" property="outNo"/>
  62. <result column="out_type" property="outType"/>
  63. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  64. <result column="from_no" property="fromNo"/>
  65. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  66. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  67. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  68. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  69. <result column="out_status" property="outStatus"/>
  70. <result column="outing_qty" property="outingQty"/>
  71. <result column="outing_amt" property="outingAmt"/>
  72. <result column="out_qty" property="outQty"/>
  73. <result column="out_amt" property="outAmt"/>
  74. <result column="return_qty" property="returnQty"/>
  75. <result column="return_amt" property="returnAmt"/>
  76. <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
  77. <result column="remarks" property="remarks"/>
  78. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  79. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  80. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  81. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  82. <result column="flg_valid" property="flgValid"/>
  83. <result column="cp_id" property="cpId"/>
  84. <result column="flg_auto_handle" property="flgAutoHandle"/>
  85. <result column="flg_handle_setting" property="flgHandleSetting"/>
  86. <!-- <result column="org_name" property="orgName"/>-->
  87. <!-- <result column="staff_name" property="staffName"/>-->
  88. <result column="cusCode" property="cusCode"/>
  89. <result column="cusName" property="cusName"/>
  90. <result column="cusPhone" property="cusPhone"/>
  91. <result column="contact_phone" property="contactPhone"/>
  92. <result column="contact_name" property="contactName"/>
  93. <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
  94. <result column="address_name" property="addressName"/>
  95. <result column="address_no" property="addressNo"/>
  96. <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
  97. <result column="addressFull" property="addressFull"/>
  98. <result column="channel_name" property="channelName"/>
  99. <result column="channel_id" property="channelId"/>
  100. <result column="cus_from_name" property="cusFromName"/>
  101. <result column="out_reason" property="outReason" typeHandler="UuidTypeHandler"/>
  102. <result column="out_reason_name" property="outReasonName" />
  103. <result column="sumOutAmt" property="sumOutAmt" />
  104. <result column="sumOutQty" property="sumOutQty" />
  105. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  106. </resultMap>
  107. <resultMap id="BaseResultMapDetailResponse" type="com.dk.mdm.model.response.ivt.OutboundResponse">
  108. <id column="out_id" property="outId"/>
  109. <result column="out_no" property="outNo"/>
  110. <result column="out_type" property="outType"/>
  111. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  112. <result column="from_no" property="fromNo"/>
  113. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  114. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  115. <result column="staffName" property="staffName" />
  116. <result column="orgName" property="orgName" />
  117. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  118. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  119. <result column="out_status" property="outStatus"/>
  120. <result column="outing_qty" property="outingQty"/>
  121. <result column="outing_amt" property="outingAmt"/>
  122. <result column="out_qty" property="outQty"/>
  123. <result column="out_amt" property="outAmt"/>
  124. <result column="return_qty" property="returnQty"/>
  125. <result column="return_amt" property="returnAmt"/>
  126. <result column="out_date" property="outDate" typeHandler="TimestampTypeHandler"/>
  127. <result column="remarks" property="remarks"/>
  128. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  129. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  130. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  131. <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
  132. <result column="flg_valid" property="flgValid"/>
  133. <result column="cp_id" property="cpId"/>
  134. <result column="flg_auto_handle" property="flgAutoHandle"/>
  135. <result column="flg_handle_setting" property="flgHandleSetting"/>
  136. <result column="cusCode" property="cusCode"/>
  137. <result column="cusName" property="cusName"/>
  138. <result column="cusPhone" property="cusPhone"/>
  139. <result column="contact_phone" property="contactPhone"/>
  140. <result column="contact_name" property="contactName"/>
  141. <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
  142. <result column="address_name" property="addressName"/>
  143. <result column="address_no" property="addressNo"/>
  144. <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
  145. <result column="addressFull" property="addressFull"/>
  146. <result column="channel_name" property="channelName"/>
  147. <result column="cus_from_name" property="cusFromName"/>
  148. <result column="out_reason" property="outReason" typeHandler="UuidTypeHandler"/>
  149. <result column="out_reason_name" property="outReasonName" />
  150. <collection property="goodsList" resultMap="itemListMap" columnPrefix="list_"/>
  151. </resultMap>
  152. <resultMap id="itemListMap" type="java.util.Map">
  153. <id column="item_id" property="itemId"/>
  154. <result column="out_id" property="outId" typeHandler="UuidTypeHandler"/>
  155. <result column="out_no" property="outNo" />
  156. <result column="out_type" property="outType"/>
  157. <result column="from_id" property="fromId" typeHandler="UuidTypeHandler"/>
  158. <result column="from_item_id" property="fromItemId" typeHandler="UuidTypeHandler"/>
  159. <result column="item_index" property="itemIndex"/>
  160. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  161. <result column="price_out" property="priceOut"/>
  162. <result column="non_std_code" property="nonStdCode"/>
  163. <result column="out_status" property="outStatus"/>
  164. <result column="outing_qty" property="outingQty"/>
  165. <result column="outing_amt" property="outingAmt"/>
  166. <result column="out_qty" property="outQty"/>
  167. <result column="out_amt" property="outAmt"/>
  168. <result column="return_qty" property="returnQty"/>
  169. <result column="return_amt" property="returnAmt"/>
  170. <result column="remarks" property="remarks"/>
  171. <result column="inv_id" property="invId" typeHandler="UuidTypeHandler"/>
  172. <result column="cost_price" property="costPrice"/>
  173. <result column="cost_amt" property="costAmt"/>
  174. <result column="flg_valid" property="flgValid"/>
  175. <result column="cp_id" property="cpId"/>
  176. <result column="s_out_id" property="sOutId" typeHandler="UuidTypeHandler"/>
  177. <result column="s_out_item_id" property="sOutItemId" typeHandler="UuidTypeHandler"/>
  178. <result column="s_order_id" property="sOrderId" typeHandler="UuidTypeHandler"/>
  179. <result column="s_order_item_id" property="sOrderItemId" typeHandler="UuidTypeHandler"/>
  180. <result column="sku_code" property="skuCode"/>
  181. <result column="sku_model" property="skuModel"/>
  182. <result column="sku_name" property="skuName"/>
  183. <result column="brand_name" property="brandName"/>
  184. <result column="price_purchase" property="pricePurchase"/>
  185. <result column="price_standard" property="priceStandard"/>
  186. <result column="sku_images" property="skuImages"/>
  187. <result column="wh_id" property="whId"/>
  188. <result column="wh_name" property="whName"/>
  189. <result column="invQty" property="invQty"/>
  190. <result column="usableQty" property="usableQty"/>
  191. <result column="pack_box" property="packBox"/>
  192. <result column="flgSubUnit" property="flgSubUnit"/>
  193. <result column="subUnitName" property="subUnitName"/>
  194. <result column="unitName" property="unitName"/>
  195. <result column="outing_box" property="outingBox"/>
  196. <result column="outing_piece" property="outingPiece"/>
  197. <result column="out_box" property="box"/>
  198. <result column="out_piece" property="piece"/>
  199. <result column="decimal_places" property="decimalPlaces"/>
  200. </resultMap>
  201. <!-- 通用条件列 -->
  202. <sql id="Condition">
  203. <where>
  204. <if test="outNo != null and outNo != ''">
  205. AND t.out_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
  206. </if>
  207. <if test="outType != null and outType != ''">
  208. AND t.out_type = #{outType}
  209. </if>
  210. <if test="outTypeList != null and outTypeList.size()>0">
  211. AND t.out_type =any(#{outTypeList,typeHandler=StringListTypeHandler})
  212. </if>
  213. <if test="outReasonList != null and outReasonList.size()>0">
  214. AND t.out_reason =any(#{outReasonList,typeHandler=UuidListTypeHandler})
  215. </if>
  216. <if test="searchText !=null and searchText != ''">
  217. AND (
  218. t.out_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  219. or t.from_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  220. or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  221. or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  222. or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  223. or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  224. or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
  225. )
  226. </if>
  227. <if test="orgName != null and orgName != ''">
  228. AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  229. </if>
  230. <if test="addressFull != null and addressFull != ''">
  231. AND tmc.address_full LIKE concat('%',my_ex.likequery(#{addressFull}),'%')
  232. </if>
  233. <if test="staffIds != null and staffIds.size()>0">
  234. AND t.staff_id = any(#{staffIds, typeHandler=uuidListTypeHandler})
  235. </if>
  236. <if test="orgIds != null and orgIds.size()>0">
  237. AND t.org_id = any(#{orgIds, typeHandler=uuidListTypeHandler})
  238. </if>
  239. <if test="supName != null and supName != ''">
  240. AND tmp.sup_name LIKE concat('%',my_ex.likequery(#{supName}),'%')
  241. </if>
  242. <if test="staffName != null and staffName != ''">
  243. AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
  244. </if>
  245. <if test="fromId != null and fromId != ''">
  246. AND t.from_id = #{fromId}
  247. </if>
  248. <if test="fromNo != null and fromNo != ''">
  249. AND t.from_no = #{fromNo}
  250. </if>
  251. <if test="orgId != null and orgId != ''">
  252. AND t.org_id = #{orgId}
  253. </if>
  254. <if test="staffId != null and staffId != ''">
  255. AND t.staff_id = #{staffId}
  256. </if>
  257. <if test="cusId != null and cusId != ''">
  258. AND t.cus_id = #{cusId}::uuid
  259. </if>
  260. <if test="supId != null and supId != ''">
  261. AND t.sup_id = #{supId}
  262. </if>
  263. <if test="outStatus != null and outStatus != ''">
  264. AND t.out_status = #{outStatus}
  265. </if>
  266. <if test="outingQty != null">
  267. AND t.outing_qty = #{outingQty}
  268. </if>
  269. <if test="outingAmt != null">
  270. AND t.outing_amt = #{outingAmt}
  271. </if>
  272. <if test="outQty != null">
  273. AND t.out_qty = #{outQty}
  274. </if>
  275. <if test="outAmt != null">
  276. AND t.out_amt = #{outAmt}
  277. </if>
  278. <if test="returnQty != null">
  279. AND t.return_qty = #{returnQty}
  280. </if>
  281. <if test="returnAmt != null">
  282. AND t.return_amt = #{returnAmt}
  283. </if>
  284. <if test="remarks != null and remarks != ''">
  285. AND t.remarks = #{remarks}
  286. </if>
  287. <if test="annexPaths != null and annexPaths != ''">
  288. AND t.annex_paths = #{annexPaths}
  289. </if>
  290. <if test="makeStaff != null and makeStaff != ''">
  291. AND t.make_staff = #{makeStaff}
  292. </if>
  293. <if test="receivableId != null and receivableId != ''">
  294. AND t.receivable_id = #{receivableId}
  295. </if>
  296. <if test="cpId != null">
  297. AND t.cp_id = #{cpId}
  298. </if>
  299. <if test="orderNo != null and orderNo != ''">
  300. AND t.from_no LIKE concat('%',my_ex.likequery(#{orderNo}),'%')
  301. </if>
  302. <if test="cusPhone != null and cusPhone != ''">
  303. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  304. </if>
  305. <if test="cusName != null and cusName != ''">
  306. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  307. </if>
  308. <if test="orgIdList != null and orgIdList.size() > 0">
  309. AND t.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  310. </if>
  311. <if test="staffIdList != null and staffIdList.size() > 0">
  312. AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  313. </if>
  314. <if test="outStatusList != null and outStatusList.size() > 0">
  315. AND t.out_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
  316. </if>
  317. <if test="outDateStart != null and outDateEnd != null">
  318. AND t.out_date &gt;= #{outDateStart}::timestamp with time zone
  319. AND t.out_date &lt; #{outDateEnd}::timestamp with time zone + interval '1 day'
  320. </if>
  321. <if test="makeTimeStart != null and makeTimeEnd != null">
  322. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  323. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  324. </if>
  325. <if test="flgValidList != null and flgValidList.size()>0">
  326. AND t.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  327. </if>
  328. <if test="viewVoidedDocuments !=null and viewVoidedDocuments == false">
  329. AND t.flg_valid = true
  330. </if>
  331. <if test="flgValid != null">
  332. AND t.flg_valid = #{flgValid}
  333. </if>
  334. </where>
  335. </sql>
  336. <sql id="idsForeach">
  337. <!-- 根据主键outId批量操作 -->
  338. WHERE out_id in
  339. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  340. #{item}
  341. </foreach>
  342. </sql>
  343. <!-- 查询表dkic_b.t_psi_outbound,(条件查询+分页)列表 -->
  344. <select id="selectByCond" resultMap="BaseResultMapResponse">
  345. SELECT t.out_id,
  346. t.out_no,
  347. t.out_type,
  348. t.from_id,
  349. t.from_no,
  350. t.from_no as "biznisNo",
  351. t.org_id,
  352. tmo.org_name as "orgName",
  353. t.staff_id,
  354. tms.staff_name as "staffName",
  355. t.cus_id,
  356. tmc.cus_code as "cusCode",
  357. tmc.cus_name as "cusName",
  358. tmc.cus_phone as "cusPhone",
  359. tmc.cus_from as "cusFrom",
  360. tmc.contact_phone as "contactPhone",
  361. tmc.address_full as "addressFull",
  362. tmdd.data_value as cus_from_name,
  363. t.sup_id,
  364. tmp.sup_name AS "supplierName",
  365. t.out_status,
  366. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
  367. sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
  368. sys.f_remove_zero(t.outing_qty) as outing_qty,
  369. t.outing_amt,
  370. CAST(t.outing_amt AS DECIMAL(10,2)) + CAST(t.out_amt AS DECIMAL(10,2)) AS "sumOutAmt",
  371. sys.f_remove_zero(CAST(t.outing_qty AS DECIMAL(10,6)) + CAST(t.out_qty AS DECIMAL(10,6))) AS "sumOutQty",
  372. sys.f_remove_zero(t.out_qty) as out_qty,
  373. t.out_amt,
  374. sys.f_remove_zero(t.return_qty) as return_qty,
  375. t.return_amt,
  376. t.out_date,
  377. t.remarks,
  378. t.annex_paths,
  379. t.make_staff,
  380. makestaff.staff_name as "makeStaffName",
  381. t.make_time,
  382. t.receivable_id,
  383. t.cp_id,
  384. t.flg_valid,
  385. tmd.data_value as out_reason_name
  386. FROM dkic_b.t_psi_outbound as t
  387. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  388. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
  389. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  390. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  391. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  392. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  393. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  394. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
  395. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
  396. <include refid="Condition"/>
  397. order by t.make_time desc
  398. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  399. limit #{end} offset #{start}
  400. </if>
  401. </select>
  402. <!-- 查询表dkic_b.t_psi_outbound,(条件查询)个数 -->
  403. <select id="countByCond" resultType="Long">
  404. SELECT
  405. count(1)
  406. FROM dkic_b.t_psi_outbound as t
  407. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  408. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
  409. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  410. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  411. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  412. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  413. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  414. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
  415. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
  416. <include refid="Condition"/>
  417. </select>
  418. <!-- 根据主键查询表dkic_b.t_psi_outbound的一行数据 -->
  419. <select id="selectById" resultMap="BaseResultMapResponse">
  420. SELECT t.out_id,
  421. t.out_no,
  422. t.out_type,
  423. t.from_id,
  424. t.from_no,
  425. t.from_no as "orderNo",
  426. t.org_id,
  427. tmo.org_name as "orgName",
  428. t.staff_id,
  429. tms.staff_name as "staffName",
  430. t.cus_id,
  431. tmc.cus_code as "cusCode",
  432. tmc.cus_name as "cusName",
  433. tmc.cus_phone as "cusPhone",
  434. tmc.cus_from as "cusFrom",
  435. tmc.contact_phone as "contactPhone",
  436. tmc.address_full as "addressFull",
  437. tmdd.data_value as cus_from_name,
  438. tmc.address_area,
  439. tmc.address_name,
  440. tmc.address_no,
  441. tmc.address_gcj02,
  442. tmc.address_full,
  443. tmc.contact_name,
  444. tmc.contact_phone,
  445. tmc.channel_id as sales_channel,
  446. tmc.channel_id ,
  447. tmsc.channel_name as channel_name,
  448. t.sup_id,
  449. t.out_status,
  450. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
  451. sys.f_remove_zero(t.outing_qty) as outing_qty,
  452. t.outing_amt,
  453. sys.f_remove_zero(t.out_qty) as out_qty,
  454. t.out_amt,
  455. sys.f_remove_zero(t.return_qty) as return_qty,
  456. t.return_amt,
  457. t.out_date,
  458. t.remarks,
  459. t.annex_paths,
  460. t.make_staff,
  461. makestaff.staff_name as "makeStaffName",
  462. t.make_time,
  463. t.receivable_id,
  464. t.cp_id,
  465. t.flg_valid,
  466. tmp.sup_name AS "supplierName",
  467. t.out_reason,
  468. t.flg_auto_handle,
  469. t.flg_handle_setting,
  470. tmd.data_value as out_reason_name
  471. FROM dkic_b.t_psi_outbound as t
  472. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  473. left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
  474. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  475. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  476. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  477. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  478. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  479. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
  480. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
  481. WHERE t.out_id = #{id}::uuid
  482. </select>
  483. <!-- 获取出库信息(新建退货用) -->
  484. <select id="selectByIdForReturn" resultMap="BaseResultMapResponse">
  485. SELECT t.out_id,
  486. t.out_no,
  487. t.out_type,
  488. t.from_id,
  489. t.from_no,
  490. t.from_no as "orderNo",
  491. t.org_id,
  492. tmo.org_name as "orgName",
  493. t.staff_id,
  494. tms.staff_name as "staffName",
  495. t.cus_id,
  496. tmc.cus_code as "cusCode",
  497. tmc.cus_name as "cusName",
  498. tmc.cus_phone as "cusPhone",
  499. tmc.cus_from as "cusFrom",
  500. tmc.contact_phone as "contactPhone",
  501. tmc.address_full as "addressFull",
  502. tmdd.data_value as cus_from_name,
  503. tmc.address_area,
  504. tmc.address_name,
  505. tmc.address_no,
  506. tmc.address_gcj02,
  507. tmc.address_full,
  508. tmc.contact_name,
  509. tmc.contact_phone,
  510. tmc.channel_id as sales_channel,
  511. tmsc.channel_name as channel_name,
  512. t.sup_id,
  513. t.out_status,
  514. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
  515. sys.f_remove_zero(t.outing_qty) as outing_qty,
  516. t.outing_amt,
  517. sys.f_remove_zero(t.out_qty) as out_qty,
  518. t.out_amt,
  519. sys.f_remove_zero(t.return_qty) as return_qty,
  520. t.return_amt,
  521. t.out_date,
  522. t.remarks,
  523. t.annex_paths,
  524. t.make_staff,
  525. makestaff.staff_name as "makeStaffName",
  526. t.make_time,
  527. t.receivable_id,
  528. t.cp_id,
  529. t.flg_valid,
  530. tmd.data_value as out_reason_name
  531. FROM dkic_b.t_psi_outbound as t
  532. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  533. left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
  534. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  535. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  536. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  537. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  538. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  539. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
  540. WHERE t.out_id = #{id}::uuid
  541. </select>
  542. <!-- 根据主键锁定表dkic_b.t_psi_outbound的一行数据 -->
  543. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  544. SELECT
  545. <include refid="Base_Column_List"/>
  546. FROM dkic_b.t_psi_outbound
  547. WHERE out_id = #{id}::uuid
  548. for update
  549. </select>
  550. <!-- 根据主键锁定表dkic_b.t_psi_outbound的多行数据 -->
  551. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  552. SELECT
  553. <include refid="Base_Column_List"/>
  554. FROM dkic_b.t_psi_outbound
  555. <include refid="idsForeach"/>
  556. for update
  557. </select>
  558. <insert id="insertBatch">
  559. insert into dkic_b.t_psi_outbound
  560. (
  561. <trim suffixOverrides=",">
  562. out_no,
  563. out_type,
  564. from_id,
  565. from_no,
  566. org_id,
  567. staff_id,
  568. order_id,
  569. order_no,
  570. into_return_id,
  571. into_return_no,
  572. cus_id,
  573. sup_id,
  574. out_status,
  575. outing_qty,
  576. outing_amt,
  577. out_qty,
  578. out_amt,
  579. return_qty,
  580. return_amt,
  581. out_date,
  582. remarks,
  583. annex_paths,
  584. make_staff,
  585. make_time,
  586. receivable_id,
  587. cp_id,
  588. op_app_code,
  589. </trim>
  590. )
  591. values
  592. <foreach collection="list" index="index" item="item" separator=",">
  593. (
  594. <trim suffixOverrides=",">
  595. #{item.outNo},
  596. #{item.outType},
  597. #{item.fromId}::uuid,
  598. #{item.fromNo},
  599. #{item.orgId}::uuid,
  600. #{item.staffId}::uuid,
  601. #{item.cusId}::uuid,
  602. #{item.supId}::uuid,
  603. #{item.outStatus},
  604. #{item.outingQty},
  605. #{item.outingAmt},
  606. #{item.outQty},
  607. #{item.outAmt},
  608. #{item.returnQty},
  609. #{item.returnAmt},
  610. #{item.outDate},
  611. #{item.remarks},
  612. #{item.annexPaths},
  613. #{item.makeStaff}::uuid,
  614. #{item.makeTime},
  615. #{item.receivableId}::uuid,
  616. #{item.cpId},
  617. #{item.opAppCode},
  618. </trim>
  619. )
  620. </foreach>
  621. </insert>
  622. <!-- 根据id查询带出销售退货单数据(销售退货出库办理用)-->
  623. <select id="selectMessageByOtherQuery" resultMap="BaseResultMapResponse">
  624. SELECT
  625. <include refid="Base_Column_List_Response"/>
  626. ,tmo.org_name
  627. ,tms.staff_name as "staffName"
  628. ,tmc.cus_code
  629. ,tmc.cus_name
  630. ,tmc.cus_phone
  631. ,tmc.contact_phone
  632. ,tmc.contact_name
  633. ,tmc.address_area
  634. ,tmc.address_name
  635. ,tmc.address_no
  636. ,tmc.address_gcj02
  637. ,tmc.address_full
  638. ,tmsc.channel_name
  639. ,tmsc.channel_name
  640. ,tmsc.channel_name
  641. ,tmd.data_value as cus_from_name
  642. FROM dkic_b.t_psi_outbound tpo
  643. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
  644. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
  645. left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
  646. left join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
  647. left join dkic_b.t_mst_dictionary_data tmd on tmc.cus_from = tmd.data_id
  648. <where>
  649. <if test="outId != null and outId != ''">
  650. AND tpo.out_id = #{outId}::uuid
  651. </if>
  652. <if test="outStatus != null and outStatus != ''">
  653. AND tpo.out_status = #{outStatus}
  654. </if>
  655. </where>
  656. </select>
  657. <!--修改退货信息 -->
  658. <update id="updateReturnMessage" parameterType="com.dk.mdm.model.pojo.sale.OrderItem">
  659. update dkic_b.t_psi_outbound
  660. <set>
  661. <if test="returnQty != null">
  662. return_qty = return_qty + #{returnQty,jdbcType=NUMERIC},
  663. </if>
  664. <if test="returnAmt != null">
  665. return_amt = return_amt + #{returnAmt,jdbcType=NUMERIC},
  666. </if>
  667. </set>
  668. where out_id = #{outId,typeHandler=UuidTypeHandler}
  669. and out_qty >= return_qty
  670. </update>
  671. <!-- 出库办理显示字段 -->
  672. <sql id="Base_Column_List_Response_Out">
  673. tpo.out_id ,
  674. tpo.out_no ,
  675. tpo.out_type ,
  676. tpo.from_id,
  677. tpo.from_no,
  678. tpo.org_id,
  679. tpo.staff_id,
  680. tpo.cus_id,
  681. tpo.sup_id,
  682. tpo.out_status,
  683. sys.f_remove_zero(tpo.outing_qty) as outing_qty ,
  684. tpo.outing_amt,
  685. sys.f_remove_zero(tpo.out_qty) as out_qty ,
  686. tpo.out_amt ,
  687. sys.f_remove_zero(tpo.return_qty) as return_qty,
  688. tpo.return_amt,
  689. tpo.out_date ,
  690. tpo.remarks,
  691. tpo.annex_paths,
  692. tpo.make_staff,
  693. tpo.make_time,
  694. tpo.out_reason,
  695. tpo.flg_valid,
  696. tpo.flg_auto_handle,
  697. tpo.flg_handle_setting,
  698. tpo.op_update_time
  699. </sql>
  700. <sql id="Base_Column_List_Response_Into">
  701. tpi.into_id as out_id,
  702. tpi.into_no as out_no,
  703. tpi.into_type as out_type,
  704. tpi.from_id,
  705. tpi.from_no,
  706. tpi.org_id,
  707. tpi.staff_id,
  708. tpi.cus_id,
  709. tpi.sup_id,
  710. tpi.into_status as out_status ,
  711. sys.f_remove_zero(tpi.intoing_qty) as outing_qty ,
  712. tpi.intoing_amt as outing_amt ,
  713. sys.f_remove_zero(tpi.into_qty) as out_qty ,
  714. tpi.into_amt as out_amt,
  715. sys.f_remove_zero(tpi.return_qty) as return_qty,
  716. tpi.return_amt,
  717. tpi.into_date as out_date,
  718. tpi.remarks,
  719. tpi.annex_paths,
  720. tpi.make_staff,
  721. tpi.make_time,
  722. tpi.into_reason as out_reason,
  723. tpi.flg_valid,
  724. tpi.flg_auto_handle,
  725. tpi.flg_handle_setting,
  726. tpi.op_update_time
  727. </sql>
  728. <!-- 条件查询 web端入库办理用,-->
  729. <select id="selectOutbound" resultMap="BaseResultMapResponse">
  730. select * from (
  731. select
  732. <include refid="Base_Column_List_Response_Out"/>,
  733. tmo.org_name AS "orgName",
  734. tmp.sup_name AS "supplierName",
  735. tms.staff_name AS "staffName",
  736. tms.staff_name AS "makeStaffName",
  737. tmc.cus_name as "cusName",
  738. tmc.cus_phone as "cusPhone",
  739. tmc.cus_from as "cusFrom",
  740. makestaff.staff_name as "makeStaffName",
  741. sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
  742. sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "outStatusName",
  743. tmd.data_value as out_reason_name
  744. from dkic_b.t_psi_outbound tpo
  745. <include refid="Select_Inbound_Join_Table_Out"/>
  746. <where>
  747. AND tpo.cp_id = #{cpId}
  748. <if test="outTypes != null and outTypes.size()>0">
  749. AND tpo.out_type =any(#{outTypes,typeHandler=StringListTypeHandler})
  750. </if>
  751. <if test="outTypes == null || outTypes.size()==0">
  752. AND (tpo.out_type = '出库类型-其他出库'
  753. or tpo.out_type = '出库类型-销售出库')
  754. </if>
  755. <if test="outStatus != null and outStatus != '' ">
  756. AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
  757. </if>
  758. <if test="makeTimeStart != null and makeTimeEnd != null">
  759. AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  760. AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  761. </if>
  762. <if test="outNo != null and outNo != ''">
  763. AND tpo.out_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
  764. </if>
  765. <if test="cusPhone != null and cusPhone != ''">
  766. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  767. </if>
  768. <if test="cusName != null and cusName != ''">
  769. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  770. </if>
  771. <if test="supId != null and supId != ''">
  772. AND tpo.sup_id = #{supId}::uuid
  773. </if>
  774. <if test="orgIdList != null and orgIdList.size() > 0">
  775. AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  776. </if>
  777. <if test="staffIdList != null and staffIdList.size() > 0">
  778. AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  779. </if>
  780. <if test="flgValidList != null and flgValidList.size()>0">
  781. AND tpo.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  782. </if>
  783. </where>
  784. union all
  785. SELECT
  786. <include refid="Base_Column_List_Response_Into"/>,
  787. tmo.org_name AS "orgName",
  788. tmp.sup_name AS "supplierName",
  789. tms.staff_name AS "staffName",
  790. tms.staff_name AS "makeStaffName",
  791. tmc.cus_name as "cusName",
  792. tmc.cus_phone as "cusPhone",
  793. tmc.cus_from as "cusFrom",
  794. makestaff.staff_name as "makeStaffName",
  795. sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
  796. sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "outStatusName",
  797. tmd.data_value as out_reason_name
  798. FROM dkic_b.t_psi_inbound tpi
  799. <include refid="Select_Inbound_Join_Table_Into"/>
  800. <where>
  801. AND tpi.cp_id = #{cpId}
  802. <if test="outTypes != null and outTypes.size()>0">
  803. AND tpi.into_type =any(#{outTypes,typeHandler=StringListTypeHandler})
  804. </if>
  805. <if test="outTypes == null || outTypes.size()==0">
  806. AND tpi.into_type = '入库类型-采退入库'
  807. </if>
  808. <if test="intoStatus != null and intoStatus != '' ">
  809. AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
  810. </if>
  811. <if test="makeTimeStart != null and makeTimeEnd != null">
  812. AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  813. AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  814. </if>
  815. <if test="outNo != null and outNo != ''">
  816. AND tpi.into_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
  817. </if>
  818. <if test="cusPhone != null and cusPhone != ''">
  819. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  820. </if>
  821. <if test="cusName != null and cusName != ''">
  822. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  823. </if>
  824. <if test="supId != null and supId != ''">
  825. AND tpi.sup_id = #{supId}::uuid
  826. </if>
  827. <if test="orgIdList != null and orgIdList.size() > 0">
  828. AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  829. </if>
  830. <if test="staffIdList != null and staffIdList.size() > 0">
  831. AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  832. </if>
  833. <if test="flgValidList != null and flgValidList.size()>0">
  834. AND tpi.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  835. </if>
  836. </where>
  837. ) tt order by tt.op_update_time desc
  838. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  839. limit #{end} offset #{start}
  840. </if>
  841. </select>
  842. <!-- 条件查询 web端入库办理用个数 -->
  843. <select id="selectOutboundCond" resultType="Long">
  844. SELECT
  845. count(1) from (
  846. select
  847. <include refid="Base_Column_List_Response_Out"/>,
  848. tmo.org_name AS "orgName",
  849. tmp.sup_name AS "supplierName",
  850. tms.staff_name AS "staffName",
  851. tms.staff_name AS "makeStaffName",
  852. tmc.cus_name as "cusName",
  853. tmc.cus_phone as "cusPhone",
  854. tmc.cus_from as "cusFrom",
  855. makestaff.staff_name as "makeStaffName",
  856. sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
  857. sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "outStatusName",
  858. tmd.data_value as out_reason_name
  859. from dkic_b.t_psi_outbound tpo
  860. <include refid="Select_Inbound_Join_Table_Out"/>
  861. <where>
  862. AND tpo.cp_id = #{cpId}
  863. <if test="outTypes != null and outTypes.size()>0">
  864. AND tpo.out_type =any(#{outTypes,typeHandler=StringListTypeHandler})
  865. </if>
  866. <if test="outTypes == null || outTypes.size()==0">
  867. AND (tpo.out_type = '出库类型-其他出库'
  868. or tpo.out_type = '出库类型-销售出库')
  869. </if>
  870. <if test="outStatus != null and outStatus != '' ">
  871. AND tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
  872. </if>
  873. <if test="makeTimeStart != null and makeTimeEnd != null">
  874. AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  875. AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  876. </if>
  877. <if test="outNo != null and outNo != ''">
  878. AND tpo.out_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
  879. </if>
  880. <if test="cusPhone != null and cusPhone != ''">
  881. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  882. </if>
  883. <if test="cusName != null and cusName != ''">
  884. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  885. </if>
  886. <if test="supId != null and supId != ''">
  887. AND tpo.sup_id = #{supId}::uuid
  888. </if>
  889. <if test="orgIdList != null and orgIdList.size() > 0">
  890. AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  891. </if>
  892. <if test="staffIdList != null and staffIdList.size() > 0">
  893. AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  894. </if>
  895. <if test="flgValidList != null and flgValidList.size()>0">
  896. AND tpo.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  897. </if>
  898. </where>
  899. union all
  900. SELECT
  901. <include refid="Base_Column_List_Response_Into"/>,
  902. tmo.org_name AS "orgName",
  903. tmp.sup_name AS "supplierName",
  904. tms.staff_name AS "staffName",
  905. tms.staff_name AS "makeStaffName",
  906. tmc.cus_name as "cusName",
  907. tmc.cus_phone as "cusPhone",
  908. tmc.cus_from as "cusFrom",
  909. makestaff.staff_name as "makeStaffName",
  910. sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
  911. sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "outStatusName",
  912. tmd.data_value as out_reason_name
  913. FROM dkic_b.t_psi_inbound tpi
  914. <include refid="Select_Inbound_Join_Table_Into"/>
  915. <where>
  916. AND tpi.cp_id = #{cpId}
  917. <if test="outTypes != null and outTypes.size()>0">
  918. AND tpi.into_type =any(#{outTypes,typeHandler=StringListTypeHandler})
  919. </if>
  920. <if test="outTypes == null || outTypes.size()==0">
  921. AND tpi.into_type = '入库类型-采退入库'
  922. </if>
  923. <if test="intoStatus != null and intoStatus != '' ">
  924. AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
  925. </if>
  926. <if test="makeTimeStart != null and makeTimeEnd != null">
  927. AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  928. AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  929. </if>
  930. <if test="outNo != null and outNo != ''">
  931. AND tpi.into_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
  932. </if>
  933. <if test="cusPhone != null and cusPhone != ''">
  934. AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
  935. </if>
  936. <if test="cusName != null and cusName != ''">
  937. AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
  938. </if>
  939. <if test="supId != null and supId != ''">
  940. AND tpi.sup_id = #{supId}::uuid
  941. </if>
  942. <if test="orgIdList != null and orgIdList.size() > 0">
  943. AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
  944. </if>
  945. <if test="staffIdList != null and staffIdList.size() > 0">
  946. AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
  947. </if>
  948. <if test="flgValidList != null and flgValidList.size()>0">
  949. AND tpi.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  950. </if>
  951. </where>
  952. ) tt
  953. </select>
  954. <!--出库办理显示出库关联表-->
  955. <sql id="Select_Inbound_Join_Table_Out">
  956. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
  957. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpo.sup_id
  958. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
  959. Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpo.make_staff
  960. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpo.out_status
  961. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpo.out_type
  962. left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
  963. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpo.out_reason
  964. </sql>
  965. <!--出库办理显示入库关联表-->
  966. <sql id="Select_Inbound_Join_Table_Into">
  967. Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
  968. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
  969. Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
  970. Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
  971. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
  972. LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
  973. left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
  974. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
  975. </sql>
  976. <!-- 根据来源id查询 -->
  977. <select id="selectByFromId" resultMap="BaseResultMapResponse">
  978. SELECT
  979. <include refid="Base_Column_List_Response"/>
  980. FROM dkic_b.t_psi_outbound tpo
  981. WHERE tpo.from_id = #{fromId}::uuid
  982. and tpo.flg_valid
  983. </select>
  984. <!-- 查询总单带明细 -->
  985. <select id="selectByCondDetail" resultMap="BaseResultMapDetailResponse">
  986. SELECT t.out_id,
  987. t.out_no,
  988. t.out_type,
  989. t.from_id,
  990. t.from_no,
  991. t.from_no as "orderNo",
  992. t.org_id,
  993. tmo.org_name as "orgName",
  994. t.staff_id,
  995. tms.staff_name as "staffName",
  996. t.cus_id,
  997. tmc.cus_code as "cusCode",
  998. tmc.cus_name as "cusName",
  999. tmc.cus_phone as "cusPhone",
  1000. tmc.cus_from as "cusFrom",
  1001. tmc.contact_phone as "contactPhone",
  1002. tmc.address_full as "addressFull",
  1003. tmdd.data_value as cus_from_name,
  1004. tmc.address_area,
  1005. tmc.address_name,
  1006. tmc.address_no,
  1007. tmc.address_gcj02,
  1008. tmc.address_full,
  1009. tmc.contact_name,
  1010. tmc.contact_phone,
  1011. tmc.channel_id as sales_channel,
  1012. tmsc.channel_name as channel_name,
  1013. t.sup_id,
  1014. t.out_status,
  1015. sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
  1016. sys.f_remove_zero(t.outing_qty) as outing_qty,
  1017. t.outing_amt,
  1018. sys.f_remove_zero(t.out_qty) as out_qty,
  1019. t.out_amt,
  1020. sys.f_remove_zero(t.return_qty) as return_qty,
  1021. t.return_amt,
  1022. t.out_date,
  1023. t.remarks,
  1024. t.annex_paths,
  1025. t.make_staff,
  1026. makestaff.staff_name as "makeStaffName",
  1027. t.make_time,
  1028. t.receivable_id,
  1029. t.cp_id,
  1030. t.flg_valid,
  1031. tmp.sup_name AS "supplierName",
  1032. t.out_reason,
  1033. t.flg_auto_handle,
  1034. t.flg_handle_setting,
  1035. tmd.data_value as out_reason_name,
  1036. <include refid="Base_Column_List_Item_Response_Detail_Join"/>
  1037. FROM dkic_b.t_psi_outbound as t
  1038. left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
  1039. left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
  1040. left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
  1041. left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
  1042. left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
  1043. left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
  1044. left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
  1045. left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
  1046. Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
  1047. left join dkic_b.t_psi_outbound_item tpoi on tpoi.out_id = t.out_id
  1048. left join dkic_b.t_psi_inventory tpi on tpi.inv_id = tpoi.inv_id
  1049. left join dkic_b.t_mst_unit as tmgu on tpoi.unit_id = tmgu.unit_id
  1050. left join dkic_b.t_mst_unit as tmgus on tpoi.sub_unit_id = tmgus.unit_id
  1051. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpoi.sku_id
  1052. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  1053. left join dkic_b.t_psi_inventory tpity on tpity.inv_id = tpoi.inv_id
  1054. left join dkic_b.t_mst_warehouse as tmw on tpity.wh_id = tmw.wh_id
  1055. <include refid="Condition"/>
  1056. order by t.make_time desc
  1057. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1058. limit #{end} offset #{start}
  1059. </if>
  1060. </select>
  1061. <sql id="Base_Column_List_Item_Response_Detail_Join">
  1062. tpoi.item_id AS "list_item_id",
  1063. tpoi.out_id AS "list_out_id",
  1064. t.out_no AS "list_out_no",
  1065. tpoi.out_type AS "list_out_type",
  1066. tpoi.from_id AS "list_from_id",
  1067. tpoi.from_item_id AS "list_from_item_id",
  1068. tpoi.item_index AS "list_item_index",
  1069. tpoi.sku_id AS "list_sku_id",
  1070. tpoi.price_out AS "list_price_out",
  1071. tpoi.non_std_code AS "list_non_std_code",
  1072. tpoi.out_status AS "list_out_status",
  1073. sys.f_remove_zero(tpoi.outing_qty) AS "list_outing_qty",
  1074. tpoi.outing_amt AS "list_outing_amt",
  1075. sys.f_remove_zero(tpoi.out_qty) AS "list_out_qty",
  1076. tpoi.out_amt AS "list_out_amt",
  1077. sys.f_remove_zero(tpoi.return_qty) AS "list_return_qty",
  1078. tpoi.return_amt AS "list_return_amt",
  1079. tpoi.remarks AS "list_remarks",
  1080. tpoi.inv_id AS "list_inv_id",
  1081. tpoi.cost_price AS "list_cost_price",
  1082. tpoi.cost_amt AS "list_cost_amt",
  1083. tpoi.flg_valid AS "list_flg_valid",
  1084. tpoi.cp_id AS "list_cp_id",
  1085. tpoi.s_out_id AS "list_s_out_id",
  1086. tpoi.s_out_item_id AS "list_s_out_item_id",
  1087. tpoi.s_order_id AS "list_s_order_id",
  1088. tpoi.s_order_item_id AS "list_s_order_item_id",
  1089. tmgs.sku_code AS list_sku_code,
  1090. tmgs.sku_model AS list_sku_model,
  1091. tmgs.sku_name AS list_sku_name,
  1092. tmgb.brand_name AS list_brand_name,
  1093. tmgb.short_name AS list_short_name,
  1094. tmgs.price_purchase AS list_price_purchase,
  1095. tmgs.price_standard AS list_price_standard,
  1096. tmgs.sku_images AS list_sku_images,
  1097. tpity.wh_id AS list_wh_id,
  1098. tmw.wh_name AS list_wh_name
  1099. ,sys.f_remove_zero(tpi.inv_qty) as "list_invQty"
  1100. ,sys.f_remove_zero(tpi.usable_qty) as "list_usableQty"
  1101. ,tmgus.unit_name as "list_subUnitName"
  1102. ,tmgu.unit_name as "list_unitName"
  1103. ,tpoi.pack_box as "list_pack_box"
  1104. ,tmgs.flg_sub_unit as "list_flgSubUnit"
  1105. ,tpoi.outing_box as "list_outing_box"
  1106. ,tpoi.outing_piece as "list_outing_piece"
  1107. ,tpoi.out_box as "list_out_box"
  1108. ,tpoi.out_piece as "list_out_piece"
  1109. ,tmgu.decimal_places as "list_decimal_places"
  1110. </sql>
  1111. <select id="countByCondDetail" resultType="Long">
  1112. SELECT
  1113. count(1)
  1114. FROM dkic_b.t_psi_outbound as t
  1115. <include refid="Condition"/>
  1116. </select>
  1117. </mapper>