|
|
@@ -308,6 +308,13 @@
|
|
|
<!-- 通用条件列 -->
|
|
|
<sql id="Condition_1">
|
|
|
<where>
|
|
|
+
|
|
|
+ <if test="orgName != null and orgName != ''">
|
|
|
+ AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="staffName != null and staffName != ''">
|
|
|
+ AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
|
|
|
+ </if>
|
|
|
<if test="purId != null and purId != ''">
|
|
|
AND tpp.pur_id = #{purId}::uuid
|
|
|
</if>
|
|
|
@@ -446,7 +453,7 @@
|
|
|
AND tpp.pickup_date < #{pickupDateEnd}::timestamp with time zone + interval '1 day'
|
|
|
</if>
|
|
|
<if test="searchText !=null and searchText!='' " >
|
|
|
- AND tpp.pur_no LIKE concat('%',my_ex.likequery(#{searchText}), '%')
|
|
|
+ AND tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
|
|
|
</if>
|
|
|
</where>
|
|
|
</sql>
|
|
|
@@ -586,7 +593,7 @@
|
|
|
SELECT
|
|
|
<include refid="Base_Column_List"/>
|
|
|
FROM dkic_b.t_psi_purchase
|
|
|
- WHERE pur_id = #{id}
|
|
|
+ WHERE pur_id = #{id}::uuid
|
|
|
for update
|
|
|
</select>
|
|
|
|
|
|
@@ -773,4 +780,145 @@
|
|
|
SELECT *
|
|
|
FROM dkic_b.f_query_pur_for_track(#{purId}::uuid)
|
|
|
</select>
|
|
|
+ <select id="selectPurOrderAndDeatil" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ tpp.pur_id AS "purId"
|
|
|
+ ,tpp.pur_no AS "purNo"
|
|
|
+ ,tpp.pur_type AS "purType"
|
|
|
+ ,tpp.org_id AS "orgId"
|
|
|
+ ,tpp.staff_id AS "staffId"
|
|
|
+ ,tpp.sup_id AS "supId"
|
|
|
+ ,tpp.contact_name AS "contactName"
|
|
|
+ ,tpp.contact_phone AS "contactPhone"
|
|
|
+ ,tpp.pickup_date AS "pickupDate"
|
|
|
+ ,tpp.sum_quantity AS "sumQuantity"
|
|
|
+ ,tpp.sum_standard AS "sumStandard"
|
|
|
+ ,tpp.sum_amount AS "sumAmount"
|
|
|
+ ,tpp.pur_discount AS "purDiscount"
|
|
|
+ ,tpp.pur_status AS "purStatus"
|
|
|
+ ,tpp.into_status AS "intoStatus"
|
|
|
+ ,tpp.intoing_qty AS "intoingQty"
|
|
|
+ ,tpp.intoing_amt AS "intoingAmt"
|
|
|
+ ,tpp.into_qty AS "intoQty"
|
|
|
+ ,tpp.into_amt AS "intoAmt"
|
|
|
+ ,tpp.return_qty AS "returnQty"
|
|
|
+ ,tpp.return_amt AS "returnAmt"
|
|
|
+ ,tpp.amt_payable AS "amtPayable"
|
|
|
+ ,tpp.amt_handle AS "amtHandle"
|
|
|
+ ,tpp.amt_residue AS "amtResidue"
|
|
|
+ ,tpp.remarks AS "remarks"
|
|
|
+ ,tpp.annex_paths AS "annexPaths"
|
|
|
+ ,tpp.make_staff AS "makeStaff"
|
|
|
+ ,tpp.make_time AS "makeTime"
|
|
|
+ ,tpp.flg_valid AS "flgValid"
|
|
|
+ ,tpp.cp_id AS "cpId"
|
|
|
+ ,tpp.op_create_time AS "opCreateTime"
|
|
|
+ ,tpp.op_create_user_id AS "opCreateUserId"
|
|
|
+ ,tpp.op_update_time AS "opUpdateTime"
|
|
|
+ ,tpp.op_update_user_id AS "opUpdateUserId"
|
|
|
+ ,tpp.op_app_code AS "opAppCode"
|
|
|
+ ,tpp.op_timestamp AS "opTimestamp"
|
|
|
+ ,tpp.op_db_user AS "opDbUser"
|
|
|
+ ,tpp.wh_id AS "whId"
|
|
|
+ ,tpp.from_ids AS "fromIds"
|
|
|
+ ,tpp.from_nos AS "fromNos"
|
|
|
+ ,tmo.org_name as "orgName"
|
|
|
+ ,tms.staff_name as "staffName"
|
|
|
+ ,tms1.staff_name as "makeStaffName"
|
|
|
+ ,tmp.sup_name as "supplierName"
|
|
|
+ ,tmp.return_address as "returnAddress"
|
|
|
+ ,tmw.wh_name as "whName"
|
|
|
+ ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "intoStatusName"
|
|
|
+ ,sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "purStatusName"
|
|
|
+ ,CASE
|
|
|
+ WHEN tpp.pur_status = '订单状态-暂存' THEN sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n})
|
|
|
+ WHEN tpp.pur_status != '订单状态-暂存' THEN sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n})
|
|
|
+ END AS "displayedStatus"
|
|
|
+ , (
|
|
|
+ SELECT
|
|
|
+ json_agg ( row_to_json ( item ) )
|
|
|
+ FROM
|
|
|
+ ( SELECT
|
|
|
+ tppi.item_id AS "itemId"
|
|
|
+ ,tppi.pur_id AS "purId"
|
|
|
+ ,tppi.item_index AS "itemIndex"
|
|
|
+ ,tppi.sku_id AS "skuId"
|
|
|
+ ,tppi.item_qty AS "itemQty"
|
|
|
+ ,tppi.price_std as "priceStd"
|
|
|
+ ,tppi.amt_std AS "amtStd"
|
|
|
+ ,tppi.price_pur AS "pricePur"
|
|
|
+ ,tppi.item_amt AS "itemAmt"
|
|
|
+ ,tppi.price_discount AS "priceDiscount"
|
|
|
+ ,tppi.non_std_code AS "nonStdCode"
|
|
|
+ ,tppi.into_status AS "intoStatus"
|
|
|
+ ,tppi.intoing_qty AS "intoingQty"
|
|
|
+ ,tppi.intoing_amt AS "intoingAmt"
|
|
|
+ ,tppi.into_qty AS "intoQty"
|
|
|
+ ,tppi.into_amt AS "intoAmt"
|
|
|
+ ,tppi.return_qty AS "returnQty"
|
|
|
+ ,tppi.return_amt AS "returnAmt"
|
|
|
+ ,tppi.remarks AS "remarks"
|
|
|
+ ,tppi.flg_valid AS "flagValid"
|
|
|
+ ,tppi.cp_id AS "cpId"
|
|
|
+ ,tppi.op_create_time AS "opCreateTime"
|
|
|
+ ,tppi.op_create_user_id AS "opCreateUserId"
|
|
|
+ ,tppi.op_update_time AS "opUpdateTime"
|
|
|
+ ,tppi.op_update_user_id AS "opUpdateUserId"
|
|
|
+ ,tppi.op_app_code AS "opAppCode"
|
|
|
+ ,tppi.op_timestamp AS "opTimestamp"
|
|
|
+ ,tppi.op_db_user AS "opDbUser"
|
|
|
+ ,tppi.from_id AS "fromId"
|
|
|
+ ,tppi.from_item_id AS "fromItemId"
|
|
|
+ ,tpoitem.order_no as "orderNo"
|
|
|
+ ,tmgsitem.sku_code as "skuCode"
|
|
|
+ ,tmgsitem.sku_model as "skuModel"
|
|
|
+ ,tmgsitem.sku_name as "skuName"
|
|
|
+ ,tmgbitem.brand_name as "brandName"
|
|
|
+ ,tmgbitem.short_name as "shortName"
|
|
|
+ ,tmgsitem.sku_spec as "skuSpec"
|
|
|
+ ,tmgsitem.price_purchase as "pricePurchase"
|
|
|
+ ,tmgsitem.price_standard as "priceStandard"
|
|
|
+ ,sys.f_get_name_i18n(tdk1item.kind_name_i18n, #{i18n}) as "intoStatusName"
|
|
|
+ ,i.inv_id AS "invId"
|
|
|
+ ,i.inv_qty AS "invQty"
|
|
|
+ ,i.usable_qty AS "usableQty"
|
|
|
+ ,tppitem.pur_no as "purNo"
|
|
|
+ FROM dkic_b.t_psi_purchase_item tppi
|
|
|
+ left join(SELECT T.*
|
|
|
+ FROM (select tpi.inv_id,
|
|
|
+ tpi.wh_id,
|
|
|
+ tpi.inv_qty,
|
|
|
+ tpi.usable_qty,
|
|
|
+ tpi.sku_id,
|
|
|
+ tpi.non_std_code,
|
|
|
+ tpi.cp_id,
|
|
|
+ tmwitem.wh_name,
|
|
|
+ rank()
|
|
|
+ over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
|
|
|
+ from dkic_b.t_psi_inventory as tpi
|
|
|
+ left join dkic_b.t_mst_warehouse as tmwitem on tmwitem.wh_id = tpi.wh_id) T
|
|
|
+ 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
|
|
|
+ left join dkic_b.t_psi_order tpoitem on tpoitem.order_id = tppi.from_id
|
|
|
+ left join dkic_b.t_mst_goods_sku tmgsitem on tppi.sku_id = tmgsitem.sku_id
|
|
|
+ left join dkic_b.t_mst_goods_brand tmgbitem on tmgbitem.brand_id = tmgsitem.brand_id
|
|
|
+ left join sys.t_data_kind tdk1item on tdk1item.kind_code = tppi.into_status
|
|
|
+ left join dkic_b.t_psi_purchase tppitem on tppitem.pur_id = tppi.pur_id
|
|
|
+ WHERE
|
|
|
+ tppi.pur_id = tpp.pur_id
|
|
|
+ ) item
|
|
|
+ ) AS "purchaseItemResponseList"
|
|
|
+ FROM dkic_b.t_psi_purchase tpp
|
|
|
+ Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
|
|
|
+ Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
|
|
|
+ Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
|
|
|
+ Left join dkic_b.t_mst_staff tms1 on tpp.make_staff = tms1.staff_id
|
|
|
+ Left join dkic_b.t_mst_warehouse tmw on tpp.wh_id = tmw.wh_id
|
|
|
+ left join sys.t_data_kind tdk1 on tdk1.kind_code = tpp.into_status
|
|
|
+ left join sys.t_data_kind tdk2 on tdk2.kind_code = tpp.pur_status
|
|
|
+ <include refid="Condition_1"/>
|
|
|
+ order by tpp.make_time desc
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|