Commit 1885895e by 泽锋 李

新增年度销量汇总

parent ed64507e
......@@ -1052,6 +1052,45 @@ end
}
/// <summary>
/// 查询特定sku的去年历史销量
/// </summary>
/// <param name="product_type"></param>
/// <returns></returns>
public static dynamic GetSalesTrendYear(string product_type)
{
var btime = DateTime.Parse( DateTime.Now.AddYears(-1).ToString("yyyy-01-01 00:00:00"));
var etime = DateTime.Parse( btime.ToString("yyyy-12-31 23:59:59"));
// 查询基础数据
var base_datas = _connection.Query<dc_report_sales_trend_year>(" select * from dc_report_sales_trend_year where product_type=@product_type and `date`>=@btime and `date`<=@etime ",new {
product_type = product_type,
btime = btime,
etime = etime
});
var months = new List<int> { 1,2,3,4,5,6,7,8,9,10,11,12};
var legendGroups = base_datas.GroupBy(s => s.country_code).OrderByDescending(s=>s.Sum(v=>v.sales)>=100).Take(10).ToList();
return new {
title = base_datas.Min(s=>s.product_type_desc),
legendDatas = legendGroups.Select(s=>s.Key),
xAxisDatas = months,
seriesDatas = legendGroups.Select(s=>new {
name = s.Key,
type = "line",
data = months.Select(m=> s.Where(b=>b.date.Month==m ).Sum(su=>su.sales))
})
};
}
/// <summary>
/// 获取产品分类
/// </summary>
/// <returns></returns>
public static List<product_type_desc_dto> GetProductTypeList()
{
return _connection.Query<product_type_desc_dto>("select DISTINCT product_type,product_type_desc from dc_report_sales_trend_year where product_type>0").ToList();
}
/// <summary>
/// 回货速改推送
/// </summary>
public static List<dc_return_goods_push> ReturnGoodsPush(string platform)
......@@ -3844,10 +3883,6 @@ where t1.bailun_order_status != 'Canceled'
}
}
public class product_type_desc_dto
{
public string product_type_desc { get; set; }
public int product_type { get; set; }
}
}
}
......
......@@ -32,6 +32,12 @@ namespace AutoTurnOver.Models.Report
public DateTime? etime { get; set; }
}
public class product_type_desc_dto
{
public string product_type_desc { get; set; }
public int product_type { get; set; }
}
public class dc_report_stock_week
{
public int id { get; set; }
......
......@@ -953,5 +953,15 @@ namespace AutoTurnOver.Services
{
return dc_report_finance_dao.GetMonthList(search);
}
public dynamic GetSalesTrendYear(string product_type)
{
return report.GetSalesTrendYear(product_type);
}
public List<product_type_desc_dto> GetProductTypeList()
{
return report.GetProductTypeList();
}
}
}
......@@ -1240,5 +1240,34 @@ namespace AutoTurnOver.Controllers
var list = services.GetInventoryStock(m);
return new JsonResult(list == null || list.Items.Count <= 0 ? new quantity_safe_inventory_dto() : list.Items[0]);
}
/// <summary>
/// 查询销量数据
/// </summary>
/// <param name="id"></param>
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public JsonResult GetSalesTrendYear(string product_type)
{
var services = new Services.ReportServices();
var result = services.GetSalesTrendYear(product_type);
return new JsonResult(result);
}
/// <summary>
/// 查询销量数据
/// </summary>
/// <param name="id"></param>
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public JsonResult GetProductTypeList()
{
var services = new Services.ReportServices();
var result = services.GetProductTypeList();
return new JsonResult(result);
}
}
}
\ No newline at end of file
......@@ -15,12 +15,12 @@ namespace ResetOutofstock
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
Task.Factory.StartNew(() =>
{
Console.WriteLine($"开始 初始化年度销量增长趋势 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.CalculationSalesTrend();
Console.WriteLine($"结束 初始化年度销量增长趋势,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
});
//Task.Factory.StartNew(() =>
//{
// Console.WriteLine($"开始 初始化年度销量增长趋势 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
// report.CalculationSalesTrend();
// Console.WriteLine($"结束 初始化年度销量增长趋势,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
//});
//Task.Factory.StartNew(() =>
//{
// Console.WriteLine($"开始 刷新出库退税数据 ,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
......
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