Browse Source

位置信息更新

Lishi
pry 2 years ago
parent
commit
a58229f571
2 changed files with 67 additions and 23 deletions
  1. +52
    -23
      HKCardOUT/ViewModels/AdWindowViewModel.cs
  2. +15
    -0
      HKControl/Main.cs

+ 52
- 23
HKCardOUT/ViewModels/AdWindowViewModel.cs View File

@@ -9,6 +9,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Windows.Media;
using HKControl;

namespace HKCardOUT.ViewModels
{
@@ -19,8 +20,8 @@ namespace HKCardOUT.ViewModels
{
ALInfo = new ObservableCollection<ScreenInfoDto>();
ARInfo = new ObservableCollection<ScreenInfoDto>();
_LInfo = new ScreenInfoDto() { UserName = "--" };
_RInfo = new ScreenInfoDto() { UserName = "--" };
_LInfo = new ScreenInfoDto();
_RInfo = new ScreenInfoDto();
}

#region 属性
@@ -108,14 +109,41 @@ namespace HKCardOUT.ViewModels
if (Foods == null)
{
string GateId = string.Empty;
int[] loc = new int[2];
if (ScreenLoc == 0)
{
loc[0] = 0;
loc[1] = 1;
GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "02" || t.Address == "01").Select(t => t.GateId).FirstOrDefault();
}
else if (ScreenLoc == 1)
{
loc[0] = 4;
loc[1] = 5;
GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "05" || t.Address == "06").Select(t => t.GateId).FirstOrDefault();
}
else if (ScreenLoc == 2)
{
loc[0] = 2;
loc[1] = 3;
GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "03" || t.Address == "04").Select(t => t.GateId).FirstOrDefault();
}
var res = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
if (res != null) Foods = new ObservableCollection<string>(res);
Main.GetInstance.CompleteNotify[loc[0]] = new Action(() =>
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
}));
});
Main.GetInstance.CompleteNotify[loc[1]] = new Action(() =>
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
}));
});
}

}
@@ -124,6 +152,7 @@ namespace HKCardOUT.ViewModels
{

FoodsInit(BindScreen);

ThreadManage.GetInstance().StartLong(() =>
{
var model = (new HKCore()).PullDaySaleLog(BindScreen);
@@ -170,37 +199,37 @@ namespace HKCardOUT.ViewModels

if (BindScreen == 1)
{
App.Current.Dispatcher.Invoke(() =>
{
if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
});
//App.Current.Dispatcher.Invoke(() =>
//{
// if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
// ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
// if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
// ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
//});
LInfo = data.Location == "6" ? data : new ScreenInfoDto();
RInfo = data.Location == "5" ? data : new ScreenInfoDto();
}
if (BindScreen == 0)
{
App.Current.Dispatcher.Invoke(() =>
{
if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
});
//App.Current.Dispatcher.Invoke(() =>
//{
// if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
// ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
// if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
// ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
//});
LInfo = data.Location == "2" ? data : new ScreenInfoDto();
RInfo = data.Location == "1" ? data : new ScreenInfoDto();
}
if (BindScreen == 2)
{
App.Current.Dispatcher.Invoke(() =>
{
if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
});
//App.Current.Dispatcher.Invoke(() =>
//{
// if (LInfo != null && !string.IsNullOrEmpty(LInfo.UserName))
// ALInfo.Insert(0, LInfo); LInfo.Time = DateTime.Now.ToString("HH:mm:ss");
// if (RInfo != null && !string.IsNullOrEmpty(RInfo.UserName))
// ARInfo.Insert(0, RInfo); RInfo.Time = DateTime.Now.ToString("HH:mm:ss");
//});
LInfo = data.Location == "4" ? data : new ScreenInfoDto();
RInfo = data.Location == "3" ? data : new ScreenInfoDto();
}


+ 15
- 0
HKControl/Main.cs View File

@@ -16,6 +16,8 @@ namespace HKControl
ConcurrentDictionary<int, DataModel> DataModels = new ConcurrentDictionary<int, DataModel>();
ConcurrentQueue<int> CarQueue = new ConcurrentQueue<int>();

public Action[] CompleteNotify { get; set; } = new Action[6];

/// <summary>
/// 判断指定出餐窗口是否允许刷卡(1-6)
/// </summary>
@@ -112,6 +114,19 @@ namespace HKControl
}
Thread.Sleep(100);
}), $"{item.DeviceNum} 号设备监听", true);

ThreadManage.GetInstance().StartLong(new Action(() =>
{
for (int i = 0; i < 6; i++)
{
if (RTrig.GetInstance($"窗口{i + 1}").Start(GetIsComplete(i + 1)))
{
CompleteNotify[i]?.Invoke();
}
}
Thread.Sleep(100);
}), "完成通知");

});
SiemensDicitonary[item.DeviceNum].Connect(CpuType.S7200Smart, item.IpAddress);
}), $"{item.DeviceNum} 号设备连接初始化");


Loading…
Cancel
Save