change-首页界面修改

dev
liuwf 1 month ago
parent 98c892a9b3
commit b6c9a4166a

@ -187,12 +187,13 @@ namespace SlnMesnac.Business
/// </summary> /// </summary>
private void ProdPlanExecHandle() private void ProdPlanExecHandle()
{ {
RefreshMesProdList();
//每5秒执行一次获取是否有已开始的计划获取已开始的计划下发给WCS进行叫料获取货架到位信息进行投料校验持续获取设备要料信号 //每5秒执行一次获取是否有已开始的计划获取已开始的计划下发给WCS进行叫料获取货架到位信息进行投料校验持续获取设备要料信号
while (true) while (true)
{ {
try try
{ {
RefreshMesProdList();
var plc = base.GetPlcByKey("plc"); var plc = base.GetPlcByKey("plc");
if (plc == null) if (plc == null)
@ -200,7 +201,7 @@ namespace SlnMesnac.Business
//throw new ArgumentException($"PLC连接信息为空"); //throw new ArgumentException($"PLC连接信息为空");
RefreshMessage($"PLC连接信息为空"); RefreshMessage($"PLC连接信息为空");
Thread.Sleep(3000); Thread.Sleep(3000);
return; continue;
} }
MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
@ -227,8 +228,6 @@ namespace SlnMesnac.Business
{ {
RefreshMessage("等待设备叫料信号触发......"); RefreshMessage("等待设备叫料信号触发......");
Thread.Sleep(5000); Thread.Sleep(5000);
continue; continue;
} }
@ -278,6 +277,8 @@ namespace SlnMesnac.Business
{ {
_logger.LogError($"计划执行逻辑处理异常:{e.Message}"); _logger.LogError($"计划执行逻辑处理异常:{e.Message}");
} }
Thread.Sleep(5000); Thread.Sleep(5000);
} }
} }

@ -175,18 +175,32 @@
<!--日产量--> <!--日产量-->
<Border Grid.Row="1" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5"> <Border Grid.Row="1" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Border Grid.Row="1" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5"> <Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" >
<Grid Margin="10,10"> <lvc:CartesianChart Series="{Binding ModelStatistics, UpdateSourceTrigger=PropertyChanged}" LegendLocation="Top" Foreground="White" DisableAnimations="True">
<lvc:CartesianChart Series="{Binding Achievement, UpdateSourceTrigger=PropertyChanged}"> <lvc:CartesianChart.DataTooltip >
<lvc:CartesianChart.AxisX> <lvc:DefaultTooltip SelectionMode="OnlySender" BulletSize="10" Foreground="Black"></lvc:DefaultTooltip>
<lvc:Axis Labels="{Binding ProductionHourList}" FontSize="15" Foreground="#0288d1"/> </lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart.AxisX> <lvc:CartesianChart.AxisX >
<lvc:CartesianChart.AxisY> <lvc:Axis Labels="{Binding ProductionHourList}" FontSize="18" Foreground="White" LabelsRotation="0" DisableAnimations="True" Position="LeftBottom" >
<lvc:Axis FontSize="15" Foreground="#0288d1"/> <lvc:Axis.Separator>
</lvc:CartesianChart.AxisY> <lvc:Separator Visibility="Hidden" Step="1" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" >
</lvc:CartesianChart> </lvc:Separator>
</Grid> </lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="18" Foreground="White" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator Step="10" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Border> </Border>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>

@ -21,6 +21,8 @@ using SlnMesnac.Common;
using HslCommunication.Profinet.GE; using HslCommunication.Profinet.GE;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
using Application = System.Windows.Application; using Application = System.Windows.Application;
using LiveCharts;
using System.Threading;
namespace SlnMesnac.WPF.ViewModel namespace SlnMesnac.WPF.ViewModel
{ {
@ -125,8 +127,8 @@ namespace SlnMesnac.WPF.ViewModel
/// <summary> /// <summary>
/// 完成率 /// 完成率
/// </summary> /// </summary>
public string compleRoution; public decimal compleRoution;
public string CompleRoution public decimal CompleRoution
{ {
get { return compleRoution; } get { return compleRoution; }
set { compleRoution = value; RaisePropertyChanged(nameof(CompleRoution)); } set { compleRoution = value; RaisePropertyChanged(nameof(CompleRoution)); }
@ -154,6 +156,33 @@ namespace SlnMesnac.WPF.ViewModel
} }
#endregion #endregion
#region 日产量柱状图X轴日期
/// <summary>
/// 日产量柱状图X轴日期
/// </summary>
private List<string> productionHourList = new List<string>();
public List<string> ProductionHourList
{
get { return productionHourList; }
set { productionHourList = value; }
}
#endregion
#region 型号统计柱状图
/// <summary>
/// 型号统计柱状图
/// </summary>
private SeriesCollection achievement = new SeriesCollection();
public SeriesCollection Achievement
{
get { return achievement; }
set { achievement = value; }
}
#endregion
#region 事件定义 #region 事件定义
/// <summary> /// <summary>
@ -169,8 +198,7 @@ namespace SlnMesnac.WPF.ViewModel
public ProdMgmtViewModel() public ProdMgmtViewModel()
{ {
StartProdPlanCommand = new RelayCommand<string>(obj => StartProdPlan(obj)); StartProdPlanCommand = new RelayCommand<string>(obj => StartProdPlan(obj));
StopProdPlanCommand = new RelayCommand<string>(obj => StopProdPlan(obj)); StopProdPlanCommand = new RelayCommand<string>(obj => StopProdPlan(obj));
_logger = App.ServiceProvider.GetService<ILogger<ProdMgmtViewModel>>(); _logger = App.ServiceProvider.GetService<ILogger<ProdMgmtViewModel>>();
@ -192,8 +220,12 @@ namespace SlnMesnac.WPF.ViewModel
Task.Run(() => Task.Run(() =>
{ {
_prodCompletionBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox; _prodCompletionBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox;
// _prodCompletionBusiness.Init(); // _prodCompletionBusiness.Init();
}); });
RefreChart();
} }
public void test() public void test()
@ -219,7 +251,7 @@ namespace SlnMesnac.WPF.ViewModel
PlanAmount = Convert.ToInt32(prodPlan.PlanAmount); PlanAmount = Convert.ToInt32(prodPlan.PlanAmount);
ComplateAmout = Convert.ToInt32(prodPlan.CompleteAmount); ComplateAmout = Convert.ToInt32(prodPlan.CompleteAmount);
DiffAmount = Convert.ToInt32(prodPlan.PlanAmount) - Convert.ToInt32(prodPlan.CompleteAmount); DiffAmount = Convert.ToInt32(prodPlan.PlanAmount) - Convert.ToInt32(prodPlan.CompleteAmount);
CompleRoution = "50"; CompleRoution = Math.Round((prodPlan.CompleteAmount / prodPlan.PlanAmount) * 100, 2);
} }
else else
{ {
@ -230,7 +262,7 @@ namespace SlnMesnac.WPF.ViewModel
PlanAmount = 0; PlanAmount = 0;
ComplateAmout = 0; ComplateAmout = 0;
DiffAmount = 0; DiffAmount = 0;
CompleRoution = string.Empty; CompleRoution = 0;
} }
} }
@ -402,5 +434,14 @@ namespace SlnMesnac.WPF.ViewModel
}); });
} }
/// <summary>
/// 刷新产量统计图表
/// </summary>
private async void RefreChart()
{
ProductionHourList = new List<string>() {"8:00","9:00","10:00","11:00","12:00","13:00", "14:00", "15:00", "16:00", "17:00","18:00","19:00","20:00" };
}
} }
} }

Loading…
Cancel
Save