终端一体化运控平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

137 lignes
5.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPASmartClient.Helper;
  11. using Microsoft.Toolkit.Mvvm.Input;
  12. using BPASmartClient.JXJFoodBigStation.Model;
  13. using BPASmartClient.JXJFoodBigStation.View;
  14. using BPASmartClient.CustomResource.UserControls;
  15. using BPASmartClient.CustomResource.UserControls.Model;
  16. using BPASmartClient.CustomResource.UserControls.Enum;
  17. using System.Windows.Media;
  18. using BPASmartClient.CustomResource.UserControls.MessageShow;
  19. using BPASmartClient.CustomResource.Pages.Model;
  20. using BPASmartClient.JXJFoodBigStation.Model.Siemens;
  21. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  22. {
  23. public class RecipeReceiveViewModel : ObservableObject
  24. {
  25. public ObservableCollection<RawMaterial> RawMaterials { get; set; } = new ObservableCollection<RawMaterial>();
  26. public RecipeReceiveViewModel()
  27. {
  28. IsUseLocalRecipe = GVL_BigStation.IsUseLocalRecipe;
  29. Json<LocalRecipe>.Read();
  30. Recipes = Json<LocalRecipe>.Data.Recipes;
  31. DetailsCommand = new RelayCommand<object>((o) =>
  32. {
  33. if (o != null && o is string num)
  34. {
  35. ActionManage.GetInstance.CancelRegister("RecipeInfo");
  36. RecipeInfosView nrv = new RecipeInfosView();
  37. var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
  38. ActionManage.GetInstance.Send("RecipeInfo", res);
  39. nrv.Show();
  40. MessageNotify.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
  41. }
  42. });
  43. NewRecipe = new RelayCommand(() =>
  44. {
  45. RecipeInfosView nrv = new RecipeInfosView();
  46. nrv.ShowDialog();
  47. });
  48. //RefreshRecipe = new RelayCommand(() =>
  49. //{
  50. // foreach (var item in ProcessControl.GetInstance.RawMaterialsInfo)
  51. // {
  52. // RawMaterialNames.Add(item.RawMaterialName);
  53. // }
  54. // foreach (var item in Json<LocalRecipe>.Data.Recipes)
  55. // {
  56. // foreach (var tep in item.RawMaterial)
  57. // {
  58. // if (RawMaterialNames.Contains(tep.RawMaterialName))
  59. // {
  60. // int index = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == tep.RawMaterialName);
  61. // tep.RawMaterialLocation = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialLocation;
  62. // }
  63. // }
  64. // }
  65. //});
  66. //模拟配方
  67. //NewSimulateRecipe = new RelayCommand(() =>
  68. //{
  69. // RawMaterials.Clear();
  70. // string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
  71. //go:
  72. // string recipeCode = new Random().Next(10000, 99999).ToString();
  73. // foreach (var item in Recipes)
  74. // {
  75. // if (item.RecipeCode == recipeCode)
  76. // {
  77. // goto go;
  78. // }
  79. // }
  80. // int trayCode = new Random().Next(1,6);
  81. // for (int i = 1; i < 13; i++)
  82. // {
  83. // int a = new Random().Next(1, 5);
  84. // if (a == 3)
  85. // {
  86. // a = 1;
  87. // }
  88. // RawMaterials.Add(new RawMaterialModel()
  89. // {
  90. // RawMaterialWeight = new Random().Next(10, 1000),
  91. // RawMaterialBarrelNum = a,
  92. // RawMaterialLocation = i,
  93. // });
  94. // }
  95. // Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
  96. // {
  97. // RecipeName = recipeName,
  98. // RecipeCode = recipeCode,
  99. // TrayCode = trayCode,
  100. // RawMaterial = RawMaterials,
  101. // });
  102. // Json<LocaPar>.Save();
  103. //});
  104. ClearAllRecipe = new RelayCommand(() =>
  105. {
  106. Json<LocalRecipe>.Data.Recipes.Clear();
  107. Json<LocalRecipe>.Save();
  108. });
  109. RemoveCommand = new RelayCommand<string>((recipeCode) =>
  110. {
  111. var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
  112. if (res != null)
  113. {
  114. Recipes.Remove(res);
  115. Json<LocalRecipe>.Save();
  116. }
  117. });
  118. }
  119. public RelayCommand<object> DetailsCommand { get; set; }
  120. // public RelayCommand NewSimulateRecipe { get; set; }
  121. public RelayCommand ClearAllRecipe { get; set; }
  122. public RelayCommand NewRecipe { get; set; }
  123. public RelayCommand RefreshRecipe { get; set; }
  124. public bool IsUseLocalRecipe { get { return _isUseLocalRecipe; } set { _isUseLocalRecipe = value; OnPropertyChanged(); } }
  125. public bool _isUseLocalRecipe { get; set; }
  126. public RelayCommand<string> RemoveCommand { get; set; }
  127. public ObservableCollection<RecipeData> Recipes { get; set; } = new ObservableCollection<RecipeData>();
  128. public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>();
  129. }
  130. }