Commit 6b2c27ac by 泽锋 李

新增商品销量计算任务

parent eef09204
...@@ -4143,5 +4143,61 @@ truncate table dc_base_trans_expectarrivaltime_temp; ...@@ -4143,5 +4143,61 @@ truncate table dc_base_trans_expectarrivaltime_temp;
} }
/// <summary>
/// 商品报表生成
/// </summary>
public static void GenerateReportGoods()
{
var datas = _connection.Query<dc_report_goods_temp>(@"
select
t2.product_code as 'product_code',
t2.sku_title_cn as 'product_title',
t2.product_type_desc as 'product_type',
t1.warehouse_code as 'warehouse_code',
t3.warehouse_name as 'warehouse_name',
t4.stock as 'stock',
t5.stock as 'on_the_way_quantity',
t2.unit_price as 'unit_price',
t2.weight as 'weight',
t2.buyer_name as 'buyer_name',
0 as 'sales_amount_usd',
sum( case when t1.paid_time>=@b1 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday',
sum( case when t1.paid_time>=@b1 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd',
sum( case when t1.paid_time>=@b7 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_7',
sum( case when t1.paid_time>=@b7 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd_7',
sum( case when t1.paid_time>=@b30 and t1.paid_time<=@e1 then t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_30',
sum( case when t1.paid_time>=@b30 and t1.paid_time<=@e1 then t1.amount_sales * t1.order_to_usd_exchange_rate * t1.bailun_sku_quantity_ordered else 0 end) as 'sales_yesterday_amount_usd_30'
from dc_base_oms_sku_30 as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code
left join ( select t4_2.product_code,sum(t4_1.usable_stock) as 'stock' from dc_base_stock as t4_1 left join dc_base_sku as t4_2 on t4_1.bailun_sku = t4_2.bailun_sku GROUP BY t4_2.product_code ) as t4 on t2.product_code = t4.product_code
left join ( select t5_2.product_code,sum(t5_1.quantity_purchase+t5_1.quantity_transfer) as 'stock' from dc_mid_transit as t5_1 left join dc_base_sku as t5_2 on t5_1.bailun_sku = t5_2.bailun_sku GROUP BY t5_2.product_code ) as t5 on t2.product_code = t5.product_code
where t1.paid_time>=@b30
GROUP BY t2.product_code
", new {
b30 = DateTime.Now.AddDays(-31).ToDayHome(),
e1 = DateTime.Now.AddDays(-1).ToDayEnd(),
b1 = DateTime.Now.AddDays(-1).ToDayHome(),
b7 = DateTime.Now.AddDays(-8).ToDayHome()
},commandTimeout:0).ToList();
_connection.Execute(" TRUNCATE table dc_report_goods_temp; ");
foreach (var item in datas)
{
_connection.Insert<dc_report_goods_temp>(item);
}
_connection.Execute(@"
alter table dc_report_goods rename dc_report_goodsTemp;
alter table dc_report_goods_temp rename dc_report_goods;
alter table dc_report_goodsTemp rename dc_report_goods_temp;
truncate table dc_report_goods_temp;
");
}
} }
} }
......
...@@ -7,7 +7,7 @@ namespace AutoTurnOver.Models ...@@ -7,7 +7,7 @@ namespace AutoTurnOver.Models
/// <summary> /// <summary>
/// 商品报表 /// 商品报表
/// </summary> /// </summary>
public class dc_report_goods public class dc_report_goods_temp
{ {
public int id { get; set; } public int id { get; set; }
public string product_code { get; set; } public string product_code { get; set; }
......
...@@ -32,6 +32,7 @@ namespace ResetOutofstock ...@@ -32,6 +32,7 @@ namespace ResetOutofstock
//dc_aims_transfer_warehouse_dao.TransferWarehouseTask(); //dc_aims_transfer_warehouse_dao.TransferWarehouseTask();
//daily.ResetFbaExtendReview(DateTime.Now); //daily.ResetFbaExtendReview(DateTime.Now);
//report.PurchaseWeekBackUp(); //report.PurchaseWeekBackUp();
report.GenerateReportGoods();
//dc_auto_turnover.ResetHistory(); //dc_auto_turnover.ResetHistory();
} }
......
...@@ -15,12 +15,12 @@ namespace ResetOutofstock ...@@ -15,12 +15,12 @@ namespace ResetOutofstock
protected override Task ExecuteAsync(CancellationToken stoppingToken) protected override Task ExecuteAsync(CancellationToken stoppingToken)
{ {
//Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
//{ {
// Console.WriteLine($"开始 初始化年度销量增长趋势 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"init 开始 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
// report.CalculationSalesTrend(); report.GenerateReportGoods();
// Console.WriteLine($"结束 初始化年度销量增长趋势,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"init 结束,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
//}); });
//Task.Factory.StartNew(() => //Task.Factory.StartNew(() =>
//{ //{
// Console.WriteLine($"开始 刷新出库退税数据 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); // Console.WriteLine($"开始 刷新出库退税数据 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
......
...@@ -21,7 +21,7 @@ namespace ResetOutofstock ...@@ -21,7 +21,7 @@ namespace ResetOutofstock
private void DoWork(object state) private void DoWork(object state)
{ {
var now = DateTime.Now; var now = DateTime.Now;
if (now.Minute == 0) if (now.Minute == 0)
{ {
if (now.Hour > 2 && now.Hour <= 8) if (now.Hour > 2 && now.Hour <= 8)
...@@ -38,7 +38,7 @@ namespace ResetOutofstock ...@@ -38,7 +38,7 @@ namespace ResetOutofstock
} }
} }
if (now.Month==1 && now.Day==1 && now.Hour == 0 && now.Minute == 01) if (now.Month==1 && now.Day==1 && now.Hour == 0 && now.Minute == 01)
{ {
Console.WriteLine($"开始 刷新年度增长趋势,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"开始 刷新年度增长趋势,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.CalculationSalesTrend(); report.CalculationSalesTrend();
...@@ -50,6 +50,12 @@ namespace ResetOutofstock ...@@ -50,6 +50,12 @@ namespace ResetOutofstock
report.ResetDailyStockWarehouse(); report.ResetDailyStockWarehouse();
Console.WriteLine($"结束 备份库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"结束 备份库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
if (now.Hour == 0 && now.Minute == 10)
{
Console.WriteLine($"开始 生成商品报表,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.GenerateReportGoods();
Console.WriteLine($"结束 生成商品报表,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.Hour == 02 && now.Minute == 1) if (now.Hour == 02 && now.Minute == 1)
{ {
......
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