From 492fc0641390c16bb7b63c34f77322b4aa878c02 Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Thu, 13 Jun 2024 10:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6=E9=94=81=E4=BB=93=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E5=85=85=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/DbModel/Station/BinInfo.cs | 8 ++++---- Service/Charger/ChargerService.cs | 4 +++- Service/Charger/Client/ChargerClient.cs | 12 +++++++----- Service/Charger/MyTask/AutoChargeTask.cs | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Entity/DbModel/Station/BinInfo.cs b/Entity/DbModel/Station/BinInfo.cs index ccc087a..1bf4505 100644 --- a/Entity/DbModel/Station/BinInfo.cs +++ b/Entity/DbModel/Station/BinInfo.cs @@ -16,7 +16,7 @@ namespace Entity.DbModel.Station /// Desc:id /// Default: /// Nullable:False - /// + /// [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] public int Id { get; set; } @@ -43,7 +43,7 @@ namespace Entity.DbModel.Station /// [SugarColumn(ColumnName = "name")] public string Name { get; set; } - + /// /// 在位状态:0-不在位;1-在位;其他-无效 /// @@ -112,7 +112,7 @@ namespace Entity.DbModel.Station /// Nullable:True /// [SugarColumn(ColumnName = "amt_lock")] - public string AmtLock { get; set; } + public int? AmtLock { get; set; } /// /// Desc:soc @@ -183,4 +183,4 @@ namespace Entity.DbModel.Station [SugarColumn(ColumnName = "can_charge_flag")] public int CanChargeFlag { get; set; } } -} \ No newline at end of file +} diff --git a/Service/Charger/ChargerService.cs b/Service/Charger/ChargerService.cs index 4a132e7..b6be198 100644 --- a/Service/Charger/ChargerService.cs +++ b/Service/Charger/ChargerService.cs @@ -44,7 +44,9 @@ public class ChargerService return Result.Fail(@"充电机未连接"); } - return chargerClient.StartCharge(); + byte chargeSoc = StaticStationInfo.ChargeSoc; + float chargePower = StaticStationInfo.ChargePower; + return chargerClient.StartCharge(chargeSoc, chargePower); } /// diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index a8e0366..0cf0fe0 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -18,7 +18,6 @@ using Service.Charger.Msg.Charger.Req; using Service.Charger.Msg.Charger.Resp; using Service.Charger.Msg.Host.Req; using Service.Charger.Msg.Host.Req.Bms; -using Service.Init; namespace Service.Charger.Client; @@ -481,7 +480,7 @@ public class ChargerClient : TcpClient /// /// /// - public Result StartCharge() + public Result StartCharge(byte chargeSoc, float chargePower) { if (string.IsNullOrWhiteSpace(BinNo)) { @@ -505,7 +504,12 @@ public class ChargerClient : TcpClient return Result.Fail($"charger-{BinNo} battery not exist"); } - if (binInfo.CanChargeFlag == 0) + if (binInfo.AmtLock == 1) + { + return Result.Fail($"仓-{BinNo} 被锁定"); + } + + if (binInfo.CanChargeFlag == 0) { return Result.Fail($"仓-{BinNo} 被禁用"); } @@ -520,8 +524,6 @@ public class ChargerClient : TcpClient redisHelper.SetKeyValueStr($"chargeNo{BinNo}Start", DateTime.Now.ToString("f"), TimeSpan.FromMinutes(1)); - byte chargeSoc = StaticStationInfo.ChargeSoc; - float chargePower = StaticStationInfo.ChargePower; Result chargeOrderNo = SendRemoteStartCharging(chargeSoc, chargePower); if (!chargeOrderNo.IsSuccess) { diff --git a/Service/Charger/MyTask/AutoChargeTask.cs b/Service/Charger/MyTask/AutoChargeTask.cs index 77dd525..b43004e 100644 --- a/Service/Charger/MyTask/AutoChargeTask.cs +++ b/Service/Charger/MyTask/AutoChargeTask.cs @@ -153,8 +153,8 @@ public class AutoChargeTask : ITask int number = 0; foreach (var binInfo in canChargeList) { - Result? result = ClientMgr.GetBySn(binInfo.ChargerNo) - ?.SendRemoteStartCharging(chargeSoc, chargePower); + Result? result = ClientMgr.GetBySn(binInfo.ChargerNo) + ?.StartCharge(chargeSoc, chargePower); if (result is { IsSuccess: true }) { Log.Info($"auto start charge {binInfo.ChargerNo}");