using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.Concurrent; using System.Collections.ObjectModel; using System.Windows; using BPASmartClient.Helper; using Microsoft.Toolkit.Mvvm.Input; using BPASmartClient.JXJFoodSmallStation.Model; using BPASmartClient.JXJFoodSmallStation.View; using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.Model; using BPASmartClient.CustomResource.UserControls.Enum; using System.Windows.Media; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public class RecipeReceiveViewModel : ObservableObject { ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); public RecipeReceiveViewModel() { //Json.Read(); Recipes = Json.Data.Recipes; DetailsCommand = new RelayCommand((o) => { if (o != null && o is long num) { ActionManage.GetInstance.CancelRegister("RecipeInfo"); RecipeInfosView nrv = new RecipeInfosView(); var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num); ActionManage.GetInstance.Send("RecipeInfo", res); nrv.Show(); MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}"); } }); NewSimulateRecipe = new RelayCommand(() => { RawMaterials.Clear(); string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; go: long recipeCode = new Random().Next(1000, 9999); foreach (var item in Recipes) { if (item.RecipeCode == recipeCode) { goto go; } } int trayCode = new Random().Next(1, 3); for (int i = 1; i < 16; i++) { RawMaterials.Add(new RemoteRecipeRawMaterial() { RawMaterialWeight = new Random().Next(10, 1000), RawMaterialBarrelNum = new Random().Next(1, 3), RawMaterialLocation = i, }); } Json.Data.Recipes.Add(new RemoteRecipeData() { RecipeName = recipeName, RecipeCode = recipeCode, TrayCode = trayCode, RawMaterial = RawMaterials, }); }); ClearAllRecipe = new RelayCommand(() => { Json.Data.Recipes.Clear(); }); } public RelayCommand DetailsCommand { get; set; } public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } public ObservableCollection Recipes { get; set; } } }