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

123 lines
4.1 KiB

  1. using BPA.Helper;
  2. using BPA.Message;
  3. using BPA.Message.Enum;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. namespace BPASmartClient.ScreenLib
  13. {
  14. public class ScreenMaxWokControlViewModel : NotifyBase
  15. {
  16. #region 变量
  17. /// <summary>
  18. /// 广告地址
  19. /// </summary>
  20. public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } }
  21. private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString());
  22. /// <summary>
  23. /// 界面数据绑定
  24. /// </summary>
  25. public ScreenModelMaxWok ViewData
  26. {
  27. get { return _ViewData; }
  28. set
  29. {
  30. _ViewData = value;
  31. OnPropertyChanged();
  32. }
  33. }
  34. private ScreenModelMaxWok _ViewData = new ScreenModelMaxWok();
  35. /// <summary>
  36. /// 1号炒锅流程
  37. /// </summary>
  38. public ObservableCollection<ProcessModelForm> ProcessModel1
  39. {
  40. get { return _ProcessModel1; }
  41. set
  42. {
  43. _ProcessModel1 = value;
  44. OnPropertyChanged();
  45. }
  46. }
  47. private ObservableCollection<ProcessModelForm> _ProcessModel1 = new ObservableCollection<ProcessModelForm>();
  48. /// <summary>
  49. /// 2号炒锅流程
  50. /// </summary>
  51. public ObservableCollection<ProcessModelForm> ProcessModel2
  52. {
  53. get { return _ProcessModel2; }
  54. set
  55. {
  56. _ProcessModel2 = value;
  57. OnPropertyChanged();
  58. }
  59. }
  60. private ObservableCollection<ProcessModelForm> _ProcessModel2 = new ObservableCollection<ProcessModelForm>();
  61. /// <summary>
  62. /// 当前刷新数据类型
  63. /// </summary>
  64. public ScreenDeviceType type = ScreenDeviceType.大炒;
  65. /// <summary>
  66. /// 订单总数
  67. /// </summary>
  68. public int OrderCount
  69. {
  70. get { return _OrderCount; }
  71. set
  72. {
  73. _OrderCount = value;
  74. OnPropertyChanged();
  75. }
  76. }
  77. private int _OrderCount =0;
  78. #endregion
  79. public ScreenMaxWokControlViewModel()
  80. {
  81. ThreadManage.GetInstance().StartLong(new Action(() =>
  82. {
  83. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  84. {
  85. if (Main.GetInstance.mqttDatasDic.ContainsKey(type))
  86. {
  87. ScreenModelMaxWok modelMaxWok= Main.GetInstance.mqttDatasDic[type] as ScreenModelMaxWok;
  88. if(modelMaxWok != null && modelMaxWok.Alarm!=null)
  89. modelMaxWok.Alarm= modelMaxWok.Alarm?.OrderByDescending(k =>DateTime.Parse(k.AlarmTime)).ToList();
  90. ProcessModel1=JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_1));
  91. ProcessModel2 = JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_2));
  92. ProcessModel1?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel1.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
  93. ProcessModel2?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel2.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
  94. ViewData = modelMaxWok;
  95. OrderCount = modelMaxWok.MaxWok_OrderCount_1 + modelMaxWok.MaxWok_OrderCount_2;
  96. }
  97. }));
  98. Thread.Sleep(1000);
  99. }), $"{DateTime.Now},线程服务");
  100. }
  101. }
  102. /// <summary>
  103. /// 是否最后
  104. /// </summary>
  105. public class ProcessModelForm: ProcessModel
  106. {
  107. public int IsLast
  108. {
  109. get;
  110. set;
  111. }
  112. }
  113. }