Commit 9d43af10 by lizefeng

周转表导出格式优化

parent eefe9ab2
...@@ -878,29 +878,29 @@ alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp; ...@@ -878,29 +878,29 @@ alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp;
truncate table buy_ontheway_detail_temp; ", commandTimeout: 0); truncate table buy_ontheway_detail_temp; ", commandTimeout: 0);
//刷新无库仓商品日均 //刷新无库仓商品日均
_connection.Execute(@" -- 刷新无库仓商品日均 // _connection.Execute(@" -- 刷新无库仓商品日均
set session transaction isolation level read uncommitted; //set session transaction isolation level read uncommitted;
start transaction; //start transaction;
-- 清空视图表的数据
Truncate table dc_not_stock_goods_sales_temp;
INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,`test_sales`,`success_sales`) ( //-- 清空视图表的数据
select //Truncate table dc_not_stock_goods_sales_temp;
t2.product_inner_code,t2.warehouse_code,
sum(case when TIMESTAMPDIFF(day,t2.push_time,t1.pay_time)<=21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量
sum(case when TIMESTAMPDIFF(day,t1.pay_time,now())<=7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量
from dc_base_sku as t2
left join dc_base_oms_sku as t1 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
where t2.warehouse_code='BLGZ03' and (t1.id is null or t1.bailun_order_status!='Canceled') and (t3.`status`=0 or t3.`status` is null) and t2.push_time >= '2010-01-01'
GROUP BY t2.product_inner_code,t2.warehouse_code
);
alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp; //INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,`test_sales`,`success_sales`) (
alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales; // select
alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp; //t2.product_inner_code,t2.warehouse_code,
truncate table dc_not_stock_goods_sales_temp; ", commandTimeout: 0); //sum(case when TIMESTAMPDIFF(day,t2.push_time,t1.pay_time)<=21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量
//sum(case when TIMESTAMPDIFF(day,t1.pay_time,now())<=7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量
//from dc_base_sku as t2
//left join dc_base_oms_sku as t1 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
//left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
//where t2.warehouse_code='BLGZ03' and (t1.id is null or t1.bailun_order_status!='Canceled') and (t3.`status`=0 or t3.`status` is null) and t2.push_time >= '2010-01-01'
//GROUP BY t2.product_inner_code,t2.warehouse_code
//);
//alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp;
//alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales;
//alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp;
//truncate table dc_not_stock_goods_sales_temp; ", commandTimeout: 0);
// _connection.Execute(@" -- 记录历史缺货 // _connection.Execute(@" -- 记录历史缺货
//set session transaction isolation level read uncommitted; //set session transaction isolation level read uncommitted;
......
...@@ -51,13 +51,13 @@ namespace AutoTurnOver.Common ...@@ -51,13 +51,13 @@ namespace AutoTurnOver.Common
for (int j = 0; j < dt.Columns.Count; j++) for (int j = 0; j < dt.Columns.Count; j++)
{ {
string str = dt.Rows[i][j].ToString(); string str = dt.Rows[i][j].ToString();
if (str.Contains(',') || str.Contains('"') //if (str.Contains(',') || str.Contains('"')
|| str.Contains('\r') || str.Contains('\n')) //含逗号 冒号 换行符的需要放到引号中 // || str.Contains('\r') || str.Contains('\n')) //含逗号 冒号 换行符的需要放到引号中
{ //{
str = string.Format("\"{0}\"", str); // str = string.Format("\"{0}\"", str);
} //}
data += str; data += ToStr(str);
if (j < dt.Columns.Count - 1) if (j < dt.Columns.Count - 1)
{ {
data += ","; data += ",";
...@@ -69,6 +69,12 @@ namespace AutoTurnOver.Common ...@@ -69,6 +69,12 @@ namespace AutoTurnOver.Common
fs.Close(); fs.Close();
} }
private static string ToStr(object obj)
{
if (obj == null) return "";
return obj.ToString().Replace(",", "").Replace("\n", "");
}
/// <summary> /// <summary>
/// 将DataTable转成csv字符串 /// 将DataTable转成csv字符串
/// </summary> /// </summary>
......
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