Commit 03f72674 by 泽锋 李

fix 临时补空运的单,不能永久改变sku的调拨配置

parent a76981fe
...@@ -42,8 +42,9 @@ namespace AutoTurnOver.DB ...@@ -42,8 +42,9 @@ namespace AutoTurnOver.DB
/// <summary> /// <summary>
/// 切换物流商 /// 切换物流商
/// </summary> /// </summary>
public static void ReplaceLogistics(DateTime date, string bailun_sku = null, string warehouse_code = null) public static List<dc_auto_replace_logistics_task> ReplaceLogistics(DateTime date, string bailun_sku = null, string warehouse_code = null)
{ {
List<dc_auto_replace_logistics_task> cahnge_datas = new List<dc_auto_replace_logistics_task>();
Console.WriteLine("查询需要切换的数据"); Console.WriteLine("查询需要切换的数据");
// 查询需要切换的数据 // 查询需要切换的数据
List<replace_logistics_outofstock_dto> ouDatas = GetOutOfStock(date, bailun_sku, warehouse_code); List<replace_logistics_outofstock_dto> ouDatas = GetOutOfStock(date, bailun_sku, warehouse_code);
...@@ -90,76 +91,7 @@ namespace AutoTurnOver.DB ...@@ -90,76 +91,7 @@ namespace AutoTurnOver.DB
} }
remarks += $" \n 默认时效 调拨天数: {item.transfer_delivery} , 入库天数:{item.abroad_inbound_delivery} 预计入库:{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(item.transfer_delivery) + (int)Math.Round(item.abroad_inbound_delivery, 0)).ToString("yyyy-MM-dd")}"; remarks += $" \n 默认时效 调拨天数: {item.transfer_delivery} , 入库天数:{item.abroad_inbound_delivery} 预计入库:{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(item.transfer_delivery) + (int)Math.Round(item.abroad_inbound_delivery, 0)).ToString("yyyy-MM-dd")}";
remarks += $" \n 当前推荐物流平均时效 调拨天数: {Math.Round(selectItem.avg_sign_days)} , 入库天数:{Math.Round(selectItem.avg_put_days.Value, 0)} \n 预计入库 :{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(selectItem.avg_sign_days) + (int)Math.Round(selectItem.avg_put_days.Value, 0)).ToString("yyyy-MM-dd")} "; remarks += $" \n 当前推荐物流平均时效 调拨天数: {Math.Round(selectItem.avg_sign_days)} , 入库天数:{Math.Round(selectItem.avg_put_days.Value, 0)} \n 预计入库 :{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(selectItem.avg_sign_days) + (int)Math.Round(selectItem.avg_put_days.Value, 0)).ToString("yyyy-MM-dd")} ";
var item_task = new dc_auto_replace_logistics_task
// 写入调拨历史值
dc_average_warehouse aveData = new dc_average_warehouse
{
warehouse_code = item.warehouse_code,
abroad_inbound_delivery = item.abroad_inbound_delivery,
bailun_sku = item.bailun_sku,
inbound_days = 0,
transfer_bale_delivery = item.transfer_bale_delivery,
transfer_delivery = item.transfer_delivery,
transfer_type_1_days = 0,
transfer_type_2_days = 0,
update_time = DateTime.Now
};
var oldData = _connection.QuerySingleOrDefault<dc_average_warehouse>(" select * from dc_average_warehouse where warehouse_code=@warehouse_code and bailun_sku=@bailun_sku ", new
{
warehouse_code = item.warehouse_code,
bailun_sku = item.bailun_sku
});
if (oldData != null)
{
aveData.inbound_days = oldData.inbound_days;
aveData.ID = oldData.ID;
}
if (aveData.ID > 0)
{
_connection.Update(aveData);
}
else
{
_connection.Insert(aveData);
}
//重新写入取数来源
// 查询该渠道历史单
var lmsAvg = ApiUtility.GetLmsAvgOrderTransferList(new Models.ApiDto.api_lms_order_transfer_sku_requst_dto
{
logistics_code = selectItem.logistics_code,
country = item.country_code
});
// 清空记录,重新记录数据源
_connection.Execute(" delete from dc_base_order_data_source where bailun_sku_warehouse_code=@bailun_sku_warehouse_code and order_type=@order_type ", new
{
bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}",
order_type = "调拨单-平均天数计算"
});
if (lmsAvg != null && lmsAvg.Count >= 1)
{
foreach (var itemLms in lmsAvg)
{
_connection.Insert(new dc_base_order_data_source
{
bailun_sku = item.bailun_sku,
warehouse_code = item.warehouse_code,
logistics_code = itemLms.logistics_code,
bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}",
bale_days = 1,
logistics_name = itemLms.logistics_name,
order_no = itemLms.order_no,
order_type = "调拨单-平均天数计算",
put_days = itemLms.put_days,
sign_days = itemLms.sign_days,
transport_type = itemLms.transport_type
});
}
}
_connection.Insert(new dc_auto_replace_logistics_task
{ {
bailun_sku = item.bailun_sku, bailun_sku = item.bailun_sku,
abroad_inbound_delivery = selectItem.avg_put_days.Value, abroad_inbound_delivery = selectItem.avg_put_days.Value,
...@@ -178,7 +110,10 @@ namespace AutoTurnOver.DB ...@@ -178,7 +110,10 @@ namespace AutoTurnOver.DB
logistics_name = selectItem.logistics_name, logistics_name = selectItem.logistics_name,
transport_type = selectItem.transport_type, transport_type = selectItem.transport_type,
remarks = remarks, remarks = remarks,
}); };
cahnge_datas.Add(item_task);
_connection.Insert(item_task);
} }
} }
} }
...@@ -197,7 +132,7 @@ namespace AutoTurnOver.DB ...@@ -197,7 +132,7 @@ namespace AutoTurnOver.DB
} }
return cahnge_datas;
} }
/// <summary> /// <summary>
......
...@@ -22,10 +22,10 @@ namespace AutoTurnOver.Services ...@@ -22,10 +22,10 @@ namespace AutoTurnOver.Services
try try
{ {
// 检查是否有可以切换渠道的sku // 检查是否有可以切换渠道的sku
purchase_advise.ReplaceLogistics(date); var change_datas = purchase_advise.ReplaceLogistics(date);
//等待后台重算任务 //等待后台重算任务
purchase_advise.WaitReplaceLogisticsTask(); purchase_advise.WaitReplaceLogisticsTask();
// 创建一个采购计划 // 创建一个采购计划
var mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo() ,buy_sys_plan_no = "Generate", title = title }); var mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo() ,buy_sys_plan_no = "Generate", title = title });
...@@ -33,6 +33,24 @@ namespace AutoTurnOver.Services ...@@ -33,6 +33,24 @@ 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)
{
foreach (var item in change_datas)
{
MyMySqlConnection._connection.Insert(new dc_base_queue
{
submit_date = DateTime.Now,
error_message = "",
consume_date = null,
error_stack_trace = "",
message = new { bailun_sku = item.bailun_sku, warehouse_code = item.warehouse_code }.ToJson(),
type = "刷新周转表",
remarks = "配置预测销量"
});
}
}
if (is_bak) if (is_bak)
{ {
dc_task_download_dao.PushData<dc_base_stock_search_dto>(new dc_task_download dc_task_download_dao.PushData<dc_base_stock_search_dto>(new dc_task_download
......
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