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" }; + + } } }