From 05a66dc2d3244fb2a2dbf116f27caecb789cfe37 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Fri, 7 Mar 2025 18:14:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE=E8=B4=A7?= =?UTF-8?q?=E6=9E=B6=E9=85=8D=E7=BD=AE=E6=95=B0=E6=8D=AE=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A8=A1=E7=BB=84=E5=92=8C=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=88=E7=BA=AF=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.发送指令异常时日志优化 --- WCS.BLL/DbModels/ShelfInfo.cs | 12 ++ WCS.BLL/Tool/TCPClient.cs | 3 +- WCS.WebApi/Controllers/StoreInfoController.cs | 121 ++++++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) diff --git a/WCS.BLL/DbModels/ShelfInfo.cs b/WCS.BLL/DbModels/ShelfInfo.cs index 9753562..cc4b64e 100644 --- a/WCS.BLL/DbModels/ShelfInfo.cs +++ b/WCS.BLL/DbModels/ShelfInfo.cs @@ -103,6 +103,18 @@ namespace WCS.DAL.DbModels [SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")] public string? BigShelfCode { get; set; } = string.Empty; + /// + /// 每块板子的灯数量 + /// + [SugarColumn(ColumnName = "light_count", IsNullable = true, ColumnDescription = "每块板子的灯数量")] + public int LightCount { get; set; } + + /// + /// 每块板子的灯数量 + /// + [SugarColumn(ColumnName = "first_board_id", IsNullable = true, ColumnDescription = "左上角的板子id")] + public int FirtstBoardId { get; set; } + /// /// 序号 /// diff --git a/WCS.BLL/Tool/TCPClient.cs b/WCS.BLL/Tool/TCPClient.cs index c43d3b8..2f5d5e6 100644 --- a/WCS.BLL/Tool/TCPClient.cs +++ b/WCS.BLL/Tool/TCPClient.cs @@ -260,7 +260,8 @@ namespace WCS.BLL } catch (Exception ex) { - Logs.Write("【发送指令时发生异常】" + ex.Message, LogsType.Instructions); + var clientIpHost = tcpClient.IP + ":" + tcpClient.Port; + Logs.Write($"【发送指令时发生异常{clientIpHost}】" + ex.Message, LogsType.Instructions); //因异常断连时(网线已经被断了) 手动重连一次 if (ex is NotConnectedException) { diff --git a/WCS.WebApi/Controllers/StoreInfoController.cs b/WCS.WebApi/Controllers/StoreInfoController.cs index 4c95616..b3d3abb 100644 --- a/WCS.WebApi/Controllers/StoreInfoController.cs +++ b/WCS.WebApi/Controllers/StoreInfoController.cs @@ -7,6 +7,8 @@ using WCS.Model.ApiModel.StoreInfo; using WCS.BLL.DbModels; using WCS.Model.ApiModel.MatBaseInfo; using WCS.DAL.DbModels; +using WCS.DAL.Db; +using WCS.BLL.Config; namespace WCS.WebApi.Controllers { @@ -102,6 +104,125 @@ namespace WCS.WebApi.Controllers { return await _storeInfoService.getDisablePercent(); } + + + + [Route("genModuleStoreInfos")] + [HttpPost(Name = "genModuleStoreInfos")] + public async Task genModuleStoreInfos(RequestBase request) + { + try + { + if (request.UserName != "aaa") + { + return new ResponseBase() + { + Code = 300, + Message = "用户名不对头!无法生成模组库位" + }; + } + //获取货架 此组后端管的货架 + var shelfInfos = DbHelp.db.Queryable() + .Where(t => t.GroupName == LocalFile.Config.GroupName) + .OrderBy(t => t.BigShelfCode) + .OrderBy(t => t.ShelfCode) + .ToList(); + + var lastBindBigShelfCode = string.Empty; + var lastColumnCount = 1; + + List moduleInfos = new List(); + //生成模组 + foreach (var shelfInfo in shelfInfos) + { + var modulePreFix = shelfInfo.IsBind ? shelfInfo.BigShelfCode : shelfInfo.ShelfCode; + //不绑定或者绑定换了面 重新从1开始计数 + if (shelfInfo.BigShelfCode != lastBindBigShelfCode) + { + lastColumnCount = 1; + } + lastBindBigShelfCode = shelfInfo.BigShelfCode; + for (int rowIndex = 0; rowIndex < shelfInfo.Rowcounts; rowIndex++) + { + for (int columnIndex = 0; columnIndex < shelfInfo.Columncounts; columnIndex++) + { + var moduleCode = modulePreFix + "-R" + (rowIndex + 1).ToString() + "C" + (lastColumnCount + columnIndex).ToString(); + var moduleInfo = new ModuleInfo() + { + ModuleCode = moduleCode, + ShelfTypeId = shelfInfo.ShelfTypeId, + ShelfId = shelfInfo.Id, + ShelfCode = shelfInfo.ShelfCode, + BoardId = shelfInfo.FirtstBoardId++, + LightCount = shelfInfo.LightCount, + CleintIp = shelfInfo.ClientIp, + GroupName = shelfInfo.GroupName, + R = (rowIndex + 1).ToString(), + C = (lastColumnCount + columnIndex).ToString(), + Bigshelfcode = shelfInfo.BigShelfCode, + IsEnable = true, + CurrentMode = BLL.HardWare.Mode.待机模式, + }; + moduleInfos.Add(moduleInfo); + } + } + lastColumnCount = lastColumnCount + shelfInfo.Columncounts; + } + DbHelp.db.Insertable(moduleInfos).ExecuteCommand(); + //生成库位 + moduleInfos = DbHelp.db.Queryable() + .Where(t => t.GroupName == LocalFile.Config.GroupName) + .OrderBy(t => t.Id) + .ToList(); + List storeInfos = new List(); + + foreach (var moduleInfo in moduleInfos) + { + for (int wei = 0; wei < moduleInfo.LightCount; wei++) + { + var storeCode = moduleInfo.ModuleCode + "-" + (wei + 1).ToString(); + var stroreInfo = new StoreInfo() + { + StoreCode = storeCode, + ShelfTypeId = moduleInfo.ShelfTypeId, + ModuleId = moduleInfo.Id, + ModuleCode = moduleInfo.ModuleCode, + ShelfId = moduleInfo.ShelfId, + ShelfCode = moduleInfo.ShelfCode, + BoardId = moduleInfo.BoardId, + LightNumber = wei + 1, + Priority = 0, + CurrentMatSn = string.Empty, + CurrentVoltage = 0, + StandardVoltage = 0, + OffsetVoltage = 0, + BigShelfCode = moduleInfo.Bigshelfcode, + R = moduleInfo.R, + C = moduleInfo.C, + Wei = (wei + 1).ToString(), + GroupName = moduleInfo.GroupName + }; + storeInfos.Add(stroreInfo); + + } + } + DbHelp.db.Insertable(storeInfos).ExecuteCommand(); + + return new ResponseBase() + { + Code = 200, + Message = "生成库位成功" + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = ex.Message + }; + } + } #endregion } }