From 897aeaae45305f76195bc093880cb4b438f70e3d Mon Sep 17 00:00:00 2001 From: lxw Date: Tue, 29 Oct 2024 09:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8=E5=85=85?= =?UTF-8?q?=E7=94=B5=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Charger/MyTask/AutoChargeTask.cs | 51 ++++++++++++------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/Service/Charger/MyTask/AutoChargeTask.cs b/Service/Charger/MyTask/AutoChargeTask.cs index 035eab6..029ea15 100644 --- a/Service/Charger/MyTask/AutoChargeTask.cs +++ b/Service/Charger/MyTask/AutoChargeTask.cs @@ -32,7 +32,7 @@ public class AutoChargeTask : ITask public int Interval() { - return 1000 * 10; + return 1000 * 15; } public void Handle() @@ -142,7 +142,7 @@ public class AutoChargeTask : ITask int needBatteryCount = opModelDetails[0].BatteryCount ?? 8; List canSwapList = allBinInfos.Where(it => - it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1) + it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1 && it.ChargeStatus!=1) .ToList(); /*if (canSwapList.Count == needBatteryCount) { @@ -171,25 +171,27 @@ public class AutoChargeTask : ITask }*/ #endregion - + int stopCount = chargingList.Count + canSwapList.Count - needBatteryCount; + Log.Info($"chargingList.Count={chargingList.Count}, canSwapList.Count={canSwapList.Count},needBatteryCount={needBatteryCount}"); + Log.Info($"stopCount={stopCount}"); if (canSwapList.Count < needBatteryCount) { - int stopCount = chargingList.Count + canSwapList.Count - needBatteryCount; + if (stopCount < 0) { - Log.Info($"stopCount={stopCount}"); + // Log.Info($"stopCount={stopCount}"); List canChargeList = binInfos.Where(it => it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc && it.CanChargeFlag == 1 && it.Exists == 1 && it.ChargeStatus != 1) .ToList(); //启动电量高的 canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0)); - stopCount = Math.Abs(stopCount); + byte chargeSoc = StaticStationInfo.ChargeSoc; // int count = needBatteryCount - canSwapList.Count; Log.Info( - $"need start count={stopCount}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}"); + $"need start count={-stopCount}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}"); int number = 0; foreach (var binInfo in canChargeList) { @@ -206,35 +208,32 @@ public class AutoChargeTask : ITask number++; } - if (stopCount == number) + if (-stopCount == number) { - Log.Info($"auto start charge count {stopCount}"); + Log.Info($"auto start charge count {-stopCount}"); break; } } } } - else + } + + if (stopCount > 0) + { + if (chargingList.Count > 0) { - Log.Info($"stopCount={stopCount}"); - if (stopCount > 0) + chargingList = chargingList.OrderByDescending(i => i.Soc).ToList(); + int count = 0; + foreach (var ch in chargingList) { - if (chargingList.Count > 0) + if (ch.Soc < StaticStationInfo.ChargeSoc) { - chargingList = chargingList.OrderByDescending(i => i.Soc).ToList(); - int count = 0; - foreach (var ch in chargingList) + Log.Info($"auto stop charge by more charging bin {ch.No} soc:{ch.Soc}"); + ClientMgr.GetBySn(ch.ChargerNo)?.SendRemoteStopCharging(); + count++; + if (count == stopCount) { - if (ch.Soc < StaticStationInfo.ChargeSoc) - { - Log.Info($"auto stop charge by more charging bin {ch.No} soc:{ch.Soc}"); - ClientMgr.GetBySn(ch.ChargerNo)?.SendRemoteStopCharging(); - count++; - if (count == stopCount) - { - break; - } - } + break; } } }