From 67464a41f8f71400dfb6343f2d1c0152a4386081 Mon Sep 17 00:00:00 2001 From: zhangxy Date: Tue, 15 Jul 2025 11:02:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=8E=B7=E5=8F=96=E5=85=A8=E9=83=A8=E6=9C=BA?= =?UTF-8?q?=E5=8F=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/WcsTaskApplication.cs | 36 +++--- SlnMesnac.WCS/WCS/BearAgv.cs | 79 +++++++++++-- SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml | 53 +++++++++ .../Page/MannulResignBoxWindow.xaml.cs | 110 ++++++++++++++++++ SlnMesnac.WPF/Page/TaskHistoryControl.xaml | 14 +++ .../ViewModel/TaskHistoryViewModel.cs | 7 ++ 6 files changed, 272 insertions(+), 27 deletions(-) create mode 100644 SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml create mode 100644 SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml.cs diff --git a/Application/WcsTaskApplication.cs b/Application/WcsTaskApplication.cs index 1e98f5e..2f3ae35 100644 --- a/Application/WcsTaskApplication.cs +++ b/Application/WcsTaskApplication.cs @@ -341,24 +341,24 @@ namespace Application ///pad获取所有机台库存列表信息 /// /// - //public PadResponse GetAllMachineInfos() - //{ - // PadResponse padResponse = new PadResponse(); - // try - // { - // List list = sqlSugarClient.Queryable().Where(x => !string.IsNullOrEmpty(x.MachineCode)).ToList(); - // padResponse.code = "200"; - // padResponse.message = "成功"; - // padResponse.data = list; - // } - // catch (Exception ex) - // { - // _logger.Error(ex.Message); - // padResponse.code = "301"; - // padResponse.message = "失败:" + ex.Message; - // } - // return padResponse; - //} + public PadResponse GetAllMachineInfos() + { + PadResponse padResponse = new PadResponse(); + try + { + List list = sqlSugarClient.Queryable().Where(x => !string.IsNullOrEmpty(x.MachineCode)).ToList(); + padResponse.code = "200"; + padResponse.message = "成功"; + padResponse.data = list; + } + catch (Exception ex) + { + _logger.Error(ex.Message); + padResponse.code = "301"; + padResponse.message = "失败:" + ex.Message; + } + return padResponse; + } /// ///指定机台优先级接口:加急/不加急 diff --git a/SlnMesnac.WCS/WCS/BearAgv.cs b/SlnMesnac.WCS/WCS/BearAgv.cs index fdeef4f..a41a253 100644 --- a/SlnMesnac.WCS/WCS/BearAgv.cs +++ b/SlnMesnac.WCS/WCS/BearAgv.cs @@ -11,6 +11,7 @@ using SlnMesnac.WCS.Library; using SqlSugar; using System.Collections.Generic; using System.Threading.Tasks; +using TouchSocket.Sockets; namespace SlnMesnac.WCS.WCS { @@ -258,19 +259,79 @@ namespace SlnMesnac.WCS.WCS //workShop3Plc.writeBoolByAddress(StaticData.GetPlcAddress("3#机台校验失败提示"), false); endLocation.LocationStatus = 0; endLocation.ContainerCode = task.PalletInfoCode; - sqlSugarClient.AsTenant().BeginTran(); - try + + #region 尝试入库 + int retrytime = 0; + bool successflag = false; + while (retrytime <= 3) { - sqlSugarClient.Updateable(endLocation).ExecuteCommand(); - sqlSugarClient.Deleteable(task).ExecuteCommand(); - sqlSugarClient.AsTenant().CommitTran(); - _logger.Agv($"Agv:{task.NextPointNo};完成{task.TaskName},起点:{task.CurrPointNo},终点:{task.EndPointNo}"); + sqlSugarClient.AsTenant().BeginTran(); + try + { + int LocationAffectedrow = sqlSugarClient.Updateable(endLocation).ExecuteCommand(); + int DeleteAffectedrow = sqlSugarClient.Deleteable(task).ExecuteCommand(); + sqlSugarClient.AsTenant().CommitTran(); + if (LocationAffectedrow > 0 && DeleteAffectedrow > 0) + { + _logger.Agv($"Agv:{task.NextPointNo};完成{task.TaskName},起点:{task.CurrPointNo},终点:{task.EndPointNo}"); + retrytime = 4; + successflag = true; + } + else + { + retrytime += 1; + } + } + catch (Exception ex) + { + retrytime += 1; + sqlSugarClient.AsTenant().RollbackTran(); + _logger.Error("SupplyEmptyPalletTaskHandlerAsync提交事务异常:" + ex.Message); + _logger.Error($"正在进行第{retrytime}次重试......"); + } } - catch (Exception ex) + if (successflag!= true) { - sqlSugarClient.AsTenant().RollbackTran(); - _logger.Error("SupplyEmptyPalletTaskHandlerAsync提交事务异常:" + ex.Message); + workShop3Plc.writeBoolByAddress("DB100.DBX120.0", true); + try + { + _logger.Error($"多次重试失败,正在上锁问题库位......"); + endLocation.LocationStatus = 1; + sqlSugarClient.AsTenant().BeginTran(); + sqlSugarClient.Updateable(endLocation).ExecuteCommand(); + sqlSugarClient.AsTenant().CommitTran(); + } + catch (Exception ex) { + _logger.Error($"上锁失败,正在重试......"); + sqlSugarClient.AsTenant().RollbackTran(); + Thread Lockthread = new Thread(new ThreadStart(delegate () + { + bool Lockflag = false; + while (!Lockflag) + { + try + { + endLocation.LocationStatus = 1; + sqlSugarClient.AsTenant().BeginTran(); + sqlSugarClient.Updateable(endLocation).ExecuteCommand(); + sqlSugarClient.AsTenant().CommitTran(); + Lockflag = true; + } + catch + { + sqlSugarClient.AsTenant().RollbackTran(); + Thread.Sleep(1000); + } + } + })); + Lockthread.Start(); + } + + } + retrytime = 0; + successflag = false; + #endregion } } } diff --git a/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml new file mode 100644 index 0000000..1b345b2 --- /dev/null +++ b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs b/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs index 8a21c80..4d45930 100644 --- a/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs @@ -56,6 +56,13 @@ namespace SlnMesnac.WPF.ViewModel window.ShowDialog(); } + [RelayCommand] + private void CreateResignBox() + { + MannulResignBoxWindow window = new MannulResignBoxWindow(); + window.ShowDialog(); + } + /// /// 获取任务列表 ///