Commit 2435f29b by lizefeng

周转表新增最近30天日均

parent 6f013d5a
...@@ -251,7 +251,7 @@ t3.sku_title_cn as 'sku_name', ...@@ -251,7 +251,7 @@ t3.sku_title_cn as 'sku_name',
t4.quantity_purchase as 'purchase_daily_quantity', t4.quantity_purchase as 'purchase_daily_quantity',
t3.buyer_name,t3.sku_title_cn,t3.sku_title_en,t3.product_inner_code, t3.buyer_name,t3.sku_title_cn,t3.sku_title_en,t3.product_inner_code,
t4.quantity_purchase as 'realtime_quantity_purchase',t4.quantity_transfer as 'realtime_quantity_transfer', t4.quantity_purchase as 'realtime_quantity_purchase',t4.quantity_transfer as 'realtime_quantity_transfer',
t1.bailun_sku,t1.warehouse_code,t3.suppliers_name,t4.quantity_out_stock,t4.gmt_out_stock_modified, t1.bailun_sku,t1.warehouse_code,t3.suppliers_name,t4.quantity_out_stock,t4.gmt_out_stock_modified,t3.weight,t3.unit_price,
t1.* t1.*
from from
dc_base_stock as t1 dc_base_stock as t1
......
...@@ -6,7 +6,7 @@ using System.Text; ...@@ -6,7 +6,7 @@ using System.Text;
namespace AutoTurnOver.DB namespace AutoTurnOver.DB
{ {
public class dc_auto_forecast_fluctuation : connectionHelper public class dc_auto_forecast_fluctuation : connectionHelper
{ {
/// <summary> /// <summary>
/// 查询异常提醒 /// 查询异常提醒
...@@ -14,15 +14,15 @@ namespace AutoTurnOver.DB ...@@ -14,15 +14,15 @@ namespace AutoTurnOver.DB
/// <param name="sku"></param> /// <param name="sku"></param>
/// <param name="warehouse_code"></param> /// <param name="warehouse_code"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<AutoTurnOver.Models.dc_auto_forecast_fluctuation_dto> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total,string order = "", string sort = "") public static IEnumerable<AutoTurnOver.Models.dc_auto_forecast_fluctuation_dto> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total, string order = "", string sort = "")
{ {
var sql = ""; var sql = "";
if (limit>10000) if (limit > 10000)
{ {
sql = @" sql = @"
select t1.*,t2.quantity_out_stock, select t1.*,t2.quantity_out_stock,
(t4.quantity_purchase-t4.quantity_inbound) as 'ontheway_quantity', -- 采购在途 (t4.quantity_purchase-t4.quantity_inbound) as 'ontheway_quantity', -- 采购在途
t4.buyer_name, t3.buyer_name,
t4.estimated_arrival_time, t4.estimated_arrival_time,
t4.purchase_id, t4.purchase_id,
(case when (t4.quantity_purchase>t4.quantity_inbound) and now()>t4.estimated_arrival_time then 1 else 0 end) as 'is_overdue', (case when (t4.quantity_purchase>t4.quantity_inbound) and now()>t4.estimated_arrival_time then 1 else 0 end) as 'is_overdue',
...@@ -49,7 +49,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code ...@@ -49,7 +49,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
where 1 = 1 where 1 = 1
"; ";
} }
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (!string.IsNullOrWhiteSpace(data.sku)) if (!string.IsNullOrWhiteSpace(data.sku))
{ {
...@@ -85,7 +85,7 @@ where 1 = 1 ...@@ -85,7 +85,7 @@ where 1 = 1
} }
if (data.err_type != null) if (data.err_type != null)
{ {
sql += " and t1.`type`= "+ data.err_type; sql += " and t1.`type`= " + data.err_type;
} }
if (data.has_overdue != null) if (data.has_overdue != null)
{ {
...@@ -109,7 +109,16 @@ where 1 = 1 ...@@ -109,7 +109,16 @@ where 1 = 1
{ {
sql += " and dbw.area_id=" + data.warehousearea; sql += " and dbw.area_id=" + data.warehousearea;
} }
total = _connection.ExecuteScalar<int>("select count(0) from (" + sql + ") tb1", parameters);
if (limit < 10000)
{
total = _connection.ExecuteScalar<int>("select count(0) from (" + sql + ") tb1", parameters, commandTimeout: 0);
}
else
{
total = 0;
}
//设置默认排序字段 //设置默认排序字段
if (string.IsNullOrWhiteSpace(sort)) sort = "avg_sales_three"; if (string.IsNullOrWhiteSpace(sort)) sort = "avg_sales_three";
...@@ -127,7 +136,7 @@ where 1 = 1 ...@@ -127,7 +136,7 @@ where 1 = 1
} }
} }
var obj = _connection.Query<Models.dc_auto_forecast_fluctuation_dto>(sql + " limit " + offset + "," + limit, parameters,commandTimeout:0); var obj = _connection.Query<Models.dc_auto_forecast_fluctuation_dto>(sql + " limit " + offset + "," + limit, parameters, commandTimeout: 0);
if (limit < 10000) if (limit < 10000)
{ {
...@@ -139,7 +148,7 @@ where 1 = 1 ...@@ -139,7 +148,7 @@ where 1 = 1
} }
} }
} }
return obj.AsList(); return obj.AsList();
} }
...@@ -159,14 +168,15 @@ where 1 = 1 ...@@ -159,14 +168,15 @@ where 1 = 1
/// </summary> /// </summary>
/// <param name="data"></param> /// <param name="data"></param>
/// <param name="user"></param> /// <param name="user"></param>
public static void Confirm(AutoTurnOver.Models.dc_auto_forecast_fluctuation data,UserData user) public static void Confirm(AutoTurnOver.Models.dc_auto_forecast_fluctuation data, UserData user)
{ {
var oldData = Info(data.id); var oldData = Info(data.id);
if (oldData == null) throw new Exception("数据不存在"); if (oldData == null) throw new Exception("数据不存在");
_connection.Execute(@" update dc_auto_forecast_fluctuation _connection.Execute(@" update dc_auto_forecast_fluctuation
set forecast_solve_time=@forecast_solve_time,bl_operator=@bl_operator,remark=@remark,has_confirm=1,confirm_time=@confirm_time set forecast_solve_time=@forecast_solve_time,bl_operator=@bl_operator,remark=@remark,has_confirm=1,confirm_time=@confirm_time
where id=@id", new { where id=@id", new
{
data.forecast_solve_time, data.forecast_solve_time,
data.remark, data.remark,
bl_operator = user.UserName, bl_operator = user.UserName,
......
...@@ -143,7 +143,8 @@ count(1) ...@@ -143,7 +143,8 @@ count(1)
from dc_base_oms_sku as t1 from dc_base_oms_sku as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-04-13' and t1.platform_type!='fba' where t1.pay_time>'2019-03-01' and t1.shipping_status!='TotalShipping' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0
and ( t6.buyer_name in ('张莹霞','张莹霞1','冯兆欣') and t1.warehouse_code ='GZBLWH' )
"; ";
sql = @" sql = @"
select select
...@@ -185,7 +186,8 @@ left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_ ...@@ -185,7 +186,8 @@ left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code
where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-04-13' and t1.platform_type!='fba' where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-03-01' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0
and ( t6.buyer_name in ('张莹霞','张莹霞1','冯兆欣') and t1.warehouse_code ='GZBLWH' )
"; ";
if (!string.IsNullOrWhiteSpace(m.product_inner_code)) if (!string.IsNullOrWhiteSpace(m.product_inner_code))
...@@ -229,7 +231,7 @@ where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-04-13' and t1.pl ...@@ -229,7 +231,7 @@ where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-04-13' and t1.pl
} }
else else
{ {
total = _connection.ExecuteScalar<int>(countSql, parameters); total = _connection.ExecuteScalar<int>(countSql, parameters, commandTimeout: 0);
//设置默认排序字段 //设置默认排序字段
if (!string.IsNullOrEmpty(sort) && !string.IsNullOrEmpty(order)) if (!string.IsNullOrEmpty(sort) && !string.IsNullOrEmpty(order))
......
...@@ -209,6 +209,11 @@ namespace AutoTurnOver.Models ...@@ -209,6 +209,11 @@ namespace AutoTurnOver.Models
public decimal history_fourteenday_sales { get; set; } public decimal history_fourteenday_sales { get; set; }
/// <summary> /// <summary>
/// 过去30天日均销量
/// </summary>
public decimal history_thirtyday_sales { get; set; }
/// <summary>
/// 销量预测算法 /// 销量预测算法
/// </summary> /// </summary>
public string sales_explain_details { get; set; } public string sales_explain_details { get; set; }
......
...@@ -202,5 +202,15 @@ namespace AutoTurnOver.Models ...@@ -202,5 +202,15 @@ namespace AutoTurnOver.Models
public decimal? quantity_out_stock { get; set; } public decimal? quantity_out_stock { get; set; }
public DateTime? gmt_out_stock_modified { get; set; } public DateTime? gmt_out_stock_modified { get; set; }
/// <summary>
/// 重量
/// </summary>
public decimal? weight { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal? unit_price { get; set; }
} }
} }
...@@ -125,7 +125,7 @@ namespace AutoTurnOver.Controllers ...@@ -125,7 +125,7 @@ namespace AutoTurnOver.Controllers
string[] cols = new string[] { "Sku", "采购名称", "中文名", "英文名称","内部编码", "仓库编码", "仓库名称", "货主编码","实时采购在途","实时调拨在途" string[] cols = new string[] { "Sku", "采购名称", "中文名", "英文名称","内部编码", "仓库编码", "仓库名称", "货主编码","实时采购在途","实时调拨在途"
,"订货数量","运输在途","中转仓库存","冻结库存","供应商库存","预售库存","不良品库存","在途库存","收货待检" ,"订货数量","运输在途","中转仓库存","冻结库存","供应商库存","预售库存","不良品库存","在途库存","收货待检"
,"待上架","可配库存","销售可用库存(聚合)","销售可用库存(私有)","销售可用库存(共享)","在仓库存(共享)","在仓库存(私有)","在仓库存(聚合)","仓库占用(共享)" ,"待上架","可配库存","销售可用库存(聚合)","销售可用库存(私有)","销售可用库存(共享)","在仓库存(共享)","在仓库存(私有)","在仓库存(聚合)","仓库占用(共享)"
,"仓库占用(私有)","仓库占用(聚合)","活动占用","单占用(私有)","订单占用(共享)","订单占用(聚合)","环球更新时间","供应商","采购员" ,"仓库占用(私有)","仓库占用(聚合)","活动占用","单占用(私有)","订单占用(共享)","订单占用(聚合)","环球更新时间","供应商","采购员","重量","单价"
}; };
foreach (var item in cols) foreach (var item in cols)
{ {
...@@ -174,6 +174,8 @@ namespace AutoTurnOver.Controllers ...@@ -174,6 +174,8 @@ namespace AutoTurnOver.Controllers
row["实时调拨在途"] = itemData.realtime_quantity_transfer; row["实时调拨在途"] = itemData.realtime_quantity_transfer;
row["供应商"] = itemData.suppliers_name; row["供应商"] = itemData.suppliers_name;
row["采购员"] = itemData.buyer_name; row["采购员"] = itemData.buyer_name;
row["重量"] = itemData.weight;
row["单价"] = itemData.unit_price;
table.Rows.Add(row); table.Rows.Add(row);
} }
......
...@@ -310,7 +310,7 @@ namespace AutoTurnOver.Controllers ...@@ -310,7 +310,7 @@ namespace AutoTurnOver.Controllers
row["sku监控状态"] = itemData.monitor_status; row["sku监控状态"] = itemData.monitor_status;
row["销售状态"] = itemData.sku_status; row["销售状态"] = itemData.sku_status;
row["总在途库存数"] = itemData.quantity_ontheway; row["总在途库存数"] = itemData.quantity_ontheway;
row["采购在途数据"] = itemData.buyer_name; row["采购在途数据"] = itemData.buy_ontheway_detail;
table.Rows.Add(row); table.Rows.Add(row);
} }
......
...@@ -179,13 +179,17 @@ namespace AutoTurnOver.Controllers ...@@ -179,13 +179,17 @@ namespace AutoTurnOver.Controllers
p.monitor_status, p.monitor_status,
p.supplier_name, p.supplier_name,
p.buyer_name, p.buyer_name,
p.delivery_days_error p.delivery_days_error,
p.history_sevenday_sales,
p.history_fourteenday_sales,
p.history_thirtyday_sales
}); });
DataTable table = new DataTable(); DataTable table = new DataTable();
string[] cols = new string[] { "Sku","商品编码", "内部编码", "sku标题", "仓库编码", "仓库名称", "MOQ", string[] cols = new string[] { "Sku","商品编码", "内部编码", "sku标题", "仓库编码", "仓库名称", "MOQ",
"采购在途", "调拨在途", "昨日销量", "明日销量", "未来7天日均", "未来14天日均", "建议采购数", "活动促销数量", "采购在途", "调拨在途", "昨日销量", "明日销量", "未来7天日均", "未来14天日均", "建议采购数", "活动促销数量",
"实际库存", "安全库存", "周转天数", "供应商交期", "质检入库天数", "调拨头程天数", "预测是否断货", "缺货数量","监控状态","供应商","采购员","交期异常" "实际库存", "安全库存", "周转天数", "供应商交期", "质检入库天数", "调拨头程天数", "预测是否断货", "缺货数量","监控状态","供应商","采购员","交期异常",
"过去7天日均","过去14天日均","过去30天日均"
}; };
foreach (var item in cols) foreach (var item in cols)
{ {
...@@ -223,6 +227,9 @@ namespace AutoTurnOver.Controllers ...@@ -223,6 +227,9 @@ namespace AutoTurnOver.Controllers
row["供应商"] = itemData.supplier_name; row["供应商"] = itemData.supplier_name;
row["采购员"] = itemData.buyer_name; row["采购员"] = itemData.buyer_name;
row["交期异常"] = itemData.delivery_days_error; row["交期异常"] = itemData.delivery_days_error;
row["过去7天日均"] = itemData.history_sevenday_sales;
row["过去14天日均"] = itemData.history_fourteenday_sales;
row["过去30天日均"] = itemData.history_thirtyday_sales;
table.Rows.Add(row); table.Rows.Add(row);
} }
......
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