Commit 21b4ac96 by 泽锋 李

改在线,新增导出,时间筛选

parent 1671ea28
......@@ -490,7 +490,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
/// 缺货推送记录
/// </summary>
/// <returns></returns>
public static List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform,string bailun_sku, int offset, int limit, ref int total)
public static 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)
{
var sql = @"select t1.id, t1.platform, t1.bailun_sku,t3.warehouse_name, t1.warehouse_code, t1.push_date,t2.push_time from dc_auto_shortage_push as t1
left join dc_return_goods_push as t2 on t1.id =t2.shortage_push_id
......@@ -499,6 +499,18 @@ where 1=1 ";
var countSql = " select count(1) from dc_auto_shortage_push as t1 where 1=1 ";
DynamicParameters parameters = new DynamicParameters();
if (start_date != null)
{
sql += " and t1.push_date>=@btime ";
countSql += " and t1.push_date>=@btime ";
parameters.Add("btime", start_date);
}
if (end_date != null)
{
sql += " and t1.push_date<=@etime ";
countSql += " and t1.push_date<=@etime ";
parameters.Add("etime", end_date);
}
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and t1.platform=@platform ";
......
......@@ -49,9 +49,72 @@ namespace AutoTurnOver.Services
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);
}
public List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform, string bailun_sku, int offset, int limit, ref int total)
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)
{
return DB.daily.ShortagePushList(platform, bailun_sku, offset, limit,ref total);
return DB.daily.ShortagePushList(platform, bailun_sku, offset, limit,ref total, start_date, end_date);
}
private static int export_shortage_count = 0;
public MemoryStream ExportShortagePush(string platform, string bailun_sku, DateTime? end_date, DateTime? start_date, UserData user)
{
try
{
export_shortage_count++;
var fileName = AppContext.BaseDirectory + $@"Result\RealtimeStock\{user.UserAccount}库存监控-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
int page = 1;
int rows = 50000;
if (export_shortage_count == 1)
{
rows = 250000;
}
while (true)
{
int total = 0;
var list = ShortagePushList(platform, bailun_sku, page, rows, ref total, start_date, end_date);
if (list == null || list.Count <= 0) break;
DataTable table = new DataTable();
string[] cols = new string[] { "仓库编码","仓库名称", "sku", "平台","改0 推送时间", "补货推送时间" };
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["仓库编码"] = itemData.warehouse_code;
row["仓库名称"] = itemData.warehouse_name;
row["sku"] = itemData.bailun_sku;
row["平台"] = itemData.platform;
row["改0 推送时间"] = itemData.push_date;
row["补货推送时间"] = itemData.push_time;
table.Rows.Add(row);
}
CsvFileHelper.SaveCSV(table, fileName, page == 1);
page++;
}
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
export_shortage_count--;
return memory;
}
catch (Exception)
{
export_shortage_count--;
throw;
}
}
......
......@@ -21,7 +21,7 @@ namespace AutoTurnOver.Controllers
[HttpGet]
public JsonResult PurchaseList(string warehousecode, string sku)
{
var service = new Services.DailyServices();
var list = service.List(sku, warehousecode);
......@@ -68,7 +68,7 @@ namespace AutoTurnOver.Controllers
{
var services = new DailyServices();
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);
return new JsonResult(new
{
......@@ -84,15 +84,15 @@ namespace AutoTurnOver.Controllers
stack_trace = ex.StackTrace
});
}
}
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)
{
var services = new DailyServices();
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);
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
}
......@@ -106,13 +106,13 @@ namespace AutoTurnOver.Controllers
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public JsonResult ShortagePushList(string platform, string bailun_sku, int offset, int limit)
public JsonResult ShortagePushList(string platform, string bailun_sku, int offset, int limit, DateTime? end_date, DateTime? start_date)
{
try
{
var services = new DailyServices();
var total = 0;
var list = services.ShortagePushList(platform, bailun_sku, offset, limit, ref total);
var list = services.ShortagePushList(platform, bailun_sku, offset, limit, ref total, start_date,end_date);
return new JsonResult(new
{
rows = list,
......@@ -129,6 +129,13 @@ namespace AutoTurnOver.Controllers
}
}
public FileResult ExportShortagePush(string platform, string bailun_sku, DateTime? end_date, DateTime? start_date)
{
var user = AutoUtility.GetUser();
var memory = new DailyServices().ExportShortagePush(platform, bailun_sku, start_date, end_date, AutoUtility.GetUser());
return File(memory, "text/csv", $"{user.UserAccount}修改在线数量日志.csv");
}
/// <summary>
/// 预计到货
/// </summary>
......@@ -191,14 +198,14 @@ namespace AutoTurnOver.Controllers
/// </summary>
/// <returns></returns>
[UseAction]
public JsonResult StockMonitorList(int? type, string bailun_sku,int offset, int limit, string order, string sort,
public JsonResult StockMonitorList(int? type, string bailun_sku, int offset, int limit, string order, string sort,
DateTime? end_date, DateTime? start_date)
{
try
{
var services = new StockMonitorService();
var page_data = services.GetPage(new dc_auto_stock_monitor_search_dto { type = type, bailun_sku =bailun_sku,page= offset+1,rows = limit,sidx = sort, sord = order,start_date = start_date,end_date = end_date });
var page_data = services.GetPage(new dc_auto_stock_monitor_search_dto { type = type, bailun_sku = bailun_sku, page = offset + 1, rows = limit, sidx = sort, sord = order, start_date = start_date, end_date = end_date });
return new JsonResult(new
{
......
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