|
@@ -24,7 +24,7 @@
|
|
|
tmgs.price_standard as "priceStandard",
|
|
tmgs.price_standard as "priceStandard",
|
|
|
tmgs.price_wholesale as "priceWholesale",
|
|
tmgs.price_wholesale as "priceWholesale",
|
|
|
tmgs.price_limited as "priceLimited",
|
|
tmgs.price_limited as "priceLimited",
|
|
|
- jsonb_array_elements(tmgs.sku_images)->>'url' as "path",
|
|
|
|
|
|
|
+ case when sku_images is null then null else sku_images -> 0 ->> 'url' end as "path",
|
|
|
tpi.non_std_code as "nonStdCode",
|
|
tpi.non_std_code as "nonStdCode",
|
|
|
sys.f_remove_zero(tpi.inv_qty) as "invQty",
|
|
sys.f_remove_zero(tpi.inv_qty) as "invQty",
|
|
|
sys.f_remove_zero(tpi.outing_qty) as "outingQty",
|
|
sys.f_remove_zero(tpi.outing_qty) as "outingQty",
|
|
@@ -34,7 +34,10 @@
|
|
|
tmw.wh_code as "whCode",
|
|
tmw.wh_code as "whCode",
|
|
|
tmw.wh_name as "whName",
|
|
tmw.wh_name as "whName",
|
|
|
dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
|
|
dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
|
|
|
- tpi.remarks
|
|
|
|
|
|
|
+ tpi.remarks,
|
|
|
|
|
+ tpi.cost_price as "costPrice",
|
|
|
|
|
+ tpi.cost_amt as "costAmt"
|
|
|
|
|
+ --,dkic_b.f_box_piece(tmgsu.unit_name,tmgu.unit_name,FLOOR(tpi.inv_qty/tmgs.pack_box),FLOOR(tpi.inv_qty%tmgs.pack_box)) AS "boxPiece"
|
|
|
from dkic_b.t_psi_inventory as tpi
|
|
from dkic_b.t_psi_inventory as tpi
|
|
|
inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
|
|
inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
|
|
|
inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
|
|
inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
|
|
@@ -42,6 +45,7 @@
|
|
|
left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
|
|
left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
|
|
|
left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
|
|
left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
|
|
|
left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
|
|
left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
|
|
|
|
|
+ left join dkic_b.t_mst_unit as tmgsu on tmgs.sub_unit_id = tmgsu.unit_id
|
|
|
where tpi.flg_valid
|
|
where tpi.flg_valid
|
|
|
AND tpi.cp_id = #{cpId}
|
|
AND tpi.cp_id = #{cpId}
|
|
|
AND tpi.inv_qty != 0
|
|
AND tpi.inv_qty != 0
|
|
@@ -63,6 +67,7 @@
|
|
|
<if test="whId != null">
|
|
<if test="whId != null">
|
|
|
AND tpi.wh_id = #{whId} ::uuid
|
|
AND tpi.wh_id = #{whId} ::uuid
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ order by tpi.sku_id,tpi.inv_id desc
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
limit #{end} offset #{start}
|
|
limit #{end} offset #{start}
|
|
|
</if>
|
|
</if>
|
|
@@ -99,6 +104,119 @@
|
|
|
AND tpi.wh_id = #{whId} ::uuid
|
|
AND tpi.wh_id = #{whId} ::uuid
|
|
|
</if>
|
|
</if>
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+ <!--库存批次查询-->
|
|
|
|
|
+ <select id="getIvtDetailBatchReport" resultType="java.util.Map">
|
|
|
|
|
+ select tpib.inv_id as "invId",
|
|
|
|
|
+ tpib.sku_id as "skuId",
|
|
|
|
|
+ tmgs.sku_code as "skuCode",
|
|
|
|
|
+ tmgs.sku_name as "skuName",
|
|
|
|
|
+ tmgs.sku_model as "skuModel",
|
|
|
|
|
+ tmgs.brand_id as "brandId",
|
|
|
|
|
+ tmgb.brand_name as "brandName",
|
|
|
|
|
+ tmgs.category_id as "categoryId",
|
|
|
|
|
+ tmgc.cat_name as "categoryName",
|
|
|
|
|
+ tmgs.unit_id as "unitId",
|
|
|
|
|
+ tmgu.unit_name as "unitName",
|
|
|
|
|
+ tmgs.sub_unit_id as "subUnitId",
|
|
|
|
|
+ tmgs.conversion_factor as "conversionFactor",
|
|
|
|
|
+ tmgs.series_id as "seriesId",
|
|
|
|
|
+ tmgseries.series_name as "seriesName",
|
|
|
|
|
+ tmgs.sku_spec as "skuSpec",
|
|
|
|
|
+ tpib.non_std_code as "nonStdCode",
|
|
|
|
|
+ sys.f_remove_zero(tpit.inv_qty) as "invQty",
|
|
|
|
|
+ sys.f_remove_zero(tpit.usable_qty) as "usableQty",
|
|
|
|
|
+ tpib.wh_id as "whId",
|
|
|
|
|
+ tmw.wh_code as "whCode",
|
|
|
|
|
+ tmw.wh_name as "whName",
|
|
|
|
|
+ tpib.remarks,
|
|
|
|
|
+ tpib.cost_price as "costPrice",
|
|
|
|
|
+ tpib.cost_amt as "costAmt",
|
|
|
|
|
+ --dkic_b.f_box_piece(tmgsu.unit_name,tmgu.unit_name,FLOOR(tpib.inv_qty/tmgs.pack_box),FLOOR(tpib.inv_qty%tmgs.pack_box)) AS "boxPiece",
|
|
|
|
|
+ case when sku_images is null then null else sku_images -> 0 ->> 'url' end as "path",
|
|
|
|
|
+ COALESCE(tpo.out_no,'') || COALESCE(tpi.into_no,'') || COALESCE(tpt.transfer_no,'') as "fromNo",
|
|
|
|
|
+ COALESCE(sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) ,'')
|
|
|
|
|
+ || COALESCE(sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}),'')
|
|
|
|
|
+ || COALESCE(sys.f_get_name_i18n(tdk3.kind_name_i18n, #{i18n}),'') as "fromTypeName",
|
|
|
|
|
+ sys.f_remove_zero(tpib.inv_qty) as "inventoryQty"
|
|
|
|
|
+ from dkic_b.t_psi_inventory_batch as tpib
|
|
|
|
|
+ inner join dkic_b.t_psi_inventory as tpit on tpit.inv_id = tpib.inv_id
|
|
|
|
|
+ inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpib.wh_id
|
|
|
|
|
+ inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpib.sku_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
|
|
|
|
|
+ left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
|
|
|
|
|
+ left join dkic_b.t_mst_unit as tmgsu on tmgs.sub_unit_id = tmgsu.unit_id
|
|
|
|
|
+ left join dkic_b.t_psi_outbound tpo on tpo.out_id = tpib.from_id
|
|
|
|
|
+ left join sys.t_data_kind as tdk1 on tpo.out_type = tdk1.kind_code
|
|
|
|
|
+ left join dkic_b.t_psi_inbound tpi on tpi.into_id = tpib.from_id
|
|
|
|
|
+ left join sys.t_data_kind as tdk2 on tpi.into_type = tdk2.kind_code
|
|
|
|
|
+ left join dkic_b.t_psi_transfer tpt on tpt.transfer_id = tpib.from_id
|
|
|
|
|
+ left join sys.t_data_kind as tdk3 on tpt.transfer_type = tdk3.kind_code
|
|
|
|
|
+ where tpib.flg_valid
|
|
|
|
|
+ AND tpib.cp_id = #{cpId}
|
|
|
|
|
+ AND tpib.inv_qty != 0
|
|
|
|
|
+ <if test="skuId != null">
|
|
|
|
|
+ AND tpib.sku_id = #{skuId} ::uuid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="nonStdCode != null">
|
|
|
|
|
+ AND tpib.non_std_code = #{nonStdCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="skuCode != null">
|
|
|
|
|
+ AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="skuName != null">
|
|
|
|
|
+ AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="whName != null">
|
|
|
|
|
+ AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="whId != null">
|
|
|
|
|
+ AND tpib.wh_id = #{whId} ::uuid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ order by tpib.sku_id,tpit.inv_id desc
|
|
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
|
|
+ limit #{end} offset #{start}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <!--库存批次查询count-->
|
|
|
|
|
+ <select id="getIvtDetailBatchReportCount" resultType="java.lang.Long">
|
|
|
|
|
+ SELECT count(1)
|
|
|
|
|
+ from dkic_b.t_psi_inventory_batch as tpib
|
|
|
|
|
+ inner join dkic_b.t_psi_inventory as tpit on tpit.inv_id = tpib.inv_id
|
|
|
|
|
+ inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpib.wh_id
|
|
|
|
|
+ inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpib.sku_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
|
|
|
|
|
+ left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
|
|
|
|
|
+ left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
|
|
|
|
|
+ left join dkic_b.t_mst_unit as tmgsu on tmgs.sub_unit_id = tmgsu.unit_id
|
|
|
|
|
+ left join dkic_b.t_psi_outbound tpo on tpo.out_id = tpib.from_id
|
|
|
|
|
+ left join dkic_b.t_psi_inbound tpi on tpi.into_id = tpib.from_id
|
|
|
|
|
+ left join dkic_b.t_psi_transfer tpt on tpt.transfer_id = tpib.from_id
|
|
|
|
|
+ where tpib.flg_valid
|
|
|
|
|
+ AND tpib.cp_id = #{cpId}
|
|
|
|
|
+ AND tpib.inv_qty != 0
|
|
|
|
|
+ <if test="skuId != null">
|
|
|
|
|
+ AND tpib.sku_id = #{skuId} ::uuid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="nonStdCode != null">
|
|
|
|
|
+ AND tpib.non_std_code = #{nonStdCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="skuCode != null">
|
|
|
|
|
+ AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="skuName != null">
|
|
|
|
|
+ AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="whName != null">
|
|
|
|
|
+ AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="whId != null">
|
|
|
|
|
+ AND tpib.wh_id = #{whId} ::uuid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<!-- 采购明细报表明细条件列 -->
|
|
<!-- 采购明细报表明细条件列 -->
|
|
|
<sql id="Condition_PurDetailReport">
|
|
<sql id="Condition_PurDetailReport">
|
|
|
<where>
|
|
<where>
|