|
- 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 ScreenMinWokControlViewModel : 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 ScreenModelMinWok ViewData
- {
- get { return _ViewData; }
- set
- {
- _ViewData = value;
- OnPropertyChanged();
- }
- }
- private ScreenModelMinWok _ViewData = new ScreenModelMinWok();
-
- /// <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 ScreenMinWokControlViewModel()
- {
- TaskManage.GetInstance.StartLong(new Action(() =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- if (Main.GetInstance.mqttDatasDic.ContainsKey(type))
- {
- ScreenModelMinWok modelMaxWok = Main.GetInstance.mqttDatasDic[type] as ScreenModelMinWok;
- 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.MinWok_Process_1));
- ProcessModel2 = JsonConvert.DeserializeObject<ObservableCollection<ProcessModelForm>>(JsonConvert.SerializeObject(modelMaxWok.MinWok_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.MinWok_OrderCount_1 + modelMaxWok.MinWok_OrderCount_2;
-
- }
- }));
- Thread.Sleep(1000);
- }), $"{DateTime.Now},线程服务");
- }
- }
- }
|