@@ -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 | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
//namespace BPASmartClient.JXJFoodSmallStation.Model | |||
//{ | |||
// public class NewRemoteRecipeModel : ObservableObject | |||
// { | |||
// /// <summary> | |||
// /// 原料名称 | |||
// /// </summary> | |||
// public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
// private string _mRawMaterialName; | |||
/// <summary> | |||
/// 原料对应的桶号 | |||
/// </summary> | |||
public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } | |||
private short _mRawMaterialBarrelNum; | |||
// /// <summary> | |||
// /// 原料对应的桶号 | |||
// /// </summary> | |||
// public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } | |||
// private short _mRawMaterialBarrelNum; | |||
/// <summary> | |||
/// 原料类型 | |||
/// </summary> | |||
public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialType; | |||
// /// <summary> | |||
// /// 原料类型 | |||
// /// </summary> | |||
// public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } | |||
// private string _mRawMaterialType; | |||
/// <summary> | |||
/// 需要原料重量 | |||
/// </summary> | |||
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||
private float _mRawMaterialWeight; | |||
// /// <summary> | |||
// /// 需要原料重量 | |||
// /// </summary> | |||
// public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||
// private float _mRawMaterialWeight; | |||
/// <summary> | |||
/// 原料对应料仓的位置 | |||
/// </summary> | |||
public int RawMaterialLocation | |||
{ | |||
get { return _mRawMaterialLocation; } | |||
set | |||
{ | |||
_mRawMaterialLocation = value; | |||
if (RawMaterialType == "小料") | |||
{ | |||
//Json<DevicePar>.Data.BomMaterial | |||
} | |||
else if (RawMaterialType == "粉料") | |||
{ | |||
// /// <summary> | |||
// /// 原料对应料仓的位置 | |||
// /// </summary> | |||
// public int RawMaterialLocation | |||
// { | |||
// get { return _mRawMaterialLocation; } | |||
// set | |||
// { | |||
// _mRawMaterialLocation = value; | |||
// //if (RawMaterialType == "小料") | |||
// //{ | |||
// // var res = Json<DevicePar>.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == value); | |||
// // if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) | |||
// // { | |||
// // var temp = Json<DevicePar>.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); | |||
// // if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) | |||
// // { | |||
// // RawMaterialName = temp.MaterialName; | |||
// // } | |||
// // } | |||
// //} | |||
// //else if (RawMaterialType == "粉料") | |||
// //{ | |||
// // var res = Json<DevicePar>.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; | |||
} | |||
} | |||
// } | |||
//} |
@@ -246,12 +246,12 @@ | |||
Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition Width="1*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
@@ -281,7 +281,7 @@ | |||
Grid.Column="4" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Text="原料重量(kg)" /> | |||
Text="重量(kg)" /> | |||
<TextBlock | |||
Grid.Column="5" | |||
@@ -315,15 +315,14 @@ | |||
<DataTemplate> | |||
<Grid Name="gr"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.4*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
FontFamily="楷体" | |||
@@ -26,10 +26,10 @@ namespace BPASmartClient.JXJFoodSmallStation.View | |||
InitializeComponent(); | |||
this.Close.Click += (o, e) => { 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); | |||
} | |||
} | |||
} |
@@ -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<object>((o) => | |||
//{ | |||
// if (o is NewRemoteRecipeModel nrr) | |||
// { | |||
// var res1 = AllRawMaterial.FirstOrDefault(p => p.Equals(nrr)); | |||
// if (res1 != null) | |||
// { | |||
// if (res1.RawMaterialType == "小料") | |||
// { | |||
// var res = Json<DevicePar>.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == res1.RawMaterialLocation); | |||
// if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) | |||
// { | |||
// var temp = Json<DevicePar>.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<DevicePar>.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == res1.RawMaterialLocation); | |||
// if (res != null) | |||
// { | |||
// res1.RawMaterialName = res.RawMaterialName; | |||
// } | |||
// } | |||
// } | |||
// } | |||
//}), "ChangeNotify", true); | |||
ActionManage.GetInstance.Register(new Action<object>((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<DevicePar>.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<DevicePar>.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<DevicePar>.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation); | |||
// if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) | |||
// { | |||
// var temp = Json<DevicePar>.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<DevicePar>.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<DevicePar>.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<object>((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<RemoteRecipeRawMaterial> AllRawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
public ObservableCollection<NewRemoteRecipeModel> AllRawMaterial { get; set; } = new ObservableCollection<NewRemoteRecipeModel>(); | |||
public ObservableCollection<RemoteRecipeRawMaterial> AllRawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
//public ObservableCollection<NewRemoteRecipeModel> AllRawMaterial { get; set; } = new ObservableCollection<NewRemoteRecipeModel>(); | |||
@@ -31,7 +31,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
IsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; | |||
IsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseWindSend; | |||
Recipes = Json<LocalRecipeDataColl>.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<LocalRecipeDataColl>.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<LocalRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); | |||
var res1 = Json<RemoteRecipeDataColl>.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<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
string recipeName = "配方" + (Json<LocalRecipeDataColl>.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<LocalRecipeDataColl>.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<object> DetailsCommand { get; set; } | |||
public RelayCommand<object> IssueRecipe { get; set; } | |||
public RelayCommand<object> 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<RemoteRecipeData> Recipes { get; set; } | |||