From 4d0768337d01e33615273cf90471092625ad2936 Mon Sep 17 00:00:00 2001 From: wenjy Date: Wed, 3 Jan 2024 19:23:52 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E9=97=A8=E4=BD=93=E5=8F=91?= =?UTF-8?q?=E6=B3=A1=E5=9E=8B=E5=8F=B7=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/RealTimePageViewModel.cs | 89 ++++++++++++++----- .../Views/RealTimePageView.xaml | 17 ++-- 2 files changed, 79 insertions(+), 27 deletions(-) diff --git a/Aucma.Core.DoorFoam/ViewModels/RealTimePageViewModel.cs b/Aucma.Core.DoorFoam/ViewModels/RealTimePageViewModel.cs index 90079006..31bbd5c7 100644 --- a/Aucma.Core.DoorFoam/ViewModels/RealTimePageViewModel.cs +++ b/Aucma.Core.DoorFoam/ViewModels/RealTimePageViewModel.cs @@ -23,6 +23,9 @@ using log4net; using System.Collections; using System.Windows.Documents; using NPOI.SS.Formula.Functions; +using Microsoft.Extensions.FileSystemGlobbing.Internal; +using System.Text.RegularExpressions; +using System.Windows.Controls; namespace Aucma.Core.DoorFoam.ViewModels { @@ -52,27 +55,41 @@ namespace Aucma.Core.DoorFoam.ViewModels /// private void InitEveryDayMethodAsync() { + ChartValues achievement = new ChartValues(); - Random random = new Random(); - for (int i = 0; i < 2; i++) - { - achievement.Add(random.Next(0, 50)); - } - ModelStatistics.Add(new ColumnSeries() - { - DataLabels = true, - Title = "型号", - Values = achievement, - Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)), - Foreground = Brushes.White, - FontSize = 18 - }); - - MaterialNameList = new List() + MaterialNameList = new List(); + + var info = _doorMateHistoryServices.Query(x => x.ScanTime.ToString("yyyy-MM-dd").Contains(DateTime.Now.ToString("yyyy-MM-dd"))); + + App.Current.Dispatcher.BeginInvoke((Action)(() => { - "BCD-287CHN", - "BCD-287CHN" - }; + ModelStatistics.Clear(); + + if (info != null) + { + var groupResult = from p in info + group p by p.MaterialName into g + select new { MaterialName = g.Key, Count = g.Count() }; + foreach (var groupItem in groupResult) + { + achievement.Add(groupItem.Count); + + MaterialNameList.Add(FormatMaterialType(groupItem.MaterialName)); + } + } + + ModelStatistics.Add(new ColumnSeries() + { + DataLabels = true, + Title = "型号", + Values = achievement, + Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)), + Foreground = Brushes.White, + FontSize = 18 + }); + })); + + } @@ -190,6 +207,8 @@ namespace Aucma.Core.DoorFoam.ViewModels #endregion #region 门体匹配队列 + + private int i = 0; /// /// 门体匹配队列 /// @@ -210,15 +229,20 @@ namespace Aucma.Core.DoorFoam.ViewModels DoorMateHistory model = new DoorMateHistory(); if (planInfoDataGrid.Count() == 0) model.ObjId = 1; else model.ObjId = planInfoDataGrid.Count() + 1; - + model.PlanCode = stationPlan.PlanCode; model.OrderCode = stationPlan.OrderCode; model.MaterialCode = stationPlan.MaterialCode; model.MaterialName = stationPlan.MaterialName; model.ScanTime = DateTime.Now; - planInfoDataGrid.Insert(0, model); SaveMateHistory(code,obj, productLineCode, plan, model); + model.MaterialName = this.FormatMaterialType(stationPlan.MaterialName); + model.ObjId = i+1; + planInfoDataGrid.Insert(0, model); + + InitEveryDayMethodAsync();//刷新型号统计图表 + } #region 记录历史 @@ -311,5 +335,28 @@ namespace Aucma.Core.DoorFoam.ViewModels return result; } #endregion + + + /// + /// 格式化物料类型 + /// + /// + /// + private string FormatMaterialType(string materialType) + { + string result = ""; + System.Text.RegularExpressions.Match match = Regex.Match(materialType, @".*?,(.*?),"); + + if (match.Success && match.Groups.Count > 1) + { + result = match.Groups[1].Value; + } + else + { + result = materialType; + } + + return result; + } } } diff --git a/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml b/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml index 1632227e..56294d26 100644 --- a/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml +++ b/Aucma.Core.DoorFoam/Views/RealTimePageView.xaml @@ -10,6 +10,7 @@ @@ -107,7 +108,11 @@ - + + + + + @@ -133,12 +138,12 @@ RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" FontSize="20" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True" - Foreground="White"> + Foreground="White" > - - - + + + @@ -174,7 +179,7 @@ - +