Commit e46ac14b by 泽锋 李

采购汇总数据 fix

parent 4b0044c5
......@@ -3734,30 +3734,29 @@ where t1.bailun_sku = t2.bailun_sku and t1.bailun_sku = t3.bailun_sku and t1.wee
public static void PurchaseWeekBackUp()
{
var btime3 = 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 ;
_connection.Execute(@"TRUNCATE table dc_base_stock_first_date;
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;
", new { btime = btime3 },commandTimeout: 0);
var btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome();
......@@ -3770,7 +3769,7 @@ delete from dc_report_purchase_week where week_tag=@week_tag;
", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0);
List<dc_report_purchase_week> dc_report_purchase_week_datas = new List<dc_report_purchase_week>();
var temp1 = _connection.Query<dc_report_purchase_week>(@"select
var temp1 = MyMySqlConnection._connection.Query<dc_report_purchase_week>(@"select
@week_tag as 'week_tag',
2 as 'type',
t_p.targetwareno as 'warehouse_code',
......@@ -3779,7 +3778,7 @@ t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t_p.creationtime <= t1.first_trans_date then 1
when t_p.creationtime <= t4.first_trans_date then 1
else 0
end
) as 'is_new',
......@@ -3792,6 +3791,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
left join dc_base_stock_first_date as t4 on t1.bailun_sku =t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where ( t2.hq_type='第三方仓库' ) and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋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", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
......@@ -3800,7 +3800,7 @@ GROUP BY t_ps.sku ,t_p.targetwareno", new { btime, etime, week_tag, eonthFirstDa
dc_report_purchase_week_datas.AddRange(temp1);
}
var temp2 = _connection.Query<dc_report_purchase_week>(@"select
var temp2 = MyMySqlConnection._connection.Query<dc_report_purchase_week>(@"select
@week_tag as 'week_tag',
1 as 'type',
t_p.warehouse_into_code as 'warehouse_code',
......@@ -3809,7 +3809,7 @@ t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t_p.create_time <= t1.first_purchase_date then 1
when t_p.create_time <= t4.first_purchase_date then 1
else 0
end
) as 'is_new',
......@@ -3821,6 +3821,7 @@ 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
left join dc_base_stock_first_date as t4 on t1.bailun_sku =t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where ( t2.hq_type='第三方仓库' ) and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋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", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
......@@ -3829,7 +3830,7 @@ GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code", new { btime, etime, week_tag,
dc_report_purchase_week_datas.AddRange(temp2);
}
var temp3 = _connection.Query<dc_report_purchase_week>(@"select
var temp3 = MyMySqlConnection._connection.Query<dc_report_purchase_week>(@"select
@week_tag as 'week_tag',
1 as 'type',
t_p.warehouse_from_code as 'warehouse_code',
......@@ -3838,7 +3839,7 @@ t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t_p.create_time <= t1.first_purchase_date then 1
when t_p.create_time <= t4.first_purchase_date then 1
else 0
end
) as 'is_new',
......@@ -3850,6 +3851,7 @@ 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
left join dc_base_stock_first_date as t4 on t1.bailun_sku =t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where ( t_p.warehouse_from_code='GZBLWH') and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋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", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
......
......@@ -31,7 +31,7 @@ namespace ResetOutofstock
//daily.ResetFbaExtendSales(DateTime.Now);
//dc_aims_transfer_warehouse_dao.TransferWarehouseTask();
//daily.ResetFbaExtendReview(DateTime.Now);
//report.PurchaseWeekBackUp();
}
catch (Exception ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment