From 4de11fd81617c81f7658c29fb668e160f3f168eb Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Wed, 26 Mar 2025 18:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E8=B4=A7=E6=9E=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=94=9F=E6=88=90=E6=B6=B2=E6=99=B6=E8=B4=A7=E6=9E=B6?= =?UTF-8?q?=E7=9A=84=E5=BA=93=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.WebApi/Controllers/HomeController.cs | 90 ++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/WCS.WebApi/Controllers/HomeController.cs b/WCS.WebApi/Controllers/HomeController.cs index a0a5c4c..a78c83e 100644 --- a/WCS.WebApi/Controllers/HomeController.cs +++ b/WCS.WebApi/Controllers/HomeController.cs @@ -8,6 +8,7 @@ using WCS.BLL.Manager; 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.Home; @@ -290,5 +291,94 @@ namespace WCS.WebApi.Controllers }; } } + + /// + /// 生成模组信息 + /// + /// + /// + [Route("generateModuleInfo")] + [HttpPost(Name = "generateModuleInfo")] + public async Task generateModuleInfo(RequestBase request) + { + try + { + //获取液晶的货架 + var shelfInfos = DbHelp.db.Queryable() + .Where(t => t.ShelfTypeName.Contains("液晶")) + .ToList(); + var moduleInfos = new List(); + + int boardId = 1; + var lastClientCode = string.Empty; + + foreach (var shelfInfo in shelfInfos) + { + if (lastClientCode != shelfInfo.ClientIp) + { + lastClientCode = shelfInfo.ClientIp; + boardId = 1; + } + int shelfNumber = 1; + int floorNumber = 1; + int moduleNumber = 0; + while (floorNumber <= 4) + { + moduleNumber++; + if (moduleNumber > 7) + { + shelfNumber++; + moduleNumber = 1; + } + if (shelfNumber > 4) + { + floorNumber++; + shelfNumber = 1; + } + + if (floorNumber == 5) + { + continue; + } + + var moduleCode = $"{shelfInfo.ShelfCode}-{shelfNumber}-L{floorNumber}-{moduleNumber}"; + var module = new ModuleInfo() + { + ModuleCode = moduleCode, + ShelfTypeId = 3, + ShelfId = shelfInfo.Id, + ShelfCode = shelfInfo.ShelfCode, + BoardId = boardId ++, + LightCount = 1, + CleintIp = shelfInfo.ClientIp, + GroupName = shelfInfo.GroupName, + R = floorNumber.ToString(), + C = moduleNumber.ToString(), + IsEnable = true, + }; + moduleInfos.Add(module); + } + ; + } + + DbHelp.db.Insertable(moduleInfos).ExecuteCommand(); + + return new ResponseBase() + { + Code = 200, + Message = "生成成功!", + Data = null + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "生成失败" + ex.Message, + Data = null + }; + } + } } }