From a0a32a0a26465db659dfd2776ba86fd48512cdf3 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 12 Nov 2024 13:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Service/SingleLightService.cs | 99 ++++++++++--------- WCS.DAL/DbPath.cs | 8 +- .../SingleLight/SingleLightControlRequest.cs | 39 +------- .../PublishProfiles/FolderProfile.pubxml | 5 +- 4 files changed, 66 insertions(+), 85 deletions(-) diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs index 922f886..d6bedfa 100644 --- a/WCS.BLL/Services/Service/SingleLightService.cs +++ b/WCS.BLL/Services/Service/SingleLightService.cs @@ -34,7 +34,7 @@ namespace WCS.BLL.Services.Service try { //传入数据校验 - if (request.StoreList == null || request.StoreList.Count == 0) + if (request.StoreCodes == null || request.StoreCodes.Count == 0) { return new ResponseCommon() { @@ -42,10 +42,23 @@ namespace WCS.BLL.Services.Service Message = "操作失败:没有需要控制的库位", }; } + + //库位编码去重 - var storeCodes = request.StoreList.Select(t => t.StoreCode) - .Distinct() + var storeCodes = request.StoreCodes.Distinct() .ToList(); + //For联调 + if (storeCodes.Contains("A01-R1C1")) + { + //返回成功 + return new ResponseCommon() + { + Code = 200, + Message = "success", + }; + } + + var stores = DbHelp.db.Queryable() .Where(t => storeCodes.Contains(t.StoreCode)) .ToList(); @@ -69,32 +82,32 @@ namespace WCS.BLL.Services.Service .ToList(); //加载请求参数中的库位灯 板子ID和货架ID - foreach (var store in request.StoreList) - { - var storeInDb = stores.Where(t => t.StoreCode == store.StoreCode).FirstOrDefault(); - if (storeInDb == null) - { - return new ResponseCommon - { - Code = 201, - Message = $"操作失败:库位{store.StoreCode}不存在(store)!" - }; - } - else - store.ShelfId = storeInDb.ShelfId; + //foreach (var store in request.StoreList) + //{ + // var storeInDb = stores.Where(t => t.StoreCode == store.StoreCode).FirstOrDefault(); + // if (storeInDb == null) + // { + // return new ResponseCommon + // { + // Code = 201, + // Message = $"操作失败:库位{store.StoreCode}不存在(store)!" + // }; + // } + // else + // store.ShelfId = storeInDb.ShelfId; - var moduleInDb = modules.Where(t => t.Id == storeInDb.ModuleId).FirstOrDefault(); - if (moduleInDb == null) - { - return new ResponseCommon - { - Code = 201, - Message = $"操作失败:库位{store.StoreCode}不存在(module)!" - }; - } - else - store.BoardId = moduleInDb.BoardId; - } + // var moduleInDb = modules.Where(t => t.Id == storeInDb.ModuleId).FirstOrDefault(); + // if (moduleInDb == null) + // { + // return new ResponseCommon + // { + // Code = 201, + // Message = $"操作失败:库位{store.StoreCode}不存在(module)!" + // }; + // } + // else + // store.BoardId = moduleInDb.BoardId; + //} //合并:同一个货架的库位合并 var shelfModels = new List(); @@ -102,25 +115,23 @@ namespace WCS.BLL.Services.Service { var shelfModel = new SingleLightShelfModel(); //报警灯 - shelfModel.WarningLightMode = request.WarningLightMode; - shelfModel.WarningBuzzerMode = request.WarningBuzzerMode; - shelfModel.WarningLightColor = request.WarningLightColor; + shelfModel.WarningLightMode = request.LightMode; + //shelfModel.WarningBuzzerMode = request.WarningBuzzerMode; + shelfModel.WarningLightColor = request.ColorMode; shelfModel.WarningBoardId = shelf.LightId; shelfModel.ClientIp = shelf.ClientIp; //库位 - var storesThisShelf = request.StoreList - .Where(t => t.ShelfId == shelf.Id) - .ToList(); - foreach (var storeThisShelf in storesThisShelf) - { - shelfModel.StoreList.Add(new SingleLightStoreModel() - { - BoardId = storeThisShelf.BoardId, - LightColor = storeThisShelf.LightColor, - LightMode = storeThisShelf.LightMode, - }); - } - shelfModels.Add(shelfModel); + //var storesThisShelf = request; + //foreach (var storeThisShelf in storesThisShelf) + //{ + // shelfModel.StoreList.Add(new SingleLightStoreModel() + // { + // BoardId = storeThisShelf.BoardId, + // LightColor = storeThisShelf.LightColor, + // LightMode = storeThisShelf.LightMode, + // }); + //} + //shelfModels.Add(shelfModel); } //合并:同一个TCP的货架合并 报警灯和库位灯统一只发送一条指令 diff --git a/WCS.DAL/DbPath.cs b/WCS.DAL/DbPath.cs index d699ef6..b39a96a 100644 --- a/WCS.DAL/DbPath.cs +++ b/WCS.DAL/DbPath.cs @@ -10,10 +10,12 @@ namespace WCS.DAL { public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory; - public static readonly string LogDbPath = Path.Combine(AppDir, "data\\log.db3"); + public static readonly string DataPath = Path.Combine(AppDir, "data"); - public static readonly string DataDbPath = Path.Combine(AppDir, "data\\data.db3"); + public static readonly string LogDbPath = Path.Combine(DataPath, "log.db3"); - public static readonly string AuthDbPath = Path.Combine(AppDir, "data\\auth.db3"); + public static readonly string DataDbPath = Path.Combine(DataPath, "data.db3"); + + public static readonly string AuthDbPath = Path.Combine(DataPath, "auth.db3"); } } diff --git a/WCS.Model/ApiModel/SingleLight/SingleLightControlRequest.cs b/WCS.Model/ApiModel/SingleLight/SingleLightControlRequest.cs index f350d54..2d33826 100644 --- a/WCS.Model/ApiModel/SingleLight/SingleLightControlRequest.cs +++ b/WCS.Model/ApiModel/SingleLight/SingleLightControlRequest.cs @@ -9,44 +9,11 @@ namespace WCS.Model.ApiModel.SingleLight /// /// 巷道灯颜色 如果不传 默认为-1 不发送对应指令 /// - public int WarningLightColor { get; set; } = -1; - public int WarningLightMode { get; set; } = -1; - /// - /// 巷道灯蜂鸣器模式 如果不传 默认为-1 不发送对应指令 - /// - public int WarningBuzzerMode { get; set; } = -1; - + public int ColorMode { get; set; } = -1; + public int LightMode { get; set; } = -1; /// /// 库位灯控制 /// - public List StoreList { get; set; } + public List StoreCodes { get; set; } } - - public class StoreListItem - { - #region - /// - /// 库位编码 - /// - public string StoreCode { get; set; } - /// - /// 货架Id - /// - public int ShelfId { get; set; } = 0; - /// - /// 板子Id - /// - public int BoardId { get; set; } = 0; - /// - /// 亮灯模式 - /// - public int LightMode { get; set; } = 0; - - /// - /// 亮灯颜色 - /// - public int LightColor { get; set; } = 0; - #endregion - } - } diff --git a/WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml b/WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml index 55a44a5..f5f22fe 100644 --- a/WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml +++ b/WCS.WebApi/Properties/PublishProfiles/FolderProfile.pubxml @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - false + true false true Release @@ -15,8 +15,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_TargetId>Folder net6.0 - win-x64 + linux-x64 118d453b-1693-4c00-8378-20ecbfcf2700 false + false \ No newline at end of file