Commit 904e9a67 by 泽锋 李

优化第三方海外仓 采购汇总表

parent 0d66a8ba
...@@ -31,7 +31,7 @@ namespace AutoGeneratePurchaseAdvise ...@@ -31,7 +31,7 @@ namespace AutoGeneratePurchaseAdvise
//PurchaseAdviseServices.AutoPushBuySys(7); //PurchaseAdviseServices.AutoPushBuySys(7);
//report.ResetTransExpectArrivaltime(); //report.ResetTransExpectArrivaltime();
//PurchaseAdviseServices.AutoPushBuySys(1); //PurchaseAdviseServices.AutoPushBuySys(1);
//report.PurchaseWeekBackUp(); report.PurchaseWeekBackUp();
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -3726,39 +3726,41 @@ where t1.bailun_sku = t2.bailun_sku and t1.bailun_sku = t3.bailun_sku and t1.wee ...@@ -3726,39 +3726,41 @@ where t1.bailun_sku = t2.bailun_sku and t1.bailun_sku = t3.bailun_sku and t1.wee
/// </summary> /// </summary>
public static void PurchaseWeekBackUp() public static void PurchaseWeekBackUp()
{ {
var btime3 = DateTime.Now.AddMonths(-3);
_connection.Execute(@"-- 刷新首次采购时间 _connection.Execute(@"-- 刷新首次采购时间
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
start transaction; start transaction;
update dc_base_stock as t1, update dc_base_stock as t1,
(select t1.bailun_sku,t1.warehouse_into_code as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1 (select t1.bailun_sku,t1.warehouse_into_code as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1
where `status`!=-1 where `status`!=-1 and t1.create_time>=@btime
GROUP BY t1.bailun_sku,t1.warehouse_into_code) as t2 GROUP BY t1.bailun_sku,t1.warehouse_into_code) as t2
set t1.first_purchase_date = t2.min_time set t1.first_purchase_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code; where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code and t1.first_purchase_date is null ;
", commandTimeout: 0); ", new { btime = btime3 },commandTimeout: 0);
_connection.Execute(@"-- 刷新首次调拨时间 _connection.Execute(@"-- 刷新首次调拨时间
set session transaction isolation level read uncommitted;
start transaction;
update dc_base_stock as t1, 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 (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 left join dc_base_transfer_info_skus as t_ps on t_p.`dataid` = t_ps.dataid
where t_p.`isdeleted`=0 where t_p.`isdeleted`=0 and t_p.creationtime>=@btime
GROUP BY t_ps.sku,t_p.targetwareno) as t2 GROUP BY t_ps.sku,t_p.targetwareno) as t2
set t1.first_trans_date = t2.min_time set t1.first_trans_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code; where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code and t1.first_trans_date is null ;
", commandTimeout: 0); ", new { btime = btime3 },commandTimeout: 0);
var btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome(); var btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome();
var etime = btime.GetWeekLastDaySun().ToDayEnd(); var etime = btime.GetWeekLastDaySun().ToDayEnd();
var eonthFirstDate = DateTime.Now.AddMonths(-1).GetMonthFirstDay(); var eonthFirstDate = DateTime.Now.AddMonths(-1).GetMonthFirstDay();
var week_tag = $"{btime.ToString("MM-dd")} ~ {etime.ToString("MM-dd")}"; var week_tag = $"{btime.ToString("MM-dd")} ~ {etime.ToString("MM-dd")}";
_connection.Execute(@"
_connection.Execute(@"
delete from dc_report_purchase_week where week_tag=@week_tag; delete from dc_report_purchase_week where week_tag=@week_tag;
", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0);
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`) 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
select
@week_tag as 'week_tag', @week_tag as 'week_tag',
2 as 'type', 2 as 'type',
t_p.targetwareno as 'warehouse_code', t_p.targetwareno as 'warehouse_code',
...@@ -3782,13 +3784,13 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code ...@@ -3782,13 +3784,13 @@ 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_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 and t_p.`isdeleted`=0 and t_p.creationtime>=@btime and t_p.creationtime<=@etime
GROUP BY t_ps.sku ,t_p.targetwareno GROUP BY t_ps.sku ,t_p.targetwareno", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
); if(temp1!=null && temp1.Count >= 1)
{
dc_report_purchase_week_datas.AddRange(temp1);
}
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`) var temp2 = _connection.Query<dc_report_purchase_week>(@"select
(
select
@week_tag as 'week_tag', @week_tag as 'week_tag',
1 as 'type', 1 as 'type',
t_p.warehouse_into_code as 'warehouse_code', t_p.warehouse_into_code as 'warehouse_code',
...@@ -3811,13 +3813,13 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code ...@@ -3811,13 +3813,13 @@ 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_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 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 GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
); if (temp2 != null && temp2.Count >= 1)
{
dc_report_purchase_week_datas.AddRange(temp2);
}
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`) var temp3 = _connection.Query<dc_report_purchase_week>(@"select
(
select
@week_tag as 'week_tag', @week_tag as 'week_tag',
1 as 'type', 1 as 'type',
t_p.warehouse_from_code as 'warehouse_code', t_p.warehouse_from_code as 'warehouse_code',
...@@ -3840,9 +3842,19 @@ left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code ...@@ -3840,9 +3842,19 @@ 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_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') 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 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 GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0).ToList();
); if (temp3 != null && temp3.Count >= 1)
", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0); {
dc_report_purchase_week_datas.AddRange(temp3);
}
if(dc_report_purchase_week_datas!=null && dc_report_purchase_week_datas.Count >= 1)
{
foreach (var item in dc_report_purchase_week_datas)
{
_connection.Insert(item);
}
}
} }
/// <summary> /// <summary>
......
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