|
|
@@ -742,36 +742,54 @@
|
|
|
tpii.sku_model AS "skuModel",
|
|
|
tpii.sku_name AS "skuName",
|
|
|
tpii.sku_id AS "skuId",
|
|
|
- tpii.cost_price AS "costPrice",
|
|
|
- tpii.cost_amt AS "costAmt",
|
|
|
+ tpii.cost_price AS "costPrice",
|
|
|
+ tpii.cost_amt AS "costAmt",
|
|
|
tmgs.brand_id AS "brandId",
|
|
|
tmgs.sku_images AS "skuImages",
|
|
|
- tmgb.brand_name as "brandName",
|
|
|
- tmgb.short_name as "shortName",
|
|
|
- json_agg(json_build_object(
|
|
|
- 'itemId', tpii.item_id,
|
|
|
- 'intoId', tpii.into_id,
|
|
|
- 'invId', tpii.inv_id,
|
|
|
- 'fromId', tpii.from_id,
|
|
|
- 'fromItemId', tpii.from_item_id,
|
|
|
- 'skuModel', tpii.sku_model,
|
|
|
- 'skuName', tpii.sku_name,
|
|
|
- 'skuId', tpii.sku_id,
|
|
|
- 'intoQty', tpii.into_qty,
|
|
|
- 'costPrice', tpii.cost_price,
|
|
|
- 'costAmt', tpii.cost_amt,
|
|
|
- 'brandId', tmgs.brand_id,
|
|
|
- 'fromItemId', tpii.from_item_id
|
|
|
- )) AS "itemList"
|
|
|
+ tmgb.brand_name AS "brandName",
|
|
|
+ tmgb.short_name AS "shortName",
|
|
|
+ json_agg (
|
|
|
+ json_build_object (
|
|
|
+ 'itemId',
|
|
|
+ tpii.item_id,
|
|
|
+ 'intoId',
|
|
|
+ tpii.into_id,
|
|
|
+ 'outId',
|
|
|
+ NULL,
|
|
|
+ 'invId',
|
|
|
+ tpii.inv_id,
|
|
|
+ 'fromId',
|
|
|
+ tpii.from_id,
|
|
|
+ 'fromItemId',
|
|
|
+ tpii.from_item_id,
|
|
|
+ 'skuModel',
|
|
|
+ tpii.sku_model,
|
|
|
+ 'skuName',
|
|
|
+ tpii.sku_name,
|
|
|
+ 'skuId',
|
|
|
+ tpii.sku_id,
|
|
|
+ 'intoQty',
|
|
|
+ tpii.into_qty,
|
|
|
+ 'costPrice',
|
|
|
+ tpii.cost_price,
|
|
|
+ 'costAmt',
|
|
|
+ tpii.cost_amt,
|
|
|
+ 'brandId',
|
|
|
+ tmgs.brand_id,
|
|
|
+ 'fromItemId',
|
|
|
+ tpii.from_item_id
|
|
|
+ )
|
|
|
+ ) AS "itemList"
|
|
|
FROM
|
|
|
dkic_b.t_psi_inbound_item tpii
|
|
|
LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
|
|
|
LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
|
|
|
- left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
<where>
|
|
|
tpii.cost_price = 0
|
|
|
AND tpii.into_qty != 0
|
|
|
- AND tpii.sku_model is not null
|
|
|
+ AND tpii.sku_model IS NOT NULL
|
|
|
+ AND tpii.into_type != '入库类型-采退入库'
|
|
|
<if test="intoId != null and intoId != ''">
|
|
|
AND tpii.into_id = #{intoId}::uuid
|
|
|
</if>
|
|
|
@@ -813,6 +831,88 @@
|
|
|
tmgs.sku_images,
|
|
|
tmgb.brand_name,
|
|
|
tmgb.short_name
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ tpoi.sku_model AS "skuModel",
|
|
|
+ tpoi.sku_name AS "skuName",
|
|
|
+ tpoi.sku_id AS "skuId",
|
|
|
+ tpoi.cost_price AS "costPrice",
|
|
|
+ tpoi.cost_amt AS "costAmt",
|
|
|
+ tmgs.brand_id AS "brandId",
|
|
|
+ tmgs.sku_images AS "skuImages",
|
|
|
+ tmgb.brand_name AS "brandName",
|
|
|
+ tmgb.short_name AS "shortName",
|
|
|
+ json_agg (
|
|
|
+ json_build_object (
|
|
|
+ 'itemId',
|
|
|
+ tpoi.item_id,
|
|
|
+ 'intoId',
|
|
|
+ NULL,
|
|
|
+ 'outId',
|
|
|
+ tpoi.out_id,
|
|
|
+ 'invId',
|
|
|
+ tpoi.inv_id,
|
|
|
+ 'fromId',
|
|
|
+ tpoi.from_id,
|
|
|
+ 'fromItemId',
|
|
|
+ tpoi.from_item_id,
|
|
|
+ 'skuModel',
|
|
|
+ tpoi.sku_model,
|
|
|
+ 'skuName',
|
|
|
+ tpoi.sku_name,
|
|
|
+ 'skuId',
|
|
|
+ tpoi.sku_id,
|
|
|
+ 'intoQty',
|
|
|
+ tpoi.out_qty,
|
|
|
+ 'costPrice',
|
|
|
+ tpoi.cost_price,
|
|
|
+ 'costAmt',
|
|
|
+ tpoi.cost_amt,
|
|
|
+ 'brandId',
|
|
|
+ tmgs.brand_id,
|
|
|
+ 'fromItemId',
|
|
|
+ tpoi.from_item_id
|
|
|
+ )
|
|
|
+ ) AS "itemList"
|
|
|
+ FROM
|
|
|
+ dkic_b.t_psi_outbound_item tpoi
|
|
|
+ LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = tpoi.out_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpoi.sku_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
+
|
|
|
+ <where>
|
|
|
+ tpoi.cost_price = 0
|
|
|
+ AND tpoi.out_qty != 0
|
|
|
+ AND tpoi.sku_model IS NOT NULL
|
|
|
+ <if test="outId != null and outId != ''">
|
|
|
+ AND tpoi.out_id = #{outId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND tpoi.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="intoDateStart != null">
|
|
|
+ AND tpo.out_date >= #{intoDateStart}::timestamp with time zone
|
|
|
+ </if>
|
|
|
+ <if test="intoDateEnd != null">
|
|
|
+ AND tpo.out_date < #{intoDateEnd}::timestamp with time zone + interval '1 day'
|
|
|
+ </if>
|
|
|
+ <if test="searchText !=null">
|
|
|
+ AND (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
|
|
|
+ OR tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ tpoi.sku_model,
|
|
|
+ tpoi.sku_name,
|
|
|
+ tpoi.sku_id,
|
|
|
+ tpoi.cost_price,
|
|
|
+ tpoi.cost_amt,
|
|
|
+ tmgs.brand_id,
|
|
|
+ tmgs.sku_images,
|
|
|
+ tmgb.brand_name,
|
|
|
+ tmgb.short_name
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
limit #{end} offset #{start}
|
|
|
</if>
|