Commit 104f0ac7 by 泽锋 李

采购建议算法调整

parent 34922b58
...@@ -520,7 +520,7 @@ where t1.mother_sku_warehouse_code in @mother_sku_warehouse_codes ", new ...@@ -520,7 +520,7 @@ where t1.mother_sku_warehouse_code in @mother_sku_warehouse_codes ", new
purchase_advice_id = "", purchase_advice_id = "",
purchase_create_order_days = turn_first_data.purchase_create_order_days, purchase_create_order_days = turn_first_data.purchase_create_order_days,
quantity_begin_advise = turn_datas.Sum(s => s.quantity_begin_advise), quantity_begin_advise = turn_datas.Sum(s => s.quantity_begin_advise),
quantity_final_advise = turn_datas.Sum(s => s.quantity_final_advise), quantity_final_advise = Math.Max(0, turn_datas.Sum(s => s.quantity_final_advise) + turn_datas.Where(s => s.quantity_init_advise<0).Sum(s=>s.quantity_init_advise)),
quantity_inbound = turn_datas.Sum(s => s.quantity_inbound), quantity_inbound = turn_datas.Sum(s => s.quantity_inbound),
quantity_init_advise = turn_datas.Sum(s => s.quantity_init_advise), quantity_init_advise = turn_datas.Sum(s => s.quantity_init_advise),
quantity_inventory = turn_datas.Sum(s => s.quantity_inventory), quantity_inventory = turn_datas.Sum(s => s.quantity_inventory),
......
...@@ -100,7 +100,7 @@ namespace AutoTurnOver.DB ...@@ -100,7 +100,7 @@ namespace AutoTurnOver.DB
create_date = DateTime.Now, create_date = DateTime.Now,
error_message = "", error_message = "",
error_stack_trace = "", error_stack_trace = "",
status = 0, status = 1,
logistics_code = selectItem.logistics_code, logistics_code = selectItem.logistics_code,
old_transfer_delivery = item.transfer_delivery, old_transfer_delivery = item.transfer_delivery,
old_transfer_bale_delivery = item.transfer_bale_delivery, old_transfer_bale_delivery = item.transfer_bale_delivery,
...@@ -114,7 +114,8 @@ namespace AutoTurnOver.DB ...@@ -114,7 +114,8 @@ namespace AutoTurnOver.DB
remarks = remarks, remarks = remarks,
}; };
cahnge_datas.Add(item_task); cahnge_datas.Add(item_task);
_connection.Insert(item_task); var task_id = _connection.Insert(item_task);
_connection.Execute(" update dc_auto_turnover set auto_replace_logistics_task_id=@auto_replace_logistics_task_id where id=@id ", new { id = item.auto_id, auto_replace_logistics_task_id = task_id });
} }
} }
...@@ -161,6 +162,7 @@ namespace AutoTurnOver.DB ...@@ -161,6 +162,7 @@ namespace AutoTurnOver.DB
List<replace_logistics_outofstock_dto> datas = new List<replace_logistics_outofstock_dto>(); List<replace_logistics_outofstock_dto> datas = new List<replace_logistics_outofstock_dto>();
var sql = @" var sql = @"
select select
t3.id as 'auto_id',
t1.bailun_sku, t1.bailun_sku,
t1.warehouse_code, t1.warehouse_code,
t1.start_time, t1.start_time,
...@@ -457,6 +459,7 @@ select ...@@ -457,6 +459,7 @@ select
t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new
( (
case case
when t1.is_mother_sku =1 then t1.quantity_final_advise -- 母sku 直接下
when t6.buyer_name in ('张莹霞') then ( case when t1.quantity_init_advise>0 then greatest(t1.quantity_init_advise,t6.moq) else 0 end) -- (张莹霞的sku取moq下单) when t6.buyer_name in ('张莹霞') then ( case when t1.quantity_init_advise>0 then greatest(t1.quantity_init_advise,t6.moq) else 0 end) -- (张莹霞的sku取moq下单)
when t7.sum_quantity_init_advise>=t7.max_moq then t1.quantity_init_advise-- 如果商品的下单总量达到moq了,就直接下单 when t7.sum_quantity_init_advise>=t7.max_moq then t1.quantity_init_advise-- 如果商品的下单总量达到moq了,就直接下单
when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq
...@@ -638,6 +641,8 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -638,6 +641,8 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
//先清洗一波子母sku //先清洗一波子母sku
if (mother_datas != null && mother_datas.Count >= 1) if (mother_datas != null && mother_datas.Count >= 1)
{ {
// 再查询需要监控库容的母sku // 再查询需要监控库容的母sku
var mother_storage_capacity_configs = _connection.Query<dc_base_storage_capacity_config>(" select * from dc_base_storage_capacity_config where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new var mother_storage_capacity_configs = _connection.Query<dc_base_storage_capacity_config>(" select * from dc_base_storage_capacity_config where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new
{ {
...@@ -649,6 +654,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -649,6 +654,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
if(mother_datas!=null && mother_datas.Count >= 1) if(mother_datas!=null && mother_datas.Count >= 1)
{ {
// 查询母sku锁包含的子sku全部清除 // 查询母sku锁包含的子sku全部清除
var maps = _connection.Query<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where mother_sku_warehouse_code in @mother_sku_warehouse_codes ", new var maps = _connection.Query<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where mother_sku_warehouse_code in @mother_sku_warehouse_codes ", new
{ {
...@@ -661,6 +667,12 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -661,6 +667,12 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
not_mother_datas = not_mother_datas.Where(s=> !maps.Any(v=>v.bailun_sku_warehouse_code==s.bailun_sku_warehouse_code)).ToList(); not_mother_datas = not_mother_datas.Where(s=> !maps.Any(v=>v.bailun_sku_warehouse_code==s.bailun_sku_warehouse_code)).ToList();
foreach (var item in mother_datas) foreach (var item in mother_datas)
{ {
if (item.bailun_sku == "M-352984501" )
{
}
var itemMaps = maps.Where(s => s.mother_sku_warehouse_code == item.bailun_sku_warehouse_code).OrderByDescending(s => s.is_main).ToList(); var itemMaps = maps.Where(s => s.mother_sku_warehouse_code == item.bailun_sku_warehouse_code).OrderByDescending(s => s.is_main).ToList();
if (itemMaps != null && itemMaps.Count >= 1) if (itemMaps != null && itemMaps.Count >= 1)
{ {
......
...@@ -7,6 +7,7 @@ namespace AutoTurnOver.Models.auto ...@@ -7,6 +7,7 @@ namespace AutoTurnOver.Models.auto
public class replace_logistics_outofstock_dto public class replace_logistics_outofstock_dto
{ {
public int id { get; set; } public int id { get; set; }
public int auto_id { get; set; }
public string bailun_sku { get; set; } public string bailun_sku { get; set; }
public int quantity { get; set; } public int quantity { get; set; }
public string warehouse_code { get; set; } public string warehouse_code { get; set; }
......
...@@ -30,7 +30,7 @@ namespace AutoTurnOver.Services ...@@ -30,7 +30,7 @@ namespace AutoTurnOver.Services
foreach (var item in change_datas) foreach (var item in change_datas)
{ {
if(item.bailun_sku== "945188402") if(item.bailun_sku== "946497701" && item.warehouse_code == "GBFBABLA")
{ {
} }
...@@ -45,22 +45,22 @@ namespace AutoTurnOver.Services ...@@ -45,22 +45,22 @@ namespace AutoTurnOver.Services
purchase_advise.ImportDetailed(mainID.Value,date, is_clear_data: is_clear_data); purchase_advise.ImportDetailed(mainID.Value,date, is_clear_data: is_clear_data);
// 如果有临时单,则需要切换回来 // 如果有临时单,则需要切换回来
if(change_datas!=null && change_datas.Count >= 1) //if(change_datas!=null && change_datas.Count >= 1)
{ //{
foreach (var item in change_datas) // foreach (var item in change_datas)
{ // {
MyMySqlConnection._connection.Insert(new dc_base_queue // MyMySqlConnection._connection.Insert(new dc_base_queue
{ // {
submit_date = DateTime.Now, // submit_date = DateTime.Now,
error_message = "", // error_message = "",
consume_date = null, // consume_date = null,
error_stack_trace = "", // error_stack_trace = "",
message = new { bailun_sku = item.bailun_sku, warehouse_code = item.warehouse_code }.ToJson(), // message = new { bailun_sku = item.bailun_sku, warehouse_code = item.warehouse_code }.ToJson(),
type = "刷新周转表", // type = "刷新周转表",
remarks = "配置预测销量" // remarks = "配置预测销量"
}); // });
} // }
} //}
if (is_bak) if (is_bak)
{ {
......
...@@ -31,7 +31,7 @@ namespace ResetOutofstock ...@@ -31,7 +31,7 @@ namespace ResetOutofstock
//daily.ResetFbaExtendSales(DateTime.Now); //daily.ResetFbaExtendSales(DateTime.Now);
//dc_base_mother_sku_dao.SynchroCalculationTurnOver(); //dc_base_mother_sku_dao.SynchroCalculationTurnOver();
//dc_base_mother_sku_dao.ResetTurnOver("945188402", "MMDUSFBA"); //dc_base_mother_sku_dao.ResetTurnOver("M-352984501", "GBFBABLA");
//dc_base_transfer_extend_dao.SynchroLmsTransferOrder(); //dc_base_transfer_extend_dao.SynchroLmsTransferOrder();
//dc_base_full_link_wait_order_dao.ResetDatas(); //dc_base_full_link_wait_order_dao.ResetDatas();
//dc_base_mother_sku_dao.GenerateData(); //dc_base_mother_sku_dao.GenerateData();
......
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