change - 门体发泡型号统计功能实现

dev
wenjy 1 year ago
parent 1a1e4bffd6
commit 4d0768337d

@ -23,6 +23,9 @@ using log4net;
using System.Collections; using System.Collections;
using System.Windows.Documents; using System.Windows.Documents;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Microsoft.Extensions.FileSystemGlobbing.Internal;
using System.Text.RegularExpressions;
using System.Windows.Controls;
namespace Aucma.Core.DoorFoam.ViewModels namespace Aucma.Core.DoorFoam.ViewModels
{ {
@ -52,27 +55,41 @@ namespace Aucma.Core.DoorFoam.ViewModels
/// <returns></returns> /// <returns></returns>
private void InitEveryDayMethodAsync() private void InitEveryDayMethodAsync()
{ {
ChartValues<double> achievement = new ChartValues<double>(); ChartValues<double> achievement = new ChartValues<double>();
Random random = new Random(); MaterialNameList = new List<string>();
for (int i = 0; i < 2; i++)
{ var info = _doorMateHistoryServices.Query(x => x.ScanTime.ToString("yyyy-MM-dd").Contains(DateTime.Now.ToString("yyyy-MM-dd")));
achievement.Add(random.Next(0, 50));
} App.Current.Dispatcher.BeginInvoke((Action)(() =>
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<string>()
{ {
"BCD-287CHN", ModelStatistics.Clear();
"BCD-287CHN"
}; 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 #endregion
#region 门体匹配队列 #region 门体匹配队列
private int i = 0;
/// <summary> /// <summary>
/// 门体匹配队列 /// 门体匹配队列
/// </summary> /// </summary>
@ -210,15 +229,20 @@ namespace Aucma.Core.DoorFoam.ViewModels
DoorMateHistory model = new DoorMateHistory(); DoorMateHistory model = new DoorMateHistory();
if (planInfoDataGrid.Count() == 0) model.ObjId = 1; if (planInfoDataGrid.Count() == 0) model.ObjId = 1;
else model.ObjId = planInfoDataGrid.Count() + 1; else model.ObjId = planInfoDataGrid.Count() + 1;
model.PlanCode = stationPlan.PlanCode; model.PlanCode = stationPlan.PlanCode;
model.OrderCode = stationPlan.OrderCode; model.OrderCode = stationPlan.OrderCode;
model.MaterialCode = stationPlan.MaterialCode; model.MaterialCode = stationPlan.MaterialCode;
model.MaterialName = stationPlan.MaterialName; model.MaterialName = stationPlan.MaterialName;
model.ScanTime = DateTime.Now; model.ScanTime = DateTime.Now;
planInfoDataGrid.Insert(0, model);
SaveMateHistory(code,obj, productLineCode, plan, model); SaveMateHistory(code,obj, productLineCode, plan, model);
model.MaterialName = this.FormatMaterialType(stationPlan.MaterialName);
model.ObjId = i+1;
planInfoDataGrid.Insert(0, model);
InitEveryDayMethodAsync();//刷新型号统计图表
} }
#region 记录历史 #region 记录历史
@ -311,5 +335,28 @@ namespace Aucma.Core.DoorFoam.ViewModels
return result; return result;
} }
#endregion #endregion
/// <summary>
/// 格式化物料类型
/// </summary>
/// <param name="materialType"></param>
/// <returns></returns>
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;
}
} }
} }

@ -10,6 +10,7 @@
<UserControl.Resources> <UserControl.Resources>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}"> <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20"/>
</Style> </Style>
@ -107,7 +108,11 @@
<Border Grid.Column="1" BorderThickness="0" Background="Transparent" CornerRadius="5" Margin="0,10,0,0"> <Border Grid.Column="1" BorderThickness="0" Background="Transparent" CornerRadius="5" Margin="0,10,0,0">
<Grid> <Grid>
<ListBox Grid.Row="1" x:Name="listBox" ItemsSource="{Binding LogInfoListBox}" Foreground="White" Background="Transparent" BorderBrush="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"/> <Grid.RowDefinitions>
<RowDefinition Height="166*"/>
<RowDefinition Height="7*"/>
</Grid.RowDefinitions>
<ListBox x:Name="listBox" ItemsSource="{Binding LogInfoListBox}" Foreground="White" Background="Transparent" BorderBrush="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" Grid.RowSpan="2"/>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
@ -133,12 +138,12 @@
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" FontSize="20" RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" FontSize="20"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
Foreground="White"> Foreground="White" >
<!--修改选中字体颜色--> <!--修改选中字体颜色-->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="编号" Width="auto" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding ObjId}" Header=" 编号" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="箱型" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding MaterialName}" Header="箱型" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ScanDate}" Header="匹配时间" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding ScanTime,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="匹配时间" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<!--<DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />--> <!--<DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />-->
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
@ -174,7 +179,7 @@
</lvc:Axis> </lvc:Axis>
</lvc:CartesianChart.AxisX> </lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="15"> <lvc:Axis FontSize="15" MinValue="0" MaxValue="50">
<lvc:Axis.Separator> <lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" > <lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator> </lvc:Separator>

Loading…
Cancel
Save