Commit 1c82464b by lizefeng

周转表分页导出

parent d998fa7d
......@@ -16,14 +16,18 @@ namespace AutoTurnOver.Common
/// <param name="fileName">CSV的文件路径</param>
public static void SaveCSV(DataTable dt, string fileName)
{
if (!Directory.Exists(Path.GetDirectoryName(fileName)))
// 是否追加
var existsPush = Directory.Exists(Path.GetDirectoryName(fileName));
if (!existsPush)
{
Directory.CreateDirectory(Path.GetDirectoryName(fileName));
}
FileStream fs = new FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
FileStream fs = new FileStream(fileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
string data = "";
if (!existsPush)
{
//写出列名称
for (int i = 0; i < dt.Columns.Count; i++)
{
......@@ -34,6 +38,8 @@ namespace AutoTurnOver.Common
}
}
sw.WriteLine(data);
}
//写出各行数据
for (int i = 0; i < dt.Rows.Count; i++)
......
......@@ -138,6 +138,8 @@ namespace AutoTurnOver.Controllers
{
try
{
var fileName = AppContext.BaseDirectory + @"Result\RealtimeStock\周转表.csv";
var m = new Condition_AutoTurnOver
{
searchType = searchType,
......@@ -158,51 +160,13 @@ namespace AutoTurnOver.Controllers
var total = 0;
var service = new Services.SkuAutoTurnServices();
var list = service.List(m, 0, int.MaxValue, ref total, order, sort).Select(p => new
int page = 1;
int rows = 10000;
while (true)
{
p.bailun_sku,
p.sku_title,
p.warehouse_code,
p.warehouse_name,
p.quantity_minimum_order,
p.quantity_final_advise,
p.quantity_promotion,
p.quantity_inventory,
p.turnover_days,
p.quantity_safe_inventory,
p.inspection_delivery,
p.status,
p.id,
p.quantity_out_stock,
p.supplier_delivery,
p.transfer_delivery,
p.quantity_purchase,
p.quantity_transfer,
p.forecast_fourteenday_sales,
p.forecast_sevenday_sales,
p.oneday_sales,
p.forecast_oneday_sales2,
p.product_inner_code,
p.product_code,
p.bailun_category_name,
p.monitor_status,
p.supplier_name,
p.buyer_name,
p.delivery_days_error,
p.history_sevenday_sales,
p.history_fourteenday_sales,
p.history_thirtyday_sales,
p.unit_price,
p.weight,
p.usable_stock,
p.suppliers_name,
p.history_sevenday_sales_ebay,
p.history_fourteenday_sales_ebay,
p.history_thirtyday_sales_ebay,
p.shipped_stock,
p.develop_time,
p.has_tort
});
var list = service.List(m, page, rows, ref total, order, sort);
if (list ==null ||list.Count <= 0) break;
page++;
DataTable table = new DataTable();
string[] cols = new string[] { "Sku","商品编码", "内部编码", "sku标题", "仓库编码", "仓库名称", "MOQ",
......@@ -261,9 +225,11 @@ namespace AutoTurnOver.Controllers
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))
......@@ -275,6 +241,7 @@ namespace AutoTurnOver.Controllers
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "----" + ex.StackTrace);
return new ContentResult() { Content = ex.Message+"----"+ex.StackTrace };
}
......
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