From 937e5b140af2cb5d249fd3c525abb15a989ef3f9 Mon Sep 17 00:00:00 2001 From: ZhaoGang <15196688790@163.com> Date: Tue, 4 Jul 2023 09:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8F=91=E9=85=8D=E6=96=B9=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=89=A9=E6=96=99=E6=9F=A5=E6=89=BE=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/RecipeManageViewModel.cs | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) 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}成功!"); }