Commit 85aa6434 by 泽锋 李

商品汇总,仓库维度。导出

parent a1c0ca7d
...@@ -646,7 +646,9 @@ namespace AutoTurnOver.Services ...@@ -646,7 +646,9 @@ namespace AutoTurnOver.Services
{ {
var dic = (IDictionary<string, object>)o; var dic = (IDictionary<string, object>)o;
dic["count_" + (dat_item.month + "-" + dat_item.day)] = new { val = Math.Round(dat_item.count, 2), year = dat_item.year, month = dat_item.month, day = dat_item.day }; dic["count_" + (dat_item.month + "-" + dat_item.day)] = new { val = Math.Round(dat_item.count, 2), year = dat_item.year, month = dat_item.month, day = dat_item.day };
dic["v_count_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.count, 2);
dic["sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2); dic["sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2);
dic["v_sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2);
} }
datas.Add(o); datas.Add(o);
......
...@@ -664,6 +664,79 @@ namespace AutoTurnOver.Controllers ...@@ -664,6 +664,79 @@ namespace AutoTurnOver.Controllers
}); });
} }
public FileResult ExportTableSkuWarehouse(string platform_type, string warehousetype, int? warehousearea, string warehousecode, DateTime? btime, DateTime? etime)
{
bailun_sku_website_sales_search_dto search_data = new bailun_sku_website_sales_search_dto
{
platform_type = platform_type,
warehousetype = warehousetype,
etime = etime,
btime = btime,
warehousearea = warehousearea,
warehouse_code = warehousecode
};
var e_btime = DateTime.Now.AddDays(-8).ToDayHome();
var e_etime = DateTime.Now.AddDays(-1).ToDayEnd();
if (search_data.btime != null)
{
e_btime = search_data.btime.Value.ToDayHome();
}
if (search_data.etime != null)
{
e_etime = search_data.etime.Value.ToDayEnd();
}
var list = new ReportServices().GetSkuWarehouseSales(search_data);
DataTable table = new DataTable();
string[] cols = new string[] { "分类", "仓库"};
foreach (var item in cols)
{
table.Columns.Add(item);
}
var col_this_date = e_etime;
while (col_this_date.ToDayHome() > e_btime.ToDayHome())
{
table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销量");
table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销售额");
col_this_date = col_this_date.AddDays(-1);
}
foreach (var itemDataD in list)
{
DataRow row = table.NewRow();
var itemData = (IDictionary<string, object>)itemDataD;
row["分类"] = itemData["label"];
row["仓库"] = itemData["warehouse_name"];
var row_this_date = e_etime;
while (row_this_date.ToDayHome() > e_btime.ToDayHome())
{
row[$"{row_this_date.ToString("MM-dd")}-销量"] = itemData["v_count_" + $"{row_this_date.Month}-{row_this_date.Day}"];
row[$"{row_this_date.ToString("MM-dd")}-销售额"] = itemData["v_sum_" + $"{row_this_date.Month}-{row_this_date.Day}"];
row_this_date = row_this_date.AddDays(-1);
}
table.Rows.Add(row);
}
var fileName = AppContext.BaseDirectory + @"Result\RealtimeStock\商品汇总_仓库.csv";
DataTableHelper.SaveCSV(table, fileName);
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
return File(memory, "text/csv", "商品汇总_仓库.csv");
}
public FileResult SkuWebsiteSalesExport(string platform_type,string label,string website,string warehouse_code, int? year,int? month,int? day) public FileResult SkuWebsiteSalesExport(string platform_type,string label,string website,string warehouse_code, int? year,int? month,int? day)
{ {
var user = AutoUtility.GetUser(); var user = AutoUtility.GetUser();
......
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