云平台上报

master
smartwyy 6 months ago
parent 9e3109cbcf
commit 870de04782

@ -0,0 +1,47 @@
namespace HybirdFrameworkCore.Utils;
/// <summary>
///
/// </summary>
public static class ObjUtils
{
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNull(object? o)
{
return o == null;
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNotNull(object? o)
{
return o != null;
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNullOrWhiteSpace(string? o)
{
return string.IsNullOrWhiteSpace(o);
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNotNullOrWhiteSpace(string? o)
{
return !string.IsNullOrWhiteSpace(o);
}
}

@ -2,6 +2,7 @@
using Autofac; using Autofac;
using Autofac.Core; using Autofac.Core;
using Common.Util; using Common.Util;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.Common; using HybirdFrameworkDriver.Common;
@ -11,18 +12,17 @@ using MQTTnet.Client;
using MQTTnet.Client.Connecting; using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting; using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Options; using MQTTnet.Client.Options;
using MQTTnet.Client.Publishing;
using MQTTnet.Client.Receiving; using MQTTnet.Client.Receiving;
using MQTTnet.Formatter; using MQTTnet.Formatter;
using MQTTnet.Protocol; using MQTTnet.Protocol;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Repository.Station;
using Service.Cloud.Handler; using Service.Cloud.Handler;
using Service.Cloud.Msg; using Service.Cloud.Msg;
using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp; using Service.Cloud.Msg.Cloud.Resp;
using Service.Cloud.Msg.Host.Req; using Service.Cloud.Msg.Host.Req;
using Service.Init;
namespace Service.Cloud.Client; namespace Service.Cloud.Client;
@ -32,6 +32,8 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
{ {
private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClient)); private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClient));
public SwapOrderRepository SwapOrderRepository { get; set;}
#region tcp param #region tcp param
public string ServerIp { get; set; } public string ServerIp { get; set; }
@ -82,8 +84,10 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
public MsgPair<SignIn, SignInResp> Sign { get; set; } = new(); public MsgPair<SignIn, SignInResp> Sign { get; set; } = new();
public MsgPair<StartLogMessage, StartLogMessageResp> StartLog { get; set; } = new(); public MsgPair<StartLogMessage, StartLogMessageResp> StartLog { get; set; } = new();
public MsgPair<TemperatureHumidityData, TemperatureHumidityDataResp> TemperatureHumidity { get; set; } = new(); public MsgPair<TemperatureHumidityData, TemperatureHumidityDataResp> TemperatureHumidity { get; set; } = new();
public MsgPair<UploadPowerChangeOrder, UploadPowerChangeOrderResp> UploadPowerChange { get; set; } = new(); public MsgPair<UploadSwapOrder, UploadSwapOrderResp> UploadPowerChange { get; set; } = new();
public MsgPair<VehicleDataReporting, VehicleDataReportingResp> VehicleData { get; set; } = new(); public MsgPair<VehicleDataReporting, VehicleDataReportingResp> VehicleData { get; set; } = new();
public MsgPair<ChargeRecordUpLoad, ChargeRecordUploadRes> ChargeRecordUpLoad { get; set; } = new();
public MsgPair<ChargeDevDataInfo, ChargeDevDataInfoRes> ChargeDevDataInfo { get; set; } = new();
#endregion #endregion
@ -193,14 +197,23 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
{ {
await DoSubTopic(SubTopic); await DoSubTopic(SubTopic);
SendSignIn(new SignIn() SendVehicleCertification(new VehicleCertification()
{ {
sn = StaticStationInfo.StationNo, dt = DateTime.Now,
st = "01",
ss = StaticStationInfo.StationStatus,
en = 1, en = 1,
cn = 7 mode =1,
rfid= "LZ5NB6D33RB000438",
ty= 2,
vi ="LZ5NB6D33RB000438"
}); });
// SendSignIn(new SignIn()
// {
// sn = StaticStationInfo.StationNo,
// st = "01",
// ss = StaticStationInfo.StationStatus,
// en = 1,
// cn = 7
// });
} }
private async Task DoSubTopic(string topic) private async Task DoSubTopic(string topic)
@ -229,7 +242,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
Header = new Header() Header = new Header()
{ {
cmd = data.GetCmd(), cmd = data.GetCmd(),
chipherFlag = Encrypt, cipherFlag = Encrypt,
id = GetIncrementId(), id = GetIncrementId(),
sid = StationNo, sid = StationNo,
timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000 timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000
@ -237,7 +250,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
body = data body = data
}; };
model.dataSign = SignData(model); model.dataSign = "";//SignData(model);
var settings = new JsonSerializerSettings() var settings = new JsonSerializerSettings()
{ {
@ -245,6 +258,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
DateFormatString = "yyyy-MM-dd HH:mm:ss", DateFormatString = "yyyy-MM-dd HH:mm:ss",
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
}; };
Log.Info(JsonConvert.SerializeObject(model, settings));
var appMsg = new MqttApplicationMessage var appMsg = new MqttApplicationMessage
{ {
Topic = PubTopic, Topic = PubTopic,
@ -253,12 +267,8 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
Retain = false Retain = false
}; };
Task<MqttClientPublishResult> task = MqttClient.PublishAsync(appMsg); MqttClient.PublishAsync(appMsg);
var result = task.Result; MqttClient.PublishAsync(appMsg);
if (result.ReasonCode == MqttClientPublishReasonCode.Success)
{
Log.Info($"send {JsonConvert.SerializeObject(model, settings)} success");
}
} }
private string SignData<T>(Model<T> model) where T : ICmd private string SignData<T>(Model<T> model) where T : ICmd
@ -460,14 +470,13 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
/// <summary> /// <summary>
/// 上传换电订单 /// 上传换电订单
/// </summary> /// </summary>
/// <param name="uploadPowerChangeOrder"></param> /// <param name="uploadSwapOrder"></param>
/// <param name="timeSpan"></param> /// <param name="timeSpan"></param>
/// <returns></returns> /// <returns></returns>
public UploadPowerChangeOrderResp? SendUploadPowerChangeOrder(UploadPowerChangeOrder uploadPowerChangeOrder, public UploadSwapOrderResp? SendUploadPowerChangeOrder(UploadSwapOrder uploadSwapOrder, TimeSpan? timeSpan = null)
TimeSpan timeSpan)
{ {
this.UploadPowerChange.Req = uploadPowerChangeOrder; this.UploadPowerChange.Req = uploadSwapOrder;
this.Publish(uploadPowerChangeOrder); this.Publish(uploadSwapOrder);
return UploadPowerChange.GetResp(timeSpan); return UploadPowerChange.GetResp(timeSpan);
} }
public VehicleDataReportingResp? SendVehicleDataReporting(VehicleDataReporting vehicleDataReporting, public VehicleDataReportingResp? SendVehicleDataReporting(VehicleDataReporting vehicleDataReporting,
@ -477,5 +486,61 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
this.Publish(vehicleDataReporting); this.Publish(vehicleDataReporting);
return VehicleData.GetResp(timeSpan); return VehicleData.GetResp(timeSpan);
} }
public ChargeRecordUploadRes? SendChargeRecordUpLoad(ChargeRecordUpLoad req, TimeSpan? timeSpan = null)
{
this.ChargeRecordUpLoad.Req = req;
this.Publish(req);
return ChargeRecordUpLoad.GetResp(timeSpan);
}
public ChargeDevDataInfoRes? SendChargeDevDataInfo(ChargeDevDataInfo req, TimeSpan? timeSpan = null)
{
this.ChargeDevDataInfo.Req = req;
this.Publish(req);
return ChargeDevDataInfo.GetResp(timeSpan);
}
#endregion
#region business func
/// <summary>
///
/// </summary>
/// <param name="chargeOrder"></param>
/// <param name="op">1 自动; 2 人工手动</param>
/// <param name="timeSpan">超时等待</param>
/// <returns></returns>
public bool PublishChargeOrder(ChargeOrder chargeOrder, int op, TimeSpan? timeSpan = null)
{
string swapOrderSn = chargeOrder.SwapOrderSn;
SwapOrder? swapOrder = SwapOrderRepository.QueryByClause(it => it.Sn == swapOrderSn);
ChargeRecordUpLoad req = new ChargeRecordUpLoad()
{
chrsn = chargeOrder.Sn,
son = swapOrderSn,
bid = chargeOrder.BatteryNo,
st = chargeOrder.StartTime ?? DateTime.Now,
et = chargeOrder.EndTime ?? DateTime.Now,
ssoc = chargeOrder.StartSoc ?? 0,
esoc = chargeOrder.StopSoc ?? 0,
//ssoe = chargeOrder.soe
//esoe
dcce = Convert.ToSingle(chargeOrder.StopDcElec ?? 0 - chargeOrder.StartDcElec ?? 0),
acce = Convert.ToSingle(chargeOrder.StopAcElec ?? 0 - chargeOrder.StartAcElec ?? 0),
tp = Convert.ToSingle(chargeOrder.SharpElecCount),
pp = Convert.ToSingle(chargeOrder.PeakElecCount),
fp = Convert.ToSingle(chargeOrder.FlatElecCount),
vp = Convert.ToSingle(chargeOrder.ValleyElecCount),
ct = ((chargeOrder.EndTime ?? DateTime.Now).Subtract(chargeOrder.StartTime ?? DateTime.Now)).Minutes,
cn = 1,
sfs = op,
vin = swapOrder?.VehicleVin,
sfoc = op,
};
this.SendChargeRecordUpLoad(req);
return true;
}
#endregion #endregion
} }

