@@ -3734,30 +3734,29 @@ where t1.bailun_sku = t2.bailun_sku and t1.bailun_sku = t3.bailun_sku and t1.wee
publicstaticvoidPurchaseWeekBackUp()
{
varbtime3=DateTime.Now.AddMonths(-3);
_connection.Execute(@"-- 刷新首次采购时间
-- 刷新首次采购时间
set session transaction isolation level read uncommitted;
start transaction;
update dc_base_stock as t1,
(select t1.bailun_sku,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end) as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1
where `status`!=-1 -- and t1.create_time>=@btime
GROUP BY t1.bailun_sku,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end)) as t2
set t1.first_purchase_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code and t1.first_purchase_date is null ;
insert into dc_base_stock_first_date(bailun_sku,warehouse_code)
select bailun_sku,warehouse_code from dc_base_stock;
update dc_base_stock_first_date as t1,
(
select t1.bailun_sku,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end) 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,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end)
) as t2
set t1.first_purchase_date = t2.min_time
where t1.bailun_sku =t2.bailun_sku and t1.warehouse_code =t2.warehouse_code;
",new{btime=btime3},commandTimeout:0);
_connection.Execute(@"-- 刷新首次调拨时间
set session transaction isolation level read uncommitted;
start transaction;
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
update dc_base_stock_first_date 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 and t_p.creationtime>=@btime
GROUP BY t_ps.sku,t_p.targetwareno) as t2
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 and t1.first_trans_date is null ;
where t1.bailun_sku =t2.bailun_sku and t1.warehouse_code =t2.warehouse_code;