change -成品下线datagrid

dev
liuwf 1 year ago
parent 28cb87275c
commit eccc078f5e

@ -107,14 +107,13 @@ namespace Aucma.Core.CodeBinding.ViewModels
records = await _codeBindingRecordServices.QueryAsync(x => x.BoxCode != null && x.RecordTime2 >= System.DateTime.Now.AddDays(-1), "RECORD_TIME2 desc");
if (records != null)
{
foreach (CodeBindingRecord record in records)
Application.Current.Dispatcher.Invoke(() =>
{
Application.Current.Dispatcher.Invoke(() =>
{
ListItems.Add(new ReaderInfo() { No = ListItems.Count + 1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName, BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass == 2 ? "plc放行成功" : "", RecordTime = record.RecordTime2.ToString() });
});
foreach (CodeBindingRecord record in records)
{
ListItems.Add(new ReaderInfo() { No = ListItems.Count + 1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName, BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass == 2 ? "plc放行成功" : "", RecordTime = record.RecordTime2.ToString() });
}
});
}
}
// 修改为统计近一天

@ -13,7 +13,8 @@ namespace Aucma.Core.ProductOffLine.Models
/// </summary>
public class TempInfo
{
public int No { get; set; } //序号
public string ProductFactoryCode { get; set; } //计划工厂
public string ProductSNCode { get; set; } //公司条码

@ -8,7 +8,6 @@ using Aucma.Core.Scanner;
using Microsoft.Extensions.Hosting;
using NPOI.SS.Formula.Functions;
using Oracle.ManagedDataAccess.Client;
using System.Windows.Forms;
using System.Threading;
using static Aucma.Core.Scanner.MvCodeHelper;
using Admin.Core.Common;
@ -31,6 +30,10 @@ using System.Windows.Forms.VisualStyles;
using Microsoft.IdentityModel.Logging;
using Aucma.Core.ProductOffLine.Business;
using System.Windows.Media;
using NPOI.HSSF.Record;
using System.Windows;
using System.Collections.ObjectModel;
using Aucma.Core.ProductOffLine.Models;
/*
@ -42,9 +45,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
private readonly IBaseOrderInfoServices _baseOrderInfoServices;
private readonly IProductPlanInfoServices? _productPlanInfoServices;
private readonly IProductOffLineServices ? _productOffLineServices;
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
System.Timers.Timer timer = new System.Timers.Timer(1000);
@ -53,16 +58,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public IndexPageViewModel()
{
offLineBusiness.test();
_productOffLineServices = App.ServiceProvider.GetService<IProductOffLineServices>();
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
// test33();
ReceiveCode("12345", 1);
StartPlcTimer();
InitEveryDayMethod();
test2();
}
/// <summary>
/// 开启plc读取定时器
@ -196,6 +198,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private void InitEveryDayMethod()
{
LoadData();
StationName = "成品下线扫描";
MaterialName = "SC-AUCMA-农夫山泉SC 门体";
OrderNo = "8512365486";
@ -243,8 +246,39 @@ namespace Aucma.Core.ProductOffLine.ViewModels
column2.Values = achievement2;
column2.Foreground = Brushes.White;
Achievement.Add(column2);
// 加载datagrid
}
public async void LoadData()
{
List<OffLineInfo> list = await _offLineInfoServices.QueryAsync(x=>x.ProductScanTime >= System.DateTime.Now.AddDays(-1), "PRODUCT_SCANTIME desc");
if (list != null)
{
foreach (OffLineInfo record in list)
{
Application.Current.Dispatcher.Invoke(() =>
{
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
});
}
}
}
#region 初始化datagrid
private ObservableCollection<TempInfo> listItems = new ObservableCollection<TempInfo>() { };
public ObservableCollection<TempInfo> ListItems
{
get { return listItems; }
set
{
listItems = value;
OnPropertyChanged();//属性通知
}
}
#endregion
#region 日产量柱状图
/// <summary>
@ -448,43 +482,6 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
#endregion
/// <summary>
/// 连接测试
/// </summary>
private void test33()
{
var list = _baseOrderInfoServices.QueryAsync();
// 使用条码数据库连接
try
{
//条码系统返回校验数据
string result = _productOffLineServices.QueryChecked("5").Result;
Console.WriteLine(result);
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// 测试
/// </summary>
private async void test2()
{
Task.Run(() =>
{
Thread.Sleep(2000);
ReceiveCode("123456", 1);
});
Task.Run(() =>
{
Thread.Sleep(3000);
ReceiveCode("654321", 2);
});
}
}
}

@ -1,7 +1,10 @@
using Admin.Core.Model;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Aucma.Core.ProductOffLine.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -15,35 +18,43 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
public partial class StatisticsPageViewModel : ObservableObject
{
public StatisticsPageViewModel() { LoadData(); }
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
public StatisticsPageViewModel() {
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
LoadData();
}
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
#region 加载DataGrid数据
private void LoadData()
private async void LoadData()
{
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 2, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 60, CompleteAmount = 40 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 3, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 4, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 40, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 5, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 30, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 6, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 20 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 7, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 10, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 8, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 9, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 80, CompleteAmount = 10 });
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 10, ProductPlanCode = "8659452123", MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10});
List<OffLineInfo> list = await _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= System.DateTime.Now.AddDays(-1), "PRODUCT_SCANTIME desc");
if (list != null)
{
foreach (OffLineInfo record in list)
{
Application.Current.Dispatcher.Invoke(() =>
{
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
});
}
}
}
#endregion
#region 初始化datagrid
private ObservableCollection<MaterialComplateInfo> materialDataGrid = new ObservableCollection<MaterialComplateInfo>();
public ObservableCollection<MaterialComplateInfo> MaterialDataGrid
private ObservableCollection<TempInfo> listItems = new ObservableCollection<TempInfo>() { };
public ObservableCollection<TempInfo> ListItems
{
get { return materialDataGrid; }
get { return listItems; }
set
{
materialDataGrid = value;
listItems = value;
OnPropertyChanged();//属性通知
}
}

@ -208,11 +208,11 @@
<Border Grid.Row="0" Grid.Column="5" Background="#1157b9">
<TextBlock Text="下线产量" Foreground="White" />
</Border>
<Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="5">
<Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="5" Height="78" VerticalAlignment="Top">
<TextBlock Text="255" Foreground="White" FontSize="40"/>
</Border>
<Border Grid.Row="3" Grid.Column="5" Height="39" VerticalAlignment="Center">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<RadioButton Content="A库" Margin="5 0" Foreground="White"/>
<RadioButton Content="B库" Margin="5 0" Foreground="White" />
</WrapPanel>
@ -298,18 +298,18 @@
</Grid>
</Border>
<Border Grid.Row="2">
<DataGrid Grid.Row="0" ItemsSource="{Binding PlanInfoDataGrid}" ColumnHeaderHeight="35" Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"
<DataGrid Grid.Row="0" ItemsSource="{Binding ListItems}" ColumnHeaderHeight="35" Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
Foreground="White" >
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanCode}" Header="订单编号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialBarCode}" Header="产品条码" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding EnterSpace}" Header="特征信息" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Status,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="扫描时间" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ProductOrderNo}" Header="订单编号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ProductSNCode}" Header="产品条码" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ProductModel}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding ProductRemark}" Header="特征信息" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ProductScanTime,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="扫描时间" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>

@ -89,7 +89,7 @@
</Button>
</WrapPanel>
<UniformGrid Grid.Row="1">
<DataGrid Grid.Row="0" ItemsSource="{Binding MaterialDataGrid}" Background="Transparent"
<DataGrid Grid.Row="0" ItemsSource="{Binding ListItems}" Background="Transparent"
ColumnHeaderHeight="35"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
@ -109,24 +109,16 @@
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<!--表头剧中-->
<!--<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center">
<Setter Property="BorderThickness" Value="1" />
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>-->
<!--修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="1*" />
<DataGridTextColumn Binding="{Binding PlanCode}" Header="订单编号" Width="3*" />
<DataGridTextColumn Binding="{Binding MaterialBarCode}" Header="产品条码" Width="3*" />
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="产品型号" Width="3*" />
<DataGridTextColumn Binding="{Binding EnterSpace}" Header="特征信息" Width="3*" />
<DataGridTextColumn Binding="{Binding Status,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="扫描时间" Width="3*"/>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="1*" />
<DataGridTextColumn Binding="{Binding ProductOrderNo}" Header="订单编号" Width="3*" />
<DataGridTextColumn Binding="{Binding ProductSNCode}" Header="产品条码" Width="3*" />
<DataGridTextColumn Binding="{Binding ProductModel}" Header="产品型号" Width="3*" />
<DataGridTextColumn Binding="{Binding ProductRemark}" Header="特征信息" Width="3*" />
<DataGridTextColumn Binding="{Binding ProductScanTime,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="扫描时间" Width="3*"/>
</DataGrid.Columns>
</DataGrid.Columns>
</DataGrid>
</UniformGrid>
</Grid>

Loading…
Cancel
Save