终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

108 linhas
3.7 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. #endregion
  66. public ScreenMaxWokControlViewModel()
  67. {
  68. ThreadManage.GetInstance().StartLong(new Action(() =>
  69. {
  70. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  71. {
  72. if (Main.GetInstance.mqttDatasDic.ContainsKey(type))
  73. {
  74. ScreenModelMaxWok modelMaxWok= Main.GetInstance.mqttDatasDic[type] as ScreenModelMaxWok;
  75. if(modelMaxWok != null && modelMaxWok.Alarm!=null)
  76. modelMaxWok.Alarm= modelMaxWok.Alarm?.OrderByDescending(k =>DateTime.Parse(k.AlarmTime)).ToList();
  77. ProcessModel1=JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_1));
  78. ProcessModel2 = JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_2));
  79. ProcessModel1?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel1.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
  80. ProcessModel2?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel2.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
  81. ViewData = modelMaxWok;
  82. }
  83. }));
  84. Thread.Sleep(1000);
  85. }), $"{DateTime.Now},线程服务");
  86. }
  87. }
  88. /// <summary>
  89. /// 是否最后
  90. /// </summary>
  91. public class ProcessModelForm: ProcessModel
  92. {
  93. public int IsLast
  94. {
  95. get;
  96. set;
  97. }
  98. }
  99. }