diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs index 041e009a..568471d7 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs @@ -1,61 +1,74 @@ -using BPA.Helper; -using Microsoft.Toolkit.Mvvm.ComponentModel; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +//using BPA.Helper; +//using Microsoft.Toolkit.Mvvm.ComponentModel; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class NewRemoteRecipeModel : ObservableObject - { - /// - /// 原料名称 - /// - public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } - private string _mRawMaterialName; +//namespace BPASmartClient.JXJFoodSmallStation.Model +//{ +// public class NewRemoteRecipeModel : ObservableObject +// { +// /// +// /// 原料名称 +// /// +// public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } +// private string _mRawMaterialName; - /// - /// 原料对应的桶号 - /// - public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } - private short _mRawMaterialBarrelNum; +// /// +// /// 原料对应的桶号 +// /// +// public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } +// private short _mRawMaterialBarrelNum; - /// - /// 原料类型 - /// - public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } - private string _mRawMaterialType; +// /// +// /// 原料类型 +// /// +// public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } +// private string _mRawMaterialType; - /// - /// 需要原料重量 - /// - public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } - private float _mRawMaterialWeight; +// /// +// /// 需要原料重量 +// /// +// public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } +// private float _mRawMaterialWeight; - /// - /// 原料对应料仓的位置 - /// - public int RawMaterialLocation - { - get { return _mRawMaterialLocation; } - set - { - _mRawMaterialLocation = value; - if (RawMaterialType == "小料") - { - //Json.Data.BomMaterial - } - else if (RawMaterialType == "粉料") - { +// /// +// /// 原料对应料仓的位置 +// /// +// public int RawMaterialLocation +// { +// get { return _mRawMaterialLocation; } +// set +// { +// _mRawMaterialLocation = value; +// //if (RawMaterialType == "小料") +// //{ +// // var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == value); +// // if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) +// // { +// // var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); +// // if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) +// // { +// // RawMaterialName = temp.MaterialName; +// // } +// // } +// //} +// //else if (RawMaterialType == "粉料") +// //{ +// // var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == value); +// // if (res != null) +// // { +// // RawMaterialName = res.RawMaterialName; +// // } +// //} +// ActionManage.GetInstance.Send("ChangeNotify", this); +// OnPropertyChanged(); +// } +// } +// private int _mRawMaterialLocation; - } - OnPropertyChanged(); - } - } - private int _mRawMaterialLocation; - - } -} +// } +//} diff --git a/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml b/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml index 3bcbb335..425e7e73 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml @@ -246,12 +246,12 @@ Background="#ff0C255F"> - - - - - - + + + + + + + Text="重量(kg)" /> - - - - - - + + + + + + - { this.Close(); }; this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; - ActionManage.GetInstance.CancelRegister("CloseNewRemoteRecipeView"); - ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRemoteRecipeView"); + //ActionManage.GetInstance.CancelRegister("CloseNewRemoteRecipeView"); + ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRemoteRecipeView", true); } - + } } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs index e7ef7ead..6536e92c 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs @@ -12,6 +12,8 @@ using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.UserControls; using System.Diagnostics; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; +using Google.Protobuf.WellKnownTypes; +using Newtonsoft.Json.Linq; namespace BPASmartClient.JXJFoodSmallStation.ViewModel { @@ -20,6 +22,39 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public NewLocalRecipeViewModel() { //ActionManage.GetInstance.CancelRegister("LocalRecipeEdit"); + + //ActionManage.GetInstance.Register(new Action((o) => + //{ + // if (o is NewRemoteRecipeModel nrr) + // { + // var res1 = AllRawMaterial.FirstOrDefault(p => p.Equals(nrr)); + // if (res1 != null) + // { + // if (res1.RawMaterialType == "小料") + // { + // var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == res1.RawMaterialLocation); + // if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) + // { + // var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); + // if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) + // { + // res1.RawMaterialName = temp.MaterialName; + // } + // } + // } + // else if (res1.RawMaterialType == "粉料") + // { + // var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == res1.RawMaterialLocation); + // if (res != null) + // { + // res1.RawMaterialName = res.RawMaterialName; + // } + // } + // } + // } + + //}), "ChangeNotify", true); + ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is RemoteRecipeData rm) @@ -29,19 +64,58 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel TrayNum = rm.TrayCode; foreach (var item in rm.RawMaterial) { - AllRawMaterial.Add(new NewRemoteRecipeModel() + //AllRawMaterial.Add(new RemoteRecipeRawMaterial() + //{ + // RawMaterialType = item.RawMaterialType, + // RawMaterialName = item.RawMaterialName, + // RawMaterialWeight = item.RawMaterialWeight, + // RawMaterialLocation = item.RawMaterialLocation, + // RawMaterialBarrelNum = item.RawMaterialBarrelNum, + //}); + + var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation); + if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) { - RawMaterialType = item.RawMaterialType, - RawMaterialName = item.RawMaterialName, - RawMaterialWeight = item.RawMaterialWeight, - RawMaterialLocation = item.RawMaterialLocation, - RawMaterialBarrelNum = item.RawMaterialBarrelNum, - }); - //AllRawMaterial.Add(item); + var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); + if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) + { + item.RawMaterialName = temp.MaterialName; + } + } + //if (item.RawMaterialType == "小料") + //{ + // var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation); + // if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) + // { + // var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); + // if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) + // { + // item.RawMaterialName = temp.MaterialName; + // } + // } + //} + //else if (item.RawMaterialType == "粉料") + //{ + // var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == item.RawMaterialLocation); + // if (res != null) + // { + // item.RawMaterialName = res.RawMaterialName; + // } + //} + + + AllRawMaterial.Add(item); } foreach (var item1 in rm.WindSend) { - AllRawMaterial.Add(new NewRemoteRecipeModel() + + var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == item1.Location); + if (res != null) + { + item1.RawMaterialName = res.RawMaterialName; + } + + AllRawMaterial.Add(new RemoteRecipeRawMaterial() { RawMaterialType = item1.RawMaterialType, RawMaterialName = item1.RawMaterialName, @@ -52,6 +126,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } } }), "LocalRecipeEdit", true); + + RemoveCommand = new RelayCommand((o) => { var res = AllRawMaterial.FirstOrDefault(p => p.RawMaterialLocation == (int)o); @@ -65,7 +141,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel var res = AllRawMaterial.Where(p => p.RawMaterialType == "小料").ToList(); if (res.Count < MaxRawMaterial) { - AllRawMaterial.Add(new NewRemoteRecipeModel() + AllRawMaterial.Add(new RemoteRecipeRawMaterial() { RawMaterialType = "小料", RawMaterialName = "小料" + (res.Count + 1), @@ -86,7 +162,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel var res = AllRawMaterial.Where(p => p.RawMaterialType == "粉料").ToList(); if (res.Count < MaxRawMaterial) { - AllRawMaterial.Add(new NewRemoteRecipeModel() + AllRawMaterial.Add(new RemoteRecipeRawMaterial() { RawMaterialType = "粉料", RawMaterialName = "粉料" + (res.Count + 1), @@ -228,8 +304,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } private string _mErrorInfo; - //public ObservableCollection AllRawMaterial { get; set; } = new ObservableCollection(); - public ObservableCollection AllRawMaterial { get; set; } = new ObservableCollection(); + public ObservableCollection AllRawMaterial { get; set; } = new ObservableCollection(); + //public ObservableCollection AllRawMaterial { get; set; } = new ObservableCollection(); diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs index 04c7f34e..58f497a6 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs @@ -31,7 +31,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel IsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; IsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseWindSend; Recipes = Json.Data.Recipes; - + NewRecipe = new RelayCommand(() => { NewLocalRecipeView NewLocalRecipe = new NewLocalRecipeView(); @@ -53,13 +53,13 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (o != null && o is string cnt) { - ActionManage.GetInstance.Send("CloseNewRemoteRecipeView"); + //ActionManage.GetInstance.Send("CloseNewRemoteRecipeView"); NewLocalRecipeView nrv = new NewLocalRecipeView(); var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); if (res != null) { ActionManage.GetInstance.Send("LocalRecipeEdit", res); - nrv.Show(); + nrv.ShowDialog(); MessageNotify.GetInstance.ShowUserLog($"编辑配方——{res.RecipeName}"); } } @@ -77,12 +77,12 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); var res1 = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); - if (res1 != null) + if (res1 != null) { NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"远程已经存在该配方!"); return; } - if (res != null && res1 ==null) + if (res != null && res1 == null) { ActionManage.GetInstance.Send("LocalSimulationRecipeIssue", res); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{res.RecipeName}配方下发成功!"); @@ -93,7 +93,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel }); NewSimulateRecipe = new RelayCommand(() => { - ObservableCollection RawMaterials = new ObservableCollection(); + ObservableCollection RawMaterials = new ObservableCollection(); string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; go: string recipeCode = new Random().Next(1000, 9999).ToString(); @@ -110,8 +110,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel RawMaterials.Add(new RemoteRecipeRawMaterial() { RawMaterialName = "原料" + i, - RawMaterialType = "小料", - RawMaterialWeight = (float)Math.Round(new Random().Next(200, 300) * 0.001 ,3), + RawMaterialType = "小料", + RawMaterialWeight = (float)Math.Round(new Random().Next(200, 300) * 0.001, 3), RawMaterialBarrelNum = (short)new Random().Next(6, 9), RawMaterialLocation = i, }); @@ -126,7 +126,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel RawMaterialType = "粉料", RawMaterialWeight = new Random().Next(1, 6), RawMaterialLocation = i, - RawMaterialBarrelNum = 3 + RawMaterialBarrelNum = 3 }); } } @@ -143,7 +143,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } }); - ClearAllRecipe = new RelayCommand(() => + ClearAllRecipe = new RelayCommand(() => { Json.Data.Recipes.Clear(); }); @@ -152,16 +152,16 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public bool NotUseSmallDosing { get { return _mNotUseSmallDosing; } set { _mNotUseSmallDosing = value; OnPropertyChanged(); } } private bool _mNotUseSmallDosing; - public bool IsUseLocalRecipe { get { return _mIsUseLocalRecipe; }set { _mIsUseLocalRecipe = value; OnPropertyChanged(); } } - private bool _mIsUseLocalRecipe ; + public bool IsUseLocalRecipe { get { return _mIsUseLocalRecipe; } set { _mIsUseLocalRecipe = value; OnPropertyChanged(); } } + private bool _mIsUseLocalRecipe; - public bool IsUseWindSendDosing { get { return _mIsUseWindSendDosing; } set { _mIsUseWindSendDosing = value;OnPropertyChanged(); } } - private bool _mIsUseWindSendDosing ; + public bool IsUseWindSendDosing { get { return _mIsUseWindSendDosing; } set { _mIsUseWindSendDosing = value; OnPropertyChanged(); } } + private bool _mIsUseWindSendDosing; public RelayCommand DetailsCommand { get; set; } public RelayCommand IssueRecipe { get; set; } public RelayCommand RemoveRecipe { get; set; } - public RelayCommand NewSimulateRecipe { get;set; } + public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } public RelayCommand NewRecipe { get; set; } public ObservableCollection Recipes { get; set; }