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 @@ - + - - + + + +