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 变量
///
/// 广告地址
///
public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } }
private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString());
///
/// 界面数据绑定
///
public ScreenModelMaxWok ViewData
{
get { return _ViewData; }
set
{
_ViewData = value;
OnPropertyChanged();
}
}
private ScreenModelMaxWok _ViewData = new ScreenModelMaxWok();
///
/// 1号炒锅流程
///
public ObservableCollection ProcessModel1
{
get { return _ProcessModel1; }
set
{
_ProcessModel1 = value;
OnPropertyChanged();
}
}
private ObservableCollection _ProcessModel1 = new ObservableCollection();
///
/// 2号炒锅流程
///
public ObservableCollection ProcessModel2
{
get { return _ProcessModel2; }
set
{
_ProcessModel2 = value;
OnPropertyChanged();
}
}
private ObservableCollection _ProcessModel2 = new ObservableCollection();
///
/// 当前刷新数据类型
///
public ScreenDeviceType type = ScreenDeviceType.大炒;
///
/// 订单总数
///
public int OrderCount
{
get { return _OrderCount; }
set
{
_OrderCount = value;
OnPropertyChanged();
}
}
private int _OrderCount =0;
#endregion
public ScreenMaxWokControlViewModel()
{
TaskManage.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>(JsonConvert.SerializeObject(modelMaxWok.MaxWok_Process_1));
ProcessModel2 = JsonConvert.DeserializeObject>(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},线程服务");
}
}
///
/// 是否最后
///
public class ProcessModelForm: ProcessModel
{
public int IsLast
{
get;
set;
}
}
}