From e0fd67c866c94260672cf2fdcaf0d40fad0fb3df Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Fri, 28 Mar 2025 09:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E7=81=AF=E5=8C=BA=E5=9F=9F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=9C=8B=E6=9D=BF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/StoreInfo.cs | 13 +++++++ .../Services/Service/SingleLightService.cs | 35 +++++++++++++++-- .../Controllers/SingleLightController.cs | 38 +++++++++++++++++++ 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/WCS.BLL/DbModels/StoreInfo.cs b/WCS.BLL/DbModels/StoreInfo.cs index f404109..8a32853 100644 --- a/WCS.BLL/DbModels/StoreInfo.cs +++ b/WCS.BLL/DbModels/StoreInfo.cs @@ -131,6 +131,19 @@ namespace WCS.DAL.DbModels [SugarColumn(ColumnName = "single_light_number", IsNullable = false, DefaultValue = "1", ColumnDescription = "单灯货架灯的个数,用于煤科院大库位灯")] public int SingleLightNumber { get; set; } + + /// + /// 灯当前模式 + /// + [SugarColumn(ColumnName = "light_mode", IsNullable = true, ColumnDescription = "亮灯模式")] + public int LightMode { get; set; } = 0; + + /// + /// 灯当前颜色 + /// + [SugarColumn(ColumnName = "color_mode", IsNullable = true, ColumnDescription = "灯当前颜色")] + public int ColorMode { get; set; }= 0; + /// /// 序号 /// diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs index 46bf66a..96bdba6 100644 --- a/WCS.BLL/Services/Service/SingleLightService.cs +++ b/WCS.BLL/Services/Service/SingleLightService.cs @@ -88,10 +88,10 @@ namespace WCS.BLL.Services.Service var shelfs = DbHelp.db.Queryable().Where(t => shelfIds.Contains(t.Id)) .ToList(); - //对应模组信息 - var moduleIds = stores.Select(t => t.ModuleId).Distinct().ToList(); - var modules = DbHelp.db.Queryable().Where(t => moduleIds.Contains(t.Id)) - .ToList(); + ////对应模组信息 + //var moduleIds = stores.Select(t => t.ModuleId).Distinct().ToList(); + //var modules = DbHelp.db.Queryable().Where(t => moduleIds.Contains(t.Id)) + // .ToList(); //合并:同一个货架的库位合并 var shelfModels = new List(); @@ -165,6 +165,11 @@ namespace WCS.BLL.Services.Service catch (Exception ex) { Logs.Write($"【单灯单独控制】{client}以下指令发送中遇到异常{ex.Message}" + BitConverter.ToString(sendData)); + return new ResponseCommon() + { + Code = 201, + Message = $"【单灯单独控制】{client}指令发送中遇到异常{ex.Message}", + }; } } else @@ -179,6 +184,16 @@ namespace WCS.BLL.Services.Service } } + //更新数据库灯的状态 + stores.ForEach(t => + { + t.LightMode = request.ColorMode; + t.ColorMode = request.LightMode; + }); + DbHelp.db.Updateable(stores) + .UpdateColumns(t => new { t.LightMode, t.ColorMode }) + .ExecuteCommand(); + //返回成功 return new ResponseCommon() { @@ -276,6 +291,7 @@ namespace WCS.BLL.Services.Service catch (Exception ex) { Logs.Write($"【熄灯】{client}以下指令发送中遇到异常{ex.Message}" + BitConverter.ToString(sendData)); + } } else @@ -290,6 +306,17 @@ namespace WCS.BLL.Services.Service } } + //更新灯状态为熄灭 + //var stores = DbHelp.db.Queryable().Where(t => t.Area == request.Area).ToList(); + stores.ForEach(t => + { + t.ColorMode = 0; + t.LightMode = 0; + }); + DbHelp.db.Updateable(stores) + .UpdateColumns(t => new { t.LightMode, t.ColorMode }) + .ExecuteCommand(); + //返回成功 return new ResponseCommon() { diff --git a/WCS.WebApi/Controllers/SingleLightController.cs b/WCS.WebApi/Controllers/SingleLightController.cs index d8a0a5d..09f416a 100644 --- a/WCS.WebApi/Controllers/SingleLightController.cs +++ b/WCS.WebApi/Controllers/SingleLightController.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Mvc; using WCS.BLL.Services.IService; using WCS.BLL.Services.Service; +using WCS.DAL.Db; +using WCS.DAL.DbModels; using WCS.Model; using WCS.Model.ApiModel; using WCS.Model.ApiModel.SelfCheck; @@ -62,5 +64,41 @@ namespace WCS.WebApi.Controllers } } + [Route("GetKanBanData")] + [HttpGet(Name = "GetKanBanData")] + public async Task GetKanBanData() + { + try + { + //获取单灯类型的库位 + var stores = DbHelp.db.Queryable() + .Where(t => t.ShelfTypeId == 2) + .OrderBy(t => t.Area) + .OrderBy(t => t.StoreCode) + .Select(t => new + { + Area = t.Area, + StoreCode = t.StoreCode, + LightMode = t.LightMode, + ColorMode = t.ColorMode, + }) + .ToList(); + return new ResponseCommon() + { + Code = 200, + Message = "success", + Data = stores + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "操作失败:" + ex.Message, + }; + } + } + } }