diff --git a/WCS.BLL/HardWare/MXL4ShelfModule.cs b/WCS.BLL/HardWare/MXL4ShelfModule.cs
index 1eef161..beb5cef 100644
--- a/WCS.BLL/HardWare/MXL4ShelfModule.cs
+++ b/WCS.BLL/HardWare/MXL4ShelfModule.cs
@@ -82,6 +82,12 @@ namespace WCS.BLL.HardWare
/// 待机模式 无库存显示信息
///
public byte[] StandbyNoInfoDisplayData = { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ ///
+ /// 发送库位编码
+ ///
+ public byte[] SendStoreCodeData = { 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
#endregion
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
@@ -223,6 +229,12 @@ namespace WCS.BLL.HardWare
SendMatQtyData[2] = boardIdData[1];
tcpClient.SendThenReturn(tcpClient.GenerateMessage(BoardId, SendMatQtyData));
}
+
+ //发送库位编码
+ public void SendStoreCode(string storeCode, TCPClient tcpClient)
+ {
+ tcpClient.SendList(tcpClient.GenerateMessageList(BoardId, SendStoreCodeData, storeCode));
+ }
#endregion
}
}
diff --git a/WCS.BLL/Tool/TCPClient.cs b/WCS.BLL/Tool/TCPClient.cs
index 1b03e11..629a233 100644
--- a/WCS.BLL/Tool/TCPClient.cs
+++ b/WCS.BLL/Tool/TCPClient.cs
@@ -289,6 +289,37 @@ namespace WCS.BLL
}
}
+ public void SendList(List messages, bool IsReSend = false)
+ {
+ try
+ {
+ lock (sendLockObject)
+ {
+ foreach (var message in messages)
+ {
+ var clientIpHost = tcpSendClient.IP + ":" + tcpSendClient.Port;
+ Logs.Write($"【发送{clientIpHost}】{BitConverter.ToString(message)}", LogsType.Instructions);
+ tcpReceiveClient.Send(message);
+ Thread.Sleep(3);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Logs.Write("【发送指令时发生异常】" + ex.Message, LogsType.Instructions);
+ //因异常断连时(网线已经被断了) 手动重连一次
+ if (ex is NotConnectedException)
+ {
+ IsReceivedClientOnline = false;
+ Task.Run(() =>
+ {
+ ReConnectAsync();
+ });
+ }
+ throw ex;
+ }
+ }
+
public void SendThenReturn(byte[] message, bool IsReSend = false)
{
try
diff --git a/WCS.WebApi/Controllers/HomeController.cs b/WCS.WebApi/Controllers/HomeController.cs
index 64016e1..d6b1652 100644
--- a/WCS.WebApi/Controllers/HomeController.cs
+++ b/WCS.WebApi/Controllers/HomeController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Mvc;
+using Kdbndp;
+using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using WCS.BLL.DbModels;
@@ -786,5 +787,55 @@ namespace WCS.WebApi.Controllers
};
}
}
+
+
+ ///
+ /// 配置库位编码
+ ///
+ ///
+ ///
+ [Route("setStoreCode")]
+ [HttpPost(Name = "setStoreCode")]
+ public async Task setStoreCode(SetBoardIdRequest request)
+ {
+ try
+ {
+ var errorList = new List();
+ //1.获取所有液晶标签货架
+ var shelfs = ShelfManager.Shelves.Where(t => t.ShelfTypeName == "液晶标签货架")
+ .WhereIF(!string.IsNullOrEmpty(request.IPPort), t => t.ClientIp == request.IPPort)
+ .Select(t => t as MXL4Shelf)
+ .ToList();
+ shelfs.ForEach(t =>
+ {
+ t.MXL4Modules.ForEach(m =>
+ {
+ try
+ {
+ m.SendStoreCode(m.ModuleCode, t.TcpCleint);
+ }
+ catch (Exception ex)
+ {
+ errorList.Add($"模组{m.ModuleCode}更新库位ID失败!原因:{ex.Message}");
+ }
+
+ });
+ });
+ return new ResponseCommon
+ {
+ Code = 200,
+ Message = "success",
+ Data = errorList
+ };
+ }
+ catch (Exception ex)
+ {
+ return new ResponseCommon
+ {
+ Code = 300,
+ Message = "操作失败:" + ex.Message,
+ };
+ }
+ }
}
}