@ -11,12 +11,7 @@ public class ChargeOrderUploadTask : AbstractTaskHandler
{ {
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargeOrderUploadTask)); private static readonly ILog Log = LogManager.GetLogger(typeof(ChargeOrderUploadTask));
private readonly ChargeOrderRepository _chargeOrderRepository; public ChargeOrderRepository _chargeOrderRepository { get; set; }
public ChargeOrderUploadTask(ChargeOrderRepository chargeOrderRepository)
{
_chargeOrderRepository = chargeOrderRepository;
}
protected override int Interval() protected override int Interval()
{ {
@ -25,15 +20,14 @@ public class ChargeOrderUploadTask : AbstractTaskHandler
protected override void Handle() protected override void Handle()
{ {
List<ChargeOrder>? chargeOrders = _chargeOrderRepository.QueryListByClause(it => it.CloudReportStatus != 1); List<ChargeOrder>? chargeOrders = _chargeOrderRepository.QueryListByClause(it => it.CloudReportStatus ==0);
Log.Info($"there are {chargeOrders?.Count ?? 0} to upload"); Log.Info($"there are {chargeOrders?.Count ?? 0} to upload");
if (chargeOrders is { Count: > 0 }) if (chargeOrders is { Count: > 0 })
{ {
foreach (ChargeOrder chargeOrder in chargeOrders) foreach (ChargeOrder chargeOrder in chargeOrders)
{ {
//TODO CloudClientMgr.CloudClient?.PublishChargeOrder(chargeOrder, 1);
//CloudClientMgr.CloudClient?.Publish();
} }
} }
} }

@ -41,6 +41,8 @@ public class CloudConst
public static readonly string amtBatRes = "amtBatRes"; public static readonly string amtBatRes = "amtBatRes";
public static readonly string ChargeRecordReport = "ChargeRecordReport"; public static readonly string ChargeRecordReport = "ChargeRecordReport";
public static readonly string ChargeRecordReportsRes = "ChargeRecordReportsRes"; public static readonly string ChargeRecordReportsRes = "ChargeRecordReportsRes";
public static readonly string ChargeRecordUpLoad = "ChargeRecordUpLoad";
public static readonly string ChargeRecordUpLoadRes = "ChargeRecordUpLoadRes";
public static readonly string stationRunStatus = "stationRunStatus"; public static readonly string stationRunStatus = "stationRunStatus";
public static readonly string stationRunStatusRes = "stationRunStatusRes"; public static readonly string stationRunStatusRes = "stationRunStatusRes";
public static readonly string stationChnRunStatus = "stationChnRunStatus"; public static readonly string stationChnRunStatus = "stationChnRunStatus";

@ -0,0 +1,32 @@
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Resp;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class ChargeDevDataInfoResHandler : IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargeDevDataInfoResHandler));
public void Handle(string t)
{
ChargeDevDataInfoRes? resp = JsonConvert.DeserializeObject<ChargeDevDataInfoRes>(t);
if (resp != null)
{
if (CloudClientMgr.CloudClient != null)
{
CloudClientMgr.CloudClient.ChargeDevDataInfo.SetResp(resp);
Log.Info($"receive ChargeDevDataInfoRes {JsonConvert.SerializeObject(resp)}");
}
}
}
public bool CanHandle(string cmd)
{
return CloudConst.chargeDevDataInfoRes == cmd;
}
}

