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

dev
wenjy 1 year ago
parent 1a1e4bffd6
commit 4d0768337d

@ -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,12 +55,29 @@ namespace Aucma.Core.DoorFoam.ViewModels
/// <returns></returns>
private void InitEveryDayMethodAsync()
{
ChartValues<double> achievement = new ChartValues<double>();
Random random = new Random();
for (int i = 0; i < 2; i++)
MaterialNameList = new List<string>();
var info = _doorMateHistoryServices.Query(x => x.ScanTime.ToString("yyyy-MM-dd").Contains(DateTime.Now.ToString("yyyy-MM-dd")));
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
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(random.Next(0, 50));
achievement.Add(groupItem.Count);
MaterialNameList.Add(FormatMaterialType(groupItem.MaterialName));
}
}
ModelStatistics.Add(new ColumnSeries()
{
DataLabels = true,
@ -67,12 +87,9 @@ namespace Aucma.Core.DoorFoam.ViewModels
Foreground = Brushes.White,
FontSize = 18
});
}));
MaterialNameList = new List<string>()
{
"BCD-287CHN",
"BCD-287CHN"
};
}
@ -190,6 +207,8 @@ namespace Aucma.Core.DoorFoam.ViewModels
#endregion
#region 门体匹配队列
private int i = 0;
/// <summary>
/// 门体匹配队列
/// </summary>
@ -216,9 +235,14 @@ namespace Aucma.Core.DoorFoam.ViewModels
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
/// <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>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="20"/>
</Style>
@ -107,7 +108,11 @@
<Border Grid.Column="1" BorderThickness="0" Background="Transparent" CornerRadius="5" Margin="0,10,0,0">
<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>
</Border>
</Grid>
@ -136,9 +141,9 @@
Foreground="White" >
<!--修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="编号" Width="auto" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="箱型" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ScanDate}" Header="匹配时间" Width="0.5*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding ObjId}" Header=" 编号" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="箱型" Width="*" 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}" />-->
</DataGrid.Columns>
</DataGrid>
@ -174,7 +179,7 @@
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="15">
<lvc:Axis FontSize="15" MinValue="0" MaxValue="50">
<lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator>

Loading…
Cancel
Save