Commit bcc5d15b by 泽锋 李

新增调拨计划的推送服务

parent fc9ac37c
...@@ -193,5 +193,43 @@ where t2.hq_type in ('海外仓','第三方仓') and t1.warehouse_code in @wareh ...@@ -193,5 +193,43 @@ where t2.hq_type in ('海外仓','第三方仓') and t1.warehouse_code in @wareh
return original_datas; return original_datas;
} }
/// <summary>
/// 推送调拨计划
/// </summary>
public static void PustTransferPlan()
{
// 查询所有待推送的计划
var plans = _connection.Query<dc_sys_allot_plan>($@" select t1.* from dc_sys_allot_plan as t1
left join dc_base_stock as t2 on t1.bailun_sku =t2.bailun_sku and t1.warehouse_code_from = t2.warehouse_code
where t1.`status`='待推送' and t2.usable_stock>=t1.question ").ToList();
if(plans!=null && plans.Count >= 1)
{
var groupList = plans.GroupBy(s => new { s.warehouse_code_from, s.warehouse_code_to }).ToList();
foreach (var item in groupList)
{
try
{
ApiUtility.AimsCreateAllotSchedule(new Models.ApiDto.AimsCreateAllotScheduleRequestDto {
TargetWareNo = item.Key.warehouse_code_to,
SourceWareNo = item.Key.warehouse_code_from
});
_connection.Execute(" update dc_sys_allot_plan set status='已推送' where id=@ids ", new
{
ids = item.Select(s => s.id).ToList()
});
}
catch (Exception ex)
{
_connection.Execute(" update dc_sys_allot_plan set status='推送失败',error_stack_trace=@error_stack_trace ,error_message=@error_message where id=@ids ", new {
ids = item.Select(s=>s.id).ToList(),
error_message = ex.Message,
error_stack_trace = ex.StackTrace
});
}
}
}
}
} }
} }
...@@ -496,6 +496,28 @@ namespace ResetOutofstock ...@@ -496,6 +496,28 @@ namespace ResetOutofstock
} }
}); });
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
Console.WriteLine($"开始 推送lm的调拨计划,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
lm_dao.PustTransferPlan();
Console.WriteLine($"结束 推送lm的调拨计划,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(60 * 1000);
}
catch (Exception ex)
{
Console.WriteLine(" 推送lm的调拨计划:" + ex.Message);
Console.WriteLine(" 推送lm的调拨计划:" + ex.StackTrace);
}
}
});
......
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