change - 老线发泡货道信息、夹具状态、模具数量显示

dev
wenjy 1 year ago
parent 1c6d48bff1
commit 7dd182e2f5

@ -33,7 +33,7 @@ namespace Aucma.Core.OldBoxFoam.Business
/// 刷新货道
/// </summary>
/// <param name="message"></param>
public delegate void RefreshSpace(List<SpaceDetailModel> spaceDetailModel);
public delegate void RefreshSpace(List<SpaceDetailModel> spaceDetailModel, List<FixtureStatus> fixtureStatus);
public static event RefreshSpace RefreshSpaceEvent;
/// <summary>
@ -74,7 +74,6 @@ namespace Aucma.Core.OldBoxFoam.Business
StoreAmount = spaceAmount.StoreAmount
};
spaceDetailModel = spaceCollection.ToList();
RefreshSpaceEvent?.Invoke(spaceDetailModel);
List<FixtureStatus> boxTypeList = ReadBoxType(plc1, plc2, plc3, plc4);
@ -101,6 +100,8 @@ namespace Aucma.Core.OldBoxFoam.Business
if(listFixtureStatus != null)
{
RefreshSpaceEvent?.Invoke(spaceDetailModel, listFixtureStatus);
RefreshFoamMachineEvent?.Invoke(listFixtureStatus);
List<RecordBoxFoamFixtureComplate> fixtureComplates = new List<RecordBoxFoamFixtureComplate>();

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Aucma.Core.OldBoxFoam.ConvertTo
{
/// <summary>
/// 货道信息列表,货道位置
/// </summary>
public class SpaceInfoLocalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return DependencyProperty.UnsetValue;
if (parameter is string stringValue && value is string cellValue)
{
return cellValue.Equals(stringValue);
}
return DependencyProperty.UnsetValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -53,5 +53,7 @@ namespace Aucma.Core.OldBoxFoam.Models
public string MaterialName { get; set; }
public string SpaceName { get; set; }
public int QualityResult { get; set; }
}
}

