From 7427b804f6726c9321dd4b2c13f7c3a172d31a1f Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 12 Nov 2024 13:33:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/StoreInfo.cs | 6 ++ .../Services/IService/ISingleLightService.cs | 6 ++ .../Services/Service/SingleLightService.cs | 62 ++++++++++++++++++- .../SingleLight/TurnoffLightByAreaRequest.cs | 12 ++++ .../Controllers/SingleLightController.cs | 18 ++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 WCS.Model/ApiModel/SingleLight/TurnoffLightByAreaRequest.cs diff --git a/WCS.BLL/DbModels/StoreInfo.cs b/WCS.BLL/DbModels/StoreInfo.cs index 1b6a409..ac83cbb 100644 --- a/WCS.BLL/DbModels/StoreInfo.cs +++ b/WCS.BLL/DbModels/StoreInfo.cs @@ -119,6 +119,12 @@ namespace WCS.DAL.DbModels [SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")] public string GroupName { get; set; } + /// + /// 区域 + /// + [SugarColumn(ColumnName = "area", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")] + public string Area { get; set; } + /// /// 序号 /// diff --git a/WCS.BLL/Services/IService/ISingleLightService.cs b/WCS.BLL/Services/IService/ISingleLightService.cs index 16efc4e..ebad429 100644 --- a/WCS.BLL/Services/IService/ISingleLightService.cs +++ b/WCS.BLL/Services/IService/ISingleLightService.cs @@ -15,5 +15,11 @@ namespace WCS.BLL.Services.IService public interface ISingleLightService { public Task> SingleLightControl(SingleLightControlRequest request); + /// + /// 按区域一键灭灯 + /// + /// + /// + public Task> TurnoffLightByArea(TurnoffLightByAreaRequest request); } } diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs index 922f886..e8c3556 100644 --- a/WCS.BLL/Services/Service/SingleLightService.cs +++ b/WCS.BLL/Services/Service/SingleLightService.cs @@ -146,7 +146,67 @@ namespace WCS.BLL.Services.Service } catch (Exception ex) { - + + //操作失败 + return new ResponseCommon() + { + Code = 300, + Message = $"操作失败:{ex.Message}", + }; + } + } + + public async Task> TurnoffLightByArea(TurnoffLightByAreaRequest request) + { + try + { + //传入数据校验 + if (string.IsNullOrEmpty(request.Area)) + { + return new ResponseCommon() + { + Code = 201, + Message = "操作失败:参数传入错误!Area为空!", + }; + } + //库位 + var stores = DbHelp.db.Queryable() + .Where(t => t.Area == request.Area) + .ToList(); + if (stores == null || stores.Count == 0) + { + return new ResponseCommon + { + Code = 201, + Message = $"操作失败:所选区域不存在库位!" + }; + } + + //对应货架(获取TCP和报警灯ID) + var shelfIds = stores.Select(t => t.ShelfId).Distinct().ToList(); + var shelfs = DbHelp.db.Queryable().Where(t => shelfIds.Contains(t.Id)) + .ToList(); + //获取对应货架所有IP + var clientIPs = shelfs.Select(t => t.ClientIp) + .Distinct() + .ToList(); + + //挨个发关灯指令 + foreach (var clientIP in clientIPs) + { + + } + + //返回成功 + return new ResponseCommon() + { + Code = 200, + Message = "success", + }; + } + catch (Exception ex) + { + //操作失败 return new ResponseCommon() { diff --git a/WCS.Model/ApiModel/SingleLight/TurnoffLightByAreaRequest.cs b/WCS.Model/ApiModel/SingleLight/TurnoffLightByAreaRequest.cs new file mode 100644 index 0000000..145f4d2 --- /dev/null +++ b/WCS.Model/ApiModel/SingleLight/TurnoffLightByAreaRequest.cs @@ -0,0 +1,12 @@ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.SingleLight +{ + public class TurnoffLightByAreaRequest : RequestBase + { + public string Area { get; set; } = string.Empty; + } +} diff --git a/WCS.WebApi/Controllers/SingleLightController.cs b/WCS.WebApi/Controllers/SingleLightController.cs index 0c3c8a6..d8a0a5d 100644 --- a/WCS.WebApi/Controllers/SingleLightController.cs +++ b/WCS.WebApi/Controllers/SingleLightController.cs @@ -44,5 +44,23 @@ namespace WCS.WebApi.Controllers } } + [Route("turnoffLightByArea")] + [HttpPost(Name = "turnoffLightByArea")] + public async Task TurnoffLightByArea(TurnoffLightByAreaRequest request) + { + try + { + return await _singleLightService.TurnoffLightByArea(request); + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "操作失败:" + ex.Message, + }; + } + } + } }