diff --git a/Entity/DbModel/Station/EquipInfo.cs b/Entity/DbModel/Station/EquipInfo.cs
index bbb0dd5..28aa8e0 100644
--- a/Entity/DbModel/Station/EquipInfo.cs
+++ b/Entity/DbModel/Station/EquipInfo.cs
@@ -64,5 +64,11 @@ namespace Entity.DbModel.Station
///
[SugarColumn(ColumnName="auto_charge")]
public int? AutoCharge {get;set;}
+
+ ///
+ /// 充电功率
+ ///
+ [SugarColumn(ColumnName="charge_power")]
+ public float? ChargePower { get; set; }
}
}
diff --git a/Repository/Station/EquipInfoRepository.cs b/Repository/Station/EquipInfoRepository.cs
index d37390e..4e7f73d 100644
--- a/Repository/Station/EquipInfoRepository.cs
+++ b/Repository/Station/EquipInfoRepository.cs
@@ -30,6 +30,20 @@ public class EquipInfoRepository: BaseRepository
.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;
+
+ }
}
\ No newline at end of file
diff --git a/Service/Charger/ChargerService.cs b/Service/Charger/ChargerService.cs
index b6be198..6512f24 100644
--- a/Service/Charger/ChargerService.cs
+++ b/Service/Charger/ChargerService.cs
@@ -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; }
///
@@ -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);
}
///
@@ -77,6 +81,7 @@ public class ChargerService
return Result.Success(true, "发送停止命令成功");
}
+
///
/// 下发尖峰平谷
///
@@ -84,7 +89,7 @@ public class ChargerService
///
public Result DistributeElecPriceForCharge(int version)
{
- ConcurrentDictionary chargerClients = ClientMgr.Dictionary;
+ ConcurrentDictionary chargerClients = ClientMgr.Dictionary;
if (chargerClients.Values.Count <= 0)
{
return Result.Fail();
@@ -92,7 +97,6 @@ public class ChargerService
foreach (var chargerClientsValue in chargerClients.Values)
{
-
if (chargerClientsValue.Connected)
{
chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version));
@@ -105,10 +109,11 @@ public class ChargerService
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
{
List 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),
+ NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour),
StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour),
StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour),
@@ -145,14 +150,16 @@ public class ChargerService
{
BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp();
List binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1);
- if(binInfos.Count>0)
+ if (binInfos.Count > 0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count();
- List canSwapCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc));
- if(canSwapCounts.Count>0)
+ List 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 chargingCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.ChargeStatus==1);
- if(chargingCounts.Count>0)
+ List chargingCounts =
+ BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1 && i.ChargeStatus == 1);
+ if (chargingCounts.Count > 0)
batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result.Success(batteryStatusInfoResp);
}
-}
+}
\ No newline at end of file
diff --git a/Service/Charger/MyTask/AutoChargeTask.cs b/Service/Charger/MyTask/AutoChargeTask.cs
index b43004e..7f2fc5d 100644
--- a/Service/Charger/MyTask/AutoChargeTask.cs
+++ b/Service/Charger/MyTask/AutoChargeTask.cs
@@ -48,8 +48,10 @@ public class AutoChargeTask : ITask
return;
}
- List chargerList = EquipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
- HashSet autoChargeSet = chargerList.Where(it => it.AutoCharge == 1).Select(it => it.Code).ToHashSet();
+ List chargerList =
+ EquipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
+ HashSet 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? result = ClientMgr.GetBySn(binInfo.ChargerNo)
- ?.StartCharge(chargeSoc, chargePower);
+ ?.StartCharge(chargeSoc, (float)power);
if (result is { IsSuccess: true })
{
Log.Info($"auto start charge {binInfo.ChargerNo}");
@@ -191,4 +194,4 @@ public class AutoChargeTask : ITask
{
_stop = false;
}
-}
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/ChargeController.cs b/WebStarter/Controllers/ChargeController.cs
index 815e373..ef2c22a 100644
--- a/WebStarter/Controllers/ChargeController.cs
+++ b/WebStarter/Controllers/ChargeController.cs
@@ -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;
}
///
@@ -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.Success(true);
}