diff --git a/BPASmartClient.MorkS/Control.cs b/BPASmartClient.MorkS/Control.cs index 3bf80358..f847d89a 100644 --- a/BPASmartClient.MorkS/Control.cs +++ b/BPASmartClient.MorkS/Control.cs @@ -153,43 +153,88 @@ namespace BPASmartClient.MorkS /// public void DataParse(T order) { - OrderCount++; - MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); - if (order is MorkOrderPush morkOrderPush) - { - foreach (var item in morkOrderPush.GoodBatchings) - { - //var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); - var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); - if (res != null) - { - if (ushort.TryParse(res.BatchingLoc, out ushort loc)) - { - if (loc >= 1 && loc <= 5) - { - if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) - mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId }); - } - else if (loc >= 10 && loc <= 11) - { - int index = 0; - if (recipeBoms != null) - { - index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); - index++; - } - if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) - mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() - { - Loc = ushort.Parse(res.BatchingLoc), - SuborderId = morkOrderPush.SuborderId, - RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 - }); - } - } - } - } - } + + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + OrderCount++; + MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); + foreach (var item in order.MorkOrder.GoodBatchings) + { + //var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + if (res != null) + { + if (ushort.TryParse(res.BatchingLoc, out ushort loc)) + { + if (loc >= 1 && loc <= 5) + { + if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId }); + } + else if (loc >= 10 && loc <= 11) + { + int index = 0; + if (recipeBoms != null) + { + index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId); + index++; + } + if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() + { + Loc = ushort.Parse(res.BatchingLoc), + SuborderId = order.MorkOrder.SuborderId, + RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 + }); + } + } + } + } + } + }); + + + + + + //if (order is MorkOrderPush morkOrderPush) + //{ + // foreach (var item in morkOrderPush.GoodBatchings) + // { + // //var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + // var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + // if (res != null) + // { + // if (ushort.TryParse(res.BatchingLoc, out ushort loc)) + // { + // if (loc >= 1 && loc <= 5) + // { + // if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) + // mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId }); + // } + // else if (loc >= 10 && loc <= 11) + // { + // int index = 0; + // if (recipeBoms != null) + // { + // index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); + // index++; + // } + // if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) + // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() + // { + // Loc = ushort.Parse(res.BatchingLoc), + // SuborderId = morkOrderPush.SuborderId, + // RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 + // }); + // } + // } + // } + // } + //} } @@ -199,6 +244,7 @@ namespace BPASmartClient.MorkS ThreadManage.GetInstance().StartLong(new Action(() => { mORKS.AllowRun = mORKS.InitComplete; + IsHealth = mORKS.Error && mORKS.InitComplete; //GeneralConfig.Healthy = mORKS.Error && mORKS.InitComplete && !GeneralConfig.EnableLocalSimOrder; TakeBowlTask();