云平台逻辑打样

master
smartwyy 6 months ago
parent 4715153df9
commit dd92a75fa0

@ -1,167 +0,0 @@
using SqlSugar;
namespace Entity.DbModel.Station
{
///<summary>
///预约订单表
///</summary>
[SugarTable("amt_order_info")]
public partial class AmtOrderInfo
{
public AmtOrderInfo()
{
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public long Id { get; set; }
/// <summary>
/// Desc:换电站编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "sn")]
public string Sn { get; set; }
/// <summary>
/// Desc:车辆编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "car_no")]
public string CarNo { get; set; }
/// <summary>
/// Desc:预约单号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "order_no")]
public string? OrderNo { get; set; }
/// <summary>
/// Desc:车辆vim码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "vin")]
public string Vin { get; set; }
/// <summary>
/// Desc:预约电池类型编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "battery_type")]
public string BatteryType { get; set; }
/// <summary>
/// Desc:预约电池编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "battery_nos")]
public string BatteryNos { get; set; }
/// <summary>
/// Desc:预约数量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "batnum")]
public int? Batnum { get; set; }
/// <summary>
/// Desc:预约电池锁仓仓号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "bin_nos")]
public string BinNos { get; set; }
/// <summary>
/// Desc:预约时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// Desc:预约到期时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "end_time")]
public DateTime? EndTime { get; set; }
/// <summary>
/// Desc:预约单状态1预约成功2预约取消3预约失败4换电完成5换电失败6换电中7预约过期
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "status")]
public byte? Status { get; set; }
/// <summary>
/// Desc:取消时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "cancel_time")]
public DateTime? CancelTime { get; set; }
/// <summary>
/// Desc:换电完成时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_finish_time")]
public DateTime? SwapFinishTime { get; set; }
/// <summary>
/// Desc:换电订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_order_no")]
public string SwapOrderNo { get; set; }
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_by")]
public string CreatedBy { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_by")]
public string UpdatedBy { get; set; }
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
}
}

@ -36,24 +36,24 @@ namespace Entity.DbModel.Station
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="pay_status")]
public int? PayStatus {get;set;}
[SugarColumn(ColumnName="battery_type")]
public string BatteryType {get;set;}
/// <summary>
/// Desc:车辆vin码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="vin")]
public string Vin {get;set;}
[SugarColumn(ColumnName="car_no")]
public string CarNo {get;set;}
/// <summary>
/// Desc:车辆mac
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="mac")]
public string Mac {get;set;}
[SugarColumn(ColumnName="battery_no_list")]
public string BatteryNoList {get;set;}
/// <summary>
/// Desc:预约电池数量

@ -2,9 +2,9 @@
namespace HybirdFrameworkDriver.Common;
public class MsgCache
public class MsgCache<T, TReq, TResp>
{
private readonly ConcurrentDictionary<string, dynamic> _dictionary = new();
private readonly ConcurrentDictionary<string, MsgPair<TReq, TResp>> _dictionary = new();
private static readonly string MsgKey = "msg_";
public void Add(string key, dynamic value)
@ -12,7 +12,7 @@ public class MsgCache
_dictionary[key] = value;
}
public bool TryGet(string key, out dynamic? value)
public bool TryGet(string key, out MsgPair<TReq, TResp>? value)
{
return _dictionary.TryGetValue(key, out value);
}
@ -22,12 +22,12 @@ public class MsgCache
_dictionary.Remove(key, out var value);
}
public void AddByMsgId(int key, dynamic value)
public void AddByMsgId(int key, MsgPair<TReq, TResp> value)
{
_dictionary[MsgKey + key] = value;
}
public bool TryGetMsgId(int key, out dynamic? value)
public bool TryGetMsgId(int key, out MsgPair<TReq, TResp>? value)
{
return _dictionary.TryGetValue(MsgKey + key, out value);
}
@ -36,4 +36,12 @@ public class MsgCache
{
_dictionary.Remove(MsgKey + key, out var value);
}
}
public class MsgPair<TReq, TResp>
{
public TReq? Req { get; set; }
public TResp? Resp { get; set; }
}

