From ffb9481bab077461d8d27abc435a20966160fb99 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Tue, 9 Jan 2024 18:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=92=A3=E9=87=91=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- .../Business/SheetMetalPlanTaskHandle.cs | 164 +++++++++++------- .../ViewModels/IndexPageViewModel.cs | 94 ++++++++-- .../ViewModels/QuantityIssuedViewModel.cs | 2 +- .../ViewModels/StatisticsPageViewModel.cs | 23 +-- .../Views/IndexPageView.xaml | 6 +- .../Views/QuantityIssuedView.xaml | 2 +- .../Views/StatisticsPageView.xaml | 60 ++----- 10 files changed, 218 insertions(+), 139 deletions(-) diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig index 2f9c868b..decf85c2 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Common -build_property.ProjectDir = E:\桌面\AUCMA_SCADA\Admin.Core.Common\ +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\ diff --git a/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig index 0f098310..f38a35e7 100644 --- a/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.EventBus -build_property.ProjectDir = E:\桌面\AUCMA_SCADA\Admin.Core.EventBus\ +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.EventBus\ diff --git a/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig index a3d7d5ba..a581a844 100644 --- a/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Serilog.Es -build_property.ProjectDir = E:\桌面\AUCMA_SCADA\Admin.Core.Serilog.Es\ +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Serilog.Es\ diff --git a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs index 84dc5333..acb3dcb0 100644 --- a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs +++ b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs @@ -13,7 +13,6 @@ using Admin.Core.Model; using Aucma.Core.HwPLc; using Microsoft.Extensions.DependencyInjection; using NetTaste; -using SqlSugar; namespace Aucma.Core.SheetMetal.Business; @@ -22,15 +21,16 @@ namespace Aucma.Core.SheetMetal.Business; /// public class SheetMetalPlanTaskHandle { + #region 刷新创建计划 /// /// 刷新创建计划 /// public delegate Task RefreshCretaePlanInfo(); - public static event RefreshCretaePlanInfo RefreshCretaePlanInfoEvent; + public static event RefreshCretaePlanInfo RefreshCreatePlanInfoEvent; #endregion - #region 刷新图标 + #region 刷新图表 /// /// 刷新创建计划 /// @@ -42,7 +42,7 @@ public class SheetMetalPlanTaskHandle /// /// 刷新当前正在执行的计划 /// - public delegate void RefreshCurrentPlanInfo(ExecutePlanInfo planInfo); + public delegate void RefreshCurrentPlanInfo(); public static event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent; #endregion @@ -56,7 +56,6 @@ public class SheetMetalPlanTaskHandle #endregion - protected readonly IExecutePlanInfoServices? _executePlanInfoServices; protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices; protected readonly IRecordBackPanelComplateServices _backPanelComplateServices; @@ -81,18 +80,17 @@ public class SheetMetalPlanTaskHandle while (true) { - var planInfos = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1||d.ExecuteStatus==2).Result; - + var planInfos = _executePlanInfoServices.Query(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1 || d.ExecuteStatus == 2); + if (planInfos != null) { if (planInfos.Count > 0) { ExecutePlanInfo planInfo = planInfos.First(); - //planInfo.PlanAmount = planInfo.PlanAmount - planInfo.CompleteAmount; if (planInfo.PlanType == 1) //联合下发 { SendPlanTask(planInfo, obj_sidePanel, obj_backPanel); - + UpdatePlanTaskByComplate(planInfo); } @@ -113,7 +111,6 @@ public class SheetMetalPlanTaskHandle else { Console.WriteLine("未获取到需要下发的任务"); - RefreshExecInfoEvent?.Invoke("未获取到需要下发的任务"); } } @@ -136,10 +133,10 @@ public class SheetMetalPlanTaskHandle do { //等待计划执行完成 - List sidePanelComplates = _sidePanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode).Result; + List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode); int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount); - List backPanelComplates = _backPanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode).Result; + List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode); int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount); Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}"); @@ -174,8 +171,13 @@ public class SheetMetalPlanTaskHandle planInfo.CompleteAmount = sumAmount; - _executePlanInfoServices.UpdateExecutePlanInfo(planInfo); - + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } Thread.Sleep(5000); } while (isComplate); @@ -203,14 +205,12 @@ public class SheetMetalPlanTaskHandle if (obj_sidePanel != null) { //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 - obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode); + obj_sidePanel.plc.WriteString("D6030", planInfo.TaskCode); string processNumber = GetProcessNumberBy(planInfo.MaterialCode); obj_sidePanel.plc.WriteString("D6010", "BCD/310NF"); obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount); obj_sidePanel.plc.WriteInt32("D6021", 1); - - Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待围板设备应答。。。。。。"); RefreshExecInfoEvent?.Invoke("等待围板设备应答"); //下发完成后读取PLC应答,应答后复位应答信号 @@ -232,8 +232,13 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - _executePlanInfoServices.UpdateExecutePlanInfo(planInfo); - RefreshCurrentPlanInfoEvent?.Invoke(planInfo); + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } #endregion //读取设备进度,完成后再次下发新任务 ReadDeviceComplate_SidePanel(obj_sidePanel); @@ -246,24 +251,22 @@ public class SheetMetalPlanTaskHandle if (obj_backPanel != null) { //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 - obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode); + obj_backPanel.plc.WriteString("D6030", planInfo.TaskCode); string processNumber = GetProcessNumberBy(planInfo.MaterialCode); - obj_backPanel.plc.WriteString("D4010", "BCD/310NF"); - obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount); - obj_backPanel.plc.WriteInt32("D4021", 1); + obj_backPanel.plc.WriteString("D6010", "BCD/310NF"); + obj_backPanel.plc.WriteInt32("D6020", planInfo.PlanAmount); + obj_backPanel.plc.WriteInt32("D6021", 1); Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。"); RefreshExecInfoEvent?.Invoke("等待背板设备应答......"); - #region PLC反馈信号逻辑处理 //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中 bool isFlag = true; do { - - if (obj_backPanel.plc.ReadInt32("D4021") == 2) + if (obj_backPanel.plc.ReadInt32("D6021") == 2) { - obj_backPanel.plc.WriteInt32("D4021", 0); + obj_backPanel.plc.WriteInt32("D6021", 0); Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址"); RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址"); isFlag = false; @@ -273,8 +276,13 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - _executePlanInfoServices.UpdateExecutePlanInfo(planInfo); - RefreshCurrentPlanInfoEvent?.Invoke(planInfo); + bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } #endregion //读取设备进度,完成后再次下发新任务 @@ -324,24 +332,29 @@ public class SheetMetalPlanTaskHandle Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到围板设备应答信号,复位应答地址"); RefreshExecInfoEvent?.Invoke("收到围板设备应答信号......"); isFlag = false; - - //更新计划状态为2执行中 - planInfo.ExecuteStatus = 2; - _executePlanInfoServices.UpdateExecutePlanInfo(planInfo); - //更新前端展示图表 - RefreshCurrentPlanInfoEvent?.Invoke(planInfo); - RefreshCretaePlanInfoEvent?.Invoke();//更新界面 - RefreshChatEvent?.Invoke();//刷新图表 } Thread.Sleep(2000); } while (isFlag); + //更新计划状态为2执行中 + planInfo.ExecuteStatus = 2; + bool result=_executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + RefreshCurrentPlanInfoEvent?.Invoke(); #endregion - - //读取设备进度,完成后再次下发新任务 ReadDeviceComplate_SidePanel(obj_sidePanel); - + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } } }); } @@ -349,7 +362,6 @@ public class SheetMetalPlanTaskHandle { MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); - RefreshExecInfoEvent?.Invoke("围板⽣产计划下发异常:{ex.Message}"); } } @@ -389,14 +401,13 @@ public class SheetMetalPlanTaskHandle int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber); Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}"); - Console.WriteLine($"===>收到围板设备应答信号,复位应答地址"); RefreshExecInfoEvent?.Invoke($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}"); - RefreshExecInfoEvent?.Invoke($"收到围板设备应答信号,复位应答地址"); + //添加完工记录 RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate() { ProductlineCode = "1001", - PlanCode = planCode.Substring(0, 16).Replace("\n","").Trim(),//.Substring(0, 16), + PlanCode = planCode.Substring(0, 16), //MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode, MaterialCode = "BCD/310NF", CompleteAmount = complateAmount, @@ -414,7 +425,7 @@ public class SheetMetalPlanTaskHandle } //先查询该计划编号下的前一条完工记录,如果不存在本条记录产量为0 - List sidePanelComplates = _sidePanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16)).Result; + List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16)); int lastComplateAmount = 0; //前一条完成记录的计划完成数量 int sumComplateAmount = 0; //当前计划总产量 if (sidePanelComplates != null) @@ -422,7 +433,7 @@ public class SheetMetalPlanTaskHandle if (sidePanelComplates.Count > 0) { sidePanelComplates = sidePanelComplates.OrderByDescending(x => x.RecordTime).ToList(); - + lastComplateAmount = sidePanelComplates.First().CompleteAmount; sidePanelComplate.OutPutAmount = complateAmount - lastComplateAmount; sumComplateAmount = sidePanelComplates.Sum(x => x.OutPutAmount) + sidePanelComplate.OutPutAmount; @@ -434,7 +445,7 @@ public class SheetMetalPlanTaskHandle } else { - List planInfos = _executePlanInfoServices.QueryAsync(x => x.TaskCode.Equals(planCode.Substring(0, 16)) && x.ExecuteStatus == 2).Result; + List planInfos = _executePlanInfoServices.Query(x => x.TaskCode.Equals(planCode.Substring(0, 16)) && x.ExecuteStatus == 2); if (planInfos != null) { if (planInfos.Count > 0) @@ -447,8 +458,6 @@ public class SheetMetalPlanTaskHandle isFlag = false; Console.WriteLine($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}"); RefreshExecInfoEvent?.Invoke($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}"); - RefreshCretaePlanInfoEvent?.Invoke();//更新界面 - RefreshChatEvent?.Invoke();//刷新图表 } } } @@ -460,8 +469,22 @@ public class SheetMetalPlanTaskHandle _sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate); + if (complateAmount!=lastComplateAmount) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + RefreshCreatePlanInfoEvent?.Invoke(); + } Thread.Sleep(5000); } while (isFlag); + + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } } catch (Exception e) { @@ -493,7 +516,7 @@ public class SheetMetalPlanTaskHandle obj_backPanel.plc.WriteInt32("D4021", 1); Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。"); - RefreshExecInfoEvent?.Invoke($"等待背板设备应答....."); + RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。"); #region PLC反馈信号逻辑处理 //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中 bool isFlag = true; @@ -512,12 +535,25 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - _executePlanInfoServices.UpdateExecutePlanInfo(planInfo); - RefreshCurrentPlanInfoEvent?.Invoke(planInfo); + bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + #endregion //读取设备进度,完成后再次下发新任务 ReadDeviceComplate_BackPanel(obj_backPanel); + + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } } }); } @@ -525,7 +561,6 @@ public class SheetMetalPlanTaskHandle { MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); - RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{ex.Message}"); } } @@ -606,7 +641,7 @@ public class SheetMetalPlanTaskHandle } else { - List planInfos = _executePlanInfoServices.QueryAsync(x => x.TaskCode == planCode.Substring(0, 16) && x.ExecuteStatus == 2).Result; + List planInfos = _executePlanInfoServices.Query(x => x.TaskCode == planCode.Substring(0, 16) && x.ExecuteStatus == 2); if (planInfos != null) { if (planInfos.Count > 0) @@ -619,9 +654,6 @@ public class SheetMetalPlanTaskHandle isFlag = false; Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}"); RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}"); - RefreshCretaePlanInfoEvent?.Invoke();//更新界面 - RefreshChatEvent?.Invoke();//刷新图表 - } } } @@ -631,17 +663,31 @@ public class SheetMetalPlanTaskHandle } _backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate); - + if (complateAmount != lastComplateAmount) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } Thread.Sleep(5000); } while (isFlag); + + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } } catch (Exception e) { Console.WriteLine($"读取背板设备完成数据异常:{e.Message}"); - RefreshExecInfoEvent?.Invoke($"读取背板设备完成数据异常:{e.Message}"); + RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}"); } } + + /// /// 通过物料编号获取工艺编号 /// diff --git a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs index 7edf6456..0cfe5a5e 100644 --- a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs @@ -64,15 +64,16 @@ namespace Aucma.Core.SheetMetal.ViewModels RefreshMaterialStats();//型号产量 SheetMetalPlanTaskHandle.RefreshCurrentPlanInfoEvent += RefreshCurrentPlanInfo; QuantityIssuedViewModel.RefreshCretaePlanInfoEvent += LoadData; - SheetMetalPlanTaskHandle.RefreshCretaePlanInfoEvent += LoadData; + SheetMetalPlanTaskHandle.RefreshCreatePlanInfoEvent += LoadData; SheetMetalPlanTaskHandle.RefreshChatEvent += RefreshChat; + } #endregion public Task RefreshChat() { - RefreshHourAmount();//小时产量 - RefreshMaterialStats();//型号产量 + RefreshHourAmountChart();//小时产量 + RefreshMaterialChart();//型号产量 return Task.CompletedTask; } @@ -96,12 +97,9 @@ namespace Aucma.Core.SheetMetal.ViewModels ExecutePlanInfo info = await _taskExecutionPlanInfoServices.FirstAsync(d => d.ProductLineCode.Equals(station) && d.ExecuteStatus == 2); if (info == null) return; - PlanNum = info.PlanAmount; + PlanMaxNum = PlanNum = info.PlanAmount; RealQuantity = info.CompleteAmount; - DiffQuantity = Math.Abs(info.CompleteAmount - info.PlanAmount); - - //CompletionRate = (_realQuantity / _planMaxNum).ToString("0%"); CompletionRate = (_realQuantity / _planMaxNum); } @@ -260,15 +258,24 @@ namespace Aucma.Core.SheetMetal.ViewModels MesMOrderCode = execPlan.ProductPlanCode; ProductModel = execPlan.MaterialName; BeginTime = execPlan.BeginTime.ToString(); - - PlanMaxNum = _planNum = execPlan.PlanAmount; + PlanMaxNum = PlanNum = execPlan.PlanAmount; RealQuantity = execPlan.CompleteAmount; double diff = _planMaxNum - _realQuantity; DiffQuantity =int.Parse(diff.ToString()); - //CompletionRate = (_realQuantity/_planMaxNum).ToString("0%"); CompletionRate = (_realQuantity / _planMaxNum); } + else + { + OrderCode =string.Empty; + MesMOrderCode = string.Empty; + ProductModel = string.Empty; + BeginTime = string.Empty; + PlanMaxNum = 0; + RealQuantity =0.0; + DiffQuantity = 0; + CompletionRate =0; + } })); } catch (Exception ex) @@ -676,7 +683,7 @@ namespace Aucma.Core.SheetMetal.ViewModels /// 刷新当前执行的计划进度 /// /// - private void RefreshCurrentPlanInfo(ExecutePlanInfo planInfo) + private void RefreshCurrentPlanInfo() { App.Current.Dispatcher.BeginInvoke((Action)(() => { @@ -712,9 +719,6 @@ namespace Aucma.Core.SheetMetal.ViewModels ProductionHourList.Add(item.HourTime); hour++; } - - - #region 按时间统计 @@ -743,6 +747,37 @@ namespace Aucma.Core.SheetMetal.ViewModels } #endregion + + #region 更新小时产量统计 + /// + /// 更新小时产量统计 + /// + private void RefreshHourAmountChart() + { + App.Current.Dispatcher.Invoke((Action)(() => + { + //获取小时产量 + string stationCode = Appsettings.app("StationInfo", "StationCode"); + var hourAmount = _sysUserInfoServices.GetSheetMetaHourData(stationCode).Result; + if (hourAmount != null) + { + int hour = 0; + + for (int i = 0; i < hourAmount.Count; i++) + { + Achievement[0].Values[i] = + new ObservablePoint(hour, Convert.ToDouble(hourAmount[i].FrontPlateAmount)); + + Achievement[1].Values[i] = + new ObservablePoint(hour, Convert.ToDouble(hourAmount[i].RearPanelAmount)); + hour++; + } + } + })); + } + #endregion + + #region 刷新物料型号统计 /// /// 刷新物料型号统计 @@ -795,6 +830,37 @@ namespace Aucma.Core.SheetMetal.ViewModels } #endregion + + #region 刷新物料型号统计 + /// + /// 刷新物料型号统计 + /// + private void RefreshMaterialChart() + { + App.Current.Dispatcher.Invoke((Action)(() => + { + //获取物料型号统计 + string stationCode = Appsettings.app("StationInfo", "StationCode"); + var sheetMetalTypeList = _sysUserInfoServices.GetSheetMetalTypeData(stationCode).Result; + if (sheetMetalTypeList != null) + { + #region 按类型统计 + for (int i = 0; i < sheetMetalTypeList.Count; i++) + { + double frontPlateAmount =Convert.ToDouble(sheetMetalTypeList[i].FrontPlateAmount); + ModelStatistics[0].Values[i] = frontPlateAmount; + double rearPanelAmount = Convert.ToDouble(sheetMetalTypeList[i].RearPanelAmount); + ModelStatistics[1].Values[i] = rearPanelAmount; + MaterialNameList[i]=sheetMetalTypeList[i].MaterialName; + } + + #endregion + } + })); + } + #endregion + + public CurrentTeamTimeView GetTeamHour() { List obj = _sysUserInfoServices.GetTeamData().Result; diff --git a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs index fb13aae0..ddcedf6c 100644 --- a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs @@ -94,7 +94,7 @@ namespace Aucma.Core.SheetMetal.ViewModels task.OrderCode = PlanInfo.OrderCode; task.ProductLineCode = stationCode;//计划工位 //task.TaskCode = GetMaxCodeAsync(); - task.TaskCode = System.Guid.NewGuid().ToString("N").Substring(0,16); + task.TaskCode = System.Guid.NewGuid().ToString("N").Substring(0,14)+DateTime.Now.ToString("ss"); task.MaterialCode = PlanInfo.MaterialCode; task.MaterialName = PlanInfo.MaterialName; if (list.Count == 0) diff --git a/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs index 57d0c7d8..8ef68d81 100644 --- a/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs @@ -62,13 +62,14 @@ namespace Aucma.Core.SheetMetal.ViewModels } } - private async Task LoadDateData(DateTime startTime,DateTime endTime) + private async Task LoadDateData(string result) { string station = Appsettings.app("StationInfo", "StationCode"); var list = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result; var sidePanelComplateList = _sidePanelComplateServices.QueryAsync(d => d.ProductlineCode == station).Result; int i = 1; - foreach (var item in list.Where(d => d.BeginTime > startTime && d.EndTime < endTime)) + var productPlanInfoList = list.Where(d => d.OrderCode.Contains(result) || d.PlanCode.Contains(result) || d.MaterialCode.Contains(result) || d.MaterialName.Contains(result)).ToList(); + foreach (var item in productPlanInfoList) { int sidePanelComplete = GetSidePanelCompleteData(sidePanelComplateList, item.OrderCode, station); int backPanelComplete = GetBackPanelCompleteData(sidePanelComplateList, item.OrderCode, station); @@ -109,29 +110,21 @@ namespace Aucma.Core.SheetMetal.ViewModels /// 查询 /// [RelayCommand] - private async Task ExecQuery(object obj) + private async Task ExecQuery(string result) { - var result = (StatisticModel)obj; - if (string.IsNullOrEmpty(result.BeginTime)) + if (string.IsNullOrEmpty(result)) { - MessageBox.Show("开始时间不能为空!"); - return; - } - if (string.IsNullOrEmpty(result.EndTime)) - { - MessageBox.Show("结束时间不能为空!"); + MessageBox.Show("查询条件不能为空!"); return; } //System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => //{ - if (!string.IsNullOrEmpty(result.BeginTime)) + if (!string.IsNullOrEmpty(result)) { - var beginTime =DateTime.Parse(result.BeginTime); - var endTime = DateTime.Parse(result.EndTime); MaterialDataGrid.Clear(); - await LoadDateData(beginTime, endTime); + await LoadDateData(result); } else { diff --git a/Aucma.Core.SheetMetal/Views/IndexPageView.xaml b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml index 1d077491..bd49b743 100644 --- a/Aucma.Core.SheetMetal/Views/IndexPageView.xaml +++ b/Aucma.Core.SheetMetal/Views/IndexPageView.xaml @@ -175,7 +175,7 @@ @@ -254,7 +254,7 @@ - + @@ -369,7 +369,7 @@ - + diff --git a/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml b/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml index dddf0f54..fa11bae8 100644 --- a/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml +++ b/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml @@ -66,7 +66,7 @@ - + diff --git a/Aucma.Core.SheetMetal/Views/StatisticsPageView.xaml b/Aucma.Core.SheetMetal/Views/StatisticsPageView.xaml index 0f150dcb..166bde7a 100644 --- a/Aucma.Core.SheetMetal/Views/StatisticsPageView.xaml +++ b/Aucma.Core.SheetMetal/Views/StatisticsPageView.xaml @@ -77,59 +77,35 @@ + + + + + - + - + - + - + - - - - - - - - - + + - - - - - - - - - + + Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" CommandParameter="{Binding Text, ElementName=queryParam}" /> + - + - -