修改充电设置充电功率

master
lxw 5 months ago
parent 578b44897d
commit 163335b314

@ -64,5 +64,11 @@ namespace Entity.DbModel.Station
/// </summary>
[SugarColumn(ColumnName="auto_charge")]
public int? AutoCharge {get;set;}
/// <summary>
/// 充电功率
/// </summary>
[SugarColumn(ColumnName="charge_power")]
public float? ChargePower { get; set; }
}
}

@ -30,6 +30,20 @@ public class EquipInfoRepository: BaseRepository<EquipInfo>
.OrderBuilder(input)
.WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber);
return page;
}
public float? QueryPowerByCode(string code)
{
EquipInfo? queryByClause = QueryByClause(i => i.Code == code);
if (queryByClause==null || queryByClause.ChargePower == null)
{
return null;
}
return queryByClause.ChargePower;
}
}

@ -18,6 +18,8 @@ namespace Service.Charger;
public class ChargerService
{
public BinInfoRepository BinInfoRepository { get; set; }
public EquipInfoRepository EquipInfoRepository { get; set; }
public ElecPriceModelVersionDetailRepository ElecPriceModelVersionDetailRepository { get; set; }
/// <summary>
@ -45,8 +47,10 @@ public class ChargerService
}
byte chargeSoc = StaticStationInfo.ChargeSoc;
float chargePower = StaticStationInfo.ChargePower;
return chargerClient.StartCharge(chargeSoc, chargePower);
float? chargePower = EquipInfoRepository.QueryPowerByCode(binNo);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
return chargerClient.StartCharge(chargeSoc,(float)power);
}
/// <summary>
@ -77,6 +81,7 @@ public class ChargerService
return Result<bool>.Success(true, "发送停止命令成功");
}
/// <summary>
/// 下发尖峰平谷
/// </summary>
@ -92,7 +97,6 @@ public class ChargerService
foreach (var chargerClientsValue in chargerClients.Values)
{
if (chargerClientsValue.Connected)
{
chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version));
@ -105,7 +109,8 @@ public class ChargerService
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
{
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails =
ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version,u=>u.StartHour,OrderByType.Asc);
ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version, u => u.StartHour,
OrderByType.Asc);
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{
NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
@ -147,10 +152,12 @@ public class ChargerService
List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1);
if (binInfos.Count > 0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count();
List<BinInfo> canSwapCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc));
List<BinInfo> canSwapCounts = BinInfoRepository.QueryListByClause(i =>
i.Exists == 1 && i.Status == 1 && i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc));
if (canSwapCounts.Count > 0)
batteryStatusInfoResp.canSwapCount = canSwapCounts.Count();
List<BinInfo> chargingCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.ChargeStatus==1);
List<BinInfo> chargingCounts =
BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1 && i.ChargeStatus == 1);
if (chargingCounts.Count > 0)
batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);

@ -48,8 +48,10 @@ public class AutoChargeTask : ITask
return;
}
List<EquipInfo> chargerList = EquipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
HashSet<string> autoChargeSet = chargerList.Where(it => it.AutoCharge == 1).Select(it => it.Code).ToHashSet();
List<EquipInfo> chargerList =
EquipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
HashSet<string> autoChargeSet =
chargerList.Where(it => it.AutoCharge == 1).Select(it => it.Code).ToHashSet();
binInfos = binInfos.Where(it => autoChargeSet.Contains(it.ChargerNo)).ToList();
@ -148,13 +150,14 @@ public class AutoChargeTask : ITask
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)
{
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.Code);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
Result<bool>? result = ClientMgr.GetBySn(binInfo.ChargerNo)
?.StartCharge(chargeSoc, chargePower);
?.StartCharge(chargeSoc, (float)power);
if (result is { IsSuccess: true })
{
Log.Info($"auto start charge {binInfo.ChargerNo}");

@ -21,11 +21,13 @@ public class ChargeController : ControllerBase
{
private ChargerService _chargerService;
private BinInfoService _binInfoService;
private EquipInfoRepository _equipInfoRepository;
public ChargeController(ChargerService chargerService, BinInfoService binInfoService)
public ChargeController(ChargerService chargerService, BinInfoService binInfoService,EquipInfoRepository equipInfoRepository)
{
_chargerService = chargerService;
_binInfoService = binInfoService;
_equipInfoRepository = equipInfoRepository;
}
/// <summary>
@ -80,6 +82,8 @@ public class ChargeController : ControllerBase
if (chargerClient != null)
{
chargerClient.SendPowerRegulation(power);
_equipInfoRepository.Update(i => i.ChargePower == power, it => it.Code == code);
return Result<bool>.Success(true);
}

Loading…
Cancel
Save