From be2d89db2573a01feefa4101a9169eaac2fd582d Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 20 Mar 2024 19:11:46 +0800 Subject: [PATCH] =?UTF-8?q?change-=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=E5=8A=A0=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1=EF=BC=8C=E6=9D=A1?= =?UTF-8?q?=E7=A0=81=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConvertTo/MultiBindingConverter.cs | 2 +- .../Models/StatisticModel.cs | 1 + .../ViewModels/StatisticsPageViewModel.cs | 73 +++++++++++++------ .../Views/HandSendPlcWindow.xaml.cs | 18 +++-- .../Views/MainWindow.xaml.cs | 5 ++ .../Views/StatisticsPageView.xaml | 14 +++- 6 files changed, 80 insertions(+), 33 deletions(-) diff --git a/Aucma.Core.ProductOffLine/ConvertTo/MultiBindingConverter.cs b/Aucma.Core.ProductOffLine/ConvertTo/MultiBindingConverter.cs index b2784b72..608f0aa2 100644 --- a/Aucma.Core.ProductOffLine/ConvertTo/MultiBindingConverter.cs +++ b/Aucma.Core.ProductOffLine/ConvertTo/MultiBindingConverter.cs @@ -27,7 +27,7 @@ namespace Aucma.Core.ProductOffLine.ConvertTo bsm.BeginTime = values[0].ToString(); bsm.EndTime = values[1].ToString(); - + return bsm; } return null; diff --git a/Aucma.Core.ProductOffLine/Models/StatisticModel.cs b/Aucma.Core.ProductOffLine/Models/StatisticModel.cs index 039b3450..ae0d6597 100644 --- a/Aucma.Core.ProductOffLine/Models/StatisticModel.cs +++ b/Aucma.Core.ProductOffLine/Models/StatisticModel.cs @@ -8,6 +8,7 @@ namespace Aucma.Core.ProductOffLine.Models { public class StatisticModel { + // public string? ProductCode { get; set; } /// /// 开始时间 /// diff --git a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs index 8ff37e76..06d0fc7f 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs @@ -2,6 +2,7 @@ using Admin.Core.Model; using Admin.Core.Model.Model_New; using Aucma.Core.ProductOffLine.Models; +using Aucma.Core.ProductOffLine.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.DependencyInjection; @@ -22,15 +23,26 @@ namespace Aucma.Core.ProductOffLine.ViewModels // 成品下线操作mes数据 private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService(); + + public RelayCommand ResetCommand { get; set; } + + public StatisticsPageViewModel() { _offLineInfoServices = App.ServiceProvider.GetService(); MainWindowViewModel.RefreshChartsEvent += LoadData; + ResetCommand = new RelayCommand(Reset); LoadData(); } List materialComplateInfos = new List(); + public void Reset() + { + ProductSNCode = string.Empty; + LoadData(); + + } #region 加载DataGrid数据 private void LoadData() { @@ -95,6 +107,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels OnPropertyChanged();//属性通知 } } + + #region 物料条码 + private string _productSNCode; + public string ProductSNCode + { + get => _productSNCode; + set => SetProperty(ref _productSNCode, value); + } + #endregion + + // 按照型号统计 private ObservableCollection totalItem = new ObservableCollection() { }; public ObservableCollection TotalItem @@ -132,36 +155,44 @@ namespace Aucma.Core.ProductOffLine.ViewModels [RelayCommand] private void ExecQuery(object obj) { + List list = null; - var result = (StatisticModel)obj; - if (string.IsNullOrEmpty(result.BeginTime) && string.IsNullOrEmpty(result.EndTime)) - { - return; - } - else if (string.IsNullOrEmpty(result.BeginTime)) - { - DateTime EndTime = Convert.ToDateTime(result.EndTime); - - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result; - } - else if (string.IsNullOrEmpty(result.EndTime)) + if (!string.IsNullOrEmpty(_productSNCode)) { - DateTime BeginTime = Convert.ToDateTime(result.BeginTime); - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductSNCode == _productSNCode).Result; } else { - DateTime BeginTime = Convert.ToDateTime(result.BeginTime); - DateTime EndTime = Convert.ToDateTime(result.EndTime); - if (BeginTime > EndTime) + var result = (StatisticModel)obj; + if (result == null) return; + + if (string.IsNullOrEmpty(result.BeginTime) && string.IsNullOrEmpty(result.EndTime)) { - MessageBox.Show("结束时间要大于开始时间!"); return; } - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; - } - + else if (string.IsNullOrEmpty(result.BeginTime)) + { + DateTime EndTime = Convert.ToDateTime(result.EndTime); + list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result; + } + else if (string.IsNullOrEmpty(result.EndTime)) + { + DateTime BeginTime = Convert.ToDateTime(result.BeginTime); + list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result; + } + else + { + DateTime BeginTime = Convert.ToDateTime(result.BeginTime); + DateTime EndTime = Convert.ToDateTime(result.EndTime); + if (BeginTime > EndTime) + { + MessageBox.Show("结束时间要大于开始时间!"); + return; + } + list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; + } + } if (list != null) { list = list.OrderByDescending(x => x.ProductScanTime).ToList(); diff --git a/Aucma.Core.ProductOffLine/Views/HandSendPlcWindow.xaml.cs b/Aucma.Core.ProductOffLine/Views/HandSendPlcWindow.xaml.cs index 625629d7..7b019b65 100644 --- a/Aucma.Core.ProductOffLine/Views/HandSendPlcWindow.xaml.cs +++ b/Aucma.Core.ProductOffLine/Views/HandSendPlcWindow.xaml.cs @@ -61,14 +61,18 @@ namespace Aucma.Core.ProductOffLine.Views { directionSelected = true; this.Close(); - if (direction == "外侧提升机箱体") + Task.Run(() => { - SendPlcPassEvent?.Invoke(2, "A"); - } - else - { - SendPlcPassEvent?.Invoke(1, "A"); - } + if (direction == "外侧提升机箱体") + { + SendPlcPassEvent?.Invoke(2, "A"); + } + else + { + SendPlcPassEvent?.Invoke(1, "A"); + } + }); + } diff --git a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs index 37f0c30c..0a4dcc69 100644 --- a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs +++ b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs @@ -19,5 +19,10 @@ namespace Aucma.Core.ProductOffLine.Views Login login = new Login(); login.ShowDialog(); } + + private void Minimized_Click(object sender, RoutedEventArgs e) + { + + } } } diff --git a/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml b/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml index 1b6ea72f..7a95a75b 100644 --- a/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views" xmlns:cvt="clr-namespace:Aucma.Core.ProductOffLine.ConvertTo" mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="800" d:DesignWidth="1500"> @@ -124,9 +124,13 @@ - +