终端一体化运控平台
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.
 
 
 

89 lignes
4.2 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.JXJFoodSmallStation.Model;
  6. using BPASmartClient.JXJFoodSmallStation.Model.Bom;
  7. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  8. using Microsoft.Toolkit.Mvvm.ComponentModel;
  9. using Microsoft.Toolkit.Mvvm.Input;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.ComponentModel;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Text;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  20. {
  21. public class BomOfMaterialViewModel : ObservableObject
  22. {
  23. public BomOfMaterialViewModel()
  24. {
  25. RawMaterialInfo = Json<DevicePar>.Data.BomMaterial;
  26. AddMaterial = new RelayCommand(() =>
  27. {
  28. RawMaterialInfo.Add(new BomMaterial()
  29. {
  30. Count = Json<DevicePar>.Data.BomMaterial.Count +1 ,
  31. });
  32. MessageNotify.GetInstance.ShowUserLog("新增一条物料数据。");
  33. });
  34. SaveMaterials = new RelayCommand(() =>
  35. {
  36. if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
  37. {
  38. Json<DevicePar>.Save();
  39. MessageNotify.GetInstance.ShowUserLog($"西门子物料清单保存成功");
  40. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  41. }
  42. });
  43. GetBomMaterialData = new RelayCommand(() =>
  44. {
  45. Json<DevicePar>.Data.BomMaterial.Clear();
  46. ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
  47. foreach (var item in GVL_SmallStation.GetInstance.RawMaterialsNameCode)
  48. {
  49. Json<DevicePar>.Data.BomMaterial.Add(new BomMaterial() { Count = Json<DevicePar>.Data.BomMaterial.Count + 1, MaterialCode = item.Key, MaterialName = item.Value });
  50. }
  51. MessageNotify.GetInstance.ShowUserLog("西门子物料数据拉取了本地数据。");
  52. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
  53. });
  54. DeleteAllMaterial = new RelayCommand(() =>
  55. {
  56. if (MessageNotify.GetInstance.ShowDialog("请确认,是否删除所有原料数据!") == true)
  57. {
  58. Json<DevicePar>.Data.BomMaterial.Clear();
  59. MessageNotify.GetInstance.ShowUserLog($"手动点击西门子物料清单全部清除。");
  60. }
  61. });
  62. RemoveCommand = new RelayCommand<int>((Count) =>
  63. {
  64. if (Count is int cnt)
  65. {
  66. var res = RawMaterialInfo.FirstOrDefault(p => p.Count == cnt);
  67. if (res != null)
  68. {
  69. if (MessageNotify.GetInstance.ShowDialog($"请确认是否删除物料编码:【{res.MaterialCode}】,物料名称:【{res.MaterialName}】的信息?") == true)
  70. {
  71. RawMaterialInfo.Remove(res);
  72. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
  73. MessageNotify.GetInstance.ShowUserLog($"删除一条物料数据,物料编码:【{res.MaterialCode}】,物料名称:{res.MaterialName}。");
  74. }
  75. }
  76. }
  77. });
  78. }
  79. public ObservableCollection<BomMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<BomMaterial>();
  80. public RelayCommand AddMaterial { get; set; }
  81. public RelayCommand SaveMaterials { get; set; }
  82. public RelayCommand<int> RemoveCommand { get; set; }
  83. public RelayCommand GetBomMaterialData { get; set; }
  84. public RelayCommand DeleteAllMaterial { get; set; }
  85. }
  86. }