From 710eaec35d23ae8bc5602ca16d638d5715a93f85 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 8 Apr 2025 16:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=85=A4=E7=A7=91=E9=99=A2=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E7=9A=84=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/Config/JsConfig.cs | 5 ++ WCS.BLL/HardWare/MXL4Shelf.cs | 2 +- .../Services/Service/SingleLightService.cs | 9 ++- WCS.WebApi/Controllers/HomeController.cs | 68 +++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/WCS.BLL/Config/JsConfig.cs b/WCS.BLL/Config/JsConfig.cs index b5905a9..d8c3773 100644 --- a/WCS.BLL/Config/JsConfig.cs +++ b/WCS.BLL/Config/JsConfig.cs @@ -41,6 +41,11 @@ namespace WCS.BLL.Config public bool IsResetDBOrTable { get; set; } public int InstoreTimeOut { get; set; } = 5000; + + + //是否是钻探分院 + public bool IsZuantan { get; set; } + #region 盟讯公司后台配置 public bool IsMx { get; set; } /// diff --git a/WCS.BLL/HardWare/MXL4Shelf.cs b/WCS.BLL/HardWare/MXL4Shelf.cs index ad7125f..ed591f5 100644 --- a/WCS.BLL/HardWare/MXL4Shelf.cs +++ b/WCS.BLL/HardWare/MXL4Shelf.cs @@ -50,7 +50,7 @@ namespace WCS.BLL.HardWare IsEnable = module.IsEnable, CurrentMode = TaskModeEnum.待机模式, - + IsNeedRefresh = false, }); } ModulesStr = string.Join(";", MXL4Modules.Select(t => t.ModuleCode)); diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs index 96bdba6..5cfd6ad 100644 --- a/WCS.BLL/Services/Service/SingleLightService.cs +++ b/WCS.BLL/Services/Service/SingleLightService.cs @@ -5,6 +5,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using TouchSocket.Core; +using WCS.BLL.Config; using WCS.BLL.Manager; using WCS.BLL.Services.IService; using WCS.BLL.Tool; @@ -63,11 +64,15 @@ namespace WCS.BLL.Services.Service } //瓦斯分院库位数与灯不匹配所以进行如下操作 //处理传入的库位 - for (int i = 0; i < request.StoreCodes.Count; i++) + if(!LocalFile.Config.IsZuantan) { - request.StoreCodes[i] = ExtractUntilSecondDashCorrect(request.StoreCodes[i]); + for (int i = 0; i < request.StoreCodes.Count; i++) + { + request.StoreCodes[i] = ExtractUntilSecondDashCorrect(request.StoreCodes[i]); + } } + //库位编码去重 var storeCodes = request.StoreCodes.Distinct() .ToList(); diff --git a/WCS.WebApi/Controllers/HomeController.cs b/WCS.WebApi/Controllers/HomeController.cs index 7653ab9..3994b82 100644 --- a/WCS.WebApi/Controllers/HomeController.cs +++ b/WCS.WebApi/Controllers/HomeController.cs @@ -585,6 +585,74 @@ namespace WCS.WebApi.Controllers } } + [Route("testLight")] + [HttpPost(Name = "testLight")] + public async Task testLight(SetBoardIdRequest request) + { + try + { + //获取TCP + var client = TCPClientManager.TCPClients + .Where(t => t.RemoteIPHost == request.IPPort) + .First(); + if (client == null) + { + return new ResponseBase() + { + Code = 300, + Message = "未获取到对应连接,请检查地址", + Data = null + }; + } + + var boardId = request.StartId; + for (;boardId <= 224;boardId++) + { + var boardIdData = BitConverter.GetBytes(unchecked((short)boardId)); + // 检查是否需要交换字节 + if (BitConverter.IsLittleEndian) + { + // 如果是小端序系统,则交换字节 + byte temp = boardIdData[0]; + boardIdData[0] = boardIdData[1]; + boardIdData[1] = temp; + } + + //发送入库亮灯 + byte[] data1 = { 0x08, 0x00, 0x00, 0x07, 0xFF, 0xA1, 0x01, 0x02, 0x02, 0x0A, 0x00, 0x00, 0x00 }; + data1[7] = boardIdData[0]; + data1[8] = boardIdData[1]; + + client.Send(data1); + Thread.Sleep(490); + //发送退出入库 + byte[] data2 = { 0x08, 0x00, 0x00, 0x07, 0xFF, 0xA1, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + data2[7] = boardIdData[0]; + data2[8] = boardIdData[1]; + client.Send(data2); + Thread.Sleep(10); + } + + + return new ResponseBase() + { + Code = 200, + Message = "指令发送成功", + Data = null + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = "指令发送失败" + ex.Message, + Data = null + }; + } + } + + [Route("resetByTCP")] [HttpPost(Name = "resetByTCP")] public async Task resetByTCP(SetBoardIdRequest request)