换电订单导出字段对应、led重连程序卡顿尝试加锁测试

master
tq 2 months ago
parent 56f40b88f5
commit ae9ced98f1

@ -35,9 +35,13 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "车牌号", IsBold = true)]
[ExporterHeader(DisplayName = "车辆代码", IsBold = true)]
public string VehicleNo { get; set; }
[ExporterHeader(DisplayName = "车牌号", IsBold = true)]
public string VehicleNoCode { get; set; }
/// <summary>
/// Desc:公司
/// Default:
@ -176,7 +180,7 @@ public class SwapOrderDto
{
get
{
return UpBatterySoc.HasValue ? $"{UpBatterySoc.Value}%" : null;
return UpBatterySoc.HasValue ? $"{UpBatterySoc.Value.ToString("0.00")}%" : null;
}
}
@ -219,7 +223,7 @@ public class SwapOrderDto
{
get
{
return DownBatterySoc.HasValue ? $"{DownBatterySoc.Value}%" : null;
return DownBatterySoc.HasValue ? $"{DownBatterySoc.Value.ToString("0.00")}%" : null;
}
}

@ -135,39 +135,45 @@ public class LedClient
_socket = null;
}
}
private static readonly object Locker = new object();
public static bool InnerSend(byte[] bytes)
{
if (_socket?.Connected ?? false)
{
try
{
_socket.Send(bytes);
Log.Info($"Sent {BitUtls.BytesToHexStr(bytes)}");
return true;
}
catch (SocketException ex)
{
Log.Error($"Failed to send data. Reason: {ex.Message}");
return false;
}
}
else
private static bool InnerSend(byte[] bytes)
{
lock (Locker)
{
Connect();
if (_socket?.Connected ?? false)
{
_socket.Send(bytes);
Log.Info($"Sent {BitUtls.BytesToHexStr(bytes)} after reconnect");
return true;
try
{
_socket.Send(bytes);
Log.Info($"Sent {BitUtls.BytesToHexStr(bytes)}");
return true;
}
catch (SocketException ex)
{
Log.Error($"Failed to send data. Reason: {ex.Message}");
return false;
}
}
else
{
Log.Error($"Failed to reconnect and send data.");
return false;
}
Connect();
if (_socket?.Connected ?? false)
{
_socket.Send(bytes);
Log.Info($"Sent {BitUtls.BytesToHexStr(bytes)} after reconnect");
return true;
}
else
{
Log.Error($"Failed to reconnect and send data.");
return false;
}
}
}
}

Loading…
Cancel
Save