|
|
@ -166,14 +166,6 @@ public static class ClientMgr
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var chargeSoc = StaticStationInfo.ChargeSoc;
|
|
|
|
|
|
|
|
List<BinInfo> socNeedChargeList = binInfos.Where(t => t.Soc < chargeSoc).ToList();
|
|
|
|
|
|
|
|
if (socNeedChargeList.Count < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"lack of binInfos.soc < {chargeSoc}");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 电价模型
|
|
|
|
#region 电价模型
|
|
|
|
|
|
|
|
|
|
|
@ -222,27 +214,57 @@ public static class ClientMgr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int needBatteryCount = opModelDetails[0].BatteryCount ?? 8;
|
|
|
|
int needBatteryCount = opModelDetails[0].BatteryCount ?? 8;
|
|
|
|
if ((binInfos.Count - socNeedChargeList.Count) >= needBatteryCount)
|
|
|
|
List<BinInfo> canSwapList = binInfos.Where(it => it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc).ToList();
|
|
|
|
|
|
|
|
if (canSwapList.Count == needBatteryCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"lack of needBatteryCount {needBatteryCount}");
|
|
|
|
Log.Info($"lack of needBatteryCount {needBatteryCount}");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(canSwapList.Count > needBatteryCount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<BinInfo> chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount);
|
|
|
|
|
|
|
|
if (needStopCount > 0)
|
|
|
|
|
|
|
|
|
|
|
|
foreach (BinInfo binInfo in socNeedChargeList)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Dictionary.TryGetValue(binInfo.ChargerNo, out var client))
|
|
|
|
chargingList.Sort((a,b) => (a.Soc??0).CompareTo(b.Soc??0));
|
|
|
|
|
|
|
|
for (int i = 0; i < needStopCount; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Result<bool> result = client.StartCharge();
|
|
|
|
Log.Info($"auto stop charge {chargingList[i].No}");
|
|
|
|
Log.Info($"start {binInfo.ChargerNo} charge {result.IsSuccess}:{result.Msg}");
|
|
|
|
GetBySn(chargingList[i].No)?.SendRemoteStopCharging();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"can not find {binInfo.ChargerNo} in dict");
|
|
|
|
List<BinInfo> canChargeList = binInfos.Where(it => it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc && it.CanChargeFlag == 1).ToList();
|
|
|
|
|
|
|
|
canChargeList.Sort((a,b) => (b.Soc??0).CompareTo(a.Soc??0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte chargeSoc = StaticStationInfo.ChargeSoc;
|
|
|
|
|
|
|
|
float chargePower = StaticStationInfo.ChargePower;
|
|
|
|
|
|
|
|
int count = needBatteryCount - canSwapList.Count;
|
|
|
|
|
|
|
|
int number = 0;
|
|
|
|
|
|
|
|
foreach (var binInfo in canChargeList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Result<string>? result = GetBySn(binInfo.ChargerNo)?.SendRemoteStartCharging(chargeSoc, chargePower);
|
|
|
|
|
|
|
|
if (result is {IsSuccess: true} )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"auto start charge {binInfo.ChargerNo}");
|
|
|
|
|
|
|
|
number++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == number)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"auto start charge count {count}");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|