下发电价配置

master
lch 6 months ago
parent 5d4b6bb30c
commit e790eac75f

@ -0,0 +1,13 @@
namespace Entity.Dto.Req;
public class DistributeElecPriceReq
{
/// <summary>
/// 充电机号
/// </summary>
public string BinNo { get; set; }
/// <summary>
/// 电价模型详情:版本
/// </summary>
public int Version { get; set; }
}

@ -3,6 +3,8 @@ using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Host.Req;
using SqlSugar;
namespace Service.Charger;
@ -13,6 +15,7 @@ namespace Service.Charger;
public class ChargerService
{
public BinInfoRepository BinInfoRepository { get; set; }
public ElecPriceModelVersionDetailRepository ElecPriceModelVersionDetailRepository { get; set; }
/// <summary>
/// 启动充电
@ -69,4 +72,63 @@ public class ChargerService
return Result<bool>.Success("发送停止命令成功");
}
/// <summary>
/// 下发尖峰平谷
/// </summary>
/// <param name="binNo"></param>
/// <returns></returns>
public Result<bool> DistributeElecPriceForCharge(string binNo,int version)
{
Dictionary<string,ChargerClient> chargerClients = ClientMgr.Dictionary;
if (chargerClients.Values.Count <= 0)
{
return Result<bool>.Fail();
}
foreach (var chargerClientsValue in chargerClients.Values)
{
if (chargerClientsValue.Connected)
{
chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version));
}
}
return Result<bool>.Success();
}
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
{
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails =
ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version,u=>u.StartHour,OrderByType.Asc);
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{
NumberTime =Convert.ToByte( elecPriceModelVersionDetails.Count),
StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour),
StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour),
StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour),
StartHH4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartHour),
StartHH5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartHour),
StartHH6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartHour),
StartHH7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartHour),
StartHH8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartHour),
StartMM1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute),
StartMM2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute),
StartMM3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute),
StartMM4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute),
StartMM5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute),
StartMM6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute),
StartMM7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute),
StartMM8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute),
TimePeak1 = Convert.ToByte(elecPriceModelVersionDetails[0].Type),
TimePeak2 = Convert.ToByte(elecPriceModelVersionDetails[1].Type),
TimePeak3 = Convert.ToByte(elecPriceModelVersionDetails[2].Type),
TimePeak4 = Convert.ToByte(elecPriceModelVersionDetails[3].Type),
TimePeak5 = Convert.ToByte(elecPriceModelVersionDetails[4].Type),
TimePeak6 = Convert.ToByte(elecPriceModelVersionDetails[5].Type),
TimePeak7 = Convert.ToByte(elecPriceModelVersionDetails[6].Type),
TimePeak8 = Convert.ToByte(elecPriceModelVersionDetails[7].Type)
};
return setPeakValleyTime;
}
}

@ -1,5 +1,6 @@
using AutoMapper;
using Entity.DbModel.Station;
using Entity.Dto.Req;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
@ -103,4 +104,16 @@ public class ChargeController : ControllerBase
{
return _chargerService.StopChargeByBinNo(binNo);
}
/// <summary>
/// 下发电价配置
/// </summary>
/// <param name="version"></param>
[HttpGet]
[Route("DistributeElecPriceForCharge")]
public Result<bool> DistributeElecPriceForCharge([FromBody] DistributeElecPriceReq input )
{
return _chargerService.DistributeElecPriceForCharge(input.BinNo,input.Version);
}
}
Loading…
Cancel
Save