@ -0,0 +1,40 @@
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Resp;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class ChargeRecordUploadResHandler : IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ChargeRecordUploadResHandler));
public ChargeOrderRepository ChargeOrderRepository { get; set; }
public void Handle(string t)
{
ChargeRecordUploadRes? res = JsonConvert.DeserializeObject<ChargeRecordUploadRes>(t);
if (res != null)
{
if (CloudClientMgr.CloudClient != null)
{
CloudClientMgr.CloudClient.ChargeRecordUpLoad.SetResp(res);
string? reqChrsn = CloudClientMgr.CloudClient.ChargeRecordUpLoad.Req?.chrsn;
Log.Info($"receive ChargeRecordUploadRes chargeOrderNo={reqChrsn} {JsonConvert.SerializeObject(res)}");
if (!string.IsNullOrWhiteSpace(reqChrsn) && res.re == 0)
{
ChargeOrderRepository.Update(it => it.CloudReportStatus == 1, it => it.Sn == reqChrsn);
}
}
}
}
public bool CanHandle(string cmd)
{
return CloudConst.ChargeRecordUpLoadRes == cmd;
}
}

@ -0,0 +1,39 @@
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Resp;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class UploadSwapOrderResHandler : IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UploadSwapOrderResHandler));
public SwapOrderRepository SwapOrderRepository { get; set; }
public void Handle(string t)
{
UploadSwapOrderResp? resp = JsonConvert.DeserializeObject<UploadSwapOrderResp>(t);
if (resp != null)
{
if (CloudClientMgr.CloudClient != null)
{
CloudClientMgr.CloudClient.UploadPowerChange.SetResp(resp);
string? reqSon = CloudClientMgr.CloudClient.UploadPowerChange.Req?.son;
Log.Info($"receive UploadSwapOrderRes swapOrderNo={reqSon} {JsonConvert.SerializeObject(resp)}");
if (!string.IsNullOrWhiteSpace(reqSon) && resp.re == 0)
{
SwapOrderRepository.Update(it => it.CloudReportStatus == 1, it => it.Sn == reqSon);
}
}
}
}
public bool CanHandle(string cmd)
{
return CloudConst.staSwapRecordRes == cmd;
}
}

