|
- 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<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
- public RecipeReceiveViewModel()
- {
- //Json<LocaPar>.Read();
- Recipes = Json<RemoteRecipeDataColl>.Data.Recipes;
- NewRecipe = new RelayCommand(() =>
- {
- NewRemoteRecipeView NewRemoteRecipe = new NewRemoteRecipeView();
- NewRemoteRecipe.ShowDialog();
- });
- DetailsCommand = new RelayCommand<object>((o) =>
- {
- if (o != null && o is string num)
- {
- ActionManage.GetInstance.Send("CloseRecipeInfosView");
- RecipeInfosView nrv = new RecipeInfosView();
- var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
- ActionManage.GetInstance.Send("RecipeInfo", res);
- nrv.Show();
- MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
- }
- });
- NewSimulateRecipe = new RelayCommand(() =>
- {
- //RawMaterials.Clear();
- ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
- string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
- go:
- string recipeCode = new Random().Next(1000, 9999).ToString();
- foreach (var item in Json<RemoteRecipeDataColl>.Data.Recipes)
- {
- if (item.RecipeCode == recipeCode)
- {
- goto go;
- }
- }
- int trayCode = new Random().Next(1, 3);
- for (int i = 1; i < 16; i++)
- {
- if ( i == 7 || i == 8 || i == 15)
- {
- }
- else
- {
- RawMaterials.Add(new RemoteRecipeRawMaterial()
- {
- RawMaterialName = "原料" + i,
- RawMaterialWeight = new Random().Next(200, 300),
- RawMaterialBarrelNum = (short)new Random().Next(1, 5),
- RawMaterialLocation = i,
- });
- }
- }
- var res = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeCode);
- if (res < 0)
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
- {
- RecipeName = recipeName,
- RecipeCode = recipeCode,
- TrayCode = trayCode,
- RawMaterial = RawMaterials,
- });
- }
-
- });
- ClearAllRecipe = new RelayCommand(() =>
- {
- Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
- });
- }
- public RelayCommand<object> DetailsCommand { get; set; }
-
- public RelayCommand NewSimulateRecipe { get; set; }
- public RelayCommand ClearAllRecipe { get; set; }
- public RelayCommand NewRecipe { get; set; }
- public ObservableCollection<RemoteRecipeData> Recipes { get; set; }
- }
- }
|