@ -16,4 +16,8 @@
<ProjectReference Include="..\Entity\Entity.csproj"/>
</ItemGroup>
<ItemGroup>
<Compile Remove="Station\AmtOrderInfoRepository.cs" />
</ItemGroup>
</Project>

@ -1,13 +0,0 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class AmtOrderInfoRepository : BaseRepository<AmtOrderInfo>
{
public AmtOrderInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}

@ -3,6 +3,7 @@ using Autofac;
using Autofac.Core;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.Common;
using log4net;
using MQTTnet;
using MQTTnet.Client;
@ -19,6 +20,7 @@ using Newtonsoft.Json.Linq;
using Service.Cloud.Handler;
using Service.Cloud.Msg;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp;
using Service.Cloud.Msg.Host.Req;
namespace Service.Cloud.Client;
@ -61,15 +63,21 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#endregion
#region Cmd
#region Cmd msg cache
public CarCanStart? CarCanStart { get; set; }
/// <summary>
///
/// </summary>
public MsgPair<VehicleCertification, VehicleCertificationResp> CarAuth { get; set; } = new();
#endregion
private IMqttClient? MqttClient;
#region basic
private List<IBaseHandler> handlers = new List<IBaseHandler>();
private IMqttClient? MqttClient;
private List<IBaseHandler> handlers = new ();
private static ushort _incrementId;
@ -329,4 +337,19 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
return builder.Build();
}
#endregion
#region 主动发送CMD
public void SendVehicleCertification(VehicleCertification vehicleCertification)
{
this.CarAuth.Req = vehicleCertification;
this.CarAuth.Resp = null;
this.Publish(vehicleCertification);
}
#endregion
}

@ -14,12 +14,12 @@ namespace Service.Cloud.Handler;
public class AmtBatHandler : IBaseHandler
{
private BinInfoRepository _binInfoRepository;
private AmtOrderInfoRepository _amtOrderInfoRepository;
private SwapAmtOrderRepository _swapAmtOrderRepository;
public AmtBatHandler(BinInfoRepository binInfoRepository, AmtOrderInfoRepository amtOrderInfoRepository)
public AmtBatHandler(BinInfoRepository binInfoRepository, SwapAmtOrderRepository swapAmtOrderRepository)
{
_binInfoRepository = binInfoRepository;
_amtOrderInfoRepository = amtOrderInfoRepository;
_swapAmtOrderRepository = swapAmtOrderRepository;
}
public void Handle(string t)
@ -29,7 +29,7 @@ public class AmtBatHandler : IBaseHandler
AmtBat? amtBat = JsonConvert.DeserializeObject<AmtBat>(t);
if (amtBat != null)
{
int count = _amtOrderInfoRepository.GetCount(it =>
int count = _swapAmtOrderRepository.GetCount(it =>
it.CarNo == amtBat.cn && it.Status == (byte)InfoEnum.AmtOrderStatus.Success);
if (count > 0)
@ -38,14 +38,14 @@ public class AmtBatHandler : IBaseHandler
}
else
{
AmtOrderInfo amtOrderInfo = new AmtOrderInfo()
SwapAmtOrder amtOrderInfo = new SwapAmtOrder()
{
Sn = StaticStationInfo.StationNo,
CarNo = amtBat.cn,
Batnum = amtBat.bm,
BatteryCount = amtBat.bm,
BatteryType = amtBat.bn,
StartTime = amtBat.at,
EndTime = amtBat.at.AddMinutes(amtBat.am)
AmtTime = amtBat.at,
ExpireTime = amtBat.at.AddMinutes(amtBat.am)
};
}

@ -0,0 +1,23 @@
using HybirdFrameworkCore.Autofac.Attribute;
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 CarAuthResHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.carAuthRes == cmd;
}
public void Handle(string t)
{
VehicleCertificationResp? resp = JsonConvert.DeserializeObject<VehicleCertificationResp>(t);
CloudClientMgr.CloudClient.CarAuth.Resp = resp;
}
}

@ -1,10 +1,12 @@
using Newtonsoft.Json;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class CarCanStartHandler : IBaseHandler
{
public bool CanHandle(string cmd)

Loading…
Cancel
Save