From 80256a01ddb3e7af2e051ef1830d884e46c725ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Sun, 6 Nov 2022 13:08:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKCardOUT/DTO/AdInfoModel.cs | 26 +++ HKCardOUT/ViewModels/AdWindowViewModel.cs | 198 +++++++++++++--------- HKCardOUT/Views/AdWindow.xaml | 76 ++------- 3 files changed, 156 insertions(+), 144 deletions(-) create mode 100644 HKCardOUT/DTO/AdInfoModel.cs diff --git a/HKCardOUT/DTO/AdInfoModel.cs b/HKCardOUT/DTO/AdInfoModel.cs new file mode 100644 index 0000000..86ee57f --- /dev/null +++ b/HKCardOUT/DTO/AdInfoModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; +using BPA.Helper; + +namespace DTO +{ + public class AdInfoModel : NotifyBase + { + public string Gate { get { return _mGate; } set { _mGate = value; OnPropertyChanged(); } } + private string _mGate; + + public string Msg { get { return _mMsg; } set { _mMsg = value; OnPropertyChanged(); } } + private string _mMsg; + + public int Count { get { return _mCount; } set { _mCount = value; OnPropertyChanged(); } } + private int _mCount; + + public ScreenInfoDto Info { get { return _mInfo; } set { _mInfo = value; OnPropertyChanged(); } } + private ScreenInfoDto _mInfo = new ScreenInfoDto(); + + public ObservableCollection AInfo { get; set; } = new ObservableCollection(); + + } +} diff --git a/HKCardOUT/ViewModels/AdWindowViewModel.cs b/HKCardOUT/ViewModels/AdWindowViewModel.cs index 5b6987f..85be5ac 100644 --- a/HKCardOUT/ViewModels/AdWindowViewModel.cs +++ b/HKCardOUT/ViewModels/AdWindowViewModel.cs @@ -14,101 +14,85 @@ using System.Collections.Concurrent; namespace HKCardOUT.ViewModels { - public class AdWindowViewModel : PropertyChangedBase + public class AdWindowViewModel : NotifyBase { public AdWindowViewModel() { - //ALInfo = new ObservableCollection(); - //ARInfo = new ObservableCollection(); - _LInfo = new ScreenInfoDto(); - _RInfo = new ScreenInfoDto(); + //_LInfo = new ScreenInfoDto(); + //_RInfo = new ScreenInfoDto(); } #region 属性 - string _LGate; - public string LGate - { - get => _LGate; - set => SetAndNotify(ref _LGate, value); - } - string _RGate; - public string RGate - { - get => _RGate; - set => SetAndNotify(ref _RGate, value); - } + public AdInfoModel LAdInfo { get { return _mLAdInfo; } set { _mLAdInfo = value; OnPropertyChanged(); } } + private AdInfoModel _mLAdInfo = new AdInfoModel(); - string _LMsg; - public string LMsg - { - get => _LMsg; - set => SetAndNotify(ref _LMsg, value); - } - - string _RMsg; - public string RMsg - { - get => _RMsg; - set => SetAndNotify(ref _RMsg, value); - } + public AdInfoModel RAdinfo { get { return _mRAdinfo; } set { _mRAdinfo = value; OnPropertyChanged(); } } + private AdInfoModel _mRAdinfo = new AdInfoModel(); - int _LCount; - public int LCount - { - get => _LCount; - set => SetAndNotify(ref _LCount, value); - } - - int _RCount; - public int RCount - { - get => _RCount; - set => SetAndNotify(ref _RCount, value); - } + //string _LGate; + //public string LGate + //{ + // get => _LGate; + // set => SetAndNotify(ref _LGate, value); + //} - ScreenInfoDto _LInfo; - public ScreenInfoDto LInfo - { - get => _LInfo; - set => SetAndNotify(ref _LInfo, value); - } + //string _RGate; + //public string RGate + //{ + // get => _RGate; + // set => SetAndNotify(ref _RGate, value); + //} - ScreenInfoDto _RInfo; - public ScreenInfoDto RInfo - { - get => _RInfo; - set => SetAndNotify(ref _RInfo, value); - } + //string _LMsg; + //public string LMsg + //{ + // get => _LMsg; + // set => SetAndNotify(ref _LMsg, value); + //} - //ObservableCollection _ALInfo; - //public ObservableCollection ALInfo + //string _RMsg; + //public string RMsg //{ - // get => _ALInfo; - // set => SetAndNotify(ref _ALInfo, value); + // get => _RMsg; + // set => SetAndNotify(ref _RMsg, value); //} - public ObservableCollection ALInfo { get; set; } = new ObservableCollection(); + //int _LCount; + //public int LCount + //{ + // get => _LCount; + // set => SetAndNotify(ref _LCount, value); + //} - //ObservableCollection _ARInfo; - //public ObservableCollection ARInfo + //int _RCount; + //public int RCount //{ - // get => _ARInfo; - // set => SetAndNotify(ref _ARInfo, value); + // get => _RCount; + // set => SetAndNotify(ref _RCount, value); //} - public ObservableCollection ARInfo { get; set; } = new ObservableCollection(); + //ScreenInfoDto _LInfo; + //public ScreenInfoDto LInfo + //{ + // get => _LInfo; + // set => SetAndNotify(ref _LInfo, value); + //} - //ObservableCollection _Foods = new ObservableCollection(); - //public ObservableCollection Foods + //ScreenInfoDto _RInfo; + //public ScreenInfoDto RInfo //{ - // get => _Foods; - // set => SetAndNotify(ref _Foods, value); + // get => _RInfo; + // set => SetAndNotify(ref _RInfo, value); //} + + //public ObservableCollection ALInfo { get; set; } = new ObservableCollection(); + + //public ObservableCollection ARInfo { get; set; } = new ObservableCollection(); + public ObservableCollection Foods { get; set; } = new ObservableCollection(); - //public ConcurrentQueue saleLogDtos { get; set; } = new ConcurrentQueue(); #endregion @@ -141,17 +125,65 @@ namespace HKCardOUT.ViewModels public void InitData(int[] BindScreen) { + //FoodsInit(BindScreen); + //ThreadManage.GetInstance().StartLong(() => + //{ + // var model = (new HKCore()).PullDaySaleLog(BindScreen); + + // LGate = $"{BindScreen[1]}号档口"; + // RGate = $"{BindScreen[0]}号档口"; + // LCount = model.Where(t => t.Key == $"{BindScreen[1]}").FirstOrDefault().Value; + // RCount = model.Where(t => t.Key == $"{BindScreen[0]}").FirstOrDefault().Value; + // LMsg = Main.GetInstance.GetIsSwipe(BindScreen[1]) ? "正常" : "异常"; + // RMsg = Main.GetInstance.GetIsSwipe(BindScreen[0]) ? "正常" : "异常"; + + // for (int i = 0; i < BindScreen.Length; i++) + // { + // if (DataBus.SaleLogDtoList.ContainsKey(BindScreen[i].ToString())) + // { + // if (DataBus.SaleLogDtoList[BindScreen[i].ToString()].Count > 0) + // { + // if (DataBus.SaleLogDtoList[BindScreen[i].ToString()].TryDequeue(out SaleLogDto info)) + // { + // ScreenInfoDto data = new ScreenInfoDto + // { + // CardNo = info.CardNo, + // UserName = "", + // Location = info.Location, + // }; + // data.UserName = DataBus.UserListDto + // .Where(t => t.Cards.Select(x => x.CardNum).Contains(data.CardNo)) + // .Select(x => x.Name).FirstOrDefault(); + + // 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 == $"{BindScreen[1]}" ? data : new ScreenInfoDto(); + // RInfo = data.Location == $"{BindScreen[0]}" ? data : new ScreenInfoDto(); + // } + // } + // } + // } + + // Thread.Sleep(10); + //}, $"屏幕刷卡信息{BindScreen[0]}-{BindScreen[1]}", true); + + FoodsInit(BindScreen); ThreadManage.GetInstance().StartLong(() => { var model = (new HKCore()).PullDaySaleLog(BindScreen); - LGate = $"{BindScreen[1]}号档口"; - RGate = $"{BindScreen[0]}号档口"; - LCount = model.Where(t => t.Key == $"{BindScreen[1]}").FirstOrDefault().Value; - RCount = model.Where(t => t.Key == $"{BindScreen[0]}").FirstOrDefault().Value; - LMsg = HKControl.Main.GetInstance.GetIsSwipe(BindScreen[1]) ? "正常" : "异常"; - RMsg = HKControl.Main.GetInstance.GetIsSwipe(BindScreen[0]) ? "正常" : "异常"; + LAdInfo.Gate = $"{BindScreen[1]}号档口"; + RAdinfo.Gate = $"{BindScreen[0]}号档口"; + LAdInfo.Count = model.Where(t => t.Key == $"{BindScreen[1]}").FirstOrDefault().Value; + RAdinfo.Count = model.Where(t => t.Key == $"{BindScreen[0]}").FirstOrDefault().Value; + LAdInfo.Msg = Main.GetInstance.GetIsSwipe(BindScreen[1]) ? "正常" : "异常"; + RAdinfo.Msg = Main.GetInstance.GetIsSwipe(BindScreen[0]) ? "正常" : "异常"; for (int i = 0; i < BindScreen.Length; i++) { @@ -173,19 +205,19 @@ namespace HKCardOUT.ViewModels 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"); + if (LAdInfo.Info != null && !string.IsNullOrEmpty(LAdInfo.Info.UserName)) + LAdInfo.AInfo.Insert(0, LAdInfo.Info); LAdInfo.Info.Time = DateTime.Now.ToString("HH:mm:ss"); + if (RAdinfo.Info != null && !string.IsNullOrEmpty(RAdinfo.Info.UserName)) + RAdinfo.AInfo.Insert(0, RAdinfo.Info); RAdinfo.Info.Time = DateTime.Now.ToString("HH:mm:ss"); }); - LInfo = data.Location == $"{BindScreen[1]}" ? data : new ScreenInfoDto(); - RInfo = data.Location == $"{BindScreen[0]}" ? data : new ScreenInfoDto(); + LAdInfo.Info = data.Location == $"{BindScreen[1]}" ? data : new ScreenInfoDto(); + RAdinfo.Info = data.Location == $"{BindScreen[0]}" ? data : new ScreenInfoDto(); } } } } - Thread.Sleep(100); + Thread.Sleep(10); }, $"屏幕刷卡信息{BindScreen[0]}-{BindScreen[1]}", true); } } diff --git a/HKCardOUT/Views/AdWindow.xaml b/HKCardOUT/Views/AdWindow.xaml index 683b161..a70b8b3 100644 --- a/HKCardOUT/Views/AdWindow.xaml +++ b/HKCardOUT/Views/AdWindow.xaml @@ -8,10 +8,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:view2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels" - d:DataContext="{d:DesignInstance Type=viewModels:AdWindowViewModel}" - Background="#3f4c5d" Width="1920" Height="1080" + d:DataContext="{d:DesignInstance Type=viewModels:AdWindowViewModel}" + Background="#3f4c5d" WindowStyle="None" mc:Ignorable="d"> - - @@ -219,36 +214,14 @@ - - - - - - @@ -325,7 +284,7 @@ HorizontalAlignment="Center" Foreground="#ddd" Style="{StaticResource Lbl}" - Text="{Binding RGate}" /> + Text="{Binding RAdinfo.Gate}" /> @@ -364,8 +323,8 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="50" - Foreground="{Binding RMsg, Converter={StaticResource TextForegroundConvert}}" - Text="{Binding RMsg}" /> + Foreground="{Binding RAdinfo.Msg, Converter={StaticResource TextForegroundConvert}}" + Text="{Binding RAdinfo.Msg}" /> + Text="{Binding RAdinfo.Count}" /> @@ -403,7 +362,7 @@ VerticalAlignment="Center" FontSize="50" Foreground="#ddd" - Text="{Binding RInfo.UserName}" /> + Text="{Binding RAdinfo.Info.UserName}" /> @@ -413,7 +372,7 @@ VerticalAlignment="Top" Background="Transparent" BorderThickness="0" - ItemsSource="{Binding ARInfo}" + ItemsSource="{Binding RAdinfo.AInfo}" Style="{StaticResource WrapPanelVerticalListBox}"> @@ -442,11 +401,6 @@ - - - - -