From 917a13b1975980ddd9ac7b243a7821921eb4a868 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Thu, 10 Apr 2025 16:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=8D=95=E7=81=AF=E8=B4=A7?= =?UTF-8?q?=E6=9E=B6=E7=9A=84=E5=BA=93=E4=BD=8D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/ShelfInfo.cs | 7 +- .../Services/Service/SingleLightService.cs | 4 +- .../Controllers/SingleLightController.cs | 109 ++++++++++++++++++ 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/WCS.BLL/DbModels/ShelfInfo.cs b/WCS.BLL/DbModels/ShelfInfo.cs index 2a40365..2452ba7 100644 --- a/WCS.BLL/DbModels/ShelfInfo.cs +++ b/WCS.BLL/DbModels/ShelfInfo.cs @@ -49,17 +49,18 @@ namespace WCS.DAL.DbModels public DateTime SetCurrentModeTime { get; set; } /// - /// 货架行数 + /// 货架行数 对应单灯的第几行 /// [SugarColumn(ColumnName = "row_counts", IsNullable = false, ColumnDescription = "货架行数")] - public int Rowcounts { get; set; } + public int Rowcounts { get; set; } /// - /// 货架列数 + /// 货架列数 对应一行有几个 /// [SugarColumn(ColumnName = "column_counts", IsNullable = false, ColumnDescription = "货架列数")] public int Columncounts { get; set; } + /// /// 货架对应警示灯的Id /// diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs index 5cfd6ad..77e8086 100644 --- a/WCS.BLL/Services/Service/SingleLightService.cs +++ b/WCS.BLL/Services/Service/SingleLightService.cs @@ -192,8 +192,8 @@ namespace WCS.BLL.Services.Service //更新数据库灯的状态 stores.ForEach(t => { - t.LightMode = request.ColorMode; - t.ColorMode = request.LightMode; + t.LightMode = request.LightMode; + t.ColorMode = request.ColorMode; }); DbHelp.db.Updateable(stores) .UpdateColumns(t => new { t.LightMode, t.ColorMode }) diff --git a/WCS.WebApi/Controllers/SingleLightController.cs b/WCS.WebApi/Controllers/SingleLightController.cs index 09f416a..8d6bd9b 100644 --- a/WCS.WebApi/Controllers/SingleLightController.cs +++ b/WCS.WebApi/Controllers/SingleLightController.cs @@ -100,5 +100,114 @@ namespace WCS.WebApi.Controllers } } + + [Route("GenerateSingleLightStoreInfo")] + [HttpGet(Name = "GenerateSingleLightStoreInfo")] + public async Task GenerateSingleLightStoreInfo() + { + try + { + //获取单灯类型的货架 + var shelfInfo = DbHelp.db.Queryable() + .Where(t => t.ShelfTypeName == "信息化货架") + .OrderBy(t => t.ShelfCode) + .ToList(); + var storesToSave = new List(); + foreach (var shelf in shelfInfo) + { + if (shelf.ShelfCode == "C07-4") + ; + var row = shelf.Rowcounts % 2; + //如果是奇数行 + if (row == 1) + { + //之前已经占用的id + var id = (shelf.Rowcounts - 1) * (shelf.Columncounts + 7); + //奇数行 灯Id是最后一个灯 + for (int i = shelf.Columncounts; i > 0; i--) + { + var storeInfo = new StoreInfo() + { + StoreCode = shelf.ShelfCode + "-" + i.ToString(), + ShelfTypeId = shelf.ShelfTypeId, + ModuleId = 0, + ModuleCode = shelf.ShelfCode + "-" + i.ToString(), + ShelfId = shelf.Id, + ShelfCode = shelf.ShelfCode, + BoardId = ++id, + LightNumber = 1, + Priority = 0, + R = shelf.Rowcounts.ToString(), + C = i.ToString(), + Wei = "1", + SingleLightNumber = 1, + LightMode = 0, + ColorMode = 0, + GroupName = shelf.GroupName, + Area = shelf.ShelfCode.Substring(0,1), + }; + storesToSave.Add(storeInfo); + } + + shelf.LightId = ++id; + } + //偶数行 + else + { + //之前已经占用的id + var id = (shelf.Rowcounts - 1) * (shelf.Columncounts + 7); + shelf.LightId = ++id; + + //灯占7个ID + id = id + 6; + //奇数行 灯Id是最后一个灯 + for (int i = 1; i <= shelf.Columncounts; i++) + { + var storeInfo = new StoreInfo() + { + StoreCode = shelf.ShelfCode + "-" + i.ToString(), + ShelfTypeId = shelf.ShelfTypeId, + ModuleId = 0, + ModuleCode = shelf.ShelfCode + "-" + i.ToString(), + ShelfId = shelf.Id, + ShelfCode = shelf.ShelfCode, + BoardId = ++id, + LightNumber = 1, + Priority = 0, + R = shelf.Rowcounts.ToString(), + C = i.ToString(), + Wei = "1", + SingleLightNumber = 1, + LightMode = 0, + ColorMode = 0, + GroupName = shelf.GroupName, + Area = shelf.ShelfCode.Substring(0, 1), + }; + storesToSave.Add(storeInfo); + } + } + + } + + DbHelp.db.Insertable(storesToSave).ExecuteCommand(); + DbHelp.db.Updateable(shelfInfo).ExecuteCommand(); + + return new ResponseCommon() + { + Code = 200, + Message = "success", + Data = null + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "操作失败:" + ex.Message, + }; + } + } + } }