1.WebSocket登录注册
2.数据重发机制
This commit is contained in:
@ -57,6 +57,8 @@ namespace WCS.BLL.HardWare
|
|||||||
/// 货架组别
|
/// 货架组别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GroupName { get; set; }
|
public string GroupName { get; set; }
|
||||||
|
|
||||||
|
public string WebSocketIpAddress { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模组
|
/// 模组
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -25,6 +25,7 @@ namespace WCS.BLL.HardWare
|
|||||||
public string ClientIp { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public string ClientIp { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
public List<string> ExceptionMessages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public List<string> ExceptionMessages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
public bool IsWarning { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public bool IsWarning { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
public string WebSocketIpAddress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
||||||
{
|
{
|
||||||
|
@ -104,6 +104,9 @@ namespace WCS.BLL.HardWare
|
|||||||
public List<int> ModuleIds { get; set; }
|
public List<int> ModuleIds { get; set; }
|
||||||
public string ClientIp { get; set; }
|
public string ClientIp { get; set; }
|
||||||
|
|
||||||
|
//websocket通知的前端的IP地址
|
||||||
|
public string WebSocketIpAddress { get; set; } = "127.0.0.2";
|
||||||
|
|
||||||
#region 协议处理
|
#region 协议处理
|
||||||
public void GoInInstore(string? IPAddress)
|
public void GoInInstore(string? IPAddress)
|
||||||
{
|
{
|
||||||
@ -186,7 +189,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
@ -267,13 +270,13 @@ namespace WCS.BLL.HardWare
|
|||||||
var warningModel = new WebSocketMessageModel()
|
var warningModel = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
IsWarning = true,
|
IsWarning = true,
|
||||||
WarningType = WarningTypeEnum.进入入库未响应,
|
WarningType = WarningTypeEnum.退出入库未响应,
|
||||||
StoreId = 0,
|
StoreId = 0,
|
||||||
StoreCode = "",
|
StoreCode = "",
|
||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
}
|
}
|
||||||
@ -354,7 +357,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
}
|
}
|
||||||
@ -411,7 +414,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
}
|
}
|
||||||
@ -503,7 +506,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
}
|
}
|
||||||
@ -536,7 +539,7 @@ namespace WCS.BLL.HardWare
|
|||||||
var messageMode = new WebSocketMessageModel()
|
var messageMode = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
IsWarning = false,
|
IsWarning = false,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
WarningType = WarningTypeEnum.通知刷新盘点
|
WarningType = WarningTypeEnum.通知刷新盘点
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(messageMode);
|
WarningManager.SendWarning(messageMode);
|
||||||
@ -590,7 +593,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
}
|
}
|
||||||
@ -797,7 +800,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
#endregion
|
#endregion
|
||||||
@ -831,7 +834,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
#endregion
|
#endregion
|
||||||
@ -916,7 +919,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!",
|
WarningMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!",
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
@ -1051,7 +1054,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
@ -1079,7 +1082,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
@ -1096,7 +1099,6 @@ namespace WCS.BLL.HardWare
|
|||||||
{
|
{
|
||||||
Logs.Write("协议处理5.4");
|
Logs.Write("协议处理5.4");
|
||||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
|
||||||
var warningModel = new WebSocketMessageModel()
|
var warningModel = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
WarningType = WarningTypeEnum.入库中异常取出,
|
WarningType = WarningTypeEnum.入库中异常取出,
|
||||||
@ -1107,7 +1109,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
@ -1213,7 +1215,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
#endregion
|
#endregion
|
||||||
@ -1247,7 +1249,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
#endregion
|
#endregion
|
||||||
@ -1402,7 +1404,7 @@ namespace WCS.BLL.HardWare
|
|||||||
var messageMode = new WebSocketMessageModel()
|
var messageMode = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
IsWarning = false,
|
IsWarning = false,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
WarningType = WarningTypeEnum.通知刷新出库
|
WarningType = WarningTypeEnum.通知刷新出库
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(messageMode);
|
WarningManager.SendWarning(messageMode);
|
||||||
@ -1625,7 +1627,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1",
|
ClientIp = WebSocketIpAddress,
|
||||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
@ -1640,7 +1642,6 @@ namespace WCS.BLL.HardWare
|
|||||||
case 0x01:
|
case 0x01:
|
||||||
{
|
{
|
||||||
var exceptionMessage = storeInfo.StoreCode + "出库过程中存在物料上架!";
|
var exceptionMessage = storeInfo.StoreCode + "出库过程中存在物料上架!";
|
||||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
|
||||||
var warningModel = new WebSocketMessageModel()
|
var warningModel = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
WarningType = WarningTypeEnum.出库中未扫描上架,
|
WarningType = WarningTypeEnum.出库中未扫描上架,
|
||||||
@ -1651,7 +1652,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress,
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
@ -1666,7 +1667,6 @@ namespace WCS.BLL.HardWare
|
|||||||
case 0x02:
|
case 0x02:
|
||||||
{
|
{
|
||||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
|
||||||
var warningModel = new WebSocketMessageModel()
|
var warningModel = new WebSocketMessageModel()
|
||||||
{
|
{
|
||||||
WarningType = WarningTypeEnum.出库中丢失,
|
WarningType = WarningTypeEnum.出库中丢失,
|
||||||
@ -1677,7 +1677,7 @@ namespace WCS.BLL.HardWare
|
|||||||
ShelfCode = ShelfCode,
|
ShelfCode = ShelfCode,
|
||||||
ShelfId = ShelfId,
|
ShelfId = ShelfId,
|
||||||
WarningMessage = exceptionMessage,
|
WarningMessage = exceptionMessage,
|
||||||
ClientIp = "127.0.0.1"
|
ClientIp = WebSocketIpAddress
|
||||||
};
|
};
|
||||||
WarningManager.SendWarning(warningModel);
|
WarningManager.SendWarning(warningModel);
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ namespace WCS.BLL.Manager
|
|||||||
{
|
{
|
||||||
public static void InitDb()
|
public static void InitDb()
|
||||||
{
|
{
|
||||||
|
Logs.Write("【初始化数据库】开始", LogsType.StartBoot);
|
||||||
|
DbHelp.db.DbMaintenance.CreateDatabase();
|
||||||
|
|
||||||
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
||||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||||
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
||||||
@ -43,6 +46,8 @@ namespace WCS.BLL.Manager
|
|||||||
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
||||||
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logs.Write("【初始化数据库】结束", LogsType.StartBoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,15 @@ namespace WCS.BLL.Manager
|
|||||||
|
|
||||||
public static void InitShelves()
|
public static void InitShelves()
|
||||||
{
|
{
|
||||||
|
Logs.Write("【InitShelves】开始", LogsType.StartBoot);
|
||||||
|
|
||||||
var shelvesInDb = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
var shelvesInDb = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||||
foreach (var shelfInDb in shelvesInDb)
|
foreach (var shelfInDb in shelvesInDb)
|
||||||
{
|
{
|
||||||
Shelves.Add(InitShelf(shelfInDb));
|
Shelves.Add(InitShelf(shelfInDb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logs.Write("【InitShelves】结束", LogsType.StartBoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
|
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
|
||||||
|
@ -21,12 +21,15 @@ namespace WCS.BLL.Manager
|
|||||||
public static List<TCPClient> TCPClients = new List<TCPClient>();
|
public static List<TCPClient> TCPClients = new List<TCPClient>();
|
||||||
public static void InitTcpClient()
|
public static void InitTcpClient()
|
||||||
{
|
{
|
||||||
|
Logs.Write("【InitTcpClient】开始", LogsType.StartBoot);
|
||||||
|
|
||||||
var ips = DbHelp.db.Queryable<ShelfInfo>()
|
var ips = DbHelp.db.Queryable<ShelfInfo>()
|
||||||
//.Where(t => t.ShelfCode.Contains("C"))
|
|
||||||
.Select(t => t.ClientIp)
|
.Select(t => t.ClientIp)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
foreach (var ip in ips)
|
foreach (var ip in ips)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var tcpCleint = new TCPClient(ip, "");
|
var tcpCleint = new TCPClient(ip, "");
|
||||||
//配置断线重连
|
//配置断线重连
|
||||||
@ -36,7 +39,6 @@ namespace WCS.BLL.Manager
|
|||||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||||
if (TcpCleint == null)
|
if (TcpCleint == null)
|
||||||
{
|
{
|
||||||
//TO DO
|
|
||||||
return EasyTask.CompletedTask;
|
return EasyTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,20 +85,6 @@ namespace WCS.BLL.Manager
|
|||||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//协议处理 判断功能位
|
|
||||||
//switch (dataTemp[TcpCleint.PreFixLength + 2])
|
|
||||||
//{
|
|
||||||
// case 0x20://进入入库模式信号
|
|
||||||
// //GoInInstoreProcess(dataTemp, boardId, lightNumber);
|
|
||||||
// break;
|
|
||||||
// case 0x03://正常入库信号
|
|
||||||
// //InStoreReturnProcess(dataTemp);
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// ;
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logs.Write("协议处理完毕!");
|
Logs.Write("协议处理完毕!");
|
||||||
@ -114,6 +102,7 @@ namespace WCS.BLL.Manager
|
|||||||
//首次连接
|
//首次连接
|
||||||
if (TcpCleint.IsFirstConnected == false)
|
if (TcpCleint.IsFirstConnected == false)
|
||||||
{
|
{
|
||||||
|
Logs.Write($"【InitTcpClient】{clientIpHost}完成首次连接", LogsType.StartBoot);
|
||||||
InitStatus(TcpCleint);
|
InitStatus(TcpCleint);
|
||||||
TcpCleint.IsFirstConnected = true;
|
TcpCleint.IsFirstConnected = true;
|
||||||
}
|
}
|
||||||
@ -122,6 +111,7 @@ namespace WCS.BLL.Manager
|
|||||||
|
|
||||||
TCPClients.Add(tcpCleint);
|
TCPClients.Add(tcpCleint);
|
||||||
tcpCleint.Connect();
|
tcpCleint.Connect();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//启动线程监听所有TCP是否已经完成首次连接
|
//启动线程监听所有TCP是否已经完成首次连接
|
||||||
@ -145,6 +135,7 @@ namespace WCS.BLL.Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Logs.Write("【InitTcpClient】完成后台继续连接", LogsType.StartBoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
//后台启动时给所有板子、警示灯发送复位操作 保持状态一致
|
//后台启动时给所有板子、警示灯发送复位操作 保持状态一致
|
||||||
|
@ -16,6 +16,7 @@ namespace WCS.BLL.Manager
|
|||||||
public static object flag = new object();
|
public static object flag = new object();
|
||||||
public static void InitWebSocket()
|
public static void InitWebSocket()
|
||||||
{
|
{
|
||||||
|
Logs.Write("【启动WebSocket】开始", LogsType.StartBoot);
|
||||||
service = new HttpService();
|
service = new HttpService();
|
||||||
service.Setup(new TouchSocketConfig()//加载配置
|
service.Setup(new TouchSocketConfig()//加载配置
|
||||||
.SetListenIPHosts(7789)
|
.SetListenIPHosts(7789)
|
||||||
@ -32,9 +33,10 @@ namespace WCS.BLL.Manager
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
service.Start();
|
service.Start();
|
||||||
service.Logger.Info("服务器已启动");
|
Logs.Write("【启动WebSocket】结束", LogsType.StartBoot);
|
||||||
}
|
}
|
||||||
//尝试发送报警信息给前端
|
|
||||||
|
//发送报警信息给前端
|
||||||
public static void TrySendMessage(string IpAddress, string Message)
|
public static void TrySendMessage(string IpAddress, string Message)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
|
using WCS.BLL.Manager;
|
||||||
using WCS.BLL.Services.IService;
|
using WCS.BLL.Services.IService;
|
||||||
using WCS.DAL;
|
using WCS.DAL;
|
||||||
using WCS.DAL.Db.AuthDb;
|
using WCS.DAL.Db.AuthDb;
|
||||||
@ -440,13 +441,23 @@ namespace WCS.BLL.Services.Service
|
|||||||
|
|
||||||
//返回字串不返回密码
|
//返回字串不返回密码
|
||||||
user.Password = "***";
|
user.Password = "***";
|
||||||
|
|
||||||
var response = new ResponseCommon<UserBase>()
|
var response = new ResponseCommon<UserBase>()
|
||||||
{
|
{
|
||||||
Code = 200,
|
Code = 200,
|
||||||
Message = "success",
|
Message = "success",
|
||||||
Data = user
|
Data = user
|
||||||
};
|
};
|
||||||
|
//登录成功
|
||||||
|
if (request.DeviceType == "WCS前端" && request.GroupNames != null)
|
||||||
|
{
|
||||||
|
var shelves = ShelfManager.Shelves.Where(t => request.GroupNames.Contains(t.GroupName))
|
||||||
|
.ToList();
|
||||||
|
foreach (var shelf in shelves)
|
||||||
|
{
|
||||||
|
shelf.WebSocketIpAddress = request.WebSocketIpAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -22,17 +22,10 @@ namespace WCS.BLL
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Info,
|
Info,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 警告
|
/// 启动信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Warning,
|
StartBoot,
|
||||||
/// <summary>
|
|
||||||
/// 错误
|
|
||||||
/// </summary>
|
|
||||||
Err,
|
|
||||||
/// <summary>
|
|
||||||
/// 数据库错误
|
|
||||||
/// </summary>
|
|
||||||
DbErr,
|
|
||||||
Api
|
Api
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,16 +108,6 @@ namespace WCS.BLL
|
|||||||
Write($"{contentTitle} {JsonConvert.SerializeObject(content)}", type);
|
Write($"{contentTitle} {JsonConvert.SerializeObject(content)}", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 写入日志
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ex">错误</param>
|
|
||||||
/// <returns>是否写入成功</returns>
|
|
||||||
public static void Write(Exception ex, LogsType type = LogsType.Err)
|
|
||||||
{
|
|
||||||
Write(ex.ToString(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清除日志
|
/// 清除日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -94,7 +94,7 @@ namespace WCS.BLL
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//获取返回指令的板子ID
|
//获取返回指令的板子ID
|
||||||
var boardId = (data[PreFixLength + 0] << 8) + data[PreFixLength + 1];
|
var boardId = (dataTemp[PreFixLength + 0] << 8) + dataTemp[PreFixLength + 1];
|
||||||
//查询当前板子是否有待验证的指令
|
//查询当前板子是否有待验证的指令
|
||||||
var message = new MessageDto();
|
var message = new MessageDto();
|
||||||
MessageList.TryGetValue(boardId, out message);
|
MessageList.TryGetValue(boardId, out message);
|
||||||
@ -103,7 +103,7 @@ namespace WCS.BLL
|
|||||||
{
|
{
|
||||||
MessageList.TryRemove(boardId, out message);
|
MessageList.TryRemove(boardId, out message);
|
||||||
}
|
}
|
||||||
index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1
|
index += (PreFixLength + DataLength - 2);//每次循环index会+1 所以这里-1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
|
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
|
||||||
@ -131,24 +131,21 @@ namespace WCS.BLL
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//TODO如果指令已发两次 则取消重发
|
//TODO如果指令已发两次 则取消重发
|
||||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
if (MessageList.Count > 0)
|
if (MessageList.Count > 0)
|
||||||
{
|
{
|
||||||
var failedMessage = MessageList.Where(t => t.Value.SendTimes >= 2).ToList();
|
var failedMessage = MessageList.Where(t => t.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
||||||
|
.ToList();
|
||||||
foreach (var message in failedMessage)
|
foreach (var message in failedMessage)
|
||||||
{
|
{
|
||||||
Logs.Write(BitConverter.ToString(message.Value.Message) +
|
Logs.Write(BitConverter.ToString(message.Value.Message) + "指令超时1s未响应");
|
||||||
"指令未响应");
|
|
||||||
}
|
}
|
||||||
MessageList.RemoveWhen(t => t.Value.SendTimes >= 3);
|
MessageList.RemoveWhen(t => t.Value.SendTimes >= 2);
|
||||||
|
|
||||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
|
||||||
foreach (var item in MessageList)
|
foreach (var item in MessageList)
|
||||||
{
|
{
|
||||||
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
||||||
{
|
{
|
||||||
tcpClient.Send(item.Value.Message);
|
Send(item.Value.Message);
|
||||||
item.Value.SendTimes++;
|
item.Value.SendTimes++;
|
||||||
item.Value.LastSendTime = DateTime.Now;
|
item.Value.LastSendTime = DateTime.Now;
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
@ -173,17 +170,25 @@ namespace WCS.BLL
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Send(byte[] message)
|
public void Send(byte[] message, bool IsReSend = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var boardId = (message[3] << 8) + message[4];
|
var boardId = (message[3] << 8) + message[4];
|
||||||
|
if (boardId != 2047 && IsReSend == false)
|
||||||
|
{
|
||||||
|
MessageList.TryAdd(boardId, new MessageDto()
|
||||||
|
{
|
||||||
|
ID = boardId,
|
||||||
|
Message = message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
lock (sendLockObject)
|
lock (sendLockObject)
|
||||||
{
|
{
|
||||||
tcpClient.Send(message);
|
tcpClient.Send(message);
|
||||||
//TODO MessageList.AddOrUpdate(new Mes)
|
//发送自带8ms间隔
|
||||||
//发送自带10ms间隔
|
Thread.Sleep(8);
|
||||||
Thread.Sleep(10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -226,18 +231,14 @@ namespace WCS.BLL
|
|||||||
public class MessageDto
|
public class MessageDto
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最后一次发送时间
|
/// 最后一次发送时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime LastSendTime { get; set; } = DateTime.Now;
|
public DateTime LastSendTime { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送内容
|
/// 发送内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[] Message { get; set; }
|
public byte[] Message { get; set; }
|
||||||
|
|
||||||
public bool IsWating { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送次数
|
/// 发送次数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,5 +14,9 @@ namespace WCS.Model.ApiModel.User
|
|||||||
/// 是否配置为不登陆(如果不登陆 直接获取admin 且不验证密码了)
|
/// 是否配置为不登陆(如果不登陆 直接获取admin 且不验证密码了)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsNoLogin { get; set; } = false;
|
public bool IsNoLogin { get; set; } = false;
|
||||||
|
|
||||||
|
public string WebSocketIpAddress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public List<string> GroupNames { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ namespace WCS.WebApi.Controllers
|
|||||||
[HttpPost(Name = "userLogin")]
|
[HttpPost(Name = "userLogin")]
|
||||||
public async Task<ResponseBase> userLogin(UserLoginRequest request)
|
public async Task<ResponseBase> userLogin(UserLoginRequest request)
|
||||||
{
|
{
|
||||||
|
//获取调用设备的Ip地址
|
||||||
|
request.WebSocketIpAddress = HttpContext?.Connection?.RemoteIpAddress?.ToString();
|
||||||
return await _userService.UserLogin(request);
|
return await _userService.UserLogin(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,21 @@ namespace WebApi
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC>websocket
|
||||||
WebSoceketManager.InitWebSocket();
|
WebSoceketManager.InitWebSocket();
|
||||||
|
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
||||||
DbInit.InitDb();
|
DbInit.InitDb();
|
||||||
|
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
LocalFile.SaveConfig();
|
LocalFile.SaveConfig();
|
||||||
|
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC>TCP<43><50><EFBFBD><EFBFBD>
|
||||||
TCPClientManager.InitTcpClient();
|
TCPClientManager.InitTcpClient();
|
||||||
|
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
ShelfManager.InitShelves();
|
ShelfManager.InitShelves();
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ƺͰ<C6BA><CDB0><EFBFBD>
|
|
||||||
//TCPClientManager.InitStatus();
|
|
||||||
|
|
||||||
WarningManager.StartWarningMessageThread();
|
WarningManager.StartWarningMessageThread();
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ namespace WebApi
|
|||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.Run("http://+:8888");
|
app.Run("http://0.0.0.0:8888");//0.0.0.0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ipv4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ using System.Collections.ObjectModel;
|
|||||||
using WCS.BLL.DbModels;
|
using WCS.BLL.DbModels;
|
||||||
using WCS.Model.ApiModel.MatBaseInfo;
|
using WCS.Model.ApiModel.MatBaseInfo;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using Ping9719.WpfEx;
|
||||||
|
|
||||||
namespace 货架标准上位机.ViewModel
|
namespace 货架标准上位机.ViewModel
|
||||||
{
|
{
|
||||||
@ -259,6 +260,33 @@ namespace 货架标准上位机.ViewModel
|
|||||||
if (Result != null && Result.Code == 200)
|
if (Result != null && Result.Code == 200)
|
||||||
{
|
{
|
||||||
scanner.MatSn = Result.Data.MatSN;
|
scanner.MatSn = Result.Data.MatSN;
|
||||||
|
#region 调用接口获取入库状态
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var body = new QueryByMatSnRequest()
|
||||||
|
{
|
||||||
|
MatSn = scanner.MatSn,
|
||||||
|
ShelfCode = scanner.ShelfCode,
|
||||||
|
IpAddress = scanner.COM,
|
||||||
|
DeviceType = LocalFile.Config.DeviceType,
|
||||||
|
UserName = LocalStatic.CurrentUser,
|
||||||
|
};
|
||||||
|
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<MatInfoModel>>(LocalFile.Config.ApiIpHost + "instore/queryInstoreStatus", body, "POST");
|
||||||
|
if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||||
|
{
|
||||||
|
TextBoxLog.AddLog(Result.Message, "InstoreLog", DateTime.Now);
|
||||||
|
scanner.MatSn = string.Empty;
|
||||||
|
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Growl.Warning(ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||||
{
|
{
|
||||||
|
@ -291,10 +291,10 @@
|
|||||||
<!--状态栏-->
|
<!--状态栏-->
|
||||||
<Border Margin="5,3" Grid.Row="2" Grid.ColumnSpan="2" Background="AliceBlue" CornerRadius="3">
|
<Border Margin="5,3" Grid.Row="2" Grid.ColumnSpan="2" Background="AliceBlue" CornerRadius="3">
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Left">
|
<!--<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Left">
|
||||||
<pi:IotState Content="WebSocket连接" IsOk="False" Height="auto" Width="auto" InteriorHeight="13" Foreground="Gray" Background="{x:Null}"></pi:IotState>
|
<pi:IotState Content="WebSocket连接" IsOk="False" Height="auto" Width="auto" InteriorHeight="13" Foreground="Gray" Background="{x:Null}"></pi:IotState>
|
||||||
<Button Content="手动重连" ></Button>
|
<Button Content="手动重连" ></Button>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<TextBlock Margin="0,0" Text="{Binding Time,StringFormat=yyyy-MM-dd HH:mm:ss,FallbackValue=2000-01-01 00:00:00}" Foreground="#FF3A90C1" VerticalAlignment="Center"></TextBlock>
|
<TextBlock Margin="0,0" Text="{Binding Time,StringFormat=yyyy-MM-dd HH:mm:ss,FallbackValue=2000-01-01 00:00:00}" Foreground="#FF3A90C1" VerticalAlignment="Center"></TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -69,6 +69,7 @@ namespace 货架标准上位机
|
|||||||
{
|
{
|
||||||
UserName = loginName,
|
UserName = loginName,
|
||||||
DeviceType = LocalFile.Config.DeviceType,
|
DeviceType = LocalFile.Config.DeviceType,
|
||||||
|
GroupNames = LocalFile.Config.GroupName,
|
||||||
PassWord = pass,
|
PassWord = pass,
|
||||||
IsNoLogin = false,
|
IsNoLogin = false,
|
||||||
};
|
};
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
//货架服务器的IP和端口号
|
//货架服务器的IP和端口号
|
||||||
"ApiIpHost": "http://localhost:8888/",
|
"ApiIpHost": "http://localhost:8888/",
|
||||||
//货架分区
|
//货架分区
|
||||||
"GroupName": [ "A", "B", "C" ],
|
"GroupName": [ "13寸智能货架", "7寸智能货架"],
|
||||||
//设备类型 可以配置为每个电脑不一样
|
//设备类型 可以配置为每个电脑不一样
|
||||||
"DeviceType": "WCS前端-开发电脑",
|
"DeviceType": "WCS前端",
|
||||||
//货架类型的是否开机自检
|
//货架类型的是否开机自检
|
||||||
"IsBootSelfTest": false,
|
"IsBootSelfTest": false,
|
||||||
//扫码枪COM口列表
|
//扫码枪COM口列表
|
||||||
"ScannerComList": [ "COM1", "COM2" ],
|
"ScannerComList": [],
|
||||||
//串口扫码枪延时
|
//串口扫码枪延时
|
||||||
"ScannerTimeOut": 2000,
|
"ScannerTimeOut": 2000,
|
||||||
//系统配置
|
//系统配置
|
||||||
|
Reference in New Issue
Block a user