PurchaseMapper.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  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.pur.PurchaseMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. pur_id, pur_no, pur_type, org_id, staff_id, sup_id, contact_name, contact_phone,
  8. pickup_date, sum_quantity, sum_standard, sum_amount, pur_discount, pur_status,
  9. into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty, return_amt,
  10. amt_payable, amt_handle, amt_residue, remarks, annex_paths, make_staff, make_time, flg_valid, cp_id,
  11. op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  12. </sql>
  13. <!-- 通用查询列 -->
  14. <sql id="Base_Column_List_Left_join">
  15. tpp.pur_id,
  16. tpp.pur_no,
  17. tpp.pur_type,
  18. tpp.org_id,
  19. tpp.staff_id,
  20. tpp.sup_id,
  21. tpp.contact_name,
  22. tpp.contact_phone,
  23. tpp.pickup_date,
  24. tpp.sum_quantity,
  25. tpp.sum_standard,
  26. tpp.sum_amount,
  27. tpp.pur_discount,
  28. tpp.pur_status,
  29. tpp.into_status,
  30. tpp.intoing_qty,
  31. tpp.intoing_amt,
  32. tpp.into_qty,
  33. tpp.into_amt,
  34. tpp.return_qty,
  35. tpp.return_amt,
  36. tpp.amt_payable,
  37. tpp.amt_handle,
  38. tpp.amt_residue,
  39. tpp.remarks,
  40. tpp.annex_paths,
  41. tpp.make_staff,
  42. tpp.make_time,
  43. tpp.flg_valid,
  44. tpp.cp_id,
  45. tpp.op_create_time,
  46. tpp.op_create_user_id,
  47. tpp.op_update_time,
  48. tpp.op_update_user_id,
  49. tpp.op_app_code,
  50. tpp.op_timestamp,
  51. tpp.op_db_user,
  52. tpp.wh_id,
  53. tpp.from_ids,
  54. tpp.from_nos
  55. </sql>
  56. <!-- 通用查询映射结果 -->
  57. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.pur.Purchase">
  58. <id column="pur_id" property="purId"/>
  59. <result column="pur_no" property="purNo"/>
  60. <result column="pur_type" property="purType"/>
  61. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  62. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  63. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  64. <result column="contact_name" property="contactName"/>
  65. <result column="contact_phone" property="contactPhone"/>
  66. <result column="pickup_date" property="pickupDate" typeHandler="TimestampTypeHandler"/>
  67. <result column="sum_quantity" property="sumQuantity"/>
  68. <result column="sum_standard" property="sumStandard"/>
  69. <result column="sum_amount" property="sumAmount"/>
  70. <result column="pur_discount" property="purDiscount"/>
  71. <result column="pur_status" property="purStatus"/>
  72. <result column="into_status" property="intoStatus"/>
  73. <result column="intoing_qty" property="intoingQty"/>
  74. <result column="intoing_amt" property="intoingAmt"/>
  75. <result column="into_qty" property="intoQty"/>
  76. <result column="into_amt" property="intoAmt"/>
  77. <result column="return_qty" property="returnQty"/>
  78. <result column="return_amt" property="returnAmt"/>
  79. <result column="amt_payable" property="amtPayable"/>
  80. <result column="amt_handle" property="amtHandle"/>
  81. <result column="amt_residue" property="amtResidue"/>
  82. <result column="remarks" property="remarks"/>
  83. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  84. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  85. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  86. <result column="flg_valid" property="flgValid"/>
  87. <result column="cp_id" property="cpId"/>
  88. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  89. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  90. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  91. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  92. <result column="op_app_code" property="opAppCode"/>
  93. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  94. <result column="op_db_user" property="opDbUser"/>
  95. <result column="wh_id" property="whId"/>
  96. </resultMap>
  97. <!-- 通用查询映射结果 -->
  98. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.pur.PurchaseResponse">
  99. <id column="pur_id" property="purId"/>
  100. <result column="pur_no" property="purNo"/>
  101. <result column="pur_type" property="purType"/>
  102. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  103. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  104. <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
  105. <result column="contact_name" property="contactName"/>
  106. <result column="contact_phone" property="contactPhone"/>
  107. <result column="pickup_date" property="pickupDate" typeHandler="TimestampTypeHandler"/>
  108. <result column="sum_quantity" property="sumQuantity"/>
  109. <result column="sum_standard" property="sumStandard"/>
  110. <result column="sum_amount" property="sumAmount"/>
  111. <result column="pur_discount" property="purDiscount"/>
  112. <result column="pur_status" property="purStatus"/>
  113. <result column="into_status" property="intoStatus"/>
  114. <result column="intoing_qty" property="intoingQty"/>
  115. <result column="intoing_amt" property="intoingAmt"/>
  116. <result column="into_qty" property="intoQty"/>
  117. <result column="into_amt" property="intoAmt"/>
  118. <result column="return_qty" property="returnQty"/>
  119. <result column="return_amt" property="returnAmt"/>
  120. <result column="amt_payable" property="amtPayable"/>
  121. <result column="amt_handle" property="amtHandle"/>
  122. <result column="amt_residue" property="amtResidue"/>
  123. <result column="remarks" property="remarks"/>
  124. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  125. <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
  126. <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
  127. <result column="flg_valid" property="flgValid"/>
  128. <result column="cp_id" property="cpId"/>
  129. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  130. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  131. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  132. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  133. <result column="op_app_code" property="opAppCode"/>
  134. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  135. <result column="op_db_user" property="opDbUser"/>
  136. <result column="wh_id" property="whId"/>
  137. <result column="orgName" property="orgName"/>
  138. <result column="staffName" property="staffName"/>
  139. <result column="makeStaffName" property="makeStaffName"/>
  140. <result column="supplierName" property="supplierName"/>
  141. <result column="whName" property="whName"/>
  142. <result column="displayedStatus" property="displayedStatus"/>
  143. <result column="intoStatusName" property="intoStatusName"/>
  144. <result column="purStatusName" property="purStatusName"/>
  145. <result column="returnAddress" property="returnAddress"/>
  146. <result column="from_ids" property="fromIds" typeHandler="StringListTypeHandler"/>
  147. <result column="from_nos" property="fromNos" typeHandler="StringListTypeHandler"/>
  148. <result column="inboundReturnQty" property="inboundReturnQty"/>
  149. <collection property="purchaseItemResponseList" resultMap="purchaseItemListMap" columnPrefix="list_"/>
  150. </resultMap>
  151. <!-- 关联映射-->
  152. <resultMap id="purchaseItemListMap" type="java.util.Map">
  153. <id column="item_id" property="itemId"/>
  154. <result column="pur_id" property="purId" typeHandler="UuidTypeHandler"/>
  155. <result column="pur_no" property="purNo"/>
  156. <result column="item_index" property="itemIndex"/>
  157. <result column="sku_id" property="skuId" typeHandler="UuidTypeHandler"/>
  158. <result column="item_qty" property="itemQty"/>
  159. <result column="price_std" property="priceStd"/>
  160. <result column="amt_std" property="amtStd"/>
  161. <result column="price_pur" property="pricePur"/>
  162. <result column="item_amt" property="itemAmt"/>
  163. <result column="price_discount" property="priceDiscount"/>
  164. <result column="non_std_code" property="nonStdCode"/>
  165. <result column="into_status" property="intoStatus"/>
  166. <result column="intoing_qty" property="intoingQty"/>
  167. <result column="intoing_amt" property="intoingAmt"/>
  168. <result column="into_qty" property="intoQty"/>
  169. <result column="into_amt" property="intoAmt"/>
  170. <result column="return_qty" property="returnQty"/>
  171. <result column="return_amt" property="returnAmt"/>
  172. <result column="remarks" property="remarks"/>
  173. <result column="flg_valid" property="flgValid"/>
  174. <result column="cp_id" property="cpId"/>
  175. <result column="sku_code" property="skuCode"/>
  176. <result column="sku_name" property="skuName"/>
  177. <result column="price_standard" property="priceStandard"/>
  178. <result column="sku_model" property="skuModel"/>
  179. <result column="short_name" property="shortName"/>
  180. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  181. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  182. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  183. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  184. <result column="op_app_code" property="opAppCode"/>
  185. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  186. <result column="op_db_user" property="opDbUser"/>
  187. </resultMap>
  188. <!-- 通用条件列 -->
  189. <sql id="Condition">
  190. <where>
  191. <if test="purNo != null and purNo != ''">
  192. AND pur_no = #{purNo}
  193. </if>
  194. <if test="purType != null and purType != ''">
  195. AND pur_type = #{purType}
  196. </if>
  197. <if test="orgId != null and orgId != ''">
  198. AND org_id = #{orgId}
  199. </if>
  200. <if test="staffId != null and staffId != ''">
  201. AND staff_id = #{staffId}
  202. </if>
  203. <if test="supId != null and supId != ''">
  204. AND sup_id = #{supId}
  205. </if>
  206. <if test="contactName != null and contactName != ''">
  207. AND contact_name = #{contactName}
  208. </if>
  209. <if test="contactPhone != null and contactPhone != ''">
  210. AND contact_phone = #{contactPhone}
  211. </if>
  212. <if test="pickupDate != null">
  213. AND pickup_date = #{pickupDate}
  214. </if>
  215. <if test="sumQuantity != null">
  216. AND sum_quantity = #{sumQuantity}
  217. </if>
  218. <if test="sumStandard != null">
  219. AND sum_standard = #{sumStandard}
  220. </if>
  221. <if test="sumAmount != null">
  222. AND sum_amount = #{sumAmount}
  223. </if>
  224. <if test="purDiscount != null">
  225. AND pur_discount = #{purDiscount}
  226. </if>
  227. <if test="purStatus != null and purStatus != ''">
  228. AND pur_status = #{purStatus}
  229. </if>
  230. <if test="intoStatus != null and intoStatus != ''">
  231. AND into_status = #{intoStatus}
  232. </if>
  233. <if test="intoingQty != null">
  234. AND intoing_qty = #{intoingQty}
  235. </if>
  236. <if test="intoingAmt != null">
  237. AND intoing_amt = #{intoingAmt}
  238. </if>
  239. <if test="intoQty != null">
  240. AND into_qty = #{intoQty}
  241. </if>
  242. <if test="intoAmt != null">
  243. AND into_amt = #{intoAmt}
  244. </if>
  245. <if test="returnQty != null">
  246. AND return_qty = #{returnQty}
  247. </if>
  248. <if test="returnAmt != null">
  249. AND return_amt = #{returnAmt}
  250. </if>
  251. <if test="amtPayable != null">
  252. AND amt_payable = #{amtPayable}
  253. </if>
  254. <if test="amtHandle != null">
  255. AND amt_handle = #{amtHandle}
  256. </if>
  257. <if test="amtResidue != null">
  258. AND amt_residue = #{amtResidue}
  259. </if>
  260. <if test="remarks != null and remarks != ''">
  261. AND remarks = #{remarks}
  262. </if>
  263. <if test="annexPaths != null and annexPaths != ''">
  264. AND annex_paths = #{annexPaths}
  265. </if>
  266. <if test="makeStaff != null and makeStaff != ''">
  267. AND make_staff = #{makeStaff}
  268. </if>
  269. <if test="makeTime != null">
  270. AND make_time = #{makeTime}
  271. </if>
  272. <if test="flgValid != null">
  273. AND flg_valid = #{flgValid}
  274. </if>
  275. <if test="cpId != null">
  276. AND cp_id = #{cpId}
  277. </if>
  278. <if test="opCreateTime != null">
  279. AND op_create_time = #{opCreateTime}
  280. </if>
  281. <if test="opCreateUserId != null and opCreateUserId != ''">
  282. AND op_create_user_id = #{opCreateUserId}
  283. </if>
  284. <if test="opUpdateTime != null">
  285. AND op_update_time = #{opUpdateTime}
  286. </if>
  287. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  288. AND op_update_user_id = #{opUpdateUserId}
  289. </if>
  290. <if test="opAppCode != null and opAppCode != ''">
  291. AND op_app_code = #{opAppCode}
  292. </if>
  293. <if test="opTimestamp != null">
  294. AND op_timestamp = #{opTimestamp}
  295. </if>
  296. <if test="opDbUser != null and opDbUser != ''">
  297. AND op_db_user = #{opDbUser}
  298. </if>
  299. </where>
  300. </sql>
  301. <!-- 通用条件列 -->
  302. <sql id="Condition_1">
  303. <where>
  304. <if test="orgName != null and orgName != ''">
  305. AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  306. </if>
  307. <if test="staffName != null and staffName != ''">
  308. AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
  309. </if>
  310. <if test="purId != null and purId != ''">
  311. AND tpp.pur_id = #{purId}::uuid
  312. </if>
  313. <if test="purNo != null and purNo != ''">
  314. AND tpp.pur_no like concat('%', my_ex.likequery(#{purNo}) , '%')
  315. </if>
  316. <if test="purType != null and purType != ''">
  317. AND tpp.pur_type = #{purType}
  318. </if>
  319. <if test="orgId != null and orgId != ''">
  320. AND tpp.org_id = #{orgId}
  321. </if>
  322. <if test="staffId != null and staffId != ''">
  323. AND tpp.staff_id = #{staffId}
  324. </if>
  325. <if test="supId != null and supId != ''">
  326. AND tpp.sup_id = #{supId}::uuid
  327. </if>
  328. <if test="contactName != null and contactName != ''">
  329. AND tpp.contact_name like concat('%', my_ex.likequery(#{contactName}) , '%')
  330. </if>
  331. <if test="contactPhone != null and contactPhone != ''">
  332. AND tpp.contact_phone like concat('%', my_ex.likequery(#{contactPhone}) , '%')
  333. </if>
  334. <if test="pickupDate != null">
  335. AND tpp.pickup_date = #{pickupDate}
  336. </if>
  337. <if test="sumQuantity != null">
  338. AND tpp.sum_quantity = #{sumQuantity}
  339. </if>
  340. <if test="sumStandard != null">
  341. AND tpp.sum_standard = #{sumStandard}
  342. </if>
  343. <if test="sumAmount != null">
  344. AND tpp.sum_amount = #{sumAmount}
  345. </if>
  346. <if test="purDiscount != null">
  347. AND tpp.pur_discount = #{purDiscount}
  348. </if>
  349. <if test="purStatus != null and purStatus != ''">
  350. AND tpp.pur_status = #{purStatus}
  351. </if>
  352. <if test="intoStatus != null and intoStatus != ''">
  353. AND tpp.into_status = #{intoStatus}
  354. </if>
  355. <if test="intoingQty != null">
  356. AND tpp.intoing_qty = #{intoingQty}
  357. </if>
  358. <if test="intoingAmt != null">
  359. AND tpp.intoing_amt = #{intoingAmt}
  360. </if>
  361. <if test="intoQty != null">
  362. AND tpp.into_qty = #{intoQty}
  363. </if>
  364. <if test="intoAmt != null">
  365. AND tpp.into_amt = #{intoAmt}
  366. </if>
  367. <if test="returnQty != null">
  368. AND tpp.return_qty = #{returnQty}
  369. </if>
  370. <if test="returnAmt != null">
  371. AND tpp.return_amt = #{returnAmt}
  372. </if>
  373. <if test="amtPayable != null">
  374. AND tpp.amt_payable = #{amtPayable}
  375. </if>
  376. <if test="amtHandle != null">
  377. AND tpp.amt_handle = #{amtHandle}
  378. </if>
  379. <if test="amtResidue != null">
  380. AND tpp.amt_residue = #{amtResidue}
  381. </if>
  382. <if test="remarks != null and remarks != ''">
  383. AND tpp.remarks = #{remarks}
  384. </if>
  385. <if test="annexPaths != null and annexPaths != ''">
  386. AND tpp.annex_paths = #{annexPaths}
  387. </if>
  388. <if test="makeStaff != null and makeStaff != ''">
  389. AND tpp.make_staff = #{makeStaff}
  390. </if>
  391. <if test="makeTime != null">
  392. AND tpp.make_time = #{makeTime}
  393. </if>
  394. <if test="makeTimeStart != null and makeTimeEnd != null">
  395. AND tpp.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  396. AND tpp.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  397. </if>
  398. <if test="opCreateTime != null">
  399. AND tpp.op_create_time = #{opCreateTime}
  400. </if>
  401. <if test="opCreateUserId != null and opCreateUserId != ''">
  402. AND tpp.op_create_user_id = #{opCreateUserId}
  403. </if>
  404. <if test="opUpdateTime != null">
  405. AND tpp.op_update_time = #{opUpdateTime}
  406. </if>
  407. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  408. AND tpp.op_update_user_id = #{opUpdateUserId}
  409. </if>
  410. <if test="opAppCode != null and opAppCode != ''">
  411. AND tpp.op_app_code = #{opAppCode}
  412. </if>
  413. <if test="opTimestamp != null">
  414. AND tpp.op_timestamp = #{opTimestamp}
  415. </if>
  416. <if test="opDbUser != null and opDbUser != ''">
  417. AND tpp.op_db_user = #{opDbUser}
  418. </if>
  419. <if test="intoStatus != null and intoStatus != ''">
  420. AND tpp.into_status = #{intoStatus}
  421. </if>
  422. <if test="intoStatusList != null and intoStatusList.size()>0">
  423. AND tpp.into_status =
  424. any(#{intoStatusList,typeHandler=StringListTypeHandler})
  425. </if>
  426. <if test="skuName != null and skuName!='' ">
  427. and exists (select 1 from dkic_b.t_psi_purchase_item tppi
  428. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tppi.sku_id
  429. where
  430. tpp.pur_id = tppi.pur_id
  431. and tppi.flg_valid
  432. AND position(#{skuName} in tmgs.sku_name) > 0
  433. )
  434. </if>
  435. <if test="pickupDateStart != null">
  436. AND tpp.pickup_date &gt;= #{pickupDateStart}::timestamp with time zone
  437. </if>
  438. <if test="pickupDateEnd != null">
  439. AND tpp.pickup_date &lt; #{pickupDateEnd}::timestamp with time zone + interval '1 day'
  440. </if>
  441. <if test="searchText !=null and searchText!='' " >
  442. AND ( tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')or
  443. tpp.pur_no LIKE concat('%',my_ex.likequery(#{searchText}), '%'))
  444. </if>
  445. <if test="flgValid != null">
  446. AND tpp.flg_valid = #{flgValid}
  447. </if>
  448. <if test="cpId != null">
  449. AND tpp.cp_id = #{cpId}
  450. </if>
  451. </where>
  452. </sql>
  453. <sql id="idsForeach">
  454. <!-- 根据主键purId批量操作 -->
  455. WHERE pur_id in
  456. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  457. #{item}
  458. </foreach>
  459. </sql>
  460. <!-- 查询表dkic_b.t_psi_purchase,(条件查询+分页)列表 -->
  461. <select id="selectByCond" resultMap="BaseResultMapResponse">
  462. SELECT
  463. <include refid="Base_Column_List_Left_join"/>
  464. ,tmo.org_name as "orgName"
  465. ,tms.staff_name as "staffName"
  466. ,tms1.staff_name as "makeStaffName"
  467. ,tmp.sup_name as "supplierName"
  468. ,tmp.return_address as "returnAddress"
  469. ,tmw.wh_name as "whName"
  470. ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
  471. ,sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "purStatusName"
  472. ,CASE
  473. WHEN tpp.pur_status = '订单状态-暂存' THEN sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n})
  474. WHEN tpp.pur_status != '订单状态-暂存' THEN sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n})
  475. END AS "displayedStatus"
  476. FROM dkic_b.t_psi_purchase tpp
  477. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  478. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  479. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  480. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  481. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  482. left join sys.t_data_kind tdk1 on tdk1.kind_code = tpp.into_status
  483. left join sys.t_data_kind tdk2 on tdk2.kind_code = tpp.pur_status
  484. <include refid="Condition_1"/>
  485. order by tpp.make_time desc
  486. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  487. limit #{end} offset #{start}
  488. </if>
  489. </select>
  490. <sql id="Base_Column_List_Item_Response_Join">
  491. ,tppi.item_id as "List_item_id",
  492. tppi.pur_id as "List_pur_id",
  493. tpp.pur_no as "List_pur_no",
  494. tppi.item_index as "List_item_index",
  495. tppi.sku_id as "List_sku_id",
  496. tppi.item_qty as "List_item_qty",
  497. tppi.price_std as "pricePurchase",
  498. tppi.amt_std as "List_amt_std",
  499. tppi.price_pur as "List_price_pur",
  500. tppi.item_amt as "List_item_amt",
  501. tppi.price_discount as "List_price_discount",
  502. tppi.non_std_code as "List_non_std_code",
  503. tppi.into_status as "List_into_status",
  504. tppi.intoing_qty as "List_intoing_qty",
  505. tppi.intoing_amt as "List_intoing_amt",
  506. tppi.into_qty as "List_into_qty",
  507. tppi.into_amt as "List_into_amt",
  508. tppi.return_qty as "List_return_qty",
  509. tppi.return_amt as "List_return_amt",
  510. tppi.remarks as "List_remarks",
  511. tppi.flg_valid as "List_flg_valid",
  512. tppi.cp_id as "List_cp_id",
  513. tppi.op_create_time as "List_op_create_time",
  514. tppi.op_create_user_id as "List_op_create_user_id",
  515. tppi.op_update_time as "List_op_update_time",
  516. tppi.op_update_user_id as "List_op_update_user_id",
  517. tppi.op_app_code as "List_op_app_code",
  518. tppi.op_timestamp as "List_op_timestamp",
  519. tppi.op_db_user as "List_op_db_user",
  520. tmgs.sku_code AS list_sku_code,
  521. tmgs.sku_name AS list_sku_name,
  522. tmgb.short_name AS list_short_name,
  523. tmgs.sku_model AS list_sku_model,
  524. tmgs.price_purchase AS list_price_purchase,
  525. tmgs.price_standard AS list_price_standard,
  526. tmgs.sku_images AS list_sku_images,
  527. tpit.usable_qty AS list_usable_qty,
  528. tpit.inv_qty AS list_inv_qty,
  529. tpit.outing_qty AS list_outing_qty
  530. </sql>
  531. <!-- 查询表dkic_b.t_psi_purchase,(条件查询+分页)列表 -->
  532. <select id="selectByCondItem" resultMap="BaseResultMapResponse">
  533. SELECT
  534. <include refid="Base_Column_List_Left_join"/>
  535. <include refid="Base_Column_List_Item_Response_Join"/>
  536. ,tmo.org_name as "orgName"
  537. ,tms.staff_name as "staffName"
  538. ,tms1.staff_name as "makeStaffName"
  539. ,tmp.sup_name as "supplierName"
  540. ,tmw.wh_name as "whName"
  541. ,tmw.wh_name as "whName"
  542. ,tmw.wh_name as "whName"
  543. FROM dkic_b.t_psi_purchase tpp
  544. left join dkic_b.t_psi_purchase_item tppi on tppi.pur_id = tpp.pur_id
  545. left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tppi.sku_id
  546. left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
  547. left join dkic_b.t_psi_inventory tpit on tpit.sku_id = tppi.sku_id
  548. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  549. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  550. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  551. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  552. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  553. <include refid="Condition_1"/>
  554. ORDER BY tpp.make_time
  555. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  556. limit #{end} offset #{start}
  557. </if>
  558. </select>
  559. <!-- 根据主键查询表dkic_b.t_psi_purchase的一行数据 -->
  560. <select id="selectById" resultMap="BaseResultMapResponse">
  561. SELECT
  562. <include refid="Base_Column_List_Left_join"/>
  563. ,tmo.org_name as "orgName"
  564. ,tms.staff_name as "staffName"
  565. ,tms1.staff_name as "makeStaffName"
  566. ,tmp.sup_name as "supplierName"
  567. ,tmw.wh_name as "whName"
  568. ,(SELECT sum(tpid.return_qty) FROM dkic_b.t_psi_inbound tpid where tpid.from_id = tpp.pur_id ) as "inboundReturnQty"
  569. FROM dkic_b.t_psi_purchase tpp
  570. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  571. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  572. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  573. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  574. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  575. WHERE pur_id = #{id}::uuid
  576. </select>
  577. <!-- 根据主键锁定表dkic_b.t_psi_purchase的一行数据 -->
  578. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  579. SELECT
  580. <include refid="Base_Column_List"/>
  581. FROM dkic_b.t_psi_purchase
  582. WHERE pur_id = #{id}::uuid
  583. for update
  584. </select>
  585. <!-- 根据主键锁定表dkic_b.t_psi_purchase的多行数据 -->
  586. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  587. SELECT
  588. <include refid="Base_Column_List"/>
  589. FROM dkic_b.t_psi_purchase
  590. <include refid="idsForeach"/>
  591. for update
  592. </select>
  593. <!-- 查询表dkic_b.t_psi_purchase,(条件查询)个数 -->
  594. <select id="countByCond" resultType="Long">
  595. SELECT
  596. count(1)
  597. FROM dkic_b.t_psi_purchase tpp
  598. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  599. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  600. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  601. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  602. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  603. left join sys.t_data_kind tdk1 on tdk1.kind_code = tpp.into_status
  604. left join sys.t_data_kind tdk2 on tdk2.kind_code = tpp.pur_status
  605. <include refid="Condition_1"/>
  606. </select>
  607. <!-- 查询表dkic_b.t_psi_purchase,(条件查询+分页)列表 -->
  608. <select id="noStoredSelectByCond" resultMap="BaseResultMapResponse">
  609. SELECT
  610. <include refid="Base_Column_List_Left_join"/>
  611. ,tmo.org_name as "orgName"
  612. ,tms.staff_name as "staffName"
  613. ,tms1.staff_name as "makeStaffName"
  614. ,tmp.sup_name as "supplierName"
  615. ,tmw.wh_name as "whName",
  616. sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "intoStatusName"
  617. FROM dkic_b.t_psi_purchase tpp
  618. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  619. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  620. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  621. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  622. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  623. LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpp.into_status
  624. <include refid="Condition_1"/>
  625. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  626. limit #{end} offset #{start}
  627. </if>
  628. </select>
  629. <!-- 查询表dkic_b.t_psi_purchase,(条件查询)个数 -->
  630. <select id="noStoredCountByCond" resultType="Long">
  631. SELECT
  632. count(1)
  633. FROM dkic_b.t_psi_purchase tpp
  634. <include refid="Condition_1"/>
  635. </select>
  636. <update id="updateAmount" parameterType="com.dk.mdm.model.pojo.pur.Purchase">
  637. update dkic_b.t_psi_purchase
  638. <set>
  639. <if test="returnQty!= null">
  640. return_qty= #{returnQty},
  641. </if>
  642. <if test="returnAmt!= null">
  643. return_amt = #{returnAmt},
  644. </if>
  645. </set>
  646. where pur_id = #{purId}::uuid
  647. </update>
  648. <!-- 查询原始数据 冲正用-->
  649. <select id="selectPurchaseByRighting" resultMap="BaseResultMap">
  650. SELECT
  651. <include refid="Base_Column_List_Left_join"/>
  652. FROM dkic_b.t_psi_purchase tpp
  653. <where>
  654. <if test="orderId!=null">
  655. tpp.pur_id = #{purId}::uuid
  656. </if>
  657. </where>
  658. </select>
  659. <!-- 根据id修改-->
  660. <update id="updateById" parameterType="com.dk.mdm.model.pojo.pur.Purchase">
  661. update dkic_b.t_psi_purchase
  662. <set>
  663. <if test=" et!=null and et.purNo != null">
  664. pur_no = #{et.purNo,jdbcType=VARCHAR},
  665. </if>
  666. <if test=" et!=null and et.purType != null">
  667. pur_type = #{et.purType,jdbcType=VARCHAR},
  668. </if>
  669. <if test=" et!=null and et.orgId != null">
  670. org_id = #{et.orgId,typeHandler=UuidTypeHandler},
  671. </if>
  672. <if test=" et!=null and et.staffId != null">
  673. staff_id = #{et.staffId,typeHandler=UuidTypeHandler},
  674. </if>
  675. <if test=" et!=null and et.supId != null">
  676. sup_id = #{et.supId,typeHandler=UuidTypeHandler},
  677. </if>
  678. <if test=" et!=null and et.contactName != null">
  679. contact_name = #{et.contactName,jdbcType=VARCHAR},
  680. </if>
  681. <if test=" et!=null and et.contactPhone != null">
  682. contact_phone = #{et.contactPhone,jdbcType=VARCHAR},
  683. </if>
  684. <if test=" et!=null and et.pickupDate != null">
  685. pickup_date = #{et.pickupDate,jdbcType=DATE},
  686. </if>
  687. <if test=" et!=null and et.sumQuantity != null">
  688. sum_quantity = #{et.sumQuantity,jdbcType=NUMERIC},
  689. </if>
  690. <if test=" et!=null and et.sumStandard != null">
  691. sum_standard = #{et.sumStandard,jdbcType=NUMERIC},
  692. </if>
  693. <if test=" et!=null and et.sumAmount != null">
  694. sum_amount = #{et.sumAmount,jdbcType=NUMERIC},
  695. </if>
  696. <if test=" et!=null and et.purDiscount != null">
  697. pur_discount = #{et.purDiscount,jdbcType=NUMERIC},
  698. </if>
  699. <if test=" et!=null and et.purStatus != null">
  700. pur_status = #{et.purStatus,jdbcType=VARCHAR},
  701. </if>
  702. <if test=" et!=null and et.intoStatus != null">
  703. into_status = #{et.intoStatus,jdbcType=VARCHAR},
  704. </if>
  705. <if test=" et!=null and et.intoingQty != null">
  706. intoing_qty = intoing_qty + #{et.intoingQty,jdbcType=NUMERIC},
  707. </if>
  708. <if test=" et!=null and et.intoingAmt != null">
  709. intoing_amt = intoing_amt + #{et.intoingAmt,jdbcType=NUMERIC},
  710. </if>
  711. <if test=" et!=null and et.intoQty != null">
  712. into_qty = into_qty + #{et.intoQty,jdbcType=NUMERIC},
  713. </if>
  714. <if test=" et!=null and et.intoAmt != null">
  715. into_amt = into_amt + #{et.intoAmt,jdbcType=NUMERIC},
  716. </if>
  717. <if test=" et!=null and et.returnQty != null">
  718. return_qty = #{et.returnQty,jdbcType=NUMERIC},
  719. </if>
  720. <if test=" et!=null and et.returnAmt != null">
  721. return_amt = #{et.returnAmt,jdbcType=NUMERIC},
  722. </if>
  723. <if test=" et!=null and et.amtPayable != null">
  724. amt_payable = #{et.amtPayable,jdbcType=NUMERIC},
  725. </if>
  726. <if test=" et!=null and et.amtHandle != null">
  727. amt_handle = #{et.amtHandle,jdbcType=NUMERIC},
  728. </if>
  729. <if test=" et!=null and et.amtResidue != null">
  730. amt_residue = #{et.amtResidue,jdbcType=NUMERIC},
  731. </if>
  732. <if test=" et!=null and et.remarks != null">
  733. remarks = #{et.remarks,jdbcType=VARCHAR},
  734. </if>
  735. <if test=" et!=null and et.annexPaths != null">
  736. annex_paths = #{et.annexPaths,typeHandler=JsonTypeHandler},
  737. </if>
  738. <if test=" et!=null and et.makeStaff != null">
  739. make_staff = #{et.makeStaff,jdbcType=OTHER},
  740. </if>
  741. <if test=" et!=null and et.makeTime != null">
  742. make_time = #{et.makeTime,jdbcType=TIMESTAMP},
  743. </if>
  744. <if test=" et!=null and et.flgValid != null">
  745. flg_valid = #{et.flgValid,jdbcType=BOOLEAN},
  746. </if>
  747. <if test=" et!=null and et.cpId != null">
  748. cp_id = #{et.cpId,jdbcType=INTEGER},
  749. </if>
  750. <if test=" et!=null and et.whId != null">
  751. wh_id = #{et.whId,typeHandler=UuidTypeHandler},
  752. </if>
  753. </set>
  754. where pur_id = #{et.purId,typeHandler=UuidTypeHandler}
  755. and sum_quantity >= (into_qty + intoing_qty)
  756. </update>
  757. <!-- 采购跟踪-->
  758. <select id="selectTrackReport" resultType="java.util.Map">
  759. SELECT *
  760. FROM dkic_b.f_query_pur_for_track(#{purId}::uuid,#{cpId},#{i18n})
  761. </select>
  762. <select id="selectPurOrderAndDeatil" resultType="java.util.Map">
  763. SELECT
  764. tpp.pur_id AS "purId"
  765. ,tpp.pur_no AS "purNo"
  766. ,tpp.pur_type AS "purType"
  767. ,tpp.org_id AS "orgId"
  768. ,tpp.staff_id AS "staffId"
  769. ,tpp.sup_id AS "supId"
  770. ,tpp.contact_name AS "contactName"
  771. ,tpp.contact_phone AS "contactPhone"
  772. ,tpp.pickup_date AS "pickupDate"
  773. ,tpp.sum_quantity AS "sumQuantity"
  774. ,tpp.sum_standard AS "sumStandard"
  775. ,tpp.sum_amount AS "sumAmount"
  776. ,tpp.pur_discount AS "purDiscount"
  777. ,tpp.pur_status AS "purStatus"
  778. ,tpp.into_status AS "intoStatus"
  779. ,tpp.intoing_qty AS "intoingQty"
  780. ,tpp.intoing_amt AS "intoingAmt"
  781. ,tpp.into_qty AS "intoQty"
  782. ,tpp.into_amt AS "intoAmt"
  783. ,tpp.return_qty AS "returnQty"
  784. ,tpp.return_amt AS "returnAmt"
  785. ,tpp.amt_payable AS "amtPayable"
  786. ,tpp.amt_handle AS "amtHandle"
  787. ,tpp.amt_residue AS "amtResidue"
  788. ,tpp.remarks AS "remarks"
  789. ,tpp.annex_paths AS "annexPaths"
  790. ,tpp.make_staff AS "makeStaff"
  791. ,tpp.make_time AS "makeTime"
  792. ,tpp.flg_valid AS "flgValid"
  793. ,tpp.cp_id AS "cpId"
  794. ,tpp.op_create_time AS "opCreateTime"
  795. ,tpp.op_create_user_id AS "opCreateUserId"
  796. ,tpp.op_update_time AS "opUpdateTime"
  797. ,tpp.op_update_user_id AS "opUpdateUserId"
  798. ,tpp.op_app_code AS "opAppCode"
  799. ,tpp.op_timestamp AS "opTimestamp"
  800. ,tpp.op_db_user AS "opDbUser"
  801. ,tpp.wh_id AS "whId"
  802. ,tpp.from_ids AS "fromIds"
  803. ,tpp.from_nos AS "fromNos"
  804. ,tmo.org_name as "orgName"
  805. ,tms.staff_name as "staffName"
  806. ,tms1.staff_name as "makeStaffName"
  807. ,tmp.sup_name as "supplierName"
  808. ,tmp.return_address as "returnAddress"
  809. ,tmw.wh_name as "whName"
  810. ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
  811. ,sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "purStatusName"
  812. ,CASE
  813. WHEN tpp.pur_status = '订单状态-暂存' THEN sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n})
  814. WHEN tpp.pur_status != '订单状态-暂存' THEN sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n})
  815. END AS "displayedStatus"
  816. , (
  817. SELECT
  818. json_agg ( row_to_json ( item ) )
  819. FROM
  820. ( SELECT
  821. tppi.item_id AS "itemId"
  822. ,tppi.pur_id AS "purId"
  823. ,tppi.item_index AS "itemIndex"
  824. ,tppi.sku_id AS "skuId"
  825. ,tppi.item_qty AS "itemQty"
  826. ,tppi.price_std as "priceStd"
  827. ,tppi.amt_std AS "amtStd"
  828. ,tppi.price_pur AS "pricePur"
  829. ,tppi.item_amt AS "itemAmt"
  830. ,tppi.price_discount AS "priceDiscount"
  831. ,tppi.non_std_code AS "nonStdCode"
  832. ,tppi.into_status AS "intoStatus"
  833. ,tppi.intoing_qty AS "intoingQty"
  834. ,tppi.intoing_amt AS "intoingAmt"
  835. ,tppi.into_qty AS "intoQty"
  836. ,tppi.into_amt AS "intoAmt"
  837. ,tppi.return_qty AS "returnQty"
  838. ,tppi.return_amt AS "returnAmt"
  839. ,tppi.remarks AS "remarks"
  840. ,tppi.flg_valid AS "flagValid"
  841. ,tppi.cp_id AS "cpId"
  842. ,tppi.op_create_time AS "opCreateTime"
  843. ,tppi.op_create_user_id AS "opCreateUserId"
  844. ,tppi.op_update_time AS "opUpdateTime"
  845. ,tppi.op_update_user_id AS "opUpdateUserId"
  846. ,tppi.op_app_code AS "opAppCode"
  847. ,tppi.op_timestamp AS "opTimestamp"
  848. ,tppi.op_db_user AS "opDbUser"
  849. ,tppi.from_id AS "fromId"
  850. ,tppi.from_item_id AS "fromItemId"
  851. ,tpoitem.order_no as "orderNo"
  852. ,tmgsitem.sku_code as "skuCode"
  853. ,tmgsitem.sku_model as "skuModel"
  854. ,tmgsitem.sku_name as "skuName"
  855. ,tmgsitem.sku_images as "skuImages"
  856. ,tmgbitem.brand_name as "brandName"
  857. ,tmgbitem.short_name as "shortName"
  858. ,tmgsitem.sku_spec as "skuSpec"
  859. ,tmgsitem.price_purchase as "pricePurchase"
  860. ,tmgsitem.price_standard as "priceStandard"
  861. ,sys.f_get_name_i18n(tdk1item.kind_name_i18n, #{i18n}) as "intoStatusName"
  862. ,i.inv_id AS "invId"
  863. ,i.inv_qty AS "invQty"
  864. ,i.usable_qty AS "usableQty"
  865. ,tppitem.pur_no as "purNo"
  866. ,tppi.unit_id AS "unitId"
  867. ,tppi.sub_unit_id AS "subUnitId"
  868. ,tppi.pack_box AS "packBox"
  869. ,tppi.box AS "box"
  870. ,tppi.piece AS "piece"
  871. ,tmguitems.unit_name as "subUnitName"
  872. ,tmguitem.unit_name as "unitName"
  873. ,tmgsitem.flg_sub_unit as "flgSubUnit"
  874. FROM dkic_b.t_psi_purchase_item tppi
  875. left join(SELECT T.*
  876. FROM (select tpi.inv_id,
  877. tpi.wh_id,
  878. tpi.inv_qty,
  879. tpi.usable_qty,
  880. tpi.sku_id,
  881. tpi.non_std_code,
  882. tpi.cp_id,
  883. tmwitem.wh_name,
  884. rank()
  885. over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
  886. from dkic_b.t_psi_inventory as tpi
  887. left join dkic_b.t_mst_warehouse as tmwitem on tmwitem.wh_id = tpi.wh_id) T
  888. WHERE T.RK = 1) as i on i.sku_id = tppi.sku_id and i.non_std_code = tppi.non_std_code and i.cp_id = tppi.cp_id
  889. left join dkic_b.t_psi_order tpoitem on tpoitem.order_id = tppi.from_id
  890. left join dkic_b.t_mst_goods_sku tmgsitem on tppi.sku_id = tmgsitem.sku_id
  891. left join dkic_b.t_mst_goods_brand tmgbitem on tmgbitem.brand_id = tmgsitem.brand_id
  892. left join sys.t_data_kind tdk1item on tdk1item.kind_code = tppi.into_status
  893. left join dkic_b.t_psi_purchase tppitem on tppitem.pur_id = tppi.pur_id
  894. left join dkic_b.t_mst_unit as tmguitem on tppi.unit_id = tmguitem.unit_id
  895. left join dkic_b.t_mst_unit as tmguitems on tppi.sub_unit_id = tmguitems.unit_id
  896. WHERE
  897. tppi.pur_id = tpp.pur_id
  898. AND tppi.into_status != '入库状态-已入库'
  899. <if test="cpId != null">
  900. AND tppi.cp_id = #{cpId}
  901. </if>
  902. <if test="flgValid != null">
  903. AND tppi.flg_valid = #{flgValid}
  904. </if>
  905. ) item
  906. ) AS "purchaseItemResponseList"
  907. FROM dkic_b.t_psi_purchase tpp
  908. Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
  909. Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
  910. Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
  911. Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
  912. Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
  913. left join sys.t_data_kind tdk1 on tdk1.kind_code = tpp.into_status
  914. left join sys.t_data_kind tdk2 on tdk2.kind_code = tpp.pur_status
  915. where tpp.into_status != '入库状态-已入库'
  916. <if test="searchText !=null and searchText!='' " >
  917. AND ( tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')or
  918. tpp.pur_no LIKE concat('%',my_ex.likequery(#{searchText}), '%'))
  919. </if>
  920. <if test="flgValid != null">
  921. AND tpp.flg_valid = #{flgValid}
  922. </if>
  923. <if test="cpId != null">
  924. AND tpp.cp_id = #{cpId}
  925. </if>
  926. order by tpp.make_time desc
  927. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  928. limit #{end} offset #{start}
  929. </if>
  930. </select>
  931. </mapper>