Commit 0403fa4e 张东亮

添加上报状态日志

1 个父辈 b349ef35
......@@ -84,25 +84,26 @@ namespace OnlineStore.DeviceLibrary
{
foreach (var item in getTrayList())
{
bool rtn = SServerManager.UpdateLocInfo("ContainerManager", item.ContainerValidCode, item.Status, item.CurLoc,out bool canRemove);
bool rtn = SServerManager.UpdateLocInfo("ContainerManager", item.ContainerValidCode, item.Status, item.CurLoc,out bool canRemove,out string msg);
if (rtn)
{
if (item.Status.Equals(TaskStatus.ERROR))
{
bool res = containerInfoMap.TryRemove(item.ContainerValidCode, out ContainerInfo containerInfo);
LogUtil.info($"因任务异常,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
LogUtil.info($"因任务异常,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】【{msg}】");
}
else if (item.Status.Equals(TaskStatus.FINISHED))
{
bool res = containerInfoMap.TryRemove(item.ContainerValidCode, out ContainerInfo containerInfo);
LogUtil.info($"任务完成,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
LogUtil.info($"任务完成,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】【{msg}】");
}
else if(canRemove)
{
bool res = containerInfoMap.TryRemove(item.ContainerValidCode, out ContainerInfo containerInfo);
LogUtil.info($"任务不存在,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】");
LogUtil.info($"任务不存在,自动删除该任务【{res}】:【{JsonHelper.SerializeObject(containerInfo)}】【{msg}】");
}
}
Thread.Sleep(1000);
}
}
public static ContainerInfo GetTrayInfo(string trayNum)
......@@ -337,6 +338,11 @@ namespace OnlineStore.DeviceLibrary
}
ContainerInfo info = new ContainerInfo(containerTarget.barcode, containerType, slotCode, deviceId);
containerInfoMap.TryAdd(containerTarget.barcode, info);
LogUtil.info($"料箱【{containerCode}】【{containerType}】【{containerTarget.barcode}】添加到容器信息里");
}
else
{
LogUtil.error($"料箱【{containerCode}】无目的地信息,无法添加到容器信息里");
}
SaveMapToFile();
}
......
......@@ -420,9 +420,9 @@ namespace OnlineStore.DeviceLibrary
/// <param name="status">状态</param>
/// <param name="locInfo">位置</param>
/// <returns></returns>
public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo ,out bool canRemove)
public static bool UpdateLocInfo(string deviceName, string barcode, string status, string locInfo ,out bool canRemove,out string msg)
{
string msg = "";
msg = "";
canRemove = false;
try
{
......@@ -444,34 +444,31 @@ namespace OnlineStore.DeviceLibrary
string server = GetAddr(Addr_UpdateLocInfo, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Get(server);
LogUtil.debug("UpdateTrayLoc " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
msg=("UpdateTrayLoc " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
// 返回: { "code": 0, "msg":"ok", "data":""}
ServerData serverResult = JsonHelper.DeserializeJsonToObject<ServerData>(resultStr);
if (serverResult == null)
{
msg = deviceName + " UpdateTrayLoc【" + barcode + "】【" + status + "】【" + locInfo + "】没有收到服务器反馈";
//msg = deviceName + " UpdateTrayLoc【" + barcode + "】【" + status + "】【" + locInfo + "】没有收到服务器反馈";
return false;
}
else if (serverResult.code.Equals(303).Equals(true))
{
canRemove = true;
// code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = deviceName + " UpdateTrayLoc 任务已完成【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
// msg = deviceName + " UpdateTrayLoc 任务已完成【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
//LogUtil.info(msg);
return true;
}
else if (serverResult.code.Equals(0).Equals(true))
{
// code: 0为正常,其他为异常, msg: 消息, data: 为空
msg = deviceName + " UpdateTrayLoc【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
// LogUtil.info(msg);
// msg = deviceName + " UpdateTrayLoc【" + barcode + "】【" + status + "】【" + locInfo + "】 :" + "【" + serverResult.code + "】" + serverResult.msg;
// LogUtil.info(msg);
return true;
}
if (!msg.Equals(""))
{
LogUtil.error(msg);
else
return false;
}
}
catch (Exception ex)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!