终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

71 lines
3.0 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.Helper;
  5. using BPASmartClient.JXJFoodBigStation.Model;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using Microsoft.Toolkit.Mvvm.Input;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  15. {
  16. internal class RecipeSendDownViewModel:ObservableObject
  17. {
  18. public ObservableCollection<RecipeData> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
  19. /// <summary>
  20. /// 当前正在制作的配方
  21. /// </summary>
  22. public static ObservableCollection<RawMaterial> recipeProcesses { get; set; } = new ObservableCollection<RawMaterial>();
  23. /// <summary>
  24. /// 等待制作的配方
  25. /// </summary>
  26. public static ObservableCollection<RecipeData> UserTreeWait { get; set; } = new ObservableCollection<RecipeData>();
  27. /// <summary>
  28. /// 已完成的配方
  29. /// </summary>
  30. public static ObservableCollection<RecipeData> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeData>();
  31. public RelayCommand<string> StartCommand { get; set; }
  32. public RecipeSendDownViewModel()
  33. {
  34. StartCommand = new RelayCommand<string>((recipeName) =>
  35. {
  36. if (recipeName != null)
  37. {
  38. if (GVL_BigStation.IsUseLocalRecipe)
  39. {
  40. //配方下发逻辑
  41. var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
  42. if (res != null)
  43. {
  44. //Json<LocalRecipe>.Data.Recipes.Add(res);
  45. //for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
  46. //{
  47. // foreach (var item in Json<LocalRecipe>.Data.Recipes.ElementAt(i).RawMaterial)
  48. // {
  49. // item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
  50. // }
  51. //}
  52. if (!ProcessControl.GetInstance.LocalRecipes.Contains(res))
  53. {
  54. ProcessControl.GetInstance.LocalRecipes.Add(res);
  55. MessageNotify.GetInstance.ShowAlarmLog($"手动下发配方:{recipeName}完成");
  56. }
  57. }
  58. }
  59. else
  60. {
  61. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"未处于本地配方模式,无法下发配方");
  62. }
  63. }
  64. });
  65. }
  66. }
  67. }