|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPA.Helper;
- using BPASmartClient.JXJFoodBigStation.Model;
- using BPASmartClient.JXJFoodBigStation.Model.Siemens;
- using BPASmartClient.JXJFoodBigStation.View;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodBigStation.ViewModel
- {
- internal class RecipeSendDownViewModel:NotifyBase
- {
- public ObservableCollection<RecipeData> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
- /// <summary>
- /// 当前正在制作的配方
- /// </summary>
- public static ObservableCollection<RawMaterial> recipeProcesses { get; set; } = new ObservableCollection<RawMaterial>();
- /// <summary>
- /// 等待制作的配方
- /// </summary>
- public static ObservableCollection<RecipeData> UserTreeWait { get; set; } = new ObservableCollection<RecipeData>();
- /// <summary>
- /// 已完成的配方
- /// </summary>
- public static ObservableCollection<RecipeData> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeData>();
-
-
- /// <summary>
- /// 筛选后的配方列表。
- /// </summary>
- public static ObservableCollection<RecipeData> SelectedRecipes { get; set; }
-
-
-
- public BPARelayCommand<string> StartCommand { get; set; }
- public BPARelayCommand SelectRecipesCommand { get; set; }
-
- public RecipeSendDownViewModel()
- {
-
- SelectedRecipes= Json<LocalRecipe>.Data.SelectedRecipes;
-
- StartCommand = new BPARelayCommand<string>((recipeName) =>
- {
- if (recipeName != null)
- {
- if (GVL_BigStation.IsUseLocalRecipe)
- {
- if (!MessageNotify.GetInstance.ShowDialog($"请确认,是否下发配方【{recipeName}】?"))
- {
- return;
- }
- //配方下发逻辑
- var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
- if (res != null)
- {
- if (!Json<RemoteRecipe>.Data.Recipes.Any(p=>p.RecipeCode==res.RecipeCode))
- {
- res.RecipesSource = RecipeSource.本地;
- Json<RemoteRecipe>.Data.Recipes.Add(res);
- MessageNotify.GetInstance.ShowRunLog($"接收手动下发配方:【{recipeName}】");
- MessageNotify.GetInstance.ShowUserLog($"手动下发配方:【{recipeName}】完成");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方下发完成");
- }
- else
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "失败", $"配方下发失败,已下发过此配方。");
- }
- }
- }
- else
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"未处于本地配方模式,无法下发配方");
- }
- }
- });
-
- SelectRecipesCommand = new BPARelayCommand(() =>
- {
- var selectView = new SelectRecipesView();
- selectView.ShowDialog();
-
- Json<LocalRecipe>.Data.SelectedRecipes.Clear();
- foreach ( var recipe in SelectRecipesViewModel.SelectRecipes )
- {
- if ( recipe != null && !Json<LocalRecipe>.Data.SelectedRecipes.Any(p=>p.RecipeCode==recipe.RecipeCode))
- {
- Json<LocalRecipe>.Data.SelectedRecipes.Add(recipe);
- }
- }
- //不保存会导致下次打开本地配方下发页面,会重新读取之前存储的文件。
- Json<LocalRecipe>.Save();
- });
- }
- }
- }
|