@@ -1845,6 +1845,26 @@ GROUP BY t1.bailun_sku_warehouse_area) as t2
set t1.first_inbound_date = t2.min_time
where t1.bailun_sku_warehouse_area=t2.bailun_sku_warehouse_area;",commandTimeout:0);
_connection.Execute(@"-- 刷新首次采购时间
update dc_base_stock as t1,
(select t1.bailun_sku,t1.warehouse_from_code as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1
where `status`!=-1
GROUP BY t1.bailun_sku,t1.warehouse_from_code) as t2
set t1.first_purchase_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code;
");
_connection.Execute(@"-- 刷新首次调拨时间
update dc_base_stock as t1,
(select t_ps.sku as 'bailun_sku',t_p.targetwareno as 'warehouse_code',min(t_p.creationtime) as 'min_time' from dc_base_transfer_info as t_p
left join dc_base_transfer_info_skus as t_ps on t_p.`dataid` = t_ps.dataid
where t_p.`isdeleted`=0
GROUP BY t_ps.sku,t_p.targetwareno) as t2
set t1.first_trans_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code;
");
_connection.Execute(@" -- 刷新库存日志
set session transaction isolation level read uncommitted;
start transaction;
...
...
@@ -3635,7 +3655,7 @@ t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
when t_p.creationtime <= t1.first_trans_date then 1
else 0
end
) as 'is_new',
...
...
@@ -3648,7 +3668,7 @@ left join dc_base_transfer_info_skus as t_ps on t_p.`dataid` = t_ps.dataid
left join dc_base_stock as t1 on t1.bailun_sku =t_ps.sku and t1.warehouse_code = t_p.targetwareno
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库' and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
where ( t2.hq_type='第三方仓库' ) and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
and t_p.`isdeleted`=0 and t_p.creationtime>=@btime and t_p.creationtime<=@etime
GROUP BY t_ps.sku ,t_p.targetwareno
);
...
...
@@ -3665,7 +3685,7 @@ t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
when t_p.create_time <= t1.first_purchase_date then 1
else 0
end
) as 'is_new',
...
...
@@ -3677,7 +3697,36 @@ from dc_base_purchase_details as t_p
left join dc_base_stock as t1 on t1.bailun_sku =t_p.bailun_sku and t1.warehouse_code = t_p.warehouse_into_code
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库' and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
where ( t2.hq_type='第三方仓库' ) and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
and t_p.`status`!=-1 and t_p.create_time>=@btime and t_p.create_time<=@etime
GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code
);
insert into dc_report_purchase_week(`week_tag`,`type`,`warehouse_code`,`bailun_sku`,`stock`,`unit_price`,`is_new`,`quantity_purchase`,`amount_paid`,`web_site`,`first_day_date`)
(
select
@week_tag as 'week_tag',
1 as 'type',
t_p.warehouse_from_code as 'warehouse_code',
t_p.bailun_sku,
t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t_p.create_time <= t1.first_purchase_date then 1
else 0
end
) as 'is_new',
sum(t_p.quantity_purchase) as 'quantity_purchase',
sum(t_p.amount_paid) as 'amount_paid',
t2.area_name as 'web_site',
@btime as 'first_day_date'
from dc_base_purchase_details as t_p
left join dc_base_stock as t1 on t1.bailun_sku =t_p.bailun_sku and t1.warehouse_code = t_p.warehouse_from_code
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where ( t_p.warehouse_from_code='GZBLWH') and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
and t_p.`status`!=-1 and t_p.create_time>=@btime and t_p.create_time<=@etime