Commit 9283eef5 by 泽锋 李

商品汇总报表优化;实时库存优化

parent db857852
...@@ -246,7 +246,8 @@ UNION ALL ...@@ -246,7 +246,8 @@ UNION ALL
/// <param name="sku">sku</param> /// <param name="sku">sku</param>
/// <param name="warehouse_code">仓库编码</param> /// <param name="warehouse_code">仓库编码</param>
/// <returns></returns> /// <returns></returns>
public static List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null,int? has_tort = null, List<bailun_category_new_dto> categoryModels = null,string buyer_name = null) public static List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null,int? has_tort = null, List<bailun_category_new_dto> categoryModels = null,string buyer_name = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
var sql = ""; var sql = "";
if (isSum) if (isSum)
...@@ -365,6 +366,24 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code ...@@ -365,6 +366,24 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
parameters.Add("time", DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); parameters.Add("time", DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
if (f_start_date != null)
{
sql += " and t1.`gmt_create`>=@f_start_date ";
countSql += " and t1.`gmt_create`>=@f_start_date ";
parameters.Add("f_start_date", f_start_date.Value.ToString("yyyy-MM-dd 00:00:00"));
}
if (f_end_date != null)
{
sql += " and t1.`gmt_create`<=@f_end_date ";
countSql += " and t1.`gmt_create`<=@f_end_date ";
parameters.Add("f_end_date", f_end_date.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (start_date != null && end_date != null)
{
sql += " and EXISTS (select * from dc_base_stock_record as t_re where t1.warehouse_code=t_re.warehouse_code and t1.bailun_sku = t_re.bailun_sku and t_re.stock_time>=@start_date and t_re.stock_time<=@end_date ) ";
parameters.Add("start_date", start_date.Value.ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("end_date", start_date.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (categoryModels != null && categoryModels.Count>=1) if (categoryModels != null && categoryModels.Count>=1)
{ {
sql += " and t3.category_simple_id in ( " + string.Join(",", categoryModels.Select(s => s.id).Distinct()) + ")"; sql += " and t3.category_simple_id in ( " + string.Join(",", categoryModels.Select(s => s.id).Distinct()) + ")";
......
...@@ -1788,11 +1788,22 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0); ...@@ -1788,11 +1788,22 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0);
} }
public static List<bailun_sku_website_sales_dto> GetSkuWebsiteSales(bailun_sku_website_sales_search_dto search_data) public static List<bailun_sku_website_sales_dto> GetSkuWebsiteSales(bailun_sku_website_sales_search_dto search_data)
{ {
var sql = @" select t1.*,t2.label from dc_base_oms_sku_7 as t1 left join dc_auto_config_sku_label as t2 on t1.bailun_sku = t2.bailun_sku var tableName = "dc_base_oms_sku_7";
if (search_data.btime != null || search_data.etime != null)
{
tableName = "dc_base_oms_sku";
}
var sql = $@" select t1.*,t2.label from {tableName} as t1 left join dc_auto_config_sku_label as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code where 1=1 "; left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code where 1=1 ";
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (search_data != null) if (search_data != null)
{ {
if(search_data.btime!=null && search_data.etime!=null)
{
sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime ";
parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("etime", search_data.etime.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (!string.IsNullOrWhiteSpace(search_data.platform_type)) if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{ {
if("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase)) if("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
...@@ -1809,7 +1820,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -1809,7 +1820,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
if (!string.IsNullOrWhiteSpace(search_data.warehousetype)) if (!string.IsNullOrWhiteSpace(search_data.warehousetype))
{ {
if (search_data.warehousetype == "中国") if (search_data.warehousetype == "国内仓")
{ {
sql += " and tdb.hq_type=@warehousetype "; sql += " and tdb.hq_type=@warehousetype ";
parameters.Add("warehousetype", "国内仓"); parameters.Add("warehousetype", "国内仓");
...@@ -1825,7 +1836,16 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -1825,7 +1836,16 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
sql += " and tdb.hq_type not in ('国内仓') "; sql += " and tdb.hq_type not in ('国内仓') ";
} }
} }
}
if (search_data.warehousearea > 0)
{
sql += " and tdb.area_id = @area_id ";
parameters.Add("area_id", search_data.warehousearea);
}
if (!string.IsNullOrWhiteSpace(search_data.warehouse_code))
{
sql += " and t1.warehouse_code=@warehouse_code ";
parameters.Add("warehouse_code", search_data.warehouse_code);
} }
} }
var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters); var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters);
...@@ -2005,6 +2025,11 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2005,6 +2025,11 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
var b_time = DateTime.Now.AddDays(-1); var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7); var e_time = b_time.AddDays(-7);
if(search_data.btime!=null && search_data.etime!=null)
{
e_time = search_data.btime.Value;
b_time = search_data.etime.Value;
}
var this_time = b_time; var this_time = b_time;
while (this_time>= e_time) while (this_time>= e_time)
{ {
......
...@@ -12,6 +12,10 @@ namespace AutoTurnOver.Models.Report ...@@ -12,6 +12,10 @@ namespace AutoTurnOver.Models.Report
public bool? has_sum { get; set; } public bool? has_sum { get; set; }
public string platform_type { get; set; } public string platform_type { get; set; }
public string warehousetype { get; set; } public string warehousetype { get; set; }
public int? warehousearea { get; set; }
public string warehouse_code { get; set; }
public DateTime? btime { get; set; }
public DateTime? etime { get; set; }
} }
......
...@@ -39,14 +39,15 @@ namespace AutoTurnOver.Services ...@@ -39,14 +39,15 @@ namespace AutoTurnOver.Services
} }
public List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea,bool isSum = false,string order = null,string sort = null,int? has_tort = null,string categoryIds = null,string buyer_name = null) public List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea,bool isSum = false,string order = null,string sort = null,int? has_tort = null,string categoryIds = null,string buyer_name = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
List<bailun_category_new_dto> categoryModels = null; List<bailun_category_new_dto> categoryModels = null;
if (!string.IsNullOrWhiteSpace(categoryIds)) if (!string.IsNullOrWhiteSpace(categoryIds))
{ {
categoryModels = ApiServices.GetNewClientNodesByIds(categoryIds.Split(',').Select(s => int.Parse(s)).ToList()); categoryModels = ApiServices.GetNewClientNodesByIds(categoryIds.Split(',').Select(s => int.Parse(s)).ToList());
} }
return DB.daily.RealtimeList(monitor_status, searchType, key_words, warehouse_code, supplier_name, offset, limit, ref total,warehousetype,warehousearea, isSum, order, sort, has_tort:has_tort, categoryModels: categoryModels, buyer_name:buyer_name); return DB.daily.RealtimeList(monitor_status, searchType, key_words, warehouse_code, supplier_name, offset, limit, ref total,warehousetype,warehousearea, isSum, order, sort, has_tort:has_tort, categoryModels: categoryModels, buyer_name:buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
} }
public List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform, string bailun_sku, int offset, int limit, ref int total, DateTime? start_date, DateTime? end_date) public List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform, string bailun_sku, int offset, int limit, ref int total, DateTime? start_date, DateTime? end_date)
...@@ -136,7 +137,8 @@ namespace AutoTurnOver.Services ...@@ -136,7 +137,8 @@ namespace AutoTurnOver.Services
private static int export_count = 0; private static int export_count = 0;
public MemoryStream Export(UserData user,int? monitor_status, int? searchType, string key_words, string warehousecode, string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null, int? has_tort = null,string buyer_name =null) public MemoryStream Export(UserData user,int? monitor_status, int? searchType, string key_words, string warehousecode, string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null, int? has_tort = null,string buyer_name =null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
try try
{ {
...@@ -152,7 +154,7 @@ namespace AutoTurnOver.Services ...@@ -152,7 +154,7 @@ namespace AutoTurnOver.Services
while (true) while (true)
{ {
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, (page - 1) * rows, rows, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name); var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, (page - 1) * rows, rows, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
if (list == null || list.Count <= 0) break; if (list == null || list.Count <= 0) break;
......
...@@ -61,14 +61,15 @@ namespace AutoTurnOver.Controllers ...@@ -61,14 +61,15 @@ namespace AutoTurnOver.Controllers
/// <param name="limit"></param> /// <param name="limit"></param>
/// <returns></returns> /// <returns></returns>
[UseAction] [UseAction]
public JsonResult RealtimeList(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null) public JsonResult RealtimeList(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null,DateTime? end_date =null,DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
try try
{ {
var services = new DailyServices(); var services = new DailyServices();
var total = 0; var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name); var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name,start_date:start_date,end_date:end_date,f_start_date:f_start_date,f_end_date:f_end_date);
return new JsonResult(new return new JsonResult(new
{ {
...@@ -87,12 +88,13 @@ namespace AutoTurnOver.Controllers ...@@ -87,12 +88,13 @@ namespace AutoTurnOver.Controllers
} }
public JsonResult RealtimeListSumFooter(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null) public JsonResult RealtimeListSumFooter(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
var services = new DailyServices(); var services = new DailyServices();
var total = 0; var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, true, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name); var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, true, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]); return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
} }
...@@ -165,11 +167,12 @@ namespace AutoTurnOver.Controllers ...@@ -165,11 +167,12 @@ namespace AutoTurnOver.Controllers
/// <param name="warehousecode"></param> /// <param name="warehousecode"></param>
/// <returns></returns> /// <returns></returns>
[UseAction] [UseAction]
public FileResult ExportRealtime(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null) public FileResult ExportRealtime(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null)
{ {
var user = AutoUtility.GetUser(); var user = AutoUtility.GetUser();
int total = 0; int total = 0;
var memory = new DailyServices().Export(user, monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name); var memory = new DailyServices().Export(user, monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, has_tort: has_tort, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date);
return File(memory, "text/csv", $"{user.UserAccount}实时库存.csv"); return File(memory, "text/csv", $"{user.UserAccount}实时库存.csv");
} }
......
...@@ -625,11 +625,15 @@ namespace AutoTurnOver.Controllers ...@@ -625,11 +625,15 @@ namespace AutoTurnOver.Controllers
/// <param name="platform_type"></param> /// <param name="platform_type"></param>
/// <returns></returns> /// <returns></returns>
[UseAction] [UseAction]
public JsonResult GetSkuWebsiteSales(string platform_type,string warehousetype) public JsonResult GetSkuWebsiteSales(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 { bailun_sku_website_sales_search_dto search_data = new bailun_sku_website_sales_search_dto {
platform_type = platform_type, platform_type = platform_type,
warehousetype = warehousetype warehousetype = warehousetype,
etime = etime,
btime = btime,
warehousearea =warehousearea,
warehouse_code = warehousecode
}; };
var list = new ReportServices().GetSkuWebsiteSales(search_data); var list = new ReportServices().GetSkuWebsiteSales(search_data);
...@@ -654,14 +658,18 @@ namespace AutoTurnOver.Controllers ...@@ -654,14 +658,18 @@ namespace AutoTurnOver.Controllers
return File(memory, "text/csv", $"{user.UserAccount}商品分类数据信息.csv"); return File(memory, "text/csv", $"{user.UserAccount}商品分类数据信息.csv");
} }
public JsonResult GetSkuWebsiteSalesSumFooter(string platform_type,string warehousetype) public JsonResult GetSkuWebsiteSalesSumFooter(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 bailun_sku_website_sales_search_dto search_data = new bailun_sku_website_sales_search_dto
{ {
platform_type = platform_type, platform_type = platform_type,
warehousetype = warehousetype, warehousetype = warehousetype,
has_sum =true has_sum =true,
etime = etime,
btime = btime,
warehousearea = warehousearea,
warehouse_code = warehousecode
}; };
var list = new ReportServices().GetSkuWebsiteSales(search_data); var list = new ReportServices().GetSkuWebsiteSales(search_data);
......
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