From e790eac75f363c961975b3fc810b286d98259745 Mon Sep 17 00:00:00 2001 From: lch <1627445470@qq.com> Date: Wed, 29 May 2024 21:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8F=91=E7=94=B5=E4=BB=B7=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Dto/Req/DistributeElecPriceReq.cs | 13 +++++ Service/Charger/ChargerService.cs | 62 ++++++++++++++++++++++ WebStarter/Controllers/ChargeController.cs | 13 +++++ 3 files changed, 88 insertions(+) create mode 100644 Entity/Dto/Req/DistributeElecPriceReq.cs diff --git a/Entity/Dto/Req/DistributeElecPriceReq.cs b/Entity/Dto/Req/DistributeElecPriceReq.cs new file mode 100644 index 0000000..ad72250 --- /dev/null +++ b/Entity/Dto/Req/DistributeElecPriceReq.cs @@ -0,0 +1,13 @@ +namespace Entity.Dto.Req; + +public class DistributeElecPriceReq +{ + /// + /// 充电机号 + /// + public string BinNo { get; set; } + /// + /// 电价模型详情:版本 + /// + public int Version { get; set; } +} \ No newline at end of file diff --git a/Service/Charger/ChargerService.cs b/Service/Charger/ChargerService.cs index 570e755..56ba458 100644 --- a/Service/Charger/ChargerService.cs +++ b/Service/Charger/ChargerService.cs @@ -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; } /// /// 启动充电 @@ -69,4 +72,63 @@ public class ChargerService return Result.Success("发送停止命令成功"); } + /// + /// 下发尖峰平谷 + /// + /// + /// + public Result DistributeElecPriceForCharge(string binNo,int version) + { + Dictionary chargerClients = ClientMgr.Dictionary; + if (chargerClients.Values.Count <= 0) + { + return Result.Fail(); + } + + foreach (var chargerClientsValue in chargerClients.Values) + { + + if (chargerClientsValue.Connected) + { + chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(version)); + } + } + + return Result.Success(); + } + + public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version) + { + List 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; + } } \ No newline at end of file diff --git a/WebStarter/Controllers/ChargeController.cs b/WebStarter/Controllers/ChargeController.cs index fb4a701..6a18ebb 100644 --- a/WebStarter/Controllers/ChargeController.cs +++ b/WebStarter/Controllers/ChargeController.cs @@ -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); } + + /// + /// 下发电价配置 + /// + /// + [HttpGet] + [Route("DistributeElecPriceForCharge")] + public Result DistributeElecPriceForCharge([FromBody] DistributeElecPriceReq input ) + { + return _chargerService.DistributeElecPriceForCharge(input.BinNo,input.Version); + } + } \ No newline at end of file