diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs index 8e4c8d2a..625a964d 100644 --- a/BPASmartClient.MorkS/Control_Morks.cs +++ b/BPASmartClient.MorkS/Control_Morks.cs @@ -330,7 +330,7 @@ namespace BPASmartClient.MorkS if (@event == null) return; if (@event is DoOrderEvent order) { - mORKS.doOrderEvents.Add(order); + //mORKS.doOrderEvents.Add(order); mORKS.doe.TryAdd(order.MorkOrder.SuborderId, order); DeviceProcessLogShow($"接收到{order.MorkOrder.SortNum}号订单"); if (order.MorkOrder.GoodBatchings == null) return; diff --git a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs index 6a26a374..715f43dc 100644 --- a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs +++ b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs @@ -128,51 +128,109 @@ namespace BPASmartClient.MorkSUpgradedVer private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) { - var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); + + + //var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); string goodName = string.Empty; string SortNum = string.Empty; - if (res != null) - { - goodName = res.MorkOrder.GoodsName; - SortNum = res.MorkOrder.SortNum.ToString(); - } + //if (res != null) + //{ + // goodName = res.MorkOrder.GoodsName; + // SortNum = res.MorkOrder.SortNum.ToString(); + //} - EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); - - var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); - if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + if (mORKS.doe.ContainsKey(subid)) { - if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + goodName = mORKS.doe[subid].MorkOrder.GoodsName; + SortNum = mORKS.doe[subid].MorkOrder.SortNum.ToString(); + if (!string.IsNullOrEmpty(goodName) && !string.IsNullOrEmpty(SortNum)) { - DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); - DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) { - Status = oRDER_STATUS, - GoodName = goodName, - SortNum = SortNum, - StopTime = DateTime.Now.ToString("HH:mm:ss") - }); - } - else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) - { - var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); - if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); - } - else - { - DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + { + DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StopTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + { + var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + } + else + { + DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + } + } + else + { + DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StartTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + mORKS.doe.Remove(subid, out _); } } - else - { - DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() - { - Status = oRDER_STATUS, - GoodName = goodName, - SortNum = SortNum, - StartTime = DateTime.Now.ToString("HH:mm:ss") - }); - } + + + + //var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); + //string goodName = string.Empty; + //string SortNum = string.Empty; + //if (res != null) + //{ + // goodName = res.MorkOrder.GoodsName; + // SortNum = res.MorkOrder.SortNum.ToString(); + //} + + //EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + + //var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + //if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + //{ + // if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + // { + // DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + // DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + // { + // Status = oRDER_STATUS, + // GoodName = goodName, + // SortNum = SortNum, + // StopTime = DateTime.Now.ToString("HH:mm:ss") + // }); + // } + // else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + // { + // var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + // if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + // } + // else + // { + // DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + // } + //} + //else + //{ + // DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + // { + // Status = oRDER_STATUS, + // GoodName = goodName, + // SortNum = SortNum, + // StartTime = DateTime.Now.ToString("HH:mm:ss") + // }); + //} } private void GetStatus(string key, Action action) @@ -342,7 +400,8 @@ namespace BPASmartClient.MorkSUpgradedVer if (@event == null) return; if (@event is DoOrderEvent order) { - mORKS.doOrderEvents.Add(order); + //mORKS.doOrderEvents.Add(order); + mORKS.doe.TryAdd(order.MorkOrder.SuborderId, order); if (order.MorkOrder.GoodBatchings == null) return; if (mORKS.HistorySuborderId.Contains(order.MorkOrder.SuborderId)) return; OrderCount++; diff --git a/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs b/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs index 7060f697..72a1f0b9 100644 --- a/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs +++ b/BPASmartClient.MorkSUpgradedVer/GVL_MorkSUpgradedVer.cs @@ -106,6 +106,8 @@ namespace BPASmartClient.MorkSUpgradedVer public List doOrderEvents { get; set; } = new List(); + public ConcurrentDictionary doe { get; set; } = new ConcurrentDictionary(); + public List HistorySuborderId { get; set; } = new List(); public NoodleShidModel[] nsm { get; set; } = new NoodleShidModel[6] { new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel(), new NoodleShidModel() };