From c21afa9642eef4f04fb92044bc627929a16ac15b Mon Sep 17 00:00:00 2001 From: yahaha Date: Sat, 24 Dec 2022 10:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=80=E5=8D=8E=E8=B0=83=E8=AF=95=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Business/Plugin/StatusMgr.cs | 2 + BPASmartClient.Device/BaseDevice.cs | 6 + BPASmartClient.Device/IDevice.cs | 6 + BPASmartClient.MorkF/Control_MorkF.cs | 416 +++++++++++++----- BPASmartClient.MorkF/Model/MaterialSurplus.cs | 22 +- BPASmartClient.MorkF/View/DebugView.xaml | 1 + BPASmartClient.MorkF/View/DebugView.xaml.cs | 2 +- BPASmartClient.MorkF/View/LocalMenu.xaml | 13 +- BPASmartClient.MorkF/View/LocalMenu.xaml.cs | 15 +- .../ViewModel/DebugViewModel.cs | 16 +- .../ViewModel/LocalMenuViewModel.cs | 144 +++++- 11 files changed, 500 insertions(+), 143 deletions(-) diff --git a/BPASmartClient.Business/Plugin/StatusMgr.cs b/BPASmartClient.Business/Plugin/StatusMgr.cs index cedb1ddc..d5295377 100644 --- a/BPASmartClient.Business/Plugin/StatusMgr.cs +++ b/BPASmartClient.Business/Plugin/StatusMgr.cs @@ -56,8 +56,10 @@ namespace BPASmartClient.Business foreach (var device in deviceMgr.GetDevices()) { wholeDeviceStatus[device.DeviceId] = device.Status.GetStatus(); + deviceStatus.Healthy = device.IsHealth ? BPA.Message.Enum.DeviceHealthy.Health : BPA.Message.Enum.DeviceHealthy.UnHealth; deviceStatus.DeviceType = device.DeviceType; + deviceStatus.BatchingInfo = device.BatchingInfos; var msg = BPAPackage.Make(deviceStatus, device.DeviceId, device.DeviceType); mqttMgr.Publish(TopicDefine.GetInstance().PushHeartbeatTopics[device.DeviceType], msg.Serialize()); } diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 1fba0596..dfb1b7ff 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -15,6 +15,7 @@ using System.Threading.Tasks; using System.Collections.ObjectModel; using BPASmartClient.Model.单片机; using BPASmartClient.EventBus; +using BPA.Models; namespace BPASmartClient.Device { @@ -88,6 +89,11 @@ namespace BPASmartClient.Device /// public List Error { get; set; } = new List(); + /// + /// mork_F暂用余量列表 + /// + public List BatchingInfos { get; set; } = new List(); + /// /// 设备变量监控 /// diff --git a/BPASmartClient.Device/IDevice.cs b/BPASmartClient.Device/IDevice.cs index ccafbe3a..2fd0dcdd 100644 --- a/BPASmartClient.Device/IDevice.cs +++ b/BPASmartClient.Device/IDevice.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; +using BPA.Models; namespace BPASmartClient.Device { @@ -53,6 +54,10 @@ namespace BPASmartClient.Device /// public List Error { get; set; } /// + /// mork_F暂用余量列表 + /// + public List BatchingInfos { get; set; } + /// /// 设备变量信息 /// ObservableCollection variableMonitors { get; set; } @@ -116,6 +121,7 @@ namespace BPASmartClient.Device /// object GetPropertyValue(object info, string field); + Action AddErrorAction { get; set; } Action DeleteErrorAction { get; set; } } diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index ad4e78eb..6093e261 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -15,6 +15,7 @@ using System.Collections.Concurrent; using System.Windows.Documents; using BPASmartClient.Business; using Microsoft.CodeAnalysis; +using BPASmartClient.MorkF.ViewModel; namespace BPASmartClient.MorkF { @@ -95,6 +96,16 @@ namespace BPASmartClient.MorkF public AutoResetEvent minorReset = new AutoResetEvent(false); public AutoResetEvent mainReset = new AutoResetEvent(false); + /// + /// 等待炒制数量 + /// + private int StagingFryCount { get; set; } + + /// + /// 正在炒制数量 + /// + private int FryingCount { get; set; } + /// /// 炒锅编号与炒锅实例 /// @@ -141,6 +152,17 @@ namespace BPASmartClient.MorkF /// /// private List statsModels = new List(); + + /// + /// 暂存使用菜品量 + /// + private List stagingGoodBatchings = new List(); + + /// + /// 是否为本地炒菜模式,默认为联网的 + /// + private bool isLocalFryingMode { get; set; } = false; + /// /// 入口 /// @@ -162,6 +184,9 @@ namespace BPASmartClient.MorkF Task2ReadMaterialData(); ScreenDataServer(); + Json.Read(); + //更新菜品余量 + UpdateMaterialSurplus(); //读取坐标系 MaterialCoordinate materialCoordinate = ReadMaterialCoordinate(); @@ -194,6 +219,7 @@ namespace BPASmartClient.MorkF MainProcessMaterial(); //MinorProcessExcute(); //SingleProcess(); + } private static object saveMaterialLock = new object(); @@ -256,12 +282,12 @@ namespace BPASmartClient.MorkF { if (isInitialArrive == false) { - MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); + //MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); isInitialArrive = true; } else { - MessageLog.GetInstance.Show("到达上升沿为true"); + //MessageLog.GetInstance.Show("到达上升沿为true"); ml_morkf.ArriveComplete = true; isInitialArrive = true; } @@ -361,6 +387,13 @@ namespace BPASmartClient.MorkF ActionManage.GetInstance.Register(StartOrderMain, "开始下单"); ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder"); ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder"); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o is string materialName) + { + NewStartLocalOrder(materialName); + } + }), "NewStartLocalOrder"); #endregion #region 菜品库 @@ -372,6 +405,10 @@ namespace BPASmartClient.MorkF }), "FoodLibInit"); }), "FoodLibInit"); ActionManage.GetInstance.Register(new Action(() => + { + isLocalFryingMode = !isLocalFryingMode; + }), "ModeChange"); + ActionManage.GetInstance.Register(new Action(() => { ThreadManage.GetInstance().Start(new Action(() => { @@ -705,7 +742,7 @@ namespace BPASmartClient.MorkF private void StartLocalOrder() { - if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 + if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 if (Json.Data.LocalstirFryGoods.StirPotActions.Count > 0) { StirFryGoodsQuenes.Enqueue(new OrderLocInfo() @@ -718,6 +755,43 @@ namespace BPASmartClient.MorkF } } + private void NewStartLocalOrder(string materialName) + { + //if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 + //if (Json.Data.LocalstirFryGoods.StirPotActions.Count > 0) + //{ + // StirFryGoodsQuenes.Enqueue(new OrderLocInfo() + // { + // SuborderId = Guid.NewGuid().ToString(), + // StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions, + // GoodName = "本地菜品" + // }); + // MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); + //} + if (Json.Data.materials.Count > 0) + { + if (!Json.Data.materials.ContainsKey(materialName)) + { + return; + } + + List potActions = new List(); + + foreach(var item in Json.Data.materials[materialName]) + { + potActions.Add(item); + } + + StirFryGoodsQuenes.Enqueue(new OrderLocInfo() + { + SuborderId = Guid.NewGuid().ToString(), + StirPotActions = potActions, + GoodName = materialName + }); + MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); + } + } + /// /// 停止本地菜单炒制 /// @@ -938,7 +1012,7 @@ namespace BPASmartClient.MorkF return false; } - MessageLog.GetInstance.Show("爪子去到1号位"); + //MessageLog.GetInstance.Show("爪子去到1号位"); MaterailLibrary_Write("M1.0", true); Thread.Sleep(500); @@ -955,7 +1029,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(300); - MessageLog.GetInstance.Show("爪子去到1号位完成"); + //MessageLog.GetInstance.Show("爪子去到1号位完成"); return true; } @@ -967,7 +1041,7 @@ namespace BPASmartClient.MorkF return false; } - MessageLog.GetInstance.Show("爪子去到2号位"); + //MessageLog.GetInstance.Show("爪子去到2号位"); MaterailLibrary_Write("M1.1", true); Thread.Sleep(500); @@ -984,7 +1058,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(300); - MessageLog.GetInstance.Show("爪子去到2号位完成"); + //MessageLog.GetInstance.Show("爪子去到2号位完成"); return true; } @@ -996,7 +1070,7 @@ namespace BPASmartClient.MorkF return false; } - MessageLog.GetInstance.Show("爪子去到3号位"); + //MessageLog.GetInstance.Show("爪子去到3号位"); MaterailLibrary_Write("M1.2", true); Thread.Sleep(500); @@ -1013,7 +1087,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(300); - MessageLog.GetInstance.Show("爪子去到3号位完成"); + //MessageLog.GetInstance.Show("爪子去到3号位完成"); return true; } @@ -1029,8 +1103,8 @@ namespace BPASmartClient.MorkF MaterailLibrary_Write("M0.3", false); Thread.Sleep(3000); - MessageLog.GetInstance.Show("1号测距开启完成"); - MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); + //MessageLog.GetInstance.Show("1号测距开启完成"); + //MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); ActionManage.GetInstance.Send("GetDistanceCallBack", new List { "1",ml_morkf.LaserDistance.ToString() });//通知获取测距界面 @@ -1048,8 +1122,8 @@ namespace BPASmartClient.MorkF MaterailLibrary_Write("M0.4", false); Thread.Sleep(3000); - MessageLog.GetInstance.Show("2号测距开启完成"); - MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); + //MessageLog.GetInstance.Show("2号测距开启完成"); + //MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); ActionManage.GetInstance.Send("GetDistanceCallBack", new List { "2", ml_morkf.LaserDistance.ToString() });//通知获取测距界面 @@ -1067,14 +1141,24 @@ namespace BPASmartClient.MorkF MaterailLibrary_Write("M0.5", false); Thread.Sleep(3000); - MessageLog.GetInstance.Show("3号测距开启完成"); - MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); + //MessageLog.GetInstance.Show("3号测距开启完成"); + //MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); ActionManage.GetInstance.Send("GetDistanceCallBack", new List { "3", ml_morkf.LaserDistance.ToString() });//通知获取测距界面 return true; } + /// + /// 写入传感器距离 + /// + /// + public void WriteSpeed(int speed) + { + MaterailLibrary_Write("VD808", speed); + Thread.Sleep(400); + } + /// /// 写入传感器距离 /// @@ -1100,7 +1184,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(400); - //获取传感器1的距离 + ////获取传感器1的距离 ret &= GetDistance_1(); } //是否在第二层菜品库 @@ -1157,7 +1241,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(200); - MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]"); + //MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]"); //到达置为false ml_morkf.ArriveComplete = false; @@ -1183,7 +1267,7 @@ namespace BPASmartClient.MorkF } } - MessageLog.GetInstance.Show("机械臂移动操作完成"); + //MessageLog.GetInstance.Show("机械臂移动操作完成"); Thread.Sleep(500); @@ -1200,7 +1284,7 @@ namespace BPASmartClient.MorkF //取反 x -= 2 * x; y -= 2 * y; - MessageLog.GetInstance.Show($"设置机械臂当前坐标为[{x},{y}]"); + //MessageLog.GetInstance.Show($"设置机械臂当前坐标为[{x},{y}]"); MaterailLibrary_Write("VD828", x); Thread.Sleep(200); MaterailLibrary_Write("VD832", y); @@ -1300,6 +1384,8 @@ namespace BPASmartClient.MorkF return false; } + WriteSpeed(10000); + //关闭电磁阀 Electromagnetism(new List { true }); Thread.Sleep(500); @@ -1357,8 +1443,13 @@ namespace BPASmartClient.MorkF return false; } - //收缩爪子 - PawShrink(); + WriteSpeed(50000); + + ThreadManage.GetInstance().Start(new Action(() => + { + //收缩爪子 + PawShrink(); + }), "GetMaterialPawShrink"); //判断炒锅是否可以放盒 for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++) @@ -1366,7 +1457,7 @@ namespace BPASmartClient.MorkF Thread.Sleep(materialSleepTime); if (i >= materialSleepCount - 1) { - MessageLog.GetInstance.Show("等待炒锅允许放盒超时"); + MessageLog.GetInstance.ShowEx("等待炒锅允许放盒超时"); return false; } } @@ -1616,11 +1707,11 @@ namespace BPASmartClient.MorkF } //盒子高度为45,但是需要考虑到误差,不足35,则认为为空 - int boxCount = heightDifferent / 35; + int boxCount = (heightDifferent + 5) / 35; count = boxCount; if (count == 0) { - MessageLog.GetInstance.Show("菜品库为空"); + MessageLog.GetInstance.ShowEx("菜品库为空"); return Laser2CoordinateState.MaterialEmpty; } else if(count > 6) @@ -1632,47 +1723,6 @@ namespace BPASmartClient.MorkF { return Laser2CoordinateState.MaterialNormal; } - //if (heightDifferent <= 20) - //{ - // MessageLog.GetInstance.ShowEx("错误:菜品量为空"); - // return Laser2CoordinateState.MaterialEmpty; - //} - - ////菜盒放多了 - //if (distance < 6) - //{ - // return Laser2CoordinateState.MaterialOverdo; - //} - //else if (distance >= 6 && distance < 10) - //{ - // count = 5; - // return Laser2CoordinateState.MaterialNormal; - //} - //else if (distance >= 10 && distance < 14) - //{ - // count = 4; - // return Laser2CoordinateState.MaterialNormal; - //} - //else if (distance >= 14 && distance < 19) - //{ - // count = 3; - // return Laser2CoordinateState.MaterialNormal; - //} - //else if (distance >= 19 && distance < 23) - //{ - // count = 2; - // return Laser2CoordinateState.MaterialNormal; - //} - //else if (distance >= 23 && distance < 28) - //{ - // count = 1; - // return Laser2CoordinateState.MaterialNormal; - //} - //else - //{ - // count = 0; - // return Laser2CoordinateState.MaterialEmpty; - //} } catch (Exception ex) { @@ -1697,10 +1747,6 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.ShowEx($"炒锅{materialOperation.fryNum}获取菜品[{materialOperation.materialInfo.Name}]失败,找不到对应位置"); return; } - lock (lock_Materail) - { - ml_morkf.MaterailIsWorking = true; - } //取菜操作 ret = GetMaterail(myCoordinate.X, myCoordinate.Y, materialOperation.fryNum); } @@ -1710,16 +1756,32 @@ namespace BPASmartClient.MorkF } finally { - lock (lock_Materail) + //本地炒制不进行菜品数量检查 + if(!isLocalFryingMode) { - ml_morkf.MaterailIsWorking = false; - } - if (ret == true) - { - //指定位置菜品减一 - MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc); - SaveMaterialData(); + GoodBatchings goodBatchings = stagingGoodBatchings.Find(o => o.BatchingId == materialOperation.materialInfo.Key); + if (ret == true) + { + if (true) + { + if (goodBatchings != null) + { + //指定位置菜品减一 + MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc, goodBatchings.BatchingCount); + } + } + else + { + //指定位置菜品减一 + MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc); + } + + SaveMaterialData(); + } + //移出占用菜品 + stagingGoodBatchings.Remove(goodBatchings); } + ml_morkf.MaterailIsWorking = false; } }), $"菜品库操作"); @@ -1877,6 +1939,7 @@ namespace BPASmartClient.MorkF public bool OutFood(int num,out string error,bool isMaterial = false) { bool ret = true; + error = string.Empty; if (!morkFs.ContainsKey(num)) { @@ -1890,17 +1953,19 @@ namespace BPASmartClient.MorkF if (isMaterial) { //判断是否完成取菜 - for (i = 0; i < materialSleepCount && !morkFs[num].GetMaterialComplete; i++) + for (i = 0; i < materialSleepCount*2 && !morkFs[num].GetMaterialComplete; i++) { if (i == 10) { //停止搅拌 - StopStir(num); + //StopStir(num); + //搅拌设置为1档 + SetStir(new List { 1 }, i); //火力设置为2档 - SetFire(new List { 2 }, num); + SetFire(new List { 1 }, num); } Thread.Sleep(materialSleepTime); - if (i >= materialSleepCount - 1) + if (i >= materialSleepCount * 2 - 1) { error = $"炒锅{num}倒菜超时:未能等到取菜完成,请检查菜品库是否正常运行"; MessageLog.GetInstance.ShowEx($"炒锅{num}倒菜超时:未能等到取菜完成"); @@ -1911,14 +1976,21 @@ namespace BPASmartClient.MorkF if (i > 9) { //开启搅拌 - StartStir(num); + //StartStir(num); + //搅拌设置为原本搅拌档位 + SetStir(new List { morkFs[num].Stir }, i); //火力设置回原本火力 SetFire(new List { morkFs[num].Fire }, num); } } + if(!ret) + { + return ret; + } + FirePot_Write("LB3", true, num); - MessageLog.GetInstance.Show("倒菜启动"); + //MessageLog.GetInstance.Show("倒菜启动"); Thread.Sleep(500); @@ -1935,9 +2007,8 @@ namespace BPASmartClient.MorkF FirePot_Write("LB3", false, num); Thread.Sleep(200); - MessageLog.GetInstance.Show("倒菜完成"); + //MessageLog.GetInstance.Show("倒菜完成"); morkFs[num].GetMaterialComplete = false; - error = string.Empty; return ret; } //搅拌臂去原点位 @@ -1949,7 +2020,7 @@ namespace BPASmartClient.MorkF } FirePot_Write("LB5", true, num); - MessageLog.GetInstance.Show("搅拌臂去原点位"); + //MessageLog.GetInstance.Show("搅拌臂去原点位"); for (int i = 0; i < sleepCount && !morkFs[num].ArmOnOrigin; i++) { @@ -1962,7 +2033,7 @@ namespace BPASmartClient.MorkF FirePot_Write("LB5", false, num); Thread.Sleep(200); - MessageLog.GetInstance.Show("搅拌臂到达原点位"); + //MessageLog.GetInstance.Show("搅拌臂到达原点位"); } //搅拌臂去炒制位 @@ -1979,7 +2050,7 @@ namespace BPASmartClient.MorkF if (!morkFs[num].ArmOnWorking/* && morkFs[num].PotOnOrigin*/) { FirePot_Write("LB6", true, num); - MessageLog.GetInstance.Show("搅拌臂去工作位"); + //MessageLog.GetInstance.Show("搅拌臂去工作位"); for (int i = 0; i < sleepCount && !morkFs[num].ArmOnWorking; i++) { @@ -1999,7 +2070,7 @@ namespace BPASmartClient.MorkF FirePot_Write("LB6", false, num); Thread.Sleep(200); - MessageLog.GetInstance.Show("搅拌臂到达工作位"); + //MessageLog.GetInstance.Show("搅拌臂到达工作位"); return ret; } @@ -2022,7 +2093,7 @@ namespace BPASmartClient.MorkF return; } FirePot_Write("LB4", true, num); - Thread.Sleep(200); + Thread.Sleep(500); FirePot_Write("LB4", false, num); } //加热挡位设定 @@ -2274,7 +2345,7 @@ namespace BPASmartClient.MorkF } /// - /// 数据解析 + /// 订单数据解析 /// private void DataParse() { @@ -2293,24 +2364,65 @@ namespace BPASmartClient.MorkF DeviceProcessLogShow($"接收到{OrderCount}次订单"); Enum.GetNames(typeof(StirFryPotActionEnum)); + if(true) + { + var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.GoodsKey);//匹配订单对应制作流程 if(order.MorkOrder.GoodBatchings.Count <= 0) { return; } - if(order.MorkOrder.DeviceId != DeviceId) + MaterialSurplus materialSurplus = MaterialSurplusOperation.GetInstance().materialSurplus; + + if (order.MorkOrder.DeviceId != DeviceId) { return; } + ///遍历并增加到待用菜品库 + foreach(var goodBatching in order.MorkOrder.GoodBatchings) + { + MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().materialSurplus.dicSurplus.Find( o => o.Key == goodBatching.BatchingId); + if (materialInfo != null) + { + //if + if(Convert.ToInt32(materialInfo.Qty) - goodBatching.BatchingCount < 0) + { + MessageLog.GetInstance.ShowEx($"{materialInfo.Name}不够,请更新菜品库,并点击检测"); + return; + } + else + { + //查找是否有该菜品 + GoodBatchings existingGoodBatchings = stagingGoodBatchings.Find( o => o.BatchingId== goodBatching.BatchingId ); + //判断是否存在 + if (existingGoodBatchings != null) + { + existingGoodBatchings.BatchingCount += goodBatching.BatchingCount; + } + else + { + stagingGoodBatchings.Add(goodBatching); + } + } + } + else + { + MessageLog.GetInstance.ShowEx($"ID为{goodBatching.BatchingId}的菜品无法找到,请联系售后人员"); + return; + } + } + //var res = LocalstirFryGoods[0]; if (res != null) { /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 - //添加到带炒小炒队列 + //添加到带炒小炒队列 if (StirFryGoodsQuenes.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) { + //待炒数量+1 + StagingFryCount++; lock (lock_MainProcessExcute) { StirFryGoodsQuenes.Enqueue(new OrderLocInfo() @@ -2323,6 +2435,11 @@ namespace BPASmartClient.MorkF } } + } + else + { + NewStartLocalOrder("莲白回锅"); + } ////暂时使用本地菜单 //StartLocalOrder(); } @@ -2333,6 +2450,11 @@ namespace BPASmartClient.MorkF private object lock_MainProcessExcute = new object(); + /// + /// 倒菜锁 + /// + private object lock_OutMeal = new object(); + /// /// 炒锅主流程 /// @@ -2344,7 +2466,7 @@ namespace BPASmartClient.MorkF //遍历炒锅,找到合适、空闲的炒锅 for(int i = 0;i + /// 更新菜品库的余量 + /// + private void UpdateMaterialSurplus() + { + ThreadManage.GetInstance().StartLong(new Action(() => { + + List listSurplus = MaterialSurplusOperation.GetInstance().materialSurplus.dicSurplus; + + if (listSurplus == null) + { + return; + } + + foreach (var surplus in listSurplus) + { + //找到已有的余量表 + var batchingInfo = BatchingInfos.Find(o => o.BatchingId == surplus.Key); + //从当前下单 + var stagingGoodBatching = stagingGoodBatchings.Find(o => o.BatchingId == surplus.Key); + + //暂存的数量 + int stagingCount = 0; + + if(stagingGoodBatching != null) + { + stagingCount = stagingGoodBatching.BatchingCount; + } + + if (batchingInfo == null) + { + //为空就新增 + BatchingInfos.Add(new BatchingInfo() { BatchingCount = Convert.ToInt32(surplus.Qty) - stagingCount, BatchingLoc = surplus.Loc, BatchingId = surplus.Key }); + } + else + { + batchingInfo.BatchingLoc = surplus.Loc; + batchingInfo.BatchingCount = Convert.ToInt32(surplus.Qty) - stagingCount; + } + } + Thread.Sleep(1000); + return; + }), "UpdateMaterialSurplus", true); + } + /// /// 菜品库主流程 /// @@ -2633,6 +2812,7 @@ namespace BPASmartClient.MorkF //待菜品库操作列出队列 if (materialOperationQuenes.TryDequeue(out var res)) { + Thread.Sleep(1000); ml_morkf.MaterailIsWorking = true; MessageLog.GetInstance.Show("开始操作菜品库"); @@ -2691,7 +2871,7 @@ namespace BPASmartClient.MorkF LocalMqtt.GetInstance.Publish(maxWok); Thread.Sleep(1000); - }), "大屏数据上报"); + }), "大屏数据上报",true); } diff --git a/BPASmartClient.MorkF/Model/MaterialSurplus.cs b/BPASmartClient.MorkF/Model/MaterialSurplus.cs index dc9d0e18..b75043fd 100644 --- a/BPASmartClient.MorkF/Model/MaterialSurplus.cs +++ b/BPASmartClient.MorkF/Model/MaterialSurplus.cs @@ -116,6 +116,26 @@ namespace BPASmartClient.MorkF } } + /// + /// 余量减少 + /// + /// 菜品位置 + /// 菜品减少数量 + /// + public bool ReduceSurplus(string loc,int count) + { + MaterialInfo materialInfo = materialSurplus.dicSurplus.Find(t => t.Loc == loc); + if (materialInfo != null) + { + materialInfo.Qty -= count; + return true; + } + else + { + return false; + } + } + /// /// 余量增加 /// @@ -192,7 +212,7 @@ namespace BPASmartClient.MorkF /// /// 余量字典,key:菜品库编号,value:余量 /// - public List dicSurplus = new List(); + public List dicSurplus { get; set; } = new List(); //public MaterialSurplus() //{ diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 91d11c4c..186c5233 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -59,6 +59,7 @@