Commit 25908b0e by lizefeng

aims采购建议新增日均加权销量

parent bbb9fdfa
......@@ -51,7 +51,7 @@ where 1=1 ";
{
sql = @"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2',
t4.bailun_category_name,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status',
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status',t4.suppliers_link,
(t4.supplier_delivery - t6.virtual_delivery_days) as 'delivery_days_error',t4.weight,t4.unit_price,t7.usable_stock,t7.shipped_stock
from dc_auto_turnover as dat
left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_code = t2.warehouse_code
......
using AutoTurnOver.Models;
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
namespace AutoTurnOver.DB
{
public class dc_not_stock : connectionHelper
{
public static List<Models.dc_not_stock> List(dc_not_stock_search_dto search, int offset, int limit, ref int total, string order = "", string sort = "", bool isSum = false)
public static List<Models.dc_not_stock> List(dc_not_stock_search_dto search, int offset, int limit, ref int total, string order = "", string sort = "")
{
try
{
......@@ -28,7 +30,7 @@ t4.quantity_purchase,
t2.moq,
t_not_stock.test_sales,
t_not_stock.success_sales,
t2.push_time
( case when t2.push_time>'1999-01-01' then t2.push_time else null end) as 'push_time'
from dc_not_stock_goods_sales as t_not_stock
left join dc_base_sku as t2 on t_not_stock.product_inner_code = t2.product_inner_code
left join dc_auto_turnover as t1 on t2.bailun_sku =t1.bailun_sku and t_not_stock.warehouse_code = t1.warehouse_code
......@@ -65,11 +67,30 @@ where 1=1
parameters.Add("goods_sales_max", search.goods_sales_max);
}
if (search.is_distribution==true)
if (search.source_type !=null)
{
if (search.source_type == 1)
{
//分销
sql += " and t2.source in (5,9,10) ";
sqlCount += " and t2.source in (5,9,10) ";
}
else if(search.source_type == 2)
{
//供应商推荐
sql += " and t2.source in (4,6) ";
sqlCount += " and t2.source in (4,6) ";
}
else
{
// 其他
sql += " and t2.source not in (4,5,6,9,10) ";
sqlCount += " and t2.source not in (4,5,6,9,10) ";
}
}
if (search.success_states != null)
{
......@@ -77,8 +98,23 @@ where 1=1
{
// 成功
sql += " and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) ";
sqlCount += " and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) ";
}
if (search.success_states == 2)
{
// 失败
sql += " and ( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
sqlCount += " and ( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
}
if (search.success_states == 3)
{
// 待定
sql += " and !( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) and !( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
sqlCount += " and !( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) and !( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
}
}
}
if (limit > 10000)
......@@ -122,5 +158,85 @@ where 1=1
}
}
/// <summary>
/// 标记淘汰
/// </summary>
/// <param name="ids"></param>
public static void Eliminate(string product_inner_codes)
{
if (!string.IsNullOrWhiteSpace(product_inner_codes))
{
throw new Exception("请选择商品");
}
MySqlConnection conn = _connection;
conn.Open();
IDbTransaction transaction = conn.BeginTransaction();
try
{
_connection.Execute(@"
update dc_sku_monitor as t1 ,
dc_base_sku as t2
set t1.is_weedout=1,weedout_updatetime=now()
where t1.sku = t2.bailun_sku and t2.product_inner_code in @product_inner_codes and t1.warehousecode='BLGZ03'
", new { product_inner_codes = product_inner_codes.Split(',') },transaction: transaction);
_connection.Execute(@"
replace into dc_auto_config_sku_warehouse_copy1(`bailun_sku`,`sku_title`,`warehouse_code`,`warehouse_name`,`gmt_create`,`gmt_modified`,`status`,`bl_operator`)
(
select
bailun_sku,
'' as 'sku_title',
'BLGZ03',
'广州-03仓' as 'warehouse_name',
now() as 'gmt_create',
now() as 'gmt_modified',
1 as 'status',
'' as 'bl_operator'
from dc_base_sku where product_inner_code in @product_inner_codes
);
", new { product_inner_codes = product_inner_codes.Split(',') }, transaction: transaction);
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
}
}
/// <summary>
/// 转仓
/// </summary>
public static void TransferWarehouse(string product_inner_codes)
{
if (!string.IsNullOrWhiteSpace(product_inner_codes))
{
throw new Exception("请选择商品");
}
MySqlConnection conn = _connection;
conn.Open();
IDbTransaction transaction = conn.BeginTransaction();
try
{
// 修改发货仓库
throw new Exception("业务待完善");
// 数据仓转移分组
_connection.Execute(@"
update dc_sku_monitor as t1 ,
dc_base_sku as t2
set t1.groupname='无库分组',groupupdatetime=now()
where t1.sku = t2.bailun_sku and t2.product_inner_code in @product_inner_codes and t1.warehousecode='BLGZ03'
", new { product_inner_codes = product_inner_codes.Split(',') }, transaction: transaction);
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
}
}
}
}
......@@ -303,11 +303,13 @@ where 1=1 ";
sql = @"
select
t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name,
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 日均加权销量
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存
(t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权
(t5.quantity_out_stock) as 'quantity_out_stock', -- 缺货
(t5.quantity_transfer) as 'quantity_transfer', -- 调拨在途
(t5.quantity_purchase) as 'quantity_purchase', -- 采购在途
(t5.quantity_inventory) as 'quantity_inventory', -- 库存数
t3.suppliers_link,
(t3.unit_price * (case when t1.quantity_actual>0 then t1.quantity_actual else t1.quantity_final_advise end ) ) as 'quantity_final_advise_price', -- 采购金额
t3.suppliers_name,
(t1.history_fourteenday_sales - t5.forecast_fourteenday_sales) as 'sudden_increase' -- 突增关注
......
......@@ -204,19 +204,35 @@ left join buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.ware
where 1=1
";
}
if (!string.IsNullOrWhiteSpace(m.key_words) && m.search_type > 0)
{
switch (m.search_type.Value)
{
case 1:
sql += " and t1.bailun_sku =@bailun_sku " ;
countSql += " and t1.bailun_sku =@bailun_sku " ;
parameters.Add("bailun_sku", m.key_words);
break;
case 2:
sql += " and t6.product_inner_code =@product_inner_code ";
countSql += " t6.product_inner_code =@product_inner_code ";
parameters.Add("product_inner_code", m.key_words);
break;
case 3:
sql += " and t1.bailun_order_id =@bailun_order_id ";
countSql += " and t1.bailun_order_id =@bailun_order_id ";
parameters.Add("bailun_order_id", m.key_words);
break;
default: break;
}
}
if (m.bailun_account_id != null)
{
sql += " and t1.bailun_account_id=@bailun_account_id ";
countSql += " and t1.bailun_account_id=@bailun_account_id ";
parameters.Add("bailun_account_id", m.bailun_account_id);
}
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
sql += " and t6.product_inner_code=@product_inner_code ";
countSql += " and t6.product_inner_code=@product_inner_code ";
parameters.Add("product_inner_code", m.product_inner_code);
}
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and t_db.hq_type=" + $"'{m.warehousetype}'";
......@@ -227,12 +243,6 @@ where 1=1
sql += " and t_db.area_id=" + m.warehousearea;
countSql += " and t_db.area_id=" + m.warehousearea;
}
if (!string.IsNullOrWhiteSpace(m.bailun_sku))
{
sql += $" and t1.bailun_sku=@bailun_sku ";
countSql += $" and t1.bailun_sku=@bailun_sku ";
parameters.Add("bailun_sku", m.bailun_sku);
}
if (m.warehouse_code != null)
{
sql += $" and t1.warehouse_code=@warehouse_code ";
......
......@@ -202,7 +202,7 @@ namespace AutoTurnOver.Models.Report
public class quantity_out_stock_detail_search_dto
{
public string bailun_sku { get; set; }
public int? search_type { get; set; }
public string warehousetype { get; set; }
......@@ -210,7 +210,7 @@ namespace AutoTurnOver.Models.Report
public string warehouse_code { get; set; }
public string product_inner_code { get; set; }
public string key_words { get; set; }
public string purchase_user { get; set; }
public int? bailun_account_id { get; set;}
......
......@@ -101,10 +101,13 @@ namespace AutoTurnOver.Models
/// </summary>
public int type { get; set; }
public string type_str { get
public string type_str
{
get
{
return ((purchase_advise_type_enum)type).ToString();
} }
}
}
/// <summary>
/// 系统建议数量
......@@ -200,9 +203,12 @@ namespace AutoTurnOver.Models
/// </summary>
public decimal sudden_increase { get; set; }
/// <summary>
/// 日均加权
/// </summary>
public decimal? daily_weighted_sales { get; set; }
public string suppliers_link { get; set; }
}
public class dc_auto_purchase_advise_detailed_time_dto : dc_auto_purchase_advise_detailed
......
......@@ -394,5 +394,10 @@ namespace AutoTurnOver.Models
/// 已发货数
/// </summary>
public decimal? shipped_stock { get; set; }
/// <summary>
/// 供应链链接
/// </summary>
public string suppliers_link { get; set; }
}
}
......@@ -11,6 +11,14 @@ namespace AutoTurnOver.Models
{
public int source { get; set; }
public string source_str
{
get
{
return ((source_enum)source).ToString();
}
}
public string bailun_sku { get; set; }
public string product_inner_code { get; set; }
......@@ -70,29 +78,23 @@ namespace AutoTurnOver.Models
/// 是否成功
/// 推送超过7天,且日均大于等于1
/// </summary>
public bool is_success
public int success_state
{
get
{
return success_sales >= 1 && (DateTime.Now - push_time.Value).TotalDays >= 7;
if (push_time == null) return 0;
if (success_sales >= 1 && (DateTime.Now - push_time.Value).TotalDays >= 7) return 1;
else if (test_sales <= 0 && (DateTime.Now - push_time.Value).TotalDays >= 21) return 2;
else return 3;
}
}
/// <summary>
/// 是否失败
/// 推送超过21天 且没有出过单
/// </summary>
public bool is_fail
{
get
{
return test_sales <= 0 && (DateTime.Now - push_time.Value).TotalDays >= 21;
}
}
}
public class dc_not_stock_search_dto
{
public int? success_states { get; set; }
public decimal? goods_sales_min { get; set; }
......@@ -100,14 +102,9 @@ namespace AutoTurnOver.Models
public decimal? goods_sales_max { get; set; }
/// <summary>
/// 是否供应商推荐
/// </summary>
public bool? is_supplier { get; set; }
/// <summary>
/// 是否分销
/// </summary>
public bool? is_distribution { get; set; }
public int? source_type { get; set; }
}
......
using AutoTurnOver.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Services
{
public class NotStockServices
{
public List<Models.dc_not_stock> List(dc_not_stock_search_dto search, int offset, int limit, ref int total)
{
return DB.dc_not_stock.List(search, offset, limit, ref total);
}
public void Eliminate(string product_inner_codes)
{
DB.dc_not_stock.Eliminate(product_inner_codes);
}
public void TransferWarehouse(string product_inner_codes)
{
DB.dc_not_stock.TransferWarehouse(product_inner_codes);
}
}
}
......@@ -125,7 +125,7 @@ namespace AutoTurnOver.Controllers
string[] cols = new string[] { "Sku", "采购名称", "中文名", "英文名称","内部编码", "仓库编码", "仓库名称", "货主编码","实时采购在途","实时调拨在途"
,"订货数量","运输在途","中转仓库存","冻结库存","供应商库存","预售库存","不良品库存","在途库存","收货待检"
,"待上架","可配库存","销售可用库存(聚合)","销售可用库存(私有)","销售可用库存(共享)","在仓库存(共享)","在仓库存(私有)","在仓库存(聚合)","仓库占用(共享)"
,"仓库占用(私有)","仓库占用(聚合)","活动占用","单占用(私有)","订单占用(共享)","订单占用(聚合)","环球更新时间","供应商","采购员","重量","单价","已发货库存"
,"仓库占用(私有)","仓库占用(聚合)","活动占用","单占用(私有)","订单占用(共享)","订单占用(聚合)","环球更新时间","供应商","采购员","重量","单价","已发货库存","实时缺货"
};
foreach (var item in cols)
{
......@@ -177,6 +177,7 @@ namespace AutoTurnOver.Controllers
row["重量"] = itemData.weight;
row["单价"] = itemData.unit_price;
row["已发货库存"] = itemData.shipped_stock;
row["实时缺货"] = itemData.quantity_out_stock;
table.Rows.Add(row);
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoTurnOver.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace AutoTurnOver.Controllers
{
/// <summary>
/// 无库仓
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class NotStockController : Controller
{
[HttpGet]
public JsonResult List(int limit, int offset, string order, string sort, decimal? goods_sales_max, decimal? goods_sales_min, int? source_type, int? success_states)
{
var m = new dc_not_stock_search_dto
{
goods_sales_max = goods_sales_max,
goods_sales_min = goods_sales_min,
source_type = source_type,
success_states = success_states
};
var total = 0;
var service = new Services.NotStockServices();
var list = service.List(m, offset, limit, ref total);
return new JsonResult(new
{
rows = list,
total = total,
});
}
/// <summary>
/// 淘汰
/// </summary>
/// <returns></returns>
[HttpPost]
public JsonResult Eliminate(string product_inner_codes)
{
try
{
new Services.NotStockServices().Eliminate(product_inner_codes);
return new JsonResult(new
{
success = true
});
}
catch (Exception ex)
{
return new JsonResult(new
{
success = false,
message = ex.Message
});
}
}
[HttpPost]
public JsonResult TransferWarehouse(string product_inner_codes)
{
try
{
new Services.NotStockServices().TransferWarehouse(product_inner_codes);
return new JsonResult(new
{
success = true
});
}
catch (Exception ex)
{
return new JsonResult(new
{
success = false,
message = ex.Message
});
}
}
}
}
\ No newline at end of file
......@@ -199,7 +199,7 @@ namespace AutoTurnOver.Controllers
row["商品建议采购"] = itemData.goods_quantity_init_advise;
row["商品14日日均"] = itemData.goods_history_fourteenday_sales;
row["商品moq"] = itemData.goods_moq;
row["日均加权销量"] = itemData.quantity_safe_inventory;
row["日均加权销量"] = itemData.daily_weighted_sales;
row["缺货"] = itemData.quantity_out_stock;
row["调拨在途"] = itemData.quantity_transfer;
row["采购在途"] = itemData.quantity_purchase;
......
......@@ -226,12 +226,12 @@ namespace AutoTurnOver.Controllers
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public JsonResult QuantityOutStockDetailList(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
public JsonResult QuantityOutStockDetailList(int? bailun_account_id, int? search_type, string warehousecode, string key_words, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
bailun_sku = bailun_sku,
product_inner_code = product_inner_code,
search_type = search_type,
key_words = key_words,
purchase_user = purchase_user,
warehousearea = warehousearea,
warehousetype = warehousetype,
......@@ -250,12 +250,12 @@ namespace AutoTurnOver.Controllers
}
public JsonResult QuantityOutStockDetailFooter(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
public JsonResult QuantityOutStockDetailFooter(int? bailun_account_id, int? search_type, string warehousecode, string key_words, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
bailun_sku = bailun_sku,
product_inner_code = product_inner_code,
search_type = search_type,
key_words = key_words,
purchase_user = purchase_user,
warehousearea = warehousearea,
isSum = true,
......@@ -276,12 +276,12 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult QuantityOutStockDetailExport(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
public FileResult QuantityOutStockDetailExport(int? bailun_account_id, int? search_type, string warehousecode, string key_words, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
bailun_sku = bailun_sku,
product_inner_code = product_inner_code,
search_type = search_type,
key_words = key_words,
purchase_user = purchase_user,
warehousearea = warehousearea,
warehousetype = warehousetype,
......
......@@ -86,7 +86,8 @@ namespace AutoTurnOver.Controllers
p.history_sevenday_sales_ebay,
p.history_fourteenday_sales_ebay,
p.history_thirtyday_sales_ebay,
p.shipped_stock
p.shipped_stock,
p.suppliers_link
});
......
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