@ -80,7 +80,10 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
_statusColor.Clear();
foreach (var item in prderList)
{
if(item.FixtureBoxType == "0")
{
item.Status = 3;
}
switch (item.Status)
{
case 1:
@ -96,7 +99,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
//Console.WriteLine("Red");
break;
default:
_statusColor.Add("Gray");
_statusColor.Add("Red");
//Console.WriteLine("Gray");
break;
}

@ -23,6 +23,7 @@ using NPOI.SS.Formula.Functions;
using System.Windows.Documents;
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
using System.Windows.Media;
using log4net;
namespace Aucma.Core.OldBoxFoam.ViewModels
{
@ -32,6 +33,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
* */
public partial class RealRoadPageViewModel : ObservableObject
{
private readonly log4net.ILog log = LogManager.GetLogger(typeof(RealRoadPageViewModel));
protected readonly IBoxFoamPlanServices? _boxFoamPlanServices;
private IOldBoxFoamTypeServices? _oldBoxFoamTypeServices;
private IBoxFoamDataServices? _boxFoamDataServices;
@ -46,13 +48,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
_boxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
//InitData();
Collection.RefreshSpaceEvent += InitData;
timer2.Elapsed += new System.Timers.ElapsedEventHandler(InitData); //到达时间的时候执行事件;
timer2.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
//RefreshHourOutPutChart();
//RefreshMaterialTypeChart();
}
#region 参数定义
@ -122,61 +118,71 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
}
#endregion
public async void InitData(object? sender, ElapsedEventArgs e)
{
List<OldBoxFoamType> list = await _oldBoxFoamTypeServices.QueryAsync();
if(list != null)
{
if(list.Count > 0)
{
list = list.OrderBy(x=>x.ObjId).ToList();
int totalItems = list.Count;
int half = totalItems / 2;
List<OldBoxFoamType> spaceInfoLeft = list.Take(half).ToList();
List<OldBoxFoamType> spaceInfoRight = list.Skip(half).ToList();
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
ListItems.Clear();
if (spaceInfoLeft == null) return;
for (int i = 0; i < spaceInfoLeft.Count; i++)
{
ListItems.Add(new OldBoxFoamTypeModel()
{
SpaceName = $"东线{i + 1}",
Local = spaceInfoLeft[i].Local,
Status = spaceInfoLeft[i].Storeamount == 3 ? "1" : "0",
Storeamount = spaceInfoLeft[i].Storeamount,
MaterialCode = spaceInfoLeft[i].MaterialCode,
MaterialName = spaceInfoLeft[i].MaterialName,
Boxtype = spaceInfoLeft[i].Boxtype,
});
}
if (spaceInfoRight == null) return;
for (int i = 0; i < spaceInfoRight.Count; i++)
{
ListItems.Add(new OldBoxFoamTypeModel()
{
SpaceName = $"西线{i + 1}",
Local = spaceInfoRight[i].Local,
Status = spaceInfoRight[i].Storeamount == 3 ? "1" : "0",
Storeamount = spaceInfoRight[i].Storeamount,
MaterialCode = spaceInfoRight[i].MaterialCode,
MaterialName = spaceInfoRight[i].MaterialName,
Boxtype = spaceInfoRight[i].Boxtype,
});
}
}));
}
}
}
#region 原货道信息刷新 Delete By wenjy 2024-01-13
//public async void InitData(object? sender, ElapsedEventArgs e)
//{
// List<OldBoxFoamType> list = await _oldBoxFoamTypeServices.QueryAsync();
// if(list != null)
// {
// if(list.Count > 0)
// {
// list = list.OrderBy(x=>x.ObjId).ToList();
// int totalItems = list.Count;
// int half = totalItems / 2;
// List<OldBoxFoamType> spaceInfoLeft = list.Take(half).ToList();
// List<OldBoxFoamType> spaceInfoRight = list.Skip(half).ToList();
// System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
// {
// ListItems.Clear();
// if (spaceInfoLeft == null) return;
// for (int i = 0; i < spaceInfoLeft.Count; i++)
// {
// if (i != 1)
// {
// spaceInfoLeft[i].Local = "";
// }
// ListItems.Add(new OldBoxFoamTypeModel()
// {
// SpaceName = $"{i + 1}#货道",
// Local = spaceInfoLeft[i].Local,
// Status = spaceInfoLeft[i].Storeamount == 3 ? "1" : "0",
// Storeamount = spaceInfoLeft[i].Storeamount > 3 ? 0 : spaceInfoLeft[i].Storeamount,
// MaterialCode = spaceInfoLeft[i].MaterialCode,
// MaterialName = spaceInfoLeft[i].MaterialName,
// Boxtype = spaceInfoLeft[i].Boxtype,
// });
// }
// if (spaceInfoRight == null) return;
// for (int i = 0; i < spaceInfoRight.Count; i++)
// {
// if (i != 1)
// {
// spaceInfoRight[i].Local = "";
// }
// ListItems.Add(new OldBoxFoamTypeModel()
// {
// SpaceName = $"{i + 1}#货道",
// Local = spaceInfoRight[i].Local,
// Status = spaceInfoRight[i].Storeamount == 3 ? "1" : "0",
// Storeamount = spaceInfoRight[i].Storeamount > 3 ? 0 : spaceInfoRight[i].Storeamount,
// MaterialCode = spaceInfoRight[i].MaterialCode,
// MaterialName = spaceInfoRight[i].MaterialName,
// Boxtype = spaceInfoRight[i].Boxtype,
// });
// }
// }));
// }
// }
//}
#endregion
#region 初始化datagrid
private ObservableCollection<OldBoxFoamTypeModel> listItems = new ObservableCollection<OldBoxFoamTypeModel>();
@ -196,7 +202,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
/// 更新货道信息
/// </summary>
/// <param name="spaceDetailModel"></param>
public async void InitData(List<SpaceDetailModel> spaceDetailModel)
public async void InitData(List<SpaceDetailModel> spaceDetailModel, List<FixtureStatus> fixtureStatus)
{
if (spaceDetailModel == null) return;
var spaceList = _oldBoxFoamTypeServices.QueryAsync().Result;
@ -221,15 +227,98 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
{
await _oldBoxFoamTypeServices.UpdateAsync(storeList);
}
RefreshSpaceInfoDataGrid(spaceDetailModel, fixtureStatus);
RefreshHourOutPutChart();
RefreshMaterialTypeChart();
}
private void RefreshSpaceInfoDataGrid(List<SpaceDetailModel> spaceDetailModel, List<FixtureStatus> fixtureStatus)
{
try
{
if (spaceDetailModel != null)
{
if (spaceDetailModel.Count > 0)
{
spaceDetailModel = spaceDetailModel.OrderBy(x => x.ObjId).ToList();
int totalItems = spaceDetailModel.Count;
int half = totalItems / 2;
List<SpaceDetailModel> spaceInfoLeft = spaceDetailModel.Take(half).ToList();
List<SpaceDetailModel> spaceInfoRight = spaceDetailModel.Skip(half).ToList();
List<OldBoxFoamType> list = _oldBoxFoamTypeServices.QueryAsync().Result;
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
ListItems.Clear();
if (spaceInfoLeft == null) return;
for (int i = 0; i < spaceInfoLeft.Count; i++)
{
var spaceInfo = list.Where(x => x.ObjId == spaceInfoLeft[i].ObjId).ToList().First();
if (i != 1)
{
spaceInfo.Local = "";
}
var boxType = spaceInfo.Boxtype;
int fixtureAmount = fixtureStatus.Where(x => x.FixtureBoxType == boxType && x.Status != 3 && x.Status != 0).ToList().Count();
ListItems.Add(new OldBoxFoamTypeModel()
{
SpaceName = $"{i + 1}#货道",
Local = spaceInfo.Local,
Status = spaceInfoLeft[i].StoreAmount == 3 ? "1" : "0",
Storeamount = spaceInfoLeft[i].StoreAmount > 3 ? 0 : spaceInfoLeft[i].StoreAmount,
MaterialCode = spaceInfo.MaterialCode,
MaterialName = spaceInfo.MaterialName,
Boxtype = spaceInfoLeft[i].StoreType,
QualityResult = fixtureAmount,
});
}
if (spaceInfoRight == null) return;
for (int i = 0; i < spaceInfoRight.Count; i++)
{
var spaceInfo = list.Where(x => x.ObjId == spaceInfoRight[i].ObjId).ToList().First();
if (i != 1)
{
spaceInfo.Local = "";
}
var boxType = spaceInfo.Boxtype;
int fixtureAmount = fixtureStatus.Where(x => x.FixtureBoxType == boxType && x.Status != 3 && x.Status != 0).ToList().Count();
ListItems.Add(new OldBoxFoamTypeModel()
{
SpaceName = $"{i + 1}#货道",
Local = spaceInfo.Local,
Status = spaceInfoRight[i].StoreAmount == 3 ? "1" : "0",
Storeamount = spaceInfoRight[i].StoreAmount > 3 ? 0 : spaceInfoRight[i].StoreAmount,
MaterialCode = spaceInfo.MaterialCode,
MaterialName = spaceInfo.MaterialName,
Boxtype = spaceInfoRight[i].StoreType,
QualityResult = fixtureAmount,
});
}
}));
}
}
}catch(Exception ex)
{
log.Error($"货道信息列表刷新异常:{ex.Message}");
}
}
/// <summary>
/// 小时统计图表
/// </summary>
private void RefreshHourOutPutChart()
{
try
{
ChartValues<double> hourAchievement = new ChartValues<double>();
HourOutPutList = new List<string>();
@ -291,6 +380,10 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
HourAchievement.Add(shellColumn);
}
}));
}catch(Exception ex)
{
log.Error($"小时统计图表刷新异常:{ex.Message}");
}
}
@ -298,6 +391,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
/// 型号统计图表
/// </summary>
private void RefreshMaterialTypeChart()
{
try
{
ChartValues<double> materialTypeAchievement = new ChartValues<double>();
MaterialTypeOutPutList = new List<string>();
@ -336,6 +431,10 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
MaterialTypeAchievement.Add(shellColumn);
}
}));
}catch(Exception ex)
{
log.Error($"型号统计图表刷新异常:{ex.Message}");
}
}
}

