终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

105 wiersze
4.3 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPA.Helper;
  5. using BPASmartClient.JXJFoodBigStation.Model;
  6. using BPASmartClient.JXJFoodBigStation.Model.Siemens;
  7. using BPASmartClient.JXJFoodBigStation.View;
  8. using BPA.Helper;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  16. {
  17. internal class RecipeSendDownViewModel:NotifyBase
  18. {
  19. public ObservableCollection<RecipeData> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
  20. /// <summary>
  21. /// 当前正在制作的配方
  22. /// </summary>
  23. public static ObservableCollection<RawMaterial> recipeProcesses { get; set; } = new ObservableCollection<RawMaterial>();
  24. /// <summary>
  25. /// 等待制作的配方
  26. /// </summary>
  27. public static ObservableCollection<RecipeData> UserTreeWait { get; set; } = new ObservableCollection<RecipeData>();
  28. /// <summary>
  29. /// 已完成的配方
  30. /// </summary>
  31. public static ObservableCollection<RecipeData> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeData>();
  32. /// <summary>
  33. /// 筛选后的配方列表。
  34. /// </summary>
  35. public static ObservableCollection<RecipeData> SelectedRecipes { get; set; }
  36. public BPARelayCommand<string> StartCommand { get; set; }
  37. public BPARelayCommand SelectRecipesCommand { get; set; }
  38. public RecipeSendDownViewModel()
  39. {
  40. SelectedRecipes= Json<LocalRecipe>.Data.SelectedRecipes;
  41. StartCommand = new BPARelayCommand<string>((recipeName) =>
  42. {
  43. if (recipeName != null)
  44. {
  45. if (GVL_BigStation.IsUseLocalRecipe)
  46. {
  47. if (!MessageNotify.GetInstance.ShowDialog($"请确认,是否下发配方【{recipeName}】?"))
  48. {
  49. return;
  50. }
  51. //配方下发逻辑
  52. var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
  53. if (res != null)
  54. {
  55. if (!Json<RemoteRecipe>.Data.Recipes.Any(p=>p.RecipeCode==res.RecipeCode))
  56. {
  57. res.RecipesSource = RecipeSource.本地;
  58. Json<RemoteRecipe>.Data.Recipes.Add(res);
  59. MessageNotify.GetInstance.ShowRunLog($"接收手动下发配方:【{recipeName}】");
  60. MessageNotify.GetInstance.ShowUserLog($"手动下发配方:【{recipeName}】完成");
  61. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方下发完成");
  62. }
  63. else
  64. {
  65. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "失败", $"配方下发失败,已下发过此配方。");
  66. }
  67. }
  68. }
  69. else
  70. {
  71. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"未处于本地配方模式,无法下发配方");
  72. }
  73. }
  74. });
  75. SelectRecipesCommand = new BPARelayCommand(() =>
  76. {
  77. var selectView = new SelectRecipesView();
  78. selectView.ShowDialog();
  79. Json<LocalRecipe>.Data.SelectedRecipes.Clear();
  80. foreach ( var recipe in SelectRecipesViewModel.SelectRecipes )
  81. {
  82. if ( recipe != null && !Json<LocalRecipe>.Data.SelectedRecipes.Any(p=>p.RecipeCode==recipe.RecipeCode))
  83. {
  84. Json<LocalRecipe>.Data.SelectedRecipes.Add(recipe);
  85. }
  86. }
  87. //不保存会导致下次打开本地配方下发页面,会重新读取之前存储的文件。
  88. Json<LocalRecipe>.Save();
  89. });
  90. }
  91. }
  92. }