Commit 9d807385 by 泽锋 李

fix

parent 063cc67b
...@@ -4481,5 +4481,48 @@ truncate table dc_report_goods_platform_temp; ...@@ -4481,5 +4481,48 @@ truncate table dc_report_goods_platform_temp;
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
} }
} }
/// <summary>
/// 查询商品报表数据
/// </summary>
/// <param name="searchData"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public static List<dc_report_goods_platform> GetReportPlatformGoodsPage(dc_report_goods_platform_search_dto searchData, int offset, int limit, ref int total, string order = "", string sort = "")
{
var sql = " select t1.* from dc_report_goods_platform as t1 where 1=1 ";
var countSql = " select count(1) from dc_report_goods_platform as t1 where 1=1 ";
DynamicParameters parameters = new DynamicParameters();
if (!string.IsNullOrWhiteSpace(searchData.product_code))
{
sql += " and t1.product_code=@product_code ";
countSql += " and t1.product_code=@product_code ";
parameters.Add("product_code", searchData.product_code);
}
if (!string.IsNullOrWhiteSpace(searchData.platform_type))
{
sql += " and t1.platform_type=@platform_type ";
countSql += " and t1.platform_type=@platform_type ";
parameters.Add("platform_type", searchData.platform_type);
}
if (!string.IsNullOrEmpty(sort))
{
sql += " order by " + sort;
if (!string.IsNullOrEmpty(order))
{
sql += " " + order;
}
else
{
sql += " asc";
}
}
sql += " limit " + offset + "," + limit;
total = _connection.QueryFirstOrDefault<int>(countSql, parameters);
return _connection.Query<dc_report_goods_platform>(sql, parameters).AsList();
}
} }
} }
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Text; using System.Text;
namespace AutoTurnOver.Models.Report namespace AutoTurnOver.Models.Report
...@@ -28,4 +29,14 @@ namespace AutoTurnOver.Models.Report ...@@ -28,4 +29,14 @@ namespace AutoTurnOver.Models.Report
{ {
} }
public class dc_report_goods_platform_search_dto
{
[Description("商品编码")]
public string product_code { get; set; }
[Description("平台类型")]
public string platform_type { get; set; }
}
} }
...@@ -57,4 +57,6 @@ namespace AutoTurnOver.Models ...@@ -57,4 +57,6 @@ namespace AutoTurnOver.Models
[Description("仓库编码")] [Description("仓库编码")]
public string warehouse_code { get; set; } public string warehouse_code { get; set; }
} }
} }
...@@ -1041,6 +1041,10 @@ namespace AutoTurnOver.Services ...@@ -1041,6 +1041,10 @@ namespace AutoTurnOver.Services
{ {
return report.GetReportGoodsPage(m, offset, limit, ref total, order, sort); return report.GetReportGoodsPage(m, offset, limit, ref total, order, sort);
} }
public List<dc_report_goods_platform> GetReportPlatformGoodsPage(dc_report_goods_platform_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{
return report.GetReportPlatformGoodsPage(m, offset, limit, ref total, order, sort);
}
public string ReportGoodsExport(dc_report_goods_search_dto m, string order, string sort) public string ReportGoodsExport(dc_report_goods_search_dto m, string order, string sort)
{ {
...@@ -1099,6 +1103,54 @@ namespace AutoTurnOver.Services ...@@ -1099,6 +1103,54 @@ namespace AutoTurnOver.Services
//return memory; //return memory;
return fileName; return fileName;
}
public string ReportPlatformGoodsExport(dc_report_goods_platform_search_dto m, string order, string sort)
{
var fileName = AppContext.BaseDirectory + $@"商品销量报表(平台维度)-{DateTime.Now.ToString("yyyyMMddHHmmss")}{Guid.NewGuid()}.csv";
var total = 0;
int page = 1;
int rows = 250000;
while (true)
{
var list = GetReportPlatformGoodsPage(m, (page - 1) * rows, rows, ref total, order, sort);
if (list == null || list.Count <= 0) break;
DataTable table = new DataTable();
string[] cols = new string[] { "商品编码","产品类型", "平台","单价", "重量","采购","中文名称","昨日销量","昨日销售额","近7天销量","近7天销售额","近30天销量","近30天销售额",
};
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["商品编码"] = itemData.product_code;
row["产品类型"] = itemData.product_type;
row["平台"] = itemData.platform_type;
row["单价"] = itemData.unit_price;
row["重量"] = itemData.weight;
row["采购"] = itemData.buyer_name;
row["中文名称"] = itemData.product_title;
row["昨日销量"] = itemData.sales_yesterday;
row["昨日销售额"] = itemData.sales_yesterday_amount_usd;
row["近7天销量"] = itemData.sales_yesterday_7;
row["近7天销售额"] = itemData.sales_yesterday_amount_usd_7;
row["近30天销量"] = itemData.sales_yesterday_30;
row["近30天销售额"] = itemData.sales_yesterday_amount_usd_30;
table.Rows.Add(row);
}
CsvFileHelper.SaveCSV(table, fileName, page == 1);
page++;
}
return fileName;
} }
} }
} }
...@@ -71,6 +71,9 @@ namespace AutoTurnOver.Services ...@@ -71,6 +71,9 @@ namespace AutoTurnOver.Services
case "商品销量报表(仓库维度)": case "商品销量报表(仓库维度)":
item.result_file_url = await DownloadReportGoods(item.parameter, item); item.result_file_url = await DownloadReportGoods(item.parameter, item);
break; break;
case "商品销量报表(平台维度)":
item.result_file_url = await DownloadPlatformReportGoods(item.parameter, item);
break;
default: throw new Exception("无法识别的任务"); default: throw new Exception("无法识别的任务");
} }
item.end_date = DateTime.Now; item.end_date = DateTime.Now;
...@@ -119,6 +122,20 @@ namespace AutoTurnOver.Services ...@@ -119,6 +122,20 @@ namespace AutoTurnOver.Services
Console.WriteLine("DownloadStock - 上传完毕"); Console.WriteLine("DownloadStock - 上传完毕");
return fileData; return fileData;
} }
/// <summary>
/// 商品销售情况统计
/// </summary>
public async Task<string> DownloadPlatformReportGoods(string par_json, dc_task_download download_data)
{
dc_report_goods_platform_search_dto search_data = par_json.ToObject<dc_report_goods_platform_search_dto>();
Console.WriteLine("DownloadStock - 开始生成文件");
var memory = new ReportServices().ReportPlatformGoodsExport(search_data,"","");
Console.WriteLine("DownloadStock - 开始生成上传文件");
var fileData = await AutoTurnOver.Utility.QiNiuCloudHelper.UploadSectioningAsync(memory);
Console.WriteLine("DownloadStock - 上传完毕");
return fileData;
}
/// <summary> /// <summary>
/// 下载改在线记录 /// 下载改在线记录
......
...@@ -1386,7 +1386,7 @@ namespace AutoTurnOver.Controllers ...@@ -1386,7 +1386,7 @@ namespace AutoTurnOver.Controllers
[HttpGet] [HttpGet]
[BrowseLog("Bailun_aims", "触发【百伦自动周转系统】->【报表】->【商品销量报表】->【搜索】页面", 0)] [BrowseLog("Bailun_aims", "触发【百伦自动周转系统】->【报表】->【商品销量报表(仓库维度)】->【搜索】页面", 0)]
public JsonResult GetReportGoodsPage([FromQuery] dc_report_goods_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort) public JsonResult GetReportGoodsPage([FromQuery] dc_report_goods_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort)
{ {
try try
...@@ -1412,7 +1412,38 @@ namespace AutoTurnOver.Controllers ...@@ -1412,7 +1412,38 @@ namespace AutoTurnOver.Controllers
}); });
} }
}
[HttpGet]
[BrowseLog("Bailun_aims", "触发【百伦自动周转系统】->【报表】->【商品销量报表(平台维度)】->【搜索】页面", 0)]
public JsonResult GetReportPlatformGoodsPage([FromQuery] dc_report_goods_platform_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort)
{
try
{
var total = 0;
var service = new Services.ReportServices();
var list = service.GetReportPlatformGoodsPage(m, offset, limit, ref total, order, sort);
return new JsonResult(new
{
rows = list,
total = total,
pagecount = (total / limit + (total % limit > 0 ? 1 : 0))
});
}
catch (Exception ex)
{
return new JsonResult(new
{
message = ex.Message,
stack_trace = ex.StackTrace
});
}
} }
public ActionResult GetReportGoodsExport([FromQuery] dc_report_goods_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort) public ActionResult GetReportGoodsExport([FromQuery] dc_report_goods_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort)
{ {
try try
...@@ -1431,5 +1462,23 @@ namespace AutoTurnOver.Controllers ...@@ -1431,5 +1462,23 @@ namespace AutoTurnOver.Controllers
} }
} }
public ActionResult GetReportPlatformGoodsExport([FromQuery] dc_report_goods_search_dto m, [FromQuery] int offset, [FromQuery] int limit, [FromQuery] string order, [FromQuery] string sort)
{
try
{
var user = AutoUtility.GetUser();
dc_task_download_dao.PushData<dc_report_goods_search_dto>(new dc_task_download
{
parameter = m.ToJson(),
task_name = "商品销量报表(平台维度)"
}, user);
return new JsonResult(new { success = true });
}
catch (Exception ex)
{
return new JsonResult(new { success = false, message = ex.Message });
}
}
} }
} }
\ No newline at end of file
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