OutboundMapper.xml 52 KB

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