From fe8c547ab5952bd8a410af328d7b1e3b766ee57b Mon Sep 17 00:00:00 2001 From: liuwf Date: Mon, 1 Jul 2024 13:35:16 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=BC=98=E5=8C=96=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2=E9=80=9F=E5=BA=A6=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=9F=A5=E8=AF=A2=E7=85=A7=E7=89=87=E5=88=97?= =?UTF-8?q?=20add-=20=E7=95=8C=E9=9D=A2=E7=BB=9F=E8=AE=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=80=9A=E8=BF=87=E7=8E=87=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/Impl/LogoIdentifyImpl.cs | 23 ++++++++---- SlnMesnac.WPF/MainWindow.xaml | 7 ++-- SlnMesnac.WPF/Models/ModelCount.cs | 7 +++- SlnMesnac.WPF/SlnMesnac.WPF.csproj | 8 +++++ SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 35 ++++++++++++------- .../ViewModel/MainWindowViewModel.cs | 11 ++++++ .../ViewModel/StatisticsPageViewModel.cs | 5 +-- SlnMesnac.WPF/Views/IndexPage.xaml | 4 +-- SlnMesnac.WPF/Views/StatisticsPageView.xaml | 8 +++-- 9 files changed, 78 insertions(+), 30 deletions(-) diff --git a/SlnMesnac.Repository/service/Impl/LogoIdentifyImpl.cs b/SlnMesnac.Repository/service/Impl/LogoIdentifyImpl.cs index 89f2cf0..862c0c5 100644 --- a/SlnMesnac.Repository/service/Impl/LogoIdentifyImpl.cs +++ b/SlnMesnac.Repository/service/Impl/LogoIdentifyImpl.cs @@ -21,9 +21,14 @@ namespace SlnMesnac.Repository.service.Impl } public async Task> GetAllRecordAsync() - { + { + + //List list = null; + //list = await _rep.GetListAsync(x => x.RecordTime >= DateTime.Now.AddDays(-3)); + //return list; + List list = null; - list = await _rep.GetListAsync(); + list = await _rep.Context.Ado.SqlQueryAsync("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-3) }); return list; } @@ -39,17 +44,21 @@ namespace SlnMesnac.Repository.service.Impl { List list = null; if(time1 == null && time2 == null){ - list = _rep.GetList(); - }else if (time1 == null) + list = await _rep.Context.Ado.SqlQueryAsync("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-1) }); + } + else if (time1 == null) { - list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList(); + list = await _rep.Context.Ado.SqlQueryAsync("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME <= @RecordTime ", new { RecordTime = DateTime.Parse(time2) }); + // list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList(); }else if (time2 == null) { - list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList(); + list = await _rep.Context.Ado.SqlQueryAsync("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Parse(time1) }); + // list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList(); } else { - list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList(); + list = await _rep.Context.Ado.SqlQueryAsync("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime1 AND RECORD_TIME <= @RecordTime2 ", new { RecordTime1 = DateTime.Parse(time1), RecordTime2 = DateTime.Parse(time2) }); + // list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList(); } return list; diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 5c05267..e2d174f 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -34,9 +34,10 @@ - - - + + + + diff --git a/SlnMesnac.WPF/Models/ModelCount.cs b/SlnMesnac.WPF/Models/ModelCount.cs index 2e5d4a6..4f1148c 100644 --- a/SlnMesnac.WPF/Models/ModelCount.cs +++ b/SlnMesnac.WPF/Models/ModelCount.cs @@ -11,6 +11,11 @@ namespace SlnMesnac.WPF.Models public int No { get; set; } public string MaterialType { get; set; } public string ProductName { get; set; } - public int Amount { get; set; } + //总数量 + public int TotalAmount { get; set; } + //合格通过数 + public int PassAmount { get; set; } + //合格通过率 + public string PassRate { get; set; } } } diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj index d074a27..189ca9e 100644 --- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj +++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj @@ -7,6 +7,14 @@ true + + embedded + + + + embedded + + diff --git a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs index 660f6d0..5ffb727 100644 --- a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs @@ -120,21 +120,32 @@ namespace SlnMesnac.WPF.ViewModel public async void RefreshDataGrid() { - - List list = await logoIdentifyService.GetAllRecordAsync(); - if (list == null || list.Count == 0) return; - LogoIdentifyDataGrid.Clear(); - await App.Current.Dispatcher.BeginInvoke((Action)(() => + try + { + await Task.Run(async() => { - LogoIdentifyDataGrid.Clear(); - list = list.OrderByDescending(x=>x.RecordTime).ToList(); - foreach (LogoIdentify verify in list) + List list = await logoIdentifyService.GetAllRecordAsync(); + if (list == null || list.Count == 0) return; + + await App.Current.Dispatcher.BeginInvoke((Action)(() => { - LogoIdentifyDataGrid.Add(verify); - } - })); - + LogoIdentifyDataGrid.Clear(); + + LogoIdentifyDataGrid.Clear(); + list = list.OrderByDescending(x => x.RecordTime).ToList(); + foreach (LogoIdentify verify in list) + { + LogoIdentifyDataGrid.Add(verify); + } + })); + }); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } #region 界面刷新 diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs index 4b4a9b4..9e71ab0 100644 --- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs @@ -84,6 +84,7 @@ namespace SlnMesnac.WPF.ViewModel } private void Timer_Tick(object sender, EventArgs e) { + Date = DateTime.Now.ToString("yyyy年MM月dd日"); Time = DateTime.Now.ToString("HH:mm:ss"); } @@ -138,6 +139,16 @@ namespace SlnMesnac.WPF.ViewModel } } + private string _Date; + public string Date + { + get { return _Date; } + set + { + _Date = value; + RaisePropertyChanged(nameof(Date)); + } + } public System.Windows.Controls.UserControl _content; diff --git a/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs b/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs index a4a5f35..0bb4c6b 100644 --- a/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs @@ -61,7 +61,8 @@ namespace SlnMesnac.WPF.ViewModel Select(x => new { ProductModel = x.Key, MaterialType = x.FirstOrDefault().MaterialType, - Amount = x.Count() + Amount = x.Count(), + PassAmount = x.Where(s=> s.Result == 1).Count(), }).ToList(); App.Current.Dispatcher.BeginInvoke((Action)(() => { @@ -69,7 +70,7 @@ namespace SlnMesnac.WPF.ViewModel int index = 1; foreach (var item in ModelList) { - ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, Amount = item.Amount }); + ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, TotalAmount = item.Amount ,PassAmount = item.PassAmount ,PassRate = ((double)item.PassAmount / item.Amount).ToString("P2") }); } })); diff --git a/SlnMesnac.WPF/Views/IndexPage.xaml b/SlnMesnac.WPF/Views/IndexPage.xaml index a09948e..6e36d62 100644 --- a/SlnMesnac.WPF/Views/IndexPage.xaml +++ b/SlnMesnac.WPF/Views/IndexPage.xaml @@ -112,7 +112,7 @@ - + @@ -216,7 +216,7 @@ - + diff --git a/SlnMesnac.WPF/Views/StatisticsPageView.xaml b/SlnMesnac.WPF/Views/StatisticsPageView.xaml index ce7e398..8d51f66 100644 --- a/SlnMesnac.WPF/Views/StatisticsPageView.xaml +++ b/SlnMesnac.WPF/Views/StatisticsPageView.xaml @@ -182,10 +182,12 @@ - + - - + + + +