From f20824dd2dfbb9b8436b1ff91812ceb2ed3cbd53 Mon Sep 17 00:00:00 2001 From: tq <1916474859@qq,com> Date: Thu, 20 Jun 2024 17:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E5=A4=96=E5=B8=A7=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Cloud/Client/CloudClient.cs | 21 +++ Service/Cloud/Common/CloudConst.cs | 8 + .../OutCharger/PileStartChargeHandler.cs | 2 +- .../OutCharger/PileStopChargeHandler.cs | 2 +- .../Req/OutCharger/Req/PileStartCharge.cs | 2 +- .../Req/OutCharger/Req/PileStopCharge.cs | 3 +- .../Resp/OutCharger/PileEndChargeResp.cs | 30 ++++ .../Host/Req/OutCharger/PileChargeRealtime.cs | 160 ++++++++++++++++++ .../Msg/Host/Req/OutCharger/PileEndCharge.cs | 103 +++++++++++ .../Resp/OutCharger/PileChargeRealtimeResp.cs | 25 +++ Service/Execute/Api/CloudApi.cs | 21 +++ .../Controllers/OutChargerController.cs | 29 ++++ 12 files changed, 402 insertions(+), 4 deletions(-) create mode 100644 Service/Cloud/Msg/Cloud/Resp/OutCharger/PileEndChargeResp.cs create mode 100644 Service/Cloud/Msg/Host/Req/OutCharger/PileChargeRealtime.cs create mode 100644 Service/Cloud/Msg/Host/Req/OutCharger/PileEndCharge.cs create mode 100644 Service/Cloud/Msg/Host/Resp/OutCharger/PileChargeRealtimeResp.cs diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs index 21d2c56..da49f64 100644 --- a/Service/Cloud/Client/CloudClient.cs +++ b/Service/Cloud/Client/CloudClient.cs @@ -22,7 +22,10 @@ using Service.Cloud.Handler; using Service.Cloud.Msg; using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Cloud.Resp; +using Service.Cloud.Msg.Cloud.Resp.OutCharger; using Service.Cloud.Msg.Host.Req; +using Service.Cloud.Msg.Host.Req.OutCharger; +using Service.Cloud.Msg.Host.Resp.OutCharger; namespace Service.Cloud.Client; @@ -88,6 +91,10 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR public MsgPair VehicleData { get; set; } = new(); public MsgPair ChargeRecordUpLoad { get; set; } = new(); public MsgPair ChargeDevDataInfo { get; set; } = new(); + + public MsgPair PileEndCharge { get; set; } = new(); + + public MsgPair PileChargeRealtime { get; set; } = new(); #endregion @@ -506,6 +513,20 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR this.Publish(req); return ChargeDevDataInfo.GetResp(timeSpan); } + + public PileEndChargeResp? SendPileEndCharge(PileEndCharge req, TimeSpan? timeSpan = null) + { + this.PileEndCharge.Req = req; + this.Publish(req); + return PileEndCharge.GetResp(timeSpan); + } + + public PileChargeRealtimeResp? SendPileChargeRealtime(PileChargeRealtime req, TimeSpan? timeSpan = null) + { + this.PileChargeRealtime.Req = req; + this.Publish(req); + return PileChargeRealtime.GetResp(timeSpan); + } #endregion #region business func diff --git a/Service/Cloud/Common/CloudConst.cs b/Service/Cloud/Common/CloudConst.cs index 8a95053..016a6b9 100644 --- a/Service/Cloud/Common/CloudConst.cs +++ b/Service/Cloud/Common/CloudConst.cs @@ -65,8 +65,16 @@ public class CloudConst /// public static readonly string pileStartCharge = "pileStartCharge"; public static readonly string pileStartChargeRes = "pileStartChargeRes"; + public static readonly string pileStopCharge = "pileStopCharge"; public static readonly string pileRealtimeRes = "pileRealtimeRes"; + + public static readonly string pileEndCharge = "pileEndCharge"; + public static readonly string pileEndChargeRes = "pileEndChargeRes"; + + + public static readonly string pileChargeRealtime = "pileChargeRealtime"; + public static readonly string pileChargeRealtimeRes = "pileChargeRealtimeRes"; #endregion } \ No newline at end of file diff --git a/Service/Cloud/Handler/OutCharger/PileStartChargeHandler.cs b/Service/Cloud/Handler/OutCharger/PileStartChargeHandler.cs index 3c09d8c..eee497b 100644 --- a/Service/Cloud/Handler/OutCharger/PileStartChargeHandler.cs +++ b/Service/Cloud/Handler/OutCharger/PileStartChargeHandler.cs @@ -4,7 +4,7 @@ using HybirdFrameworkCore.Autofac.Attribute; using NewLife.Remoting; using Newtonsoft.Json; using Service.Cloud.Common; -using Service.Cloud.Msg.Cloud.OutCharger.Req; +using Service.Cloud.Msg.Cloud.Req.OutCharger.Req; namespace Service.Cloud.Handler.OutCharger; diff --git a/Service/Cloud/Handler/OutCharger/PileStopChargeHandler.cs b/Service/Cloud/Handler/OutCharger/PileStopChargeHandler.cs index 03030ae..5e81cc8 100644 --- a/Service/Cloud/Handler/OutCharger/PileStopChargeHandler.cs +++ b/Service/Cloud/Handler/OutCharger/PileStopChargeHandler.cs @@ -3,7 +3,7 @@ using Common.Util; using HybirdFrameworkCore.Autofac.Attribute; using Newtonsoft.Json; using Service.Cloud.Common; -using Service.Cloud.Msg.Cloud.OutCharger.Req; +using Service.Cloud.Msg.Cloud.Req.OutCharger.Req; namespace Service.Cloud.Handler.OutCharger; diff --git a/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStartCharge.cs b/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStartCharge.cs index ac77b08..88bfca9 100644 --- a/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStartCharge.cs +++ b/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStartCharge.cs @@ -1,6 +1,6 @@ using Service.Cloud.Common; -namespace Service.Cloud.Msg.Cloud.OutCharger.Req; +namespace Service.Cloud.Msg.Cloud.Req.OutCharger.Req; /// /// 9.2.1.1 云平台下发开始充电操作 diff --git a/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStopCharge.cs b/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStopCharge.cs index bdb589f..6b49cff 100644 --- a/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStopCharge.cs +++ b/Service/Cloud/Msg/Cloud/Req/OutCharger/Req/PileStopCharge.cs @@ -1,6 +1,7 @@ using Service.Cloud.Common; -namespace Service.Cloud.Msg.Cloud.OutCharger.Req; +namespace Service.Cloud.Msg.Cloud.Req.OutCharger.Req; + /// /// 9.2.17 云端下发充电枪停止充电 diff --git a/Service/Cloud/Msg/Cloud/Resp/OutCharger/PileEndChargeResp.cs b/Service/Cloud/Msg/Cloud/Resp/OutCharger/PileEndChargeResp.cs new file mode 100644 index 0000000..3890629 --- /dev/null +++ b/Service/Cloud/Msg/Cloud/Resp/OutCharger/PileEndChargeResp.cs @@ -0,0 +1,30 @@ +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Cloud.Resp.OutCharger; + +/// +/// 9.2.1.4 云端响应充电枪充电结束事件 +/// +public class PileEndChargeResp : ICmd +{ + /// + /// 应答结果 + /// 1:成功 2:失败 + /// + public string re { get; set; } + + /// + /// 故障码 + /// + public string ec { get; set; } + + /// + /// 充电枪编码 + /// + public string pn { get; set; } + + public string GetCmd() + { + return CloudConst.pileEndChargeRes; + } +} \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/OutCharger/PileChargeRealtime.cs b/Service/Cloud/Msg/Host/Req/OutCharger/PileChargeRealtime.cs new file mode 100644 index 0000000..730d4a5 --- /dev/null +++ b/Service/Cloud/Msg/Host/Req/OutCharger/PileChargeRealtime.cs @@ -0,0 +1,160 @@ +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req.OutCharger; + +/// +/// 9.2.1.7 站控上报充电枪充电遥测数据 +/// +public class PileChargeRealtime : ICmd +{ + /// + /// 换电站编码 + /// + public string sn { get; set; } + + /// + /// 充电订单号 + /// 云平台下发的充电订单编号,;当启动模式为本地主动启动(即插即充)时,该 值以 0 填充 + /// + public string con { get; set; } + + /// + /// 充电流水号 + /// 充电记录唯一编码 + /// + public string cosn { get; set; } + + /// + /// Desc:充电枪编号 + /// Default: + /// Nullable:True + /// + public string? pn { get; set; } + + /// + /// 需求电压 + /// + public float rv { get; set; } + + /// + /// 需求电流 + /// + public float re { get; set; } + + + /// + /// 充电模式 01H:恒压充电、02H恒流充电 + /// + public int cm { get; set; } + + /// + /// 充电电压测量值 + /// + public float cdv { get; set; } + + /// + /// 充电电流测量值 + /// + public float cde { get; set; } + + /// + /// 当前荷电状态 S0C (%) + /// + public float soc { get; set; } + + /// + /// 估算剩余充电时间 + /// + public int tr { get; set; } + + /// + /// 电桩电压输岀值 + /// + public float pov { get; set; } + + /// + /// 电桩电流输岀值 + /// + public float poe { get; set; } + + /// + /// 累计充电时间 + /// + public int tct { get; set; } + + /// + /// 最高单体动力 蓄电池电压所 在编号 + /// + public int? hbvn { get; set; } + + /// + /// 最高单体动力 蓄电池电压 + /// + public float? hbv { get; set; } + + /// + /// 最高温度检测 点编号 + /// + public int hbtn { get; set; } + + /// + /// 最高动力蓄电池温度 + /// + public int hbt { get; set; } + + /// + /// 最低单体动力 蓄电池电压所在编号 + /// + public int lbvn { get; set; } + + /// + /// 最低单体动力蓄电池电压 + /// + public float lbv { get; set; } + + /// + /// 最低动力蓄电池温度检测点 编号 + /// + public int lbtn { get; set; } + + /// + /// 最低动力蓄电 池温度 + /// + public int lbt { get; set; } + + /// + /// 单体动力蓄电 池电压过高 / 过低告警 + /// + public int hlbva { get; set; } + + /// + /// 整车动力蓄电 池荷电状态 S0C 过高/过低 告警 + /// + public int hlbsa { get; set; } + + /// + /// 动力蓄电池充电过流告警 + /// + public int baa { get; set; } + + /// + /// 动力蓄电池温度过高告警 + /// + public int bta { get; set; } + + /// + /// 动力蓄电池绝缘状态告警 + /// + public int bia { get; set; } + + /// + /// 动力蓄电池组 输岀连接器连 接状态告警 + /// + public int bca { get; set; } + + + public string GetCmd() + { + return CloudConst.pileChargeRealtime; + } +} \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Req/OutCharger/PileEndCharge.cs b/Service/Cloud/Msg/Host/Req/OutCharger/PileEndCharge.cs new file mode 100644 index 0000000..03f842e --- /dev/null +++ b/Service/Cloud/Msg/Host/Req/OutCharger/PileEndCharge.cs @@ -0,0 +1,103 @@ +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Req.OutCharger; + +/// +/// 9.2.1.3 站控上报充电枪充电结束事件 +/// +public class PileEndCharge : ICmd +{ + /// + /// 换电站编码 + /// + public string sn { get; set; } + + + /// + /// 充电订单号 + /// 云平台下发的充电订单编号,;当启动模式为本地主动启动(即插即充)时,该 值以 0 填充 + /// + public string con { get; set; } + + + /// + /// 充电流水号 + /// 充电记录唯一编码 + /// + public string cosn { get; set; } + + /// + /// Desc:充电枪编号 + /// Default: + /// Nullable:True + /// + public string? pn { get; set; } + + /// + /// 充电方式 + /// 0:自动(充满为止); 1:按电量; 2:按时间; 3:按金额; + /// + public int ct { get; set; } + + /// + /// 充电参数 + /// 按充电方式判断,除0外 电量:单位 kWh,精确到 0.01 时间:单位 min,精确到 0.01 金额:单位 元,精确到 0.01 + /// + public string cp { get; set; } + + /// + /// 启动类型 + /// 0:运营平台启动;1:APP 启动;2: 本地启动 + /// + public int st { get; set; } + + /// + /// 本次充电订单的开始时间 格式 yyyy-MM-dd HH:mm:ss + /// + public DateTime cst { get; set; } + + /// + /// 本次充电订单的开始时间 格式 yyyy-MM-dd HH:mm:ss + /// + public DateTime? cet { get; set; } + + /// + /// 充电电量 + /// 至少保留两位有效小数 + /// + public float ceq { get; set; } + + /// + /// Desc:充电开始soc + /// Default: + /// Nullable:True + /// + public int? cssoc { get; set; } + + /// + /// Desc:充电结束soc + /// Default: + /// Nullable:True + /// + public int? cesoc { get; set; } + + /// + /// 计费时间段个数 + /// + public int? ctn { get; set; } + + /// + /// 计费时间段列表 + /// + public List ctl { get; set; } + + /// + /// 充电车辆车架号 + /// + public string cvin { get; set; } + + public string GetCmd() + { + return CloudConst.pileEndCharge; + } +} \ No newline at end of file diff --git a/Service/Cloud/Msg/Host/Resp/OutCharger/PileChargeRealtimeResp.cs b/Service/Cloud/Msg/Host/Resp/OutCharger/PileChargeRealtimeResp.cs new file mode 100644 index 0000000..e34d8f4 --- /dev/null +++ b/Service/Cloud/Msg/Host/Resp/OutCharger/PileChargeRealtimeResp.cs @@ -0,0 +1,25 @@ +using Service.Cloud.Common; + +namespace Service.Cloud.Msg.Host.Resp.OutCharger; + +/// +/// 9.2.1.6 云端响应充电枪充电遥测数据 +/// +public class PileChargeRealtimeResp : ICmd +{ + /// + /// 执行结果 + /// + public string rs { get; set; } + + + /// + /// 充电枪编号 + /// + public string pn { get; set; } + + public string GetCmd() + { + return CloudConst.pileRealtimeRes; + } +} \ No newline at end of file diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs index 3719a1d..6965135 100644 --- a/Service/Execute/Api/CloudApi.cs +++ b/Service/Execute/Api/CloudApi.cs @@ -6,6 +6,7 @@ using Service.Cloud.Client; using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Cloud.Resp; using Service.Cloud.Msg.Host.Req; +using Service.Cloud.Msg.Host.Req.OutCharger; using Service.Execute.Model; using Service.Execute.Model.Tbox; using Service.Init; @@ -153,4 +154,24 @@ public abstract class CloudApi CloudClientMgr.CloudClient.CarCanStart = null; return true; } + + /// + /// 9.2.1.3 站控上报充电枪充电结束事件 + /// + /// + public static void SendPileEndCharge(PileEndCharge req) + { + CloudClientMgr.CloudClient?.SendPileEndCharge(req, + global::System.TimeSpan.FromSeconds(TimeSpan)); + } + + /// + /// 9.2.1.7 站控上报充电枪充电遥测数据 + /// + /// + public static void SendPileChargeRealtime(PileChargeRealtime req) + { + CloudClientMgr.CloudClient?.SendPileChargeRealtime(req, + global::System.TimeSpan.FromSeconds(TimeSpan)); + } } \ No newline at end of file diff --git a/WebStarter/Controllers/OutChargerController.cs b/WebStarter/Controllers/OutChargerController.cs index 3857444..347f2d8 100644 --- a/WebStarter/Controllers/OutChargerController.cs +++ b/WebStarter/Controllers/OutChargerController.cs @@ -1,7 +1,9 @@ using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Service.Cloud.Client; +using Service.Cloud.Msg.Host.Req.OutCharger; using Service.Cloud.Msg.Host.Resp.OutCharger; +using Service.Execute.Api; using Service.Init; namespace WebStarter.Controllers; @@ -39,4 +41,31 @@ public class OutChargerController CloudClientMgr.CloudClient?.Publish(req); return Result.Success(true); } + + /// + /// 9.2.1.3 站控上报充电枪充电结束事件 + /// + /// + /// + [HttpPost] + [Route("SendPileEndCharge")] + public Result SendPileEndCharge([FromBody] PileEndCharge req) + { + CloudApi.SendPileEndCharge(req); + + return Result.Success(true); + } + /// + /// 9.2.1.7 站控上报充电枪充电遥测数据 + /// + /// + /// + [HttpPost] + [Route("SendPileChargeRealtime")] + public Result SendPileChargeRealtime([FromBody] PileChargeRealtime req) + { + CloudApi.SendPileChargeRealtime(req); + + return Result.Success(true); + } } \ No newline at end of file