From 66ba2ce2a80d4ebe1303a547f01838318fa391e0 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Thu, 11 Jan 2024 00:39:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=A3=E9=87=91=E6=B7=BB=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Api/Admin.Core.Model.xml | 135 ++++++ .../IExecutePlanInfoRepository.cs | 4 + .../IService_New/IExecutePlanInfoServices.cs | 19 + Admin.Core.Model/Model_New/ExecutePlanInfo.cs | 7 + .../ViewModels/SheetMetaPlanInfoView.cs | 71 +++ .../ViewModels/SheetMetaSendPlanInfoView.cs | 85 ++++ .../ExecutePlanInfoRepository.cs | 36 ++ .../Service_New/ExecutePlanInfoServices.cs | 35 ++ .../Business/SheetMetalPlanTaskHandle.cs | 436 +++++++++++++++++- .../Models/ProductPlanInfoModel.cs | 4 + .../ViewModels/IndexPageViewModel.cs | 71 +-- .../ViewModels/MainWindowViewModel.cs | 10 +- .../ViewModels/QuantityIssuedViewModel.cs | 3 +- .../ViewModels/SplitPlanViewModel.cs | 12 +- .../ViewModels/StatisticsPageViewModel.cs | 50 +- .../Views/QuantityIssuedView.xaml | 7 +- .../Views/SplitPlanView.xaml | 1 + Aucma.Core.SheetMetal/appsettings.json | 2 +- Aucma.Core.Tasks/AucamTaskService.cs | 69 +-- Aucma.Core.Tasks/IAucamTaskService.cs | 5 +- 20 files changed, 924 insertions(+), 138 deletions(-) create mode 100644 Admin.Core.Model/ViewModels/SheetMetaPlanInfoView.cs create mode 100644 Admin.Core.Model/ViewModels/SheetMetaSendPlanInfoView.cs diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 2e944930..0486eacc 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -2346,6 +2346,11 @@ 计划任务执行编号——钣金任务 + + + 产品简码 + + 条码下线信息记录 @@ -5126,6 +5131,136 @@ 后板数量 + + + 钣金计划 + + + + + 下发计划的ID + + + + + 计划编码 + + + + + 订单编码 + + + + + 物料编码 + + + + + 物料名称 + + + + + 产线工位 + + + + + 计划数量 + + + + + 完成数量 + + + + + 开始时间 + + + + + 结束时间 + + + + + 产品型号 + + + + + 主键 + + + + + 计划Code + + + + + 订单Code + + + + + 物料编码 + + + + + 物料名称 + + + + + 物料名称 + + + + + 执行状态 + + + + + 执行类型 + + + + + 计划数量 + + + + + 计划数量 + + + + + 任务编码 + + + + + 前板数量 + + + + + 后板数量 + + + + + 执行顺序 + + 产线编码 diff --git a/Admin.Core.IRepository/IRepository_New/IExecutePlanInfoRepository.cs b/Admin.Core.IRepository/IRepository_New/IExecutePlanInfoRepository.cs index 4af90bb5..b2488de2 100644 --- a/Admin.Core.IRepository/IRepository_New/IExecutePlanInfoRepository.cs +++ b/Admin.Core.IRepository/IRepository_New/IExecutePlanInfoRepository.cs @@ -19,5 +19,9 @@ namespace Admin.Core.IRepository List GetStationSheetMetalStats(string stationCode); List QuerySheetMetalData(string stationCode); + + List QuerySheetMetalPlanData(string stationCode); + + List QuerySheetMetalSendPlanData(string stationCode); } } \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IExecutePlanInfoServices.cs b/Admin.Core.IService/IService_New/IExecutePlanInfoServices.cs index 41dfd8c1..d8e09404 100644 --- a/Admin.Core.IService/IService_New/IExecutePlanInfoServices.cs +++ b/Admin.Core.IService/IService_New/IExecutePlanInfoServices.cs @@ -118,6 +118,25 @@ namespace Admin.Core.IService /// /// List QuerySheetMetalData(string stationCode); + /// + /// 获取钣金当前工位计划 + /// + /// + /// + List QuerySheetMetalPlanData(string stationCode); + /// + /// 查询钣金计划执行任务 + /// + /// + /// + List QuerySheetMetalSendPlanData(string stationCode); + + /// + /// 修改钣金执行计划 + /// + /// + /// + Task UpdateSheetMetalExecutePlanInfo(int execPanId,int status); #endregion } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/ExecutePlanInfo.cs b/Admin.Core.Model/Model_New/ExecutePlanInfo.cs index 743abfc7..ec63abfb 100644 --- a/Admin.Core.Model/Model_New/ExecutePlanInfo.cs +++ b/Admin.Core.Model/Model_New/ExecutePlanInfo.cs @@ -118,5 +118,12 @@ namespace Admin.Core.Model /// [SugarColumn(ColumnName = "TASK_CODE")] public string TaskCode { get; set; } + + /// + /// 产品简码 + /// + [SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")] + public string MaterialSpecificatons { get; set; } + } } diff --git a/Admin.Core.Model/ViewModels/SheetMetaPlanInfoView.cs b/Admin.Core.Model/ViewModels/SheetMetaPlanInfoView.cs new file mode 100644 index 00000000..c422b2e0 --- /dev/null +++ b/Admin.Core.Model/ViewModels/SheetMetaPlanInfoView.cs @@ -0,0 +1,71 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + /// + /// 钣金计划 + /// + public class SheetMetaPlanInfoView + { + /// + /// 下发计划的ID + /// + [SugarColumn(ColumnName = "OBJ_ID")] + public int ObjID { get; set; } + /// + /// 计划编码 + /// + [SugarColumn(ColumnName = "PLAN_CODE")] + public string PlanCode { get; set; } + /// + /// 订单编码 + /// + [SugarColumn(ColumnName = "ORDER_CODE")] + public string OrderCode { get; set; } + /// + /// 物料编码 + /// + [SugarColumn(ColumnName = "MATERIAL_CODE")] + public string MaterialCode { get; set; } + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MATERIAL_NAME")] + public string MaterialName { get; set; } + /// + /// 产线工位 + /// + [SugarColumn(ColumnName = "PRODUCTLINE_CODE")] + public string ProductLineCode { get; set; } + /// + /// 计划数量 + /// + [SugarColumn(ColumnName = "PLAN_AMOUNT")] + public int PlanAmount { get; set; } + /// + /// 完成数量 + /// + [SugarColumn(ColumnName = "COMPLETE_AMOUNT")] + public int CompleteAmount { get; set; } + /// + /// 开始时间 + /// + [SugarColumn(ColumnName = "BEGIN_TIME")] + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + [SugarColumn(ColumnName = "END_TIME")] + public DateTime EndTime { get; set; } + /// + /// 产品型号 + /// + [SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")] + public string MaterialSpecificatons { get; set; } + } +} diff --git a/Admin.Core.Model/ViewModels/SheetMetaSendPlanInfoView.cs b/Admin.Core.Model/ViewModels/SheetMetaSendPlanInfoView.cs new file mode 100644 index 00000000..0a454ca0 --- /dev/null +++ b/Admin.Core.Model/ViewModels/SheetMetaSendPlanInfoView.cs @@ -0,0 +1,85 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + public class SheetMetaSendPlanInfoView + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID")] + public int ObjId { get; set; } + /// + /// 计划Code + /// + [SugarColumn(ColumnName = "EXECUTE_PLANCODE")] + public string ExecutePlanCode { get; set; } + /// + /// 订单Code + /// + [SugarColumn(ColumnName = "ORDER_CODE")] + public string OrderCode { get; set; } + /// + /// 物料编码 + /// + [SugarColumn(ColumnName = "MATERIAL_CODE")] + public string MaterialCode { get; set; } + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MATERIAL_NAME")] + public string MaterialName { get; set; } + /// + /// 物料名称 + /// + [SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")] + public string MaterialSpecificatons { get; set; } + + + /// + /// 执行状态 + /// + [SugarColumn(ColumnName = "EXECUTE_STATUS")] + public int ExecuteStatus { get; set; } + /// + /// 执行类型 + /// + [SugarColumn(ColumnName = "PLAN_TYPE")] + public int PlanType { get; set; } + /// + /// 计划数量 + /// + [SugarColumn(ColumnName = "PLAN_AMOUNT")] + public int PlanAmount { get; set; } + /// + /// 计划数量 + /// + [SugarColumn(ColumnName = "COMPLETE_AMOUNT")] + public int CompleteAmount { get; set; } + /// + /// 任务编码 + /// + [SugarColumn(ColumnName = "TASK_CODE")] + public string TaskCode { get; set; } + /// + /// 前板数量 + /// + [SugarColumn(ColumnName = "SIDEPANELAMOUNT")] + public int SidePanelAmount { get; set; } + /// + /// 后板数量 + /// + [SugarColumn(ColumnName = "BACKPANELAMOUNT")] + public int BackPanelAmount { get; set; } + /// + /// 执行顺序 + /// + [SugarColumn(ColumnName = "EXECUTE_ORDER")] + public int ExecuteOrder { get; set; } + } +} diff --git a/Admin.Core.Repository/Repository_New/ExecutePlanInfoRepository.cs b/Admin.Core.Repository/Repository_New/ExecutePlanInfoRepository.cs index 4b5aa4e7..6afc8cd6 100644 --- a/Admin.Core.Repository/Repository_New/ExecutePlanInfoRepository.cs +++ b/Admin.Core.Repository/Repository_New/ExecutePlanInfoRepository.cs @@ -82,5 +82,41 @@ namespace Admin.Core.Repository return Db.CopyNew().SqlQueryable(sql).Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList(); } + /// + /// 下发计划 + /// + /// + /// + public List QuerySheetMetalPlanData(string stationCode) + { + string sql = $@"select P.OBJ_ID,P.PLAN_CODE,P.ORDER_CODE,P.MATERIAL_CODE,P.MATERIAL_NAME,P.PRODUCTLINE_CODE, + P.PLAN_AMOUNT,P.COMPLETE_AMOUNT,P.BEGIN_TIME,P.END_TIME,SPC.MATERIAL_SPECIFICATIONS from C##AUCMA_MES.PRODUCT_PLANINFO P + inner join (select SPC.*,ML.MATERIAL_SPECIFICATIONS FROM C##AUCMA_MES.PRODUCT_PLANINFO SPC + inner JOIN C##AUCMA_MES.BASE_MATERIALINFO ML ON ML.MATERIAL_CODE = SPC.MATERIAL_CODE where SPC.PRODUCTLINE_CODE ='{stationCode}' + ) SPC on p.ORDER_CODE=SPC.ORDER_CODE + where p.PRODUCTLINE_CODE ='{stationCode}' "; + + return Db.CopyNew().SqlQueryable(sql).Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList(); + } + /// + /// 获取钣金下发的计划 + /// + /// + /// + public List QuerySheetMetalSendPlanData(string stationCode) + { + string sql = $@"select *from (select e.OBJ_ID,e.EXECUTE_PLANCODE, e.ORDER_CODE, e.MATERIAL_CODE,e.MATERIAL_NAME, e.MATERIAL_SPECIFICATIONS, + e.EXECUTE_STATUS,e.PLAN_TYPE,e.PLAN_AMOUNT,e.COMPLETE_AMOUNT,e.TASK_CODE,COUNT(c.PLAN_CODE) BACKPANELAMOUNT,COUNT(s.PLAN_CODE) SIDEPANELAMOUNT,e.EXECUTE_ORDER + from EXECUTE_PLANINFO e left join RECORD_BACKPANEL_COMPLATE c on e.TASK_CODE=c.PLAN_CODE + left join RECORD_SIDEPANEL_COMPLATE s on e.TASK_CODE=s.PLAN_CODE + where e.PRODUCTLINE_CODE='{stationCode}' and EXECUTE_STATUS in (1,2) + GROUP BY e.OBJ_ID,e.EXECUTE_PLANCODE,e.ORDER_CODE, e.MATERIAL_CODE,e.MATERIAL_NAME,e.MATERIAL_SPECIFICATIONS, e.PLAN_TYPE,e.PLAN_AMOUNT,e.EXECUTE_STATUS,e.COMPLETE_AMOUNT, e.TASK_CODE,e.EXECUTE_ORDER ) t + + order by t.EXECUTE_ORDER "; + + return Db.CopyNew().SqlQueryable(sql).ToList(); + } + + } } \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/ExecutePlanInfoServices.cs b/Admin.Core.Service/Service_New/ExecutePlanInfoServices.cs index 5cb6b97f..ae028a5c 100644 --- a/Admin.Core.Service/Service_New/ExecutePlanInfoServices.cs +++ b/Admin.Core.Service/Service_New/ExecutePlanInfoServices.cs @@ -41,6 +41,8 @@ namespace Admin.Core.Service /// public async Task ExecPlanDelete(string id) { + if (string.IsNullOrWhiteSpace(id)) { return false; } + return await _dal.DeleteByIdAsync(id); } #endregion @@ -405,5 +407,38 @@ namespace Admin.Core.Service { return _executePlanInfoRepository.QuerySheetMetalData(stationCode); } + + public List QuerySheetMetalPlanData(string stationCode) + { + return _executePlanInfoRepository.QuerySheetMetalPlanData(stationCode); + } + + public List QuerySheetMetalSendPlanData(string stationCode) + { + return _executePlanInfoRepository.QuerySheetMetalSendPlanData(stationCode); + } + + /// + /// 修改执行计划 + /// + /// + /// + public async Task UpdateSheetMetalExecutePlanInfo(int execPanId, int status) + { + bool result = false; + try + { + var executePlanInfo =await _dal.FirstAsync(d=>d.ObjId== execPanId); + executePlanInfo.ExecuteStatus = status; + result = await _dal.UpdateAsync(executePlanInfo); + } + catch (Exception ex) + { + logHelper.Error("修改执行计划异常", ex); + } + return result; + } + + } } \ No newline at end of file diff --git a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs index b09bd1c8..c232f031 100644 --- a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs +++ b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs @@ -10,9 +10,12 @@ using System.Windows.Documents; using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using Admin.Core.Service; using Aucma.Core.HwPLc; using Microsoft.Extensions.DependencyInjection; using NetTaste; +using NPOI.SS.Formula.Functions; namespace Aucma.Core.SheetMetal.Business; @@ -69,6 +72,401 @@ public class SheetMetalPlanTaskHandle _backPanelComplateServices = App.ServiceProvider.GetService(); } + + #region 下发多个计划同步执行 + + /// + /// 初始化下发生产计划,获取已拆分的计划进行下发——后板任务 + /// + public void InitSendBackPanelPlan() + { + Thread.Sleep(5000); + var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC")); + + while (true) + { + var planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Where(d => d.PlanAmount > d.BackPanelAmount).ToList(); + planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList(); + if (planInfoList == null|| planInfoList.Count==0) continue; + var planInfos = planInfoList.Where(d => d.PlanType == 3 || d.PlanType == 1).ToList(); + if (planInfos!=null) + { + if (planInfos.Count > 0) + { + SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.BackPanelAmount != d.PlanAmount); + if (planInfo == null) continue; + if (planInfo.PlanType == 3||planInfo.PlanType == 1)//如果为3或者为1 后板计划单独下发 以前板完成为主 + { + SendPlanTaskToBackPanel(planInfo, obj_backPanel); + + UpdateBackPanelPlanTaskByComplate(planInfo); + } + } + else + { + Console.WriteLine("未获取到需要下发的任务"); + } + } + + Thread.Sleep(3000); + } + } + + /// + /// 初始化下发生产计划,获取已拆分的计划进行下发——前板任务 + /// + public void InitSendSidePanelPlan() + { + Thread.Sleep(5000); + var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc")); + + while (true) + { + var planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Where(d=>d.PlanAmount > d.SidePanelAmount).ToList(); + planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList(); + if (planInfoList == null || planInfoList.Count == 0) continue; + var planInfos = planInfoList.Where(d => d.PlanType == 2 || d.PlanType == 1).ToList(); + if (planInfos != null) + { + if (planInfos.Count > 0) + { + SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.SidePanelAmount != d.PlanAmount); + if (planInfo == null) continue; + if (planInfo.PlanType == 2 || planInfo.PlanType == 1)//如果为2或者为1 前板板计划单独下发 以前板完成为主 + { + SendPlanTaskToSidPanel(planInfo, obj_sidePanel); + + UpdateSidPanelPlanTaskByComplate(planInfo); + } + } + else + { + Console.WriteLine("未获取到需要下发的任务"); + } + } + + Thread.Sleep(3000); + } + } + /// + /// 下发前板生产计划 + /// + /// + /// + public void SendPlanTaskToSidPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_sidePanel) + { + try + { + Task.Run(() => + { + if (obj_sidePanel != null) + { + //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 + obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode); + string processNumber = GetProcessNumberBy(planInfo.MaterialCode); + obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons); + obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount); + obj_sidePanel.plc.WriteInt32("D6021", 1); + + Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。"); + RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。"); + #region PLC反馈信号逻辑处理 + //循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中 + bool isFlag = true; + do + { + + if (obj_sidePanel.plc.ReadInt32("D6021") == 2) + { + obj_sidePanel.plc.WriteInt32("D6021", 0); + Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址"); + RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址"); + isFlag = false; + } + Thread.Sleep(2000); + } while (isFlag); + + //更新计划状态为2执行中 + planInfo.ExecuteStatus = 2; + bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + + #endregion + + //读取设备进度,完成后再次下发新任务 + ReadDeviceComplate_SidePanel(obj_sidePanel); + + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + } + }); + } + catch (Exception ex) + { + MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error, + MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); + } + } + + /// + /// 下发背板生产计划 + /// + /// + /// + public void SendPlanTaskToBackPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_backPanel) + { + try + { + Task.Run(() => + { + if (obj_backPanel != null) + { + //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 + obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode); + string processNumber = GetProcessNumberBy(planInfo.MaterialCode); + obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons); + obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount); + obj_backPanel.plc.WriteInt32("D4021", 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) + { + obj_backPanel.plc.WriteInt32("D4021", 0); + Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址"); + RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址"); + isFlag = false; + } + Thread.Sleep(2000); + } while (isFlag); + + //更新计划状态为2执行中 + planInfo.ExecuteStatus = 2; + bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + + #endregion + + //读取设备进度,完成后再次下发新任务 + ReadDeviceComplate_BackPanel(obj_backPanel); + + if (!isFlag) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + } + }); + } + catch (Exception ex) + { + MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error, + MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); + } + } + + /// + /// 根据后板完成记录更新生产计划 + /// + /// + private void UpdateBackPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo) + { + try + { + lock (string.Empty) + { + bool isComplate = true; + + do + { + //等待计划执行完成 + List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode); + int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount); + + 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}"); + RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}"); + int sumAmount = 0; + + if (planInfo.PlanType == 1) + { + if(planInfo.PlanAmount == sumBackPanelAmount) + { + if (sumSidePanelAmount<= sumBackPanelAmount) + { + sumAmount = sumSidePanelAmount; + isComplate = false; + } + else + { + sumAmount = planInfo.PlanAmount; + isComplate = false; + } + } + else + { + sumAmount = sumSidePanelAmount; + } + } + + if (planInfo.PlanType == 3) + { + sumAmount = sumBackPanelAmount; + if (planInfo.PlanAmount - sumAmount == 0) + { + planInfo.ExecuteStatus = 3; + isComplate = false; + } + planInfo.CompleteAmount = sumAmount; + } + + + + var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result; + obj.ExecuteStatus = planInfo.ExecuteStatus; + if (obj.PlanType==1) + { + obj.CompleteAmount = sumAmount; + } + else + { + obj.CompleteAmount = sumAmount; + } + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result; + if (result) + { + //更新前端展示图表 + // RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + + Thread.Sleep(5000); + + } while (isComplate); + + } + } + catch (Exception ex) + { + Console.WriteLine($"计划任务信息更新异常:{ex.Message}"); + RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}"); + } + } + /// + /// 根据前板完成记录更新生产计划 + /// + /// + private void UpdateSidPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo) + { + try + { + lock (string.Empty) + { + bool isComplate = true; + + do + { + //等待计划执行完成 + List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode); + int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount); + + 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}"); + RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}"); + int sumAmount = 0; + + if (planInfo.PlanType == 1) + { + if (sumSidePanelAmount >= sumBackPanelAmount) + { + sumAmount = sumBackPanelAmount; + } + else + { + sumAmount = sumSidePanelAmount; + } + } + else if (planInfo.PlanType == 2) + { + sumAmount = sumSidePanelAmount; + } + else + { + sumAmount = sumBackPanelAmount; + } + + if (planInfo.PlanAmount - sumAmount == 0) + { + planInfo.ExecuteStatus = 3; + isComplate = false; + } + + planInfo.CompleteAmount = sumAmount; + + var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result; + obj.CompleteAmount = planInfo.CompleteAmount; + obj.ExecuteStatus = planInfo.ExecuteStatus; + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result; + if (result) + { + //更新前端展示图表 + RefreshCreatePlanInfoEvent?.Invoke();//更新界面 + RefreshChatEvent?.Invoke();//刷新图表 + } + Thread.Sleep(5000); + + } while (isComplate); + } + } + catch (Exception ex) + { + Console.WriteLine($"计划任务信息更新异常:{ex.Message}"); + RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}"); + } + } + + #endregion + + + + + + + + + + + + #region 下发单个计划逻辑 + + + + /// /// 初始化下发生产计划,获取已拆分的计划进行下发 /// @@ -200,6 +598,7 @@ public class SheetMetalPlanTaskHandle { try { + //前板 Task.Run(() => { if (obj_sidePanel != null) @@ -207,7 +606,7 @@ public class SheetMetalPlanTaskHandle //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode); string processNumber = GetProcessNumberBy(planInfo.MaterialCode); - obj_sidePanel.plc.WriteString("D6010", "BCD/310NF"); + obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons); obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount); obj_sidePanel.plc.WriteInt32("D6021", 1); @@ -220,6 +619,7 @@ public class SheetMetalPlanTaskHandle bool isFlag = true; do { + //开始做计划的时候给我 if (obj_sidePanel.plc.ReadInt32("D6021") == 2) { obj_sidePanel.plc.WriteInt32("D6021", 0); @@ -250,7 +650,7 @@ public class SheetMetalPlanTaskHandle } } }); - + //背板 Task.Run(() => { if (obj_backPanel != null) @@ -281,7 +681,7 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; if (result) { //更新前端展示图表 @@ -308,6 +708,7 @@ public class SheetMetalPlanTaskHandle } } + /// /// 下发围板生产计划 /// @@ -324,7 +725,7 @@ public class SheetMetalPlanTaskHandle //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode); string processNumber = GetProcessNumberBy(planInfo.MaterialCode); - obj_sidePanel.plc.WriteString("D6010", "BCD/310NF"); + obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons); obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount); obj_sidePanel.plc.WriteInt32("D6021", 1); @@ -349,7 +750,7 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - bool result=_executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; if (result) { //更新前端展示图表 @@ -357,7 +758,7 @@ public class SheetMetalPlanTaskHandle RefreshChatEvent?.Invoke();//刷新图表 RefreshCurrentPlanInfoEvent?.Invoke(); } - + #endregion //读取设备进度,完成后再次下发新任务 ReadDeviceComplate_SidePanel(obj_sidePanel); @@ -414,14 +815,14 @@ public class SheetMetalPlanTaskHandle Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}"); RefreshExecInfoEvent?.Invoke($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}"); - + //添加完工记录 RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate() { ProductlineCode = "1001", PlanCode = planCode.Substring(0, 16), //MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode, - MaterialCode = "BCD/310NF", + MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF", CompleteAmount = complateAmount, OffLineAmount = offLineAmount, DeviceStatus = deviceStatus, @@ -481,7 +882,7 @@ public class SheetMetalPlanTaskHandle _sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate); - if (complateAmount!=lastComplateAmount) + if (complateAmount != lastComplateAmount) { //更新前端展示图表 RefreshCreatePlanInfoEvent?.Invoke();//更新界面 @@ -523,7 +924,7 @@ public class SheetMetalPlanTaskHandle //计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021 obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode); string processNumber = GetProcessNumberBy(planInfo.MaterialCode); - obj_backPanel.plc.WriteString("D4010", "BCD/310NF"); + obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons); obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount); obj_backPanel.plc.WriteInt32("D4021", 1); @@ -547,14 +948,14 @@ public class SheetMetalPlanTaskHandle //更新计划状态为2执行中 planInfo.ExecuteStatus = 2; - bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; + bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result; if (result) { //更新前端展示图表 RefreshCreatePlanInfoEvent?.Invoke();//更新界面 RefreshChatEvent?.Invoke();//刷新图表 } - + #endregion //读取设备进度,完成后再次下发新任务 @@ -598,9 +999,9 @@ public class SheetMetalPlanTaskHandle } //计划编号 - string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()); + string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim(); //物料编号 - string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray()); + string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray()).Replace("\0", "").Trim(); //完成数量 int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); //下线数量 @@ -616,9 +1017,9 @@ public class SheetMetalPlanTaskHandle RecordBackPanelComplate backPanelComplate = new RecordBackPanelComplate() { ProductlineCode = "1001", - PlanCode = planCode.Substring(0, 16), + PlanCode = planCode.Substring(0, 16).Replace("\0", "").Trim(), //MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode, - MaterialCode = "BCD/310NF", + MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF", CompleteAmount = complateAmount, OffLineAmount = offLineAmount, DeviceStatus = deviceStatus, @@ -721,5 +1122,6 @@ public class SheetMetalPlanTaskHandle } } return returnStr; - } + } + #endregion } \ No newline at end of file diff --git a/Aucma.Core.SheetMetal/Models/ProductPlanInfoModel.cs b/Aucma.Core.SheetMetal/Models/ProductPlanInfoModel.cs index 33b2cb10..4ff3d40f 100644 --- a/Aucma.Core.SheetMetal/Models/ProductPlanInfoModel.cs +++ b/Aucma.Core.SheetMetal/Models/ProductPlanInfoModel.cs @@ -83,5 +83,9 @@ namespace Aucma.Core.SheetMetal.Models /// 钣金类型 /// public int PlanType { get; set; } + /// + /// 产品型号 + /// + public string MaterialSpecificatons { get; set; } } } diff --git a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs index 0cfe5a5e..e8574676 100644 --- a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs @@ -21,6 +21,7 @@ using Aucma.Core.SheetMetal.Business; using Admin.Core.Model.ViewModels; using NPOI.SS.Formula.Functions; using log4net; +using Aucma.Core.HwPLc; /* * 首页信息 */ @@ -209,7 +210,7 @@ namespace Aucma.Core.SheetMetal.ViewModels string stationCode = Appsettings.app("StationInfo", "StationCode"); CurrentTeamTimeView view = GetTeamHour(); - var list = _taskExecutionPlanInfoServices.QueryAsync(x => x.ProductLineCode == stationCode && x.BeginTime > view.StartTime || x.ExecuteStatus == 2).Result; + var list = _taskExecutionPlanInfoServices.QueryAsync(x => x.IsFlag == 0 && x.ProductLineCode == stationCode && x.BeginTime > view.StartTime || x.ExecuteStatus == 2).Result; if (list == null) return Task.CompletedTask; var execList = list.OrderByDescending(d => d.ExecuteOrder); @@ -251,31 +252,31 @@ namespace Aucma.Core.SheetMetal.ViewModels } //更新首页显示信息 - ExecutePlanInfo execPlan = execList.SingleOrDefault(d => d.ExecuteStatus == 2); - if (execPlan != null) - { - OrderCode = execPlan.OrderCode; - MesMOrderCode = execPlan.ProductPlanCode; - ProductModel = execPlan.MaterialName; - BeginTime = execPlan.BeginTime.ToString(); - 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; - } + //ExecutePlanInfo execPlan = execList.SingleOrDefault(d => d.ExecuteStatus == 2); + //if (execPlan != null) + //{ + // OrderCode = execPlan.OrderCode; + // MesMOrderCode = execPlan.ProductPlanCode; + // ProductModel = execPlan.MaterialName; + // BeginTime = execPlan.BeginTime.ToString(); + // 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) @@ -330,11 +331,25 @@ namespace Aucma.Core.SheetMetal.ViewModels MessageBoxResult msg = MessageBox.Show("确定要删除吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (MessageBoxResult.Yes == msg) { - bool result = await _taskExecutionPlanInfoServices.ExecPlanDelete(Id); + int id = Convert.ToInt32(Id); + ExecutePlanInfo executionPlanInfo= _taskExecutionPlanInfoServices.FirstAsync(s => s.ObjId == id).Result; + + if (executionPlanInfo.PlanAmount== executionPlanInfo.CompleteAmount) + { + MessageBox.Show("执行计划已经完成,不可以删除!", "系统信息"); + return; + } + executionPlanInfo.IsFlag = 1; + bool result = await _taskExecutionPlanInfoServices.UpdateAsync(executionPlanInfo); if (result) { + //下发该计划取消PLC任务 + //var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc")); + //var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC")); + //obj_backPanel.plc.WriteInt16("D4021","5");//下传5为计划结束 + PlanInfoDataGrid.Clear(); - LoadData(); + await LoadData(); MessageBox.Show("执行计划删除成功", "系统信息"); } diff --git a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs index 515f5293..4ddb059f 100644 --- a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs @@ -32,9 +32,13 @@ namespace Aucma.Core.SheetMetal.ViewModels init(); Task.Run(() => { - //_taskHandle.InitSendPlanData(); - _taskHandle.InitSendPlan(); - + //_taskHandle.InitSendPlan(); + _taskHandle.InitSendBackPanelPlan(); + }); + Task.Run(() => + { + //_taskHandle.InitSendPlan(); + _taskHandle.InitSendSidePanelPlan(); }); } public void init() diff --git a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs index 8c8c1488..b3ca6da1 100644 --- a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs @@ -109,7 +109,8 @@ namespace Aucma.Core.SheetMetal.ViewModels task.BeginTime = DateTime.Now; task.ExecuteStatus = 1; task.PlanType = productPlanInfo.PlanType; - + task.MaterialSpecificatons = productPlanInfo.MaterialSpecificatons; + var result = await _executePlanInfoServices.AddAsync(task); if (result > 0) { diff --git a/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs index 5af2ab65..674eda3c 100644 --- a/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/SplitPlanViewModel.cs @@ -31,7 +31,6 @@ namespace Aucma.Core.SheetMetal.ViewModels private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SplitPlanViewModel)); protected readonly IProductPlanInfoServices? _productPlanInfoServices; - //protected readonly ISmTaskExecutionServices? _smTaskExecutionServices; protected readonly IExecutePlanInfoServices? _executePlanInfoServices; private AppConfigHelper appConfig = new AppConfigHelper(); @@ -52,11 +51,13 @@ namespace Aucma.Core.SheetMetal.ViewModels MaterialDataGrid.Clear(); int i = 1; string station = Appsettings.app("StationInfo", "StationCode"); - var planlist = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result; - if (planlist == null) return ; - var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + //var planlist = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result; + //if (planlist == null) return ; + //var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)); + //if (execList == null) return; + var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station); if (execList == null) return; - foreach (var item in planlist) + foreach (var item in execList) { int residue = 0; if (execList == null) residue = 0; @@ -71,6 +72,7 @@ namespace Aucma.Core.SheetMetal.ViewModels PlanAmount = item.PlanAmount, ResidueAmount = item.PlanAmount - item.CompleteAmount, SpliteResidueAmount = item.PlanAmount - residue, + MaterialSpecificatons = item.MaterialSpecificatons, StartDate = item.BeginTime }); i++; diff --git a/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs index 93c1e521..271c87b6 100644 --- a/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/StatisticsPageViewModel.cs @@ -60,7 +60,7 @@ namespace Aucma.Core.SheetMetal.ViewModels } } - private async Task LoadDateData(string result) + private Task LoadDateData(string result) { string station = Appsettings.app("StationInfo", "StationCode"); var list = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result; @@ -86,6 +86,7 @@ namespace Aucma.Core.SheetMetal.ViewModels }); i++; } + return Task.CompletedTask; } #endregion @@ -109,13 +110,9 @@ namespace Aucma.Core.SheetMetal.ViewModels [RelayCommand] private async Task ExecQuery(string result) { - - //System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => - //{ if (!string.IsNullOrEmpty(result)) { MaterialDataGrid.Clear(); - await LoadDateData(result); } else @@ -126,48 +123,5 @@ namespace Aucma.Core.SheetMetal.ViewModels } #endregion - - /// - /// 围板完成数量 - /// - /// - /// 订单 - /// 工位 - /// - public int GetSidePanelCompleteData(List sidePanelComplate, string orderCode, string productLineCode) - { - try - { - var execList = _executePlanInfoServices.QueryAsync(d => d.OrderCode == orderCode && d.ProductPlanCode == productLineCode).Result; - List taskCodeList = execList.Select(x => x.TaskCode).ToList(); - var list = _sidePanelComplateServices.QueryAsync(d => taskCodeList.Contains(d.PlanCode)).Result; - return list.Count; - } - catch (Exception) - { - return 0; - } - } - /// - /// 背板完成数量 - /// - /// - /// - /// - /// - public int GetBackPanelCompleteData(List sidePanelComplate, string orderCode, string productLineCode) - { - try - { - var execList = _executePlanInfoServices.QueryAsync(d => d.OrderCode == orderCode && d.ProductPlanCode == productLineCode).Result; - List taskCodeList = execList.Select(x => x.TaskCode).ToList(); - var list = _backPanelComplateServices.QueryAsync(d => taskCodeList.Contains(d.PlanCode)).Result; - return list.Count; - } - catch (Exception) - { - return 0; - } - } } } diff --git a/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml b/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml index fa11bae8..8561884f 100644 --- a/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml +++ b/Aucma.Core.SheetMetal/Views/QuantityIssuedView.xaml @@ -31,6 +31,7 @@ + @@ -46,11 +47,15 @@ + + + + - + diff --git a/Aucma.Core.SheetMetal/Views/SplitPlanView.xaml b/Aucma.Core.SheetMetal/Views/SplitPlanView.xaml index c7d005db..4bee6173 100644 --- a/Aucma.Core.SheetMetal/Views/SplitPlanView.xaml +++ b/Aucma.Core.SheetMetal/Views/SplitPlanView.xaml @@ -236,6 +236,7 @@ + diff --git a/Aucma.Core.SheetMetal/appsettings.json b/Aucma.Core.SheetMetal/appsettings.json index 369a633d..c926d2a4 100644 --- a/Aucma.Core.SheetMetal/appsettings.json +++ b/Aucma.Core.SheetMetal/appsettings.json @@ -136,7 +136,7 @@ "PlcType": "Melsec", "Enabled": true, "IP": "10.10.91.6", - "Port": 5552 + "Port": 5553 } ] } diff --git a/Aucma.Core.Tasks/AucamTaskService.cs b/Aucma.Core.Tasks/AucamTaskService.cs index 699aa464..aeeae41b 100644 --- a/Aucma.Core.Tasks/AucamTaskService.cs +++ b/Aucma.Core.Tasks/AucamTaskService.cs @@ -2,6 +2,7 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; using Aucma.Core.HwPLc; using Aucma.Core.Tasks.Business; using log4net; @@ -16,55 +17,57 @@ namespace Aucma.Core.Tasks { private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(AucamTaskService)); IPerfusionRecordServices _perfusionRecordServices; - - public AucamTaskService(IPerfusionRecordServices perfusionRecordServices, IPerfusionAlarmServices perfusionAlarmServices, IPerfusionDeviceStatusServices perfusionDeviceStatusServices) + IExecutePlanInfoServices _executePlanInfoServices; + System.Timers.Timer timer1 = new System.Timers.Timer(5000); + + public AucamTaskService(IPerfusionRecordServices perfusionRecordServices, + IPerfusionAlarmServices perfusionAlarmServices, IExecutePlanInfoServices executePlanInfoServices, + IPerfusionDeviceStatusServices perfusionDeviceStatusServices) { - PerfusionCollection coll = new PerfusionCollection(perfusionRecordServices, perfusionAlarmServices, perfusionDeviceStatusServices); - - } - System.Timers.Timer timer1 = new System.Timers.Timer(5000); - - bool qFlay=true;//完成 + #region 更新钣金工位计划数 + bool qFlay = true;//完成 - public void AucamTaskAsync() + public void AucamUpdatePlanNumTask() { - timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件; - timer1.AutoReset = true;//设置是执行一次(false)还是一直执行(true); - timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它, - timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true; + //timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件; + //timer1.AutoReset = true;//设置是执行一次(false)还是一直执行(true); + //timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它, + //timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true; } - #region 老发泡 - /// - /// 老发泡 - /// - /// - /// private void Run1(object? sender, ElapsedEventArgs e) { if (qFlay) { qFlay = false; - try - { - Collection.startCollect(); - } - catch (Exception) - { - - throw; - } - finally + List viewList=new List(); + List list= _executePlanInfoServices.QuerySheetMetalData("1001"); + foreach (SheetMetalDataView item in list) { - qFlay = true; + if (item.SidPanelAmount==item.BackPanelAmount) + { + SheetMetalDataView view = new SheetMetalDataView(); + view.CompleteAmount= item.PlanAmount; + viewList.Add(view); + } + if (item.SidPanelAmount > item.BackPanelAmount) + { + SheetMetalDataView view = new SheetMetalDataView(); + view.CompleteAmount = item.BackPanelAmount; + viewList.Add(view); + } + if (item.SidPanelAmount < item.BackPanelAmount) + { + SheetMetalDataView view = new SheetMetalDataView(); + view.CompleteAmount = item.SidPanelAmount; + viewList.Add(view); + } } } - } - + } #endregion - } } diff --git a/Aucma.Core.Tasks/IAucamTaskService.cs b/Aucma.Core.Tasks/IAucamTaskService.cs index dc6644ab..2cda6c5f 100644 --- a/Aucma.Core.Tasks/IAucamTaskService.cs +++ b/Aucma.Core.Tasks/IAucamTaskService.cs @@ -3,6 +3,9 @@ namespace Aucma.Core.Tasks { public interface IAucamTaskService { - void AucamTaskAsync(); + /// + /// 实时更新工位计划表中的数据 + /// + public void AucamUpdatePlanNumTask(); } }