充电策略增加日志

master
wyy 5 months ago
parent db87fadf1d
commit 7bf09a907b

@ -1,11 +1,11 @@
using Common.Const; using Common.Const;
using Entity.DbModel.Station; using Entity.DbModel.Station;
using Entity.DbModel.System;
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Utils; using HybirdFrameworkCore.Utils;
using log4net; using log4net;
using Newtonsoft.Json;
using Repository.Station; using Repository.Station;
using Service.Charger.Client; using Service.Charger.Client;
using Service.Init; using Service.Init;
@ -151,32 +151,31 @@ public class AutoChargeTask : ITask
}*/ }*/
List<BinInfo> chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList(); List<BinInfo> chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList();
Log.Info(
$"chargingList={JsonConvert.SerializeObject(chargingList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
if (canSwapList.Count >= needBatteryCount) if (canSwapList.Count >= needBatteryCount)
{ {
int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount); Log.Info($"can swap count {canSwapList.Count} > {needBatteryCount}, all stop={JsonConvert.SerializeObject(chargingList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
//if (needStopCount > 0) foreach (var t in chargingList)
if (chargingList.Count > 0)
{ {
//停电量低的 Log.Info($"auto stop charge {t.No}");
chargingList.Sort((a, b) => (a.Soc ?? 0).CompareTo(b.Soc ?? 0)); ClientMgr.GetBySn(t.No)?.SendRemoteStopCharging();
for (int i = 0; i < chargingList.Count; i++)
{
Log.Info($"auto stop charge {chargingList[i].No}");
ClientMgr.GetBySn(chargingList[i].No)?.SendRemoteStopCharging();
}
} }
} }
else else
{ {
List<BinInfo> canChargeList = binInfos.Where(it => List<BinInfo> canChargeList = binInfos.Where(it =>
it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.ChargeSoc && it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc &&
it.CanChargeFlag == 1 && it.Exists == 1) it.CanChargeFlag == 1 && it.Exists == 1)
.ToList(); .ToList();
//启动电量高的 //启动电量高的
canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0)); canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0));
byte chargeSoc = StaticStationInfo.ChargeSoc; byte chargeSoc = StaticStationInfo.ChargeSoc;
int count = needBatteryCount - canSwapList.Count; int count = needBatteryCount - canSwapList.Count;
Log.Info(
$"need start count={count}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
int number = 0; int number = 0;
foreach (var binInfo in canChargeList) foreach (var binInfo in canChargeList)
{ {
@ -204,13 +203,13 @@ public class AutoChargeTask : ITask
#region 达到充电SOC自动停 #region 达到充电SOC自动停
foreach (var VARIABLE in chargingList) List<BinInfo> stopList = chargingList.Where(it => it.Soc > StaticStationInfo.ChargeSoc).ToList();
Log.Info(
$"need stop count={stopList.Count}, stopList={JsonConvert.SerializeObject(stopList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
foreach (var binInfo in stopList)
{ {
if (VARIABLE.Soc >= (StaticStationInfo.ChargeSoc + 1)) Log.Info($"auto stop charge {binInfo.No} soc:{binInfo.Soc}");
{ ClientMgr.GetBySn(binInfo.No)?.SendRemoteStopCharging();
Log.Info($"auto stop charge {VARIABLE.No} soc>=chaegeSoc+1 soc:{VARIABLE.Soc}");
ClientMgr.GetBySn(VARIABLE.No)?.SendRemoteStopCharging();
}
} }
#endregion #endregion

Loading…
Cancel
Save