修改充电设置充电功率

master
lxw 5 months ago
parent 578b44897d
commit 163335b314

@ -64,5 +64,11 @@ namespace Entity.DbModel.Station
/// </summary> /// </summary>
[SugarColumn(ColumnName="auto_charge")] [SugarColumn(ColumnName="auto_charge")]
public int? AutoCharge {get;set;} 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) .OrderBuilder(input)
.WithNoLockOrNot(blUseNoLock) .WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber); .ToPageListAsync(pageNumber, pageSize, totalNumber);
return page; 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 class ChargerService
{ {
public BinInfoRepository BinInfoRepository { get; set; } public BinInfoRepository BinInfoRepository { get; set; }
public EquipInfoRepository EquipInfoRepository { get; set; }
public ElecPriceModelVersionDetailRepository ElecPriceModelVersionDetailRepository { get; set; } public ElecPriceModelVersionDetailRepository ElecPriceModelVersionDetailRepository { get; set; }
/// <summary> /// <summary>
@ -45,8 +47,10 @@ public class ChargerService
} }
byte chargeSoc = StaticStationInfo.ChargeSoc; 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> /// <summary>
@ -77,6 +81,7 @@ public class ChargerService
return Result<bool>.Success(true, "发送停止命令成功"); return Result<bool>.Success(true, "发送停止命令成功");
} }
/// <summary> /// <summary>
/// 下发尖峰平谷 /// 下发尖峰平谷
/// </summary> /// </summary>
@ -84,7 +89,7 @@ public class ChargerService
/// <returns></returns> /// <returns></returns>
public Result<bool> DistributeElecPriceForCharge(int version) public Result<bool> DistributeElecPriceForCharge(int version)
{ {
ConcurrentDictionary<string,ChargerClient> chargerClients = ClientMgr.Dictionary; ConcurrentDictionary<string, ChargerClient> chargerClients = ClientMgr.Dictionary;
if (chargerClients.Values.Count <= 0) if (chargerClients.Values.Count <= 0)
{ {
return Result<bool>.Fail(); return Result<bool>.Fail();
@ -92,7 +97,6 @@ public class ChargerService
foreach (var chargerClientsValue in chargerClients.Values) foreach (var chargerClientsValue in chargerClients.Values)
{ {
if (chargerClientsValue.Connected) if (chargerClientsValue.Connected)
{ {
chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version)); chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version));
@ -105,10 +109,11 @@ public class ChargerService
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version) public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
{ {
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = 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() SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{ {
NumberTime =Convert.ToByte( elecPriceModelVersionDetails.Count), NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour), StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour),
StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour), StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour),
StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour), StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour),
@ -145,13 +150,15 @@ public class ChargerService
{ {
BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp(); BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp();
List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1); List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1);
if(binInfos.Count>0) if (binInfos.Count > 0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count(); 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 =>
if(canSwapCounts.Count>0) i.Exists == 1 && i.Status == 1 && i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc));
if (canSwapCounts.Count > 0)
batteryStatusInfoResp.canSwapCount = canSwapCounts.Count(); batteryStatusInfoResp.canSwapCount = canSwapCounts.Count();
List<BinInfo> chargingCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.ChargeStatus==1); List<BinInfo> chargingCounts =
if(chargingCounts.Count>0) BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1 && i.ChargeStatus == 1);
if (chargingCounts.Count > 0)
batteryStatusInfoResp.chargingCount = chargingCounts.Count(); batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp); return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);
} }

@ -48,8 +48,10 @@ public class AutoChargeTask : ITask
return; return;
} }
List<EquipInfo> chargerList = EquipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger); List<EquipInfo> chargerList =
HashSet<string> autoChargeSet = chargerList.Where(it => it.AutoCharge == 1).Select(it => it.Code).ToHashSet(); 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(); 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)); canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0));
byte chargeSoc = StaticStationInfo.ChargeSoc; byte chargeSoc = StaticStationInfo.ChargeSoc;
float chargePower = StaticStationInfo.ChargePower;
int count = needBatteryCount - canSwapList.Count; int count = needBatteryCount - canSwapList.Count;
int number = 0; int number = 0;
foreach (var binInfo in canChargeList) 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) Result<bool>? result = ClientMgr.GetBySn(binInfo.ChargerNo)
?.StartCharge(chargeSoc, chargePower); ?.StartCharge(chargeSoc, (float)power);
if (result is { IsSuccess: true }) if (result is { IsSuccess: true })
{ {
Log.Info($"auto start charge {binInfo.ChargerNo}"); Log.Info($"auto start charge {binInfo.ChargerNo}");

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

Loading…
Cancel
Save