|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
using Common.Const;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.DbModel.System;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using HybirdFrameworkCore.AutoTask;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Charger.Client;
|
|
|
|
|
using Service.Init;
|
|
|
|
@ -151,32 +151,31 @@ public class AutoChargeTask : ITask
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount);
|
|
|
|
|
//if (needStopCount > 0)
|
|
|
|
|
if (chargingList.Count > 0)
|
|
|
|
|
Log.Info($"can swap count {canSwapList.Count} > {needBatteryCount}, all stop={JsonConvert.SerializeObject(chargingList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
|
|
|
|
|
foreach (var t in chargingList)
|
|
|
|
|
{
|
|
|
|
|
//停电量低的
|
|
|
|
|
chargingList.Sort((a, b) => (a.Soc ?? 0).CompareTo(b.Soc ?? 0));
|
|
|
|
|
for (int i = 0; i < chargingList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"auto stop charge {chargingList[i].No}");
|
|
|
|
|
ClientMgr.GetBySn(chargingList[i].No)?.SendRemoteStopCharging();
|
|
|
|
|
}
|
|
|
|
|
Log.Info($"auto stop charge {t.No}");
|
|
|
|
|
ClientMgr.GetBySn(t.No)?.SendRemoteStopCharging();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
.ToList();
|
|
|
|
|
//启动电量高的
|
|
|
|
|
canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte chargeSoc = StaticStationInfo.ChargeSoc;
|
|
|
|
|
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;
|
|
|
|
|
foreach (var binInfo in canChargeList)
|
|
|
|
|
{
|
|
|
|
@ -204,13 +203,13 @@ public class AutoChargeTask : ITask
|
|
|
|
|
|
|
|
|
|
#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 {VARIABLE.No} soc>=chaegeSoc+1 soc:{VARIABLE.Soc}");
|
|
|
|
|
ClientMgr.GetBySn(VARIABLE.No)?.SendRemoteStopCharging();
|
|
|
|
|
}
|
|
|
|
|
Log.Info($"auto stop charge {binInfo.No} soc:{binInfo.Soc}");
|
|
|
|
|
ClientMgr.GetBySn(binInfo.No)?.SendRemoteStopCharging();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|