From ae9ced98f1f70957d9a62bcda7e2e09806691162 Mon Sep 17 00:00:00 2001 From: tq <1916474859@qq,com> Date: Thu, 26 Sep 2024 11:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=A2=E7=94=B5=E8=AE=A2=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=AD=97=E6=AE=B5=E5=AF=B9=E5=BA=94=E3=80=81led?= =?UTF-8?q?=E9=87=8D=E8=BF=9E=E7=A8=8B=E5=BA=8F=E5=8D=A1=E9=A1=BF=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E5=8A=A0=E9=94=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Dto/SwapOrderDto.cs | 10 +++++-- Service/Led/LedClient.cs | 56 +++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/Entity/Dto/SwapOrderDto.cs b/Entity/Dto/SwapOrderDto.cs index 9cb5430..96f0772 100644 --- a/Entity/Dto/SwapOrderDto.cs +++ b/Entity/Dto/SwapOrderDto.cs @@ -35,9 +35,13 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [ExporterHeader(DisplayName = "车牌号", IsBold = true)] + [ExporterHeader(DisplayName = "车辆代码", IsBold = true)] public string VehicleNo { get; set; } + + [ExporterHeader(DisplayName = "车牌号", IsBold = true)] + public string VehicleNoCode { get; set; } + /// /// 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; } } diff --git a/Service/Led/LedClient.cs b/Service/Led/LedClient.cs index b0ffb96..53e20fd 100644 --- a/Service/Led/LedClient.cs +++ b/Service/Led/LedClient.cs @@ -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; + } + } } }