日志完善

This commit is contained in:
hehaibing-1996
2025-03-06 11:28:24 +08:00
parent 66f700c560
commit cb16700a71
3 changed files with 17 additions and 7 deletions

View File

@ -25,6 +25,7 @@ namespace WCS.BLL.Manager
{ {
while (true) while (true)
{ {
//每5秒同步一次 //每5秒同步一次
Thread.Sleep(3000); Thread.Sleep(3000);
try try
@ -38,6 +39,7 @@ namespace WCS.BLL.Manager
.ToList(); .ToList();
if (tasks != null && tasks.Count > 0) if (tasks != null && tasks.Count > 0)
{ {
Logs.Write("【定时任务】获取任务状态 开始", LogsType.Tasks);
for (int i = 0; i < tasks.Count; i++) for (int i = 0; i < tasks.Count; i++)
{ {
try try
@ -95,15 +97,19 @@ namespace WCS.BLL.Manager
} }
catch (Exception ex) catch (Exception ex)
{ {
Logs.Write("【定时任务】获取任务状态异常:" + ex.Message); Logs.Write("【定时任务】获取任务状态异常:" + ex.Message, LogsType.Tasks);
} }
Thread.Sleep(50); Thread.Sleep(50);
} }
} }
else
{
}
} }
catch (Exception ex) catch (Exception ex)
{ {
Logs.Write("【定时任务】获取任务状态异常:" + ex.Message); Logs.Write("【定时任务】获取任务状态异常:" + ex.Message, LogsType.Tasks);
} }
} }
}); });
@ -114,6 +120,7 @@ namespace WCS.BLL.Manager
{ {
while (true) while (true)
{ {
Logs.Write("【定时任务】定时同步货架绑定情况,开始", LogsType.Tasks);
try try
{ {
var url = @"http://192.168.18.150:8181/rcms/services/rest/hikRpcService/syncMapDatas"; var url = @"http://192.168.18.150:8181/rcms/services/rest/hikRpcService/syncMapDatas";
@ -186,20 +193,23 @@ namespace WCS.BLL.Manager
if (shelfs != null && shelfs.Count > 0) if (shelfs != null && shelfs.Count > 0)
{ {
Logs.Write($"【定时任务】定时同步货架绑定情况,更新{shelfs.Count}个货架", LogsType.Tasks);
DbHelp.db.Updateable(shelfs) DbHelp.db.Updateable(shelfs)
.UpdateColumns(t => new { t.CurrentLocationId, t.CurrentLocaiotnCode }) .UpdateColumns(t => new { t.CurrentLocationId, t.CurrentLocaiotnCode })
//.Where(t => t.TransStatus == TransStatusEnum.静止) //.Where(t => t.TransStatus == TransStatusEnum.静止)
.ExecuteCommand(); .ExecuteCommand();
} }
Logs.Write($"【定时任务】定时同步货架绑定情况,更新0个货架", LogsType.Tasks);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logs.Write("【定时任务】定时同步货架绑定情况异常:" + ex.Message); Logs.Write("【定时任务】定时同步货架绑定情况异常:" + ex.Message,LogsType.Tasks);
} }
Logs.Write("【定时任务】定时同步货架绑定情况,结束", LogsType.Tasks);
//每60秒同步一次 //每60秒同步一次
Thread.Sleep(30000); Thread.Sleep(20000);
} }
}); });
#endregion #endregion

View File

@ -32,7 +32,7 @@ namespace WCS.BLL
/// <summary> /// <summary>
/// 指令发送接收 /// 指令发送接收
/// </summary> /// </summary>
Instructions, Tasks,
/// <summary> /// <summary>
/// 指令重发 /// 指令重发
/// </summary> /// </summary>

View File

@ -252,7 +252,7 @@ namespace WCS.BLL
tcpClient.Send(message); tcpClient.Send(message);
var clientIpHost = tcpClient.IP + ":" + tcpClient.Port; var clientIpHost = tcpClient.IP + ":" + tcpClient.Port;
Logs.Write($"【发送{clientIpHost}】{BitConverter.ToString(message)}", LogsType.Instructions); Logs.Write($"【发送{clientIpHost}】{BitConverter.ToString(message)}", LogsType.Tasks);
//发送自带15ms间隔 //发送自带15ms间隔
Thread.Sleep(18); Thread.Sleep(18);
@ -260,7 +260,7 @@ namespace WCS.BLL
} }
catch (Exception ex) catch (Exception ex)
{ {
Logs.Write("【发送指令时发生异常】" + ex.Message, LogsType.Instructions); Logs.Write("【发送指令时发生异常】" + ex.Message, LogsType.Tasks);
//因异常断连时(网线已经被断了) 手动重连一次 //因异常断连时(网线已经被断了) 手动重连一次
if (ex is NotConnectedException) if (ex is NotConnectedException)
{ {