Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1895,11 +1895,16 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
try
|
||||
{
|
||||
string jsonString = await _redisData.GetHash(DevName, field);
|
||||
Log.Information($"查询X2Server数据 {DevName} {field}:" + jsonString);
|
||||
if (string.IsNullOrEmpty(jsonString))
|
||||
return false;
|
||||
|
||||
JObject jsonObject = JObject.Parse(jsonString);
|
||||
|
||||
if (jsonObject.TryGetValue("StatusCode", out JToken valueToken1))
|
||||
{
|
||||
if (valueToken1.ToString() == "-1")
|
||||
return false;
|
||||
}
|
||||
if (jsonObject.TryGetValue("Value", out JToken valueToken2))
|
||||
{
|
||||
return bool.Parse(valueToken2.ToString());
|
||||
@@ -1920,59 +1925,59 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
public async Task<string> GetStringTag(string DevName, string field)
|
||||
{
|
||||
#region
|
||||
//try
|
||||
//{
|
||||
// string jsonString = await _redisData.GetHash(DevName, field);
|
||||
|
||||
// JObject jsonObject = JObject.Parse(jsonString);
|
||||
// if (jsonObject.TryGetValue("StatusCode", out JToken valueToken1))
|
||||
// {
|
||||
// if (valueToken1.ToString() == "-1")
|
||||
// return "";
|
||||
// }
|
||||
// if (jsonObject.TryGetValue("Value", out JToken valueToken2))
|
||||
// {
|
||||
// return valueToken2.ToString();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($"未找到匹配项 {DevName} {field}");
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// // 捕获并处理异常
|
||||
// Console.WriteLine($"发生异常: {ex.Message}");
|
||||
//}
|
||||
|
||||
//return $"未找到匹配项 {DevName} {field}";
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
string jsonString = await _redisData.GetHash(DevName, field);
|
||||
if (string.IsNullOrEmpty(jsonString))
|
||||
return "";
|
||||
|
||||
string pattern = "\"Value\":\"(.*?)\"";
|
||||
|
||||
System.Text.RegularExpressions.Match match = Regex.Match(jsonString, pattern);
|
||||
if (match.Success)
|
||||
Log.Information($"查询X2Server数据 {DevName} {field}:" + jsonString);
|
||||
JObject jsonObject = JObject.Parse(jsonString);
|
||||
if (jsonObject.TryGetValue("StatusCode", out JToken valueToken1))
|
||||
{
|
||||
|
||||
return match.Groups[1].Value;
|
||||
if (valueToken1.ToString() == "-1")
|
||||
return "";
|
||||
}
|
||||
if (jsonObject.TryGetValue("Value", out JToken valueToken2))
|
||||
{
|
||||
return valueToken2.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"未找到匹配项{DevName} {field}");
|
||||
Console.WriteLine($"未找到匹配项 {DevName} {field}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"未找到匹配项{DevName} {field}");
|
||||
// 捕获并处理异常
|
||||
Console.WriteLine($"发生异常: {ex.Message}");
|
||||
}
|
||||
|
||||
return $"未找到匹配项 {DevName} {field}";
|
||||
#endregion
|
||||
|
||||
//try
|
||||
//{
|
||||
// string jsonString = await _redisData.GetHash(DevName, field);
|
||||
// if (string.IsNullOrEmpty(jsonString))
|
||||
// return "";
|
||||
|
||||
// string pattern = "\"Value\":\"(.*?)\"";
|
||||
|
||||
// System.Text.RegularExpressions.Match match = Regex.Match(jsonString, pattern);
|
||||
// if (match.Success)
|
||||
// {
|
||||
|
||||
// return match.Groups[1].Value;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($"未找到匹配项{DevName} {field}");
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Console.WriteLine($"未找到匹配项{DevName} {field}");
|
||||
//}
|
||||
|
||||
//return $"未找到匹配项 {DevName} {field}";
|
||||
}
|
||||
|
||||
private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value)
|
||||
@@ -2524,7 +2529,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
|
||||
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.Zero, TimeSpan.FromSeconds(180));
|
||||
//YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.Zero, TimeSpan.FromSeconds(180));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex.Message);
|
||||
Logger.LogError(ex.StackTrace);
|
||||
Logger.LogError("【LoadConfirm】" + ex.Message);
|
||||
Logger.LogError("【LoadConfirm】" + ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"取货确认..................失败 原因是{ex.Message}");
|
||||
throw;
|
||||
}
|
||||
@@ -159,6 +159,11 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
if (elevator != null && s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
|
||||
{
|
||||
if (!TimedTaskBackgroundService.elevatorStatus[elevatorCode.ToString()])
|
||||
{
|
||||
Logger.LogError($"【LoadConfirm】 {elevatorCode} 电梯心跳中断,请重试!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"{elevatorCode} 电梯心跳中断,请重试!");
|
||||
}
|
||||
//s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.空闲;
|
||||
string devName = elevatorCode?.ToString();
|
||||
Logger.Information($"【LoadConfirm】 获取设备:{devName},状态");
|
||||
@@ -180,7 +185,7 @@ namespace Tnb.WarehouseMgr
|
||||
if (curFloor != floorNo)
|
||||
{
|
||||
Logger.Information($"【LoadConfirm】 电梯还未开门,请重试!curFloor != floorNo");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "【LoadConfirm】 电梯还未开门,请重试!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "电梯还未开门,请重试!");
|
||||
}
|
||||
if (doorStatus.ToEnum<EnumDoorStatus>() != EnumDoorStatus.开门到位保持 && runStatus.ToEnum<EnumRunStatus>() == EnumRunStatus.停梯 && floorNo == curFloor) //判断电梯楼层与当前放货在同一楼层在允许放货
|
||||
{
|
||||
@@ -202,9 +207,11 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
|
||||
Logger.LogError("【LoadConfirm】" + ex.Message);
|
||||
Logger.LogError("【LoadConfirm】" + ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"取货确认..................失败 原因是{ex.Message}");
|
||||
throw;
|
||||
}
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "请重试!");
|
||||
@@ -339,6 +346,11 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
if (s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
|
||||
{
|
||||
if (!TimedTaskBackgroundService.elevatorStatus[elevatorCode.ToString()])
|
||||
{
|
||||
Logger.LogError($"【UnloadConfirm】 {elevatorCode} 电梯心跳中断,请重试!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"{elevatorCode} 电梯心跳中断,请重试!");
|
||||
}
|
||||
|
||||
string devName = elevatorCode?.ToString();
|
||||
|
||||
@@ -397,7 +409,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("【UnloadConfirm】 放货确认失败", ex);
|
||||
Logger.Error("【UnloadConfirm】 放货确认失败", ex.Message);
|
||||
Logger.Error("【UnloadConfirm】 放货确认失败", ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, "电梯还未开门,请重试!");
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.OpenXmlFormats.Dml.Diagram;
|
||||
using NPOI.SS.Format;
|
||||
using Tnb.Common.Extension;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
@@ -32,14 +34,19 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IHostApplicationLifetime _lifeTime;
|
||||
private List<string> s_heartbeatDevNames = new();
|
||||
//private static Dictionary<string, Func<CancellationToken?, Task>> _timedFuncMap = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static Dictionary<string, bool> elevatorStatus = new Dictionary<string, bool>();
|
||||
public TimedTaskBackgroundService()
|
||||
{
|
||||
s_heartbeatDevNames = _elevatorControlConfiguration.HeartbeatDevNames;
|
||||
if (elevatorStatus.Count == 0)
|
||||
foreach (var devName in s_heartbeatDevNames)
|
||||
elevatorStatus.Add(devName, false);
|
||||
}
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
IsStarted = true;
|
||||
s_heartbeatDevNames = _elevatorControlConfiguration.HeartbeatDevNames;
|
||||
Task timedTask = Task.Run(() =>
|
||||
{
|
||||
_eventPublisher = App.GetRequiredService<IEventPublisher>();
|
||||
@@ -56,12 +63,23 @@ namespace Tnb.WarehouseMgr
|
||||
["token"] = _elevatorControlConfiguration.token
|
||||
};
|
||||
Log.Information($"{devName.Match(@"\d+")}#梯, 心跳检测");
|
||||
string result = await HttpClientHelper.GetAsync(_elevatorControlConfiguration.WriteTagUrl, pars: parameter);
|
||||
Log.Information($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
|
||||
//var result = await RedisHelper.HSetAsync(devName, ElevatorConsts.AGVKeepalive, "123");
|
||||
await Console.Out.WriteLineAsync($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
try
|
||||
{
|
||||
string result = await HttpClientHelper.GetAsync(_elevatorControlConfiguration.WriteTagUrl, pars: parameter);
|
||||
Log.Information($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
JObject resObj = JObject.Parse(result);
|
||||
elevatorStatus[devName] = resObj["Result"].ToString() == "Ok";
|
||||
//var result = await RedisHelper.HSetAsync(devName, ElevatorConsts.AGVKeepalive, "123");
|
||||
await Console.Out.WriteLineAsync($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{result}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"{devName.Match(@"\d+")}#梯, 心跳检测结果:{ex.Message}");
|
||||
elevatorStatus[devName] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, stoppingToken, 30);
|
||||
|
||||
});
|
||||
|
||||
@@ -800,7 +800,7 @@ namespace Tnb.WarehouseMgr
|
||||
string data = await _redisData.GetHash(strs[0], strs[1]);
|
||||
Logger.Information("wcs请求CheckPut接口查询X2Server数据:" + data);
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
||||
bool result = res != null && res["Value"] != null && res["StatusCode"].ToString() == "0" ? res.Value<bool>("Value") : false;
|
||||
if (!result)
|
||||
throw new AppFriendlyException("点位" + input.targetName + "不可放", 500);
|
||||
Logger.Information("wcs请求CheckPut接口结果:CTU可放货" + data);
|
||||
@@ -921,7 +921,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
string data = _redisData.GetHash(strs[0], strs[1]).Result;
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
||||
bool result = res != null && res["Value"] != null && res["StatusCode"].ToString() == "0" ? res.Value<bool>("Value") : false;
|
||||
Logger.Information($"【Check】{action} 判断KIVA是否可以取货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result} ");
|
||||
if (!result)
|
||||
{
|
||||
@@ -943,7 +943,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
string data = _redisData.GetHash(strs[0], strs[1]).Result;
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
||||
bool result = res != null && res["Value"] != null && res["StatusCode"].ToString() == "0" ? res.Value<bool>("Value") : false;
|
||||
Logger.Information($"【Check】 判断CTU是否可以放货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result}");
|
||||
if (!result)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user