|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using BPA.Helper;
- using BPA.Message;
- using BPA.Message.Enum;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.ScreenLib
- {
- public class ScreenMaxWokControlViewModel : NotifyBase
- {
- #region 变量
- /// <summary>
- /// 广告地址
- /// </summary>
- public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } }
- private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString());
-
- /// <summary>
- /// 界面数据绑定
- /// </summary>
- public ScreenModelMaxWok ViewData
- {
- get { return _ViewData; }
- set
- {
- _ViewData = value;
- OnPropertyChanged();
- }
- }
- private ScreenModelMaxWok _ViewData = new ScreenModelMaxWok();
-
- /// <summary>
- /// 1号炒锅流程
- /// </summary>
- public ObservableCollection<ProcessModelForm> ProcessModel1
- {
- get { return _ProcessModel1; }
- set
- {
- _ProcessModel1 = value;
- OnPropertyChanged();
- }
- }
- private ObservableCollection<ProcessModelForm> _ProcessModel1 = new ObservableCollection<ProcessModelForm>();
-
- /// <summary>
- /// 2号炒锅流程
- /// </summary>
- public ObservableCollection<ProcessModelForm> ProcessModel2
- {
- get { return _ProcessModel2; }
- set
- {
- _ProcessModel2 = value;
- OnPropertyChanged();
- }
- }
- private ObservableCollection<ProcessModelForm> _ProcessModel2 = new ObservableCollection<ProcessModelForm>();
-
- /// <summary>
- /// 当前刷新数据类型
- /// </summary>
- public ScreenDeviceType type = ScreenDeviceType.大炒;
-
- /// <summary>
- /// 订单总数
- /// </summary>
- public int OrderCount
- {
- get { return _OrderCount; }
- set
- {
- _OrderCount = value;
- OnPropertyChanged();
- }
- }
- private int _OrderCount =0;
- #endregion
-
- public ScreenMaxWokControlViewModel()
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- if (Main.GetInstance.mqttDatasDic.ContainsKey(type))
- {
- ScreenModelMaxWok modelMaxWok= Main.GetInstance.mqttDatasDic[type] as ScreenModelMaxWok;
- if(modelMaxWok != null && modelMaxWok.Alarm!=null)
- modelMaxWok.Alarm= modelMaxWok.Alarm?.OrderByDescending(k =>DateTime.Parse(k.AlarmTime)).ToList();
-
- ProcessModel1=JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_1));
- ProcessModel2 = JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_2));
- ProcessModel1?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel1.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
- ProcessModel2?.ToList().ForEach(par => { if (par.Id+1 == ProcessModel2.Count) { par.IsLast = 1; } else { par.IsLast = 0; } });
- ViewData = modelMaxWok;
- OrderCount = modelMaxWok.MaxWok_OrderCount_1 + modelMaxWok.MaxWok_OrderCount_2;
- }
- }));
- Thread.Sleep(1000);
- }), $"{DateTime.Now},线程服务");
- }
- }
-
- /// <summary>
- /// 是否最后
- /// </summary>
- public class ProcessModelForm: ProcessModel
- {
- public int IsLast
- {
- get;
- set;
- }
- }
- }
|