调试中的修改

This commit is contained in:
hehaibing-1996
2025-01-17 15:23:20 +08:00
parent 0bec70f175
commit de682b3884
5 changed files with 123 additions and 66 deletions

View File

@ -24,6 +24,25 @@ namespace WCS.BLL.Services.Service
{
public class SingleLightService : ISingleLightService
{
public string ExtractUntilSecondDashCorrect(string input)
{
int firstDashIndex = input.IndexOf('-');
if (firstDashIndex == -1)
{
return string.Empty; // 如果没有找到第一个'-',则返回空字符串
}
int secondDashIndex = input.IndexOf('-', firstDashIndex + 1);
if (secondDashIndex == -1)
{
return input;
}
else
{
return input.Substring(0, secondDashIndex);
}
}
/// <summary>
/// 单灯 一个库位对应一个硬件
/// </summary>
@ -42,7 +61,12 @@ namespace WCS.BLL.Services.Service
Message = "操作失败:没有需要控制的库位",
};
}
//瓦斯分院库位数与灯不匹配所以进行如下操作
//处理传入的库位
for (int i = 0; i < request.StoreCodes.Count; i++)
{
request.StoreCodes[i] = ExtractUntilSecondDashCorrect(request.StoreCodes[i]);
}
//库位编码去重
var storeCodes = request.StoreCodes.Distinct()
@ -135,7 +159,7 @@ namespace WCS.BLL.Services.Service
{
try
{
tcpClient.Send(sendData,0,sendData.Length);
tcpClient.Send(sendData, 0, sendData.Length);
Logs.Write("【单灯单独控制】发送指令" + BitConverter.ToString(sendData));
}
catch (Exception ex)