From ac9e1caaebd87eaacfb8855ed167587d1f9db0a4 Mon Sep 17 00:00:00 2001 From: tq <1916474859@qq,com> Date: Tue, 25 Jun 2024 16:09:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E5=A4=96=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Dto/Resp/ChargerPileResp.cs | 38 +++++++++++++++++++ Service/Charger/Client/ChargerClient.cs | 5 +++ .../OutCharger/PileUploadTelemetryHandler.cs | 2 +- .../Controllers/OutChargerController.cs | 31 ++++++++++++++- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Entity/Dto/Resp/ChargerPileResp.cs diff --git a/Entity/Dto/Resp/ChargerPileResp.cs b/Entity/Dto/Resp/ChargerPileResp.cs new file mode 100644 index 0000000..d64a533 --- /dev/null +++ b/Entity/Dto/Resp/ChargerPileResp.cs @@ -0,0 +1,38 @@ +namespace Entity.Dto.Resp; + +/// +/// 充电桩信息 +/// +public class ChargerPileResp +{ + public ChargerPileResp() + { + } + + public string Sn { get; set; } + /// + /// 站外1枪是否充电 + /// + public bool GunChargedOne { get; set; } + /// + /// 站外2枪是否充电 + /// + public bool GunChargedTwo { get; set; } + /// + /// 站外1枪是否连接 + /// + public bool ChargedPileOne { get; set; } + /// + /// 站外2枪是否连接 + /// + public bool ChargedPileTwo { get; set; } + /// + /// 站外1枪充电功率 + /// + public float? ChargePilePowerOne { get; set; } + /// + /// 站外2枪充电功率 + /// + public float? ChargePilePowerTwo { get; set; } + +} \ No newline at end of file diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index ae49cee..1a1b12f 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -170,6 +170,11 @@ public class ChargerClient : TcpClient /// 充电桩状态信息 /// public ConcurrentDictionary ChargerPile = new(); + + /// + /// 充电桩功率 + /// + public ConcurrentDictionary ChargePilePower = new(); /// ///充电机实时充电功率 diff --git a/Service/Charger/Handler/OutCharger/PileUploadTelemetryHandler.cs b/Service/Charger/Handler/OutCharger/PileUploadTelemetryHandler.cs index 5a85c0c..970fe63 100644 --- a/Service/Charger/Handler/OutCharger/PileUploadTelemetryHandler.cs +++ b/Service/Charger/Handler/OutCharger/PileUploadTelemetryHandler.cs @@ -23,7 +23,7 @@ public class PileUploadTelemetryHandler : SimpleChannelInboundHandler.Fail("充电机未连接"); } + + /// + /// 获取充电桩信息 + /// + /// + [HttpGet] + [Route("GetChargerPile")] + public Result> GetChargerPile() + { + var chargerClients = ClientMgr.Dictionary; + if (chargerClients.IsEmpty) + { + return Result>.Fail("没有充电机连接"); + } + + var list = chargerClients.Values.Select(client => new ChargerPileResp + { + Sn = client.Sn, + GunChargedOne = client.GunCharged[1], + GunChargedTwo = client.GunCharged[2], + ChargedPileOne = client.ChargedPile[1], + ChargedPileTwo = client.ChargedPile[2], + ChargePilePowerOne = client.ChargePilePower[1], + ChargePilePowerTwo = client.ChargePilePower[2] + }).ToList(); + + return Result>.Success(list); + } } \ No newline at end of file