@ -111,7 +111,7 @@
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.ColumnSpan="4" Background="#1157b9">
<TextBlock Text="发泡线" Foreground="White" FontSize="18" FontWeight="Bold"/>
<TextBlock Text="东线发泡线" Foreground="White" FontSize="18" FontWeight="Bold"/>
</Border>
<Border Grid.Row="1" Grid.Column="0" Background="#1157b9">
<TextBlock Text="夹具号" Foreground="White" FontSize="18" FontWeight="Bold"/>
@ -314,7 +314,7 @@
<TextBlock Text="{Binding Beat[11]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="0" Grid.Column="6" Grid.ColumnSpan="4" Background="#1157b9">
<TextBlock Text="发泡线" Foreground="White" FontSize="18" FontWeight="Bold"/>
<TextBlock Text="西线发泡线" Foreground="White" FontSize="18" FontWeight="Bold"/>
</Border>
<Border Grid.Row="1" Grid.Column="5" Background="#1157b9">

@ -228,8 +228,8 @@
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
Foreground="White">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding SpaceName}" Header="货道号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Local}" Header="位置" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding SpaceName}" Header="货道号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTemplateColumn Width="*" Header="状态">
<DataGridTemplateColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
@ -244,13 +244,13 @@
</Style>
</DataGridTemplateColumn.CellStyle>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Boxtype}" Header="货道型" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Boxtype}" Header="货道型" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Storeamount}" Header="库存数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding Status}" Header="库存状态" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="物料编号" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<!--<DataGridTextColumn Binding="{Binding QualityResult}" Header="模具数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding QualityResult}" Header="模具数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
<!--<Grid.RowDefinitions>

@ -1,6 +1,7 @@
using Aucma.Core.OldBoxFoam.ViewModels;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

@ -205,7 +205,7 @@
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc1",
"IP": "10.10.93.151",
"IP": "10.10.93.153",
//"IP": "127.0.0.1",
"Port": 5002
},
@ -214,7 +214,7 @@
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc2",
"IP": "10.10.93.152",
"IP": "10.10.93.154",
"Port": 5002
},
{
@ -222,7 +222,7 @@
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc3",
"IP": "10.10.93.153",
"IP": "10.10.93.151",
"Port": 5002
},
{
@ -230,7 +230,7 @@
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc4",
"IP": "10.10.93.154",
"IP": "10.10.93.152",
"Port": 5002
},
{

Loading…
Cancel
Save