@ -0,0 +1,13 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Cloud.Resp;
public class ChargeRecordUploadRes : ICmd
{
public int re { get; set; }
public string GetCmd()
{
return CloudConst.ChargeRecordUpLoadRes;
}
}

@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Cloud.Resp
/// <summary> /// <summary>
/// 4.2.1.2 后台服务器应答换电站上报的订单信息 /// 4.2.1.2 后台服务器应答换电站上报的订单信息
/// </summary> /// </summary>
public class UploadPowerChangeOrderResp : ICmd public class UploadSwapOrderResp : ICmd
{ {
/// <summary> /// <summary>
/// 应答结果 /// 应答结果

@ -17,7 +17,7 @@ public class Header
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int chipherFlag { get; set; } public int cipherFlag { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

@ -1,136 +1,160 @@
using Service.Cloud.Common; using Service.Cloud.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Cloud.Msg.Host.Req namespace Service.Cloud.Msg.Host.Req
{ {
/// <summary> /// <summary>
/// 4.2.10.1 换电站充电机数据上报 /// 4.2.10.1 换电站充电机数据上报
/// </summary> /// </summary>
public class ChargeDevDataInfo public class ChargeDevDataInfo : ICmd
{ {
/// <summary> /// <summary>
/// 场站编码 换电站唯一码 /// 场站编码 换电站唯一码
/// </summary> /// </summary>
public string sn { get; set; } public string sn { get; set; }
/// <summary> /// <summary>
/// 设备编号 设备编号 /// 设备编号 设备编号
/// </summary> /// </summary>
public string en { get; set; } public string en { get; set; }
/// <summary> /// <summary>
/// 充电架 ID 按电池架的编号 A1A2… /// 充电架 ID 按电池架的编号 A1A2…
/// </summary> /// </summary>
public string sd { get; set; } public string sd { get; set; }
/// <summary> /// <summary>
/// 充电机最大允许 输出功率 单位 0.1kw /// 充电机最大允许 输出功率 单位 0.1kw
/// </summary> /// </summary>
public float mtp { get; set; } public float mtp { get; set; }
/// <summary> /// <summary>
/// 充电机最大允 许充电速率 单位 0.1C /// 充电机最大允 许充电速率 单位 0.1C
/// </summary> /// </summary>
public float mcr { get; set; } public float mcr { get; set; }
/// <summary> /// <summary>
/// 电池架上是否有 电池 0未知 1有电池 2无电池 /// 电池架上是否有 电池 0未知 1有电池 2无电池
/// </summary> /// </summary>
public int hb { get; set; } public int hb { get; set; }
/// <summary> /// <summary>
/// 电接头连接状态 0未知 1已经连接 2未连接 /// 电接头连接状态 0未知 1已经连接 2未连接
/// </summary> /// </summary>
public int el { get; set; } public int el { get; set; }
/// <summary> /// <summary>
/// 充电机序号 从 1 开始递增 /// 充电机序号 从 1 开始递增
/// </summary> /// </summary>
public int cno { get; set; } public int cno { get; set; }
/// <summary> /// <summary>
/// 充电机的工作状态 00H待机 01H工作02H工作完成03H充电暂停 /// 充电机的工作状态 00H待机 01H工作02H工作完成03H充电暂停
/// </summary> /// </summary>
public int cs { get; set; } public int cs { get; set; }
/// <summary> /// <summary>
/// 故障状态 00H无故障 01H有故障 /// 故障状态 00H无故障 01H有故障
/// </summary> /// </summary>
public int fs { get; set; } public int fs { get; set; }
///告警状态 00H无告警.01H:有告警 ///告警状态 00H无告警.01H:有告警
public int @as { get; set; } public int @as { get; set; }
/// <summary> /// <summary>
/// 故障码 参考充电机的故障码定义 /// 故障码 参考充电机的故障码定义
/// </summary> /// </summary>
public int fc { get; set; } public int fc { get; set; }
/// <summary> /// <summary>
/// 充电开始时间 没有进行充电填空 /// 充电开始时间 没有进行充电填空
/// </summary> /// </summary>
public DateTime st { get; set; } public DateTime st { get; set; }
/// <summary> /// <summary>
/// 已经充电时间 单位 分钟 /// 已经充电时间 单位 分钟
/// </summary> /// </summary>
public int ct { get; set; } public int ct { get; set; }
/// <summary> /// <summary>
/// 充电开始 SOC 0-100 单位 0.1 ,没有充电填 0 /// 充电开始 SOC 0-100 单位 0.1 ,没有充电填 0
/// </summary> /// </summary>
public int ssoc { get; set; } public int ssoc { get; set; }
/// <summary> /// <summary>
/// 当前 SOC 单位 0.1 /// 当前 SOC 单位 0.1
/// </summary> /// </summary>
public int csoc { get; set; } public int csoc { get; set; }
/// <summary> /// <summary>
/// 充电开始 SOE 单位 0.1kwh,没有充电填 0 /// 充电开始 SOE 单位 0.1kwh,没有充电填 0
/// </summary> /// </summary>
public float ssoe { get; set; } public float ssoe { get; set; }
/// <summary> /// <summary>
/// 当前 SOE 单位 0.1kwh /// 当前 SOE 单位 0.1kwh
/// </summary> /// </summary>
public float csoe { get; set; } public float csoe { get; set; }
/// <summary> /// <summary>
/// 当前充电电压 单位 0.1V,没有充电填 0 /// 当前充电电压 单位 0.1V,没有充电填 0
/// </summary> /// </summary>
public float cvot { get; set; } public float cvot { get; set; }
/// <summary> /// <summary>
/// 当前充电电流 单位 0.1A,没有充电填 0 /// 当前充电电流 单位 0.1A,没有充电填 0
/// </summary> /// </summary>
public float ccur { get; set; } public float ccur { get; set; }
/// <summary> /// <summary>
/// BMS 需求电压 单位 0.1V,没有充电填 0 /// BMS 需求电压 单位 0.1V,没有充电填 0
/// </summary> /// </summary>
public float nvot { get; set; } public float nvot { get; set; }
/// <summary> /// <summary>
/// BMS 需求电流 单位 0.1A,没有充电填 0 /// BMS 需求电流 单位 0.1A,没有充电填 0
/// </summary> /// </summary>
public float ncur { get; set; } public float ncur { get; set; }
/// <summary> /// <summary>
/// 最低单体电压 单位 0.01V /// 最低单体电压 单位 0.01V
/// </summary> /// </summary>
public float lsv { get; set; } public float lsv { get; set; }
/// <summary> /// <summary>
/// 最高单体电压 单位 0.01V /// 最高单体电压 单位 0.01V
/// </summary> /// </summary>
public float hsv { get; set; } public float hsv { get; set; }
/// <summary> /// <summary>
/// 最低单体温度 单位 0.1℃ /// 最低单体温度 单位 0.1℃
/// </summary> /// </summary>
public float lst { get; set; } public float lst { get; set; }
/// <summary> /// <summary>
/// 最高单体温度 单位 0.1℃ /// 最高单体温度 单位 0.1℃
/// </summary> /// </summary>
public float hst { get; set; } public float hst { get; set; }
/// <summary> /// <summary>
/// 水冷状态 0未知 1开启 2关闭 0xFF 无水冷设备 /// 水冷状态 0未知 1开启 2关闭 0xFF 无水冷设备
/// </summary> /// </summary>
public byte ws { get; set; } public byte ws { get; set; }
/// <summary> /// <summary>
/// 进水口温度 单位 0.1℃ , 没有水冷设备填 0xFF /// 进水口温度 单位 0.1℃ , 没有水冷设备填 0xFF
/// </summary> /// </summary>
public float it { get; set; } public float it { get; set; }
/// <summary> /// <summary>
/// 出水口温度 单位 0.1℃ , 没有水冷设备填 0xFF /// 出水口温度 单位 0.1℃ , 没有水冷设备填 0xFF
/// </summary> /// </summary>
public float ot { get; set; } public float ot { get; set; }
/// <summary> /// <summary>
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary> /// </summary>
public DateTime bt { get; set; } public DateTime bt { get; set; }
public string GetCmd() public string GetCmd()
{ {
return CloudConst.chargeDevDataInfo; return CloudConst.chargeDevDataInfo;

@ -0,0 +1,111 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Host.Req;
public class ChargeRecordUpLoad : ICmd
{
/// <summary>
/// 充电序列号
/// </summary>
public string chrsn { get; set; }
/// <summary>
/// 换电序列号
/// </summary>
public string son { get; set; }
/// <summary>
/// 电池序列号
/// </summary>
public string bid { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public DateTime st { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime et { get; set; }
/// <summary>
/// 开始 SOC
/// </summary>
public int ssoc { get; set; }
/// <summary>
/// 结束 SOC
/// </summary>
public int esoc { get; set; }
/// <summary>
/// 开始 SOE
/// </summary>
public float ssoe { get; set; }
/// <summary>
/// 结束 SOE
/// </summary>
public float esoe { get; set; }
/// <summary>
/// 直流电表充电 电量
/// </summary>
public float dcce { get; set; }
/// <summary>
/// 交流电表充电 电量
/// </summary>
public float acce { get; set; }
/// <summary>
/// 尖时段电量
/// </summary>
public float tp { get; set; }
/// <summary>
/// 峰时段电量
/// </summary>
public float pp { get; set; }
/// <summary>
/// 平时段电量
/// </summary>
public float fp { get; set; }
/// <summary>
/// 谷时段电量
/// </summary>
public float vp { get; set; }
/// <summary>
/// 充电时长 分钟
/// </summary>
public int ct { get; set; }
/// <summary>
/// 充电次数
/// </summary>
public int cn { get; set; }
/// <summary>
/// 1 自动; 2 人工手动
/// </summary>
public int sfs { get; set; }
/// <summary>
/// 车辆vin码
/// </summary>
public string? vin { get; set; }
/// <summary>
/// 0:站内充电 1 站外充电
/// </summary>
public int sfoc { get; set; }
public string GetCmd()
{
return CloudConst.ChargeRecordUpLoad;
}
}

@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Host.Req
/// <summary> /// <summary>
/// 4.2.1.1 换电上传换电订单 /// 4.2.1.1 换电上传换电订单
/// </summary> /// </summary>
public class UploadPowerChangeOrder : ICmd public class UploadSwapOrder : ICmd
{ {
/// <summary> /// <summary>
/// 换电站编码 /// 换电站编码

@ -53,7 +53,7 @@ public abstract class CloudApi
public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType) public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType)
{ {
UploadPowerChangeOrder uploadPowerChangeOrder = new() UploadSwapOrder uploadSwapOrder = new()
{ {
son = swapOrder.CloudSn, son = swapOrder.CloudSn,
cn = swapOrder.VehicleNo, cn = swapOrder.VehicleNo,
@ -78,8 +78,8 @@ public abstract class CloudApi
wt = new TimeSpan((swapOrder.SwapEndTime.ToDateTime().Ticks - swapOrder.SwapBeginTime.ToDateTime().Ticks)) wt = new TimeSpan((swapOrder.SwapEndTime.ToDateTime().Ticks - swapOrder.SwapBeginTime.ToDateTime().Ticks))
.TotalSeconds.ToInt(), .TotalSeconds.ToInt(),
}; };
UploadPowerChangeOrderResp? sendUploadPowerChangeOrder = CloudClientMgr.CloudClient?.SendUploadPowerChangeOrder( UploadSwapOrderResp? sendUploadPowerChangeOrder = CloudClientMgr.CloudClient?.SendUploadPowerChangeOrder(
uploadPowerChangeOrder, uploadSwapOrder,
global::System.TimeSpan.FromSeconds(TimeSpan)); global::System.TimeSpan.FromSeconds(TimeSpan));
if (sendUploadPowerChangeOrder == null) if (sendUploadPowerChangeOrder == null)
{ {

@ -1,6 +1,6 @@
using Service.BusinessTask; using Service.BusinessTask;
using Service.BusinessTask.MyTask; using Service.BusinessTask.MyTask;
using Service.Execute.StaticTools; using Service.Cloud.Client.MyTask;
namespace Service.Execute namespace Service.Execute
{ {
@ -14,6 +14,7 @@ namespace Service.Execute
private static readonly AbstractTaskHandler SwapOrderReportCloudTask = new SwapOrderReportCloudTask(); private static readonly AbstractTaskHandler SwapOrderReportCloudTask = new SwapOrderReportCloudTask();
private static readonly AbstractTaskHandler BatteryMoveTask = new BatteryMoveTask(); private static readonly AbstractTaskHandler BatteryMoveTask = new BatteryMoveTask();
private static readonly AbstractTaskHandler ChargeOrderUploadTask = new ChargeOrderUploadTask();
#region Task #region Task
@ -25,6 +26,7 @@ namespace Service.Execute
{ {
SwapOrderReportCloudTask.Start(); SwapOrderReportCloudTask.Start();
BatteryMoveTask.Start(); BatteryMoveTask.Start();
ChargeOrderUploadTask.Start();
} }
/// <summary> /// <summary>

@ -6,10 +6,12 @@ using HybirdFrameworkCore.Entity;
using Repository.Station; using Repository.Station;
using SqlSugar; using SqlSugar;
using System.Linq.Expressions; using System.Linq.Expressions;
using HybirdFrameworkCore.Utils;
using Service.Cloud.Client;
namespace Service.Station; namespace Service.Station;
/// <summary> /// <summary>
/// 充电订单 /// 充电订单
/// </summary> /// </summary>
[Scope("SingleInstance")] [Scope("SingleInstance")]
public class ChargeOrderService : BaseServices<ChargeOrder> public class ChargeOrderService : BaseServices<ChargeOrder>
@ -23,19 +25,19 @@ public class ChargeOrderService : BaseServices<ChargeOrder>
/// <summary> /// <summary>
/// 根据条件查询分页数据 /// 根据条件查询分页数据
/// </summary> /// </summary>
/// <param name="equipAlarmLevel"></param> /// <param name="equipAlarmLevel"></param>
/// <returns></returns> /// <returns></returns>
public PageResult<ChargeOrderResp> QueryChargeOrder(QueryChargeOrderReq chargeOrder) public PageResult<ChargeOrderResp> QueryChargeOrder(QueryChargeOrderReq chargeOrder)
{ {
//创建一个空的表达式树 //创建一个空的表达式树
Expression<Func<ChargeOrder, bool>> where = null; Expression<Func<ChargeOrder, bool>> where = null;
//// 定义参数表达式 //// 定义参数表达式
ParameterExpression parameter = Expression.Parameter(typeof(ChargeOrder), "u"); ParameterExpression parameter = Expression.Parameter(typeof(ChargeOrder), "u");
#region 构建动态查询树 #region 构建动态查询树
if (chargeOrder.Id != 0) if (chargeOrder.Id != 0)
{ {
Expression<Func<ChargeOrder, bool>> condition1Expr = u => u.Id == chargeOrder.Id; Expression<Func<ChargeOrder, bool>> condition1Expr = u => u.Id == chargeOrder.Id;
@ -118,9 +120,30 @@ public class ChargeOrderService : BaseServices<ChargeOrder>
} }
#endregion #endregion
//查询 //查询
return PageResult<ChargeOrderResp>.ConvertPage(chargeOrderRepository.QueryIPageByCause(chargeOrder, where)); return PageResult<ChargeOrderResp>.ConvertPage(chargeOrderRepository.QueryIPageByCause(chargeOrder, where));
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<Result<bool>> Upload2Cloud(int id)
{
ChargeOrder? order = await BaseDal.QueryByIdAsync(id);
if (ObjUtils.IsNull(order))
{
return Result<bool>.Fail("数据不存在");
}
if (order.CloudReportStatus == 1)
{
return Result<bool>.Success("已经上传到云平台");
}
CloudClientMgr.CloudClient?.PublishChargeOrder(order, 2);
return Result<bool>.Success();
} }
} }

@ -56,20 +56,13 @@ public class ChargeOrderController : ControllerBase
} }
/// <summary> /// <summary>
/// 充电订单上报云端 /// 充电订单上报云端
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet("UploadCloud/{id}")] [HttpGet("UploadCloud/{id}")]
public async Task<Result<bool>> UploadCloud(long id) public async Task<Result<bool>> UploadCloud(int id)
{ {
return await chargeOrderService.Upload2Cloud(id);
return Result<bool>.Success(null);
} }
} }
Loading…
Cancel
Save