From b6c9a4166a5b7f4e09786574a8748a20e57c1a7d Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 11 Oct 2024 13:31:40 +0800 Subject: [PATCH] =?UTF-8?q?change-=E9=A6=96=E9=A1=B5=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/ProdMgmtBusiness.cs | 9 ++-- SlnMesnac.WPF/Page/ProdMgmtPage.xaml | 36 +++++++++---- SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs | 53 +++++++++++++++++--- 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/SlnMesnac.Business/ProdMgmtBusiness.cs b/SlnMesnac.Business/ProdMgmtBusiness.cs index ea4e0c3..b5be52e 100644 --- a/SlnMesnac.Business/ProdMgmtBusiness.cs +++ b/SlnMesnac.Business/ProdMgmtBusiness.cs @@ -187,12 +187,13 @@ namespace SlnMesnac.Business /// private void ProdPlanExecHandle() { - RefreshMesProdList(); + //每5秒执行一次,获取是否有已开始的计划,获取已开始的计划下发给WCS进行叫料,获取货架到位信息进行投料校验,持续获取设备要料信号 while (true) { try { + RefreshMesProdList(); var plc = base.GetPlcByKey("plc"); if (plc == null) @@ -200,7 +201,7 @@ namespace SlnMesnac.Business //throw new ArgumentException($"PLC连接信息为空"); RefreshMessage($"PLC连接信息为空"); Thread.Sleep(3000); - return; + continue; } MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); @@ -227,8 +228,6 @@ namespace SlnMesnac.Business { RefreshMessage("等待设备叫料信号触发......"); Thread.Sleep(5000); - - continue; } @@ -278,6 +277,8 @@ namespace SlnMesnac.Business { _logger.LogError($"计划执行逻辑处理异常:{e.Message}"); } + + Thread.Sleep(5000); } } diff --git a/SlnMesnac.WPF/Page/ProdMgmtPage.xaml b/SlnMesnac.WPF/Page/ProdMgmtPage.xaml index d4bae3b..fd42f39 100644 --- a/SlnMesnac.WPF/Page/ProdMgmtPage.xaml +++ b/SlnMesnac.WPF/Page/ProdMgmtPage.xaml @@ -175,18 +175,32 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs index 0aabc31..e85b0a4 100644 --- a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs @@ -21,6 +21,8 @@ using SlnMesnac.Common; using HslCommunication.Profinet.GE; using static System.Net.Mime.MediaTypeNames; using Application = System.Windows.Application; +using LiveCharts; +using System.Threading; namespace SlnMesnac.WPF.ViewModel { @@ -125,8 +127,8 @@ namespace SlnMesnac.WPF.ViewModel /// /// 完成率 /// - public string compleRoution; - public string CompleRoution + public decimal compleRoution; + public decimal CompleRoution { get { return compleRoution; } set { compleRoution = value; RaisePropertyChanged(nameof(CompleRoution)); } @@ -154,6 +156,33 @@ namespace SlnMesnac.WPF.ViewModel } #endregion + + #region 日产量柱状图X轴日期 + /// + /// 日产量柱状图X轴日期 + /// + private List productionHourList = new List(); + + public List ProductionHourList + { + get { return productionHourList; } + set { productionHourList = value; } + } + #endregion + + #region 型号统计柱状图 + /// + /// 型号统计柱状图 + /// + private SeriesCollection achievement = new SeriesCollection(); + + public SeriesCollection Achievement + { + get { return achievement; } + set { achievement = value; } + } + #endregion + #region 事件定义 /// @@ -169,8 +198,7 @@ namespace SlnMesnac.WPF.ViewModel public ProdMgmtViewModel() { - - + StartProdPlanCommand = new RelayCommand(obj => StartProdPlan(obj)); StopProdPlanCommand = new RelayCommand(obj => StopProdPlan(obj)); _logger = App.ServiceProvider.GetService>(); @@ -192,8 +220,12 @@ namespace SlnMesnac.WPF.ViewModel Task.Run(() => { _prodCompletionBusiness.PrintMessageToListBoxEvent += PrintMessageToListBox; + + // _prodCompletionBusiness.Init(); }); + + RefreChart(); } public void test() @@ -219,7 +251,7 @@ namespace SlnMesnac.WPF.ViewModel PlanAmount = Convert.ToInt32(prodPlan.PlanAmount); ComplateAmout = 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 { @@ -230,7 +262,7 @@ namespace SlnMesnac.WPF.ViewModel PlanAmount = 0; ComplateAmout = 0; DiffAmount = 0; - CompleRoution = string.Empty; + CompleRoution = 0; } } @@ -402,5 +434,14 @@ namespace SlnMesnac.WPF.ViewModel }); } + + /// + /// 刷新产量统计图表 + /// + private async void RefreChart() + { + ProductionHourList = new List() {"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" }; + + } } }