diff --git a/BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs b/BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs index 6ccdaaa2..f3607aaf 100644 --- a/BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs +++ b/BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs @@ -2,6 +2,7 @@ using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.MorkCL.Model.Json; +using BPASmartClient.MorkCL.Server; using Newtonsoft.Json; namespace BPASmartClient.MorkCL.ViewModel @@ -50,14 +51,58 @@ namespace BPASmartClient.MorkCL.ViewModel }); IssueCommand = new((o) => { - //参数为ControlData,可能需要转换。 - if (MessageNotify.GetInstance.ShowDialog("请确认,是否下发订单?")) + //参数为ControlData,可能需要转换。 + if (MessageNotify.GetInstance.ShowDialog("请确认,是否下发订单?")) + { + if (o != null && o is ControlData) { - if (o != null && o is ControlData) + var jsonString = o.ToJSON(); + var data = JsonConvert.DeserializeObject(jsonString); + #region 查询主料,调料,辅料是否在信息中。 + foreach (var item in data.ControlFuncs) { - var jsonString = o.ToJSON(); - var data= JsonConvert.DeserializeObject(jsonString); - + switch (item.eFunc) + { + case EFunc.搅拌启动: + case EFunc.搅拌停止: + case EFunc.加热启动: + case EFunc.加热停止: + case EFunc.炒锅回原点位: + case EFunc.出餐启动: + case EFunc.炒锅清洗: + case EFunc.炒锅回调料投料位置: + case EFunc.去指定炒制位: + case EFunc.炒制: + break; + case EFunc.添加主料: + var Id = item.funcPars[0].Id; + var weight = (float)(item.funcPars[1].ParValue); + if (!Json.Data.IngredientsStorage.Any(i => i.MaterialID == Id && i.Weight ==weight)) + { + MessageNotify.GetInstance.ShowDialog($"未在主料库查找到配方所需的主料【{Id}】,下发失败。",DialogType.Error); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, Application.Current.MainWindow, "提示", $"下发订单{data.Name}失败!"); + return; + } + break; + case EFunc.添加辅料: + if (SqliteHelper.GetInstance.GetAccessoriesInfo(item.funcPars[0].Id)==null) + { + MessageNotify.GetInstance.ShowDialog($"未在辅料信息查找到配方所需的辅料【{item.funcPars[0].Id}】,下发失败。", DialogType.Error); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, Application.Current.MainWindow, "提示", $"下发订单{data.Name}失败!"); + return; + } + break; + case EFunc.添加调料: + if (SqliteHelper.GetInstance.GetSeasoningInfo(item.funcPars[0].Id) == null) + { + MessageNotify.GetInstance.ShowDialog($"未在调料信息查找到配方所需的调料【{item.funcPars[0].Id}】,下发失败。", DialogType.Error); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, Application.Current.MainWindow, "提示", $"下发订单{data.Name}失败!"); + return; + } + break; + } + } + #endregion ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, data); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"下发订单{data.Name}成功!"); }