From ddf94cdcf0aa269124176e802fdbd840d2b76d05 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Thu, 20 Mar 2025 09:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=BB=99=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=A4=84=E7=90=86=E8=B4=A7=E6=9E=B6=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/HardWare/IShelfBase.cs | 5 +++ WCS.BLL/HardWare/SingleLightShelf.cs | 5 +++ WCS.BLL/HardWare/SmartShelf.cs | 25 +++++++++++++ WCS.WebApi/Controllers/HomeController.cs | 36 +++++++++++++++++++ 货架标准上位机/ViewModels/DeviceViewModel.cs | 31 ++++++++++++++++ 货架标准上位机/Views/Controls/DeviceView.xaml | 5 +++ 6 files changed, 107 insertions(+) diff --git a/WCS.BLL/HardWare/IShelfBase.cs b/WCS.BLL/HardWare/IShelfBase.cs index af7a266..0751c22 100644 --- a/WCS.BLL/HardWare/IShelfBase.cs +++ b/WCS.BLL/HardWare/IShelfBase.cs @@ -124,6 +124,11 @@ namespace WCS.BLL.HardWare /// public void Reset(); + /// + /// 板子与货架状态不一致的复位(未响应的复位) + /// + public void NoResponseReset(); + /// /// 货架自检 /// diff --git a/WCS.BLL/HardWare/SingleLightShelf.cs b/WCS.BLL/HardWare/SingleLightShelf.cs index ae8ea0e..c94f5ca 100644 --- a/WCS.BLL/HardWare/SingleLightShelf.cs +++ b/WCS.BLL/HardWare/SingleLightShelf.cs @@ -95,6 +95,11 @@ namespace WCS.BLL.HardWare return; } + public void NoResponseReset() + { + return; + } + public void SetCurrentMode(Mode mode) { diff --git a/WCS.BLL/HardWare/SmartShelf.cs b/WCS.BLL/HardWare/SmartShelf.cs index 9b64871..a494eee 100644 --- a/WCS.BLL/HardWare/SmartShelf.cs +++ b/WCS.BLL/HardWare/SmartShelf.cs @@ -923,6 +923,31 @@ namespace WCS.BLL.HardWare SetCurrentMode(Mode.待机模式); } + /// + /// 板子与货架状态不一致的复位(未响应的复位) + /// + public void NoResponseReset() + { + //不是待机模式不发送指令 + if (CurrentMode != Mode.待机模式) + { + return; + } + //获取状态不一致的板子 + var modules = Modules.Where(t => t.IsEnable && t.CurrentMode != Mode.待机模式) + .ToList(); + if (modules != null && modules.Count > 0) + { + modules.ForEach(t => + { + //复位状态不一致的板子 + Logs.Write($"复位模组【{t.ModuleCode}({t.CurrentMode})】发送指令成功!"); + t.Reset(TcpCleint); + }); + } + + } + public void QueryVoltage(int moduleId) { var moudle = Modules.Where(t => t.ModuleId == moduleId).First(); diff --git a/WCS.WebApi/Controllers/HomeController.cs b/WCS.WebApi/Controllers/HomeController.cs index 7d74fb0..ffece0d 100644 --- a/WCS.WebApi/Controllers/HomeController.cs +++ b/WCS.WebApi/Controllers/HomeController.cs @@ -239,6 +239,42 @@ namespace WCS.WebApi.Controllers } } + /// + /// 重置货架的状态 使其回到待机模式 + /// + /// + /// + [Route("noResponseReset")] + [HttpPost(Name = "noResponseReset")] + public async Task noResponseReset(RequestBase request) + { + try + { + var shelfs = new List(); + shelfs = ShelfManager.Shelves + .Where(t => t.CurrentMode == Mode.待机模式) + .ToList(); + + foreach (var shelf in shelfs) + { + shelf.NoResponseReset(); + } + return new ResponseBase() + { + Code = 200, + Message = "success", + }; + + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = ex.Message, + }; + } + } /// diff --git a/货架标准上位机/ViewModels/DeviceViewModel.cs b/货架标准上位机/ViewModels/DeviceViewModel.cs index f683fb2..1aaf136 100644 --- a/货架标准上位机/ViewModels/DeviceViewModel.cs +++ b/货架标准上位机/ViewModels/DeviceViewModel.cs @@ -61,6 +61,37 @@ namespace 智能仓储WCS管理系统.ViewModel Growl.Error("打开文件夹失败。"); } } + + public ICommand NoResponseResetCommand { get => new DelegateCommand(NoResponseReset); } + /// + /// 打开用户 + /// + public void NoResponseReset() + { + var result = HandyControl.Controls.MessageBox.Show("此功能用于“未成功退出入库、出库”等异常提示\r\n建议所有货架都处于待机模式时使用,继续复位请点击[确定]", "提示", MessageBoxButton.OKCancel); + if (result == MessageBoxResult.Cancel) + return; + #region 调用接口 请求重置所有货架的状态 + var body = new RequestBase() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "home/noResponseReset", body, "POST"); + if (Result != null && Result.Code == 200) + { + Growl.Warning("已给状态不一致的板子发送复位指令,建议点击第一个按钮[货架状态初始化]重置所有货架状态!"); + } + else if (Result != null) + { + Growl.Warning(Result.Message); + } + else + { + Growl.Warning("调用接口失败!"); + } + #endregion + } } public class DeviceReadModel : BindableBase diff --git a/货架标准上位机/Views/Controls/DeviceView.xaml b/货架标准上位机/Views/Controls/DeviceView.xaml index 9587c0d..5028f85 100644 --- a/货架标准上位机/Views/Controls/DeviceView.xaml +++ b/货架标准上位机/Views/Controls/DeviceView.xaml @@ -18,6 +18,11 @@ + +