OutboundMapper.xml 53 KB

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