云平台认证车辆

master
lxw 6 months ago
parent 3a8de78a25
commit 920d8ecdd9

@ -0,0 +1,6 @@
namespace Entity.Constant;
public class CloudEnum
{
}

@ -58,7 +58,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
public int Encrypt { get; set; } public int Encrypt { get; set; }
public string? AesKey { get; set; } public string? AesKey { get; set; }
public bool Authed { get; set; } public bool Authed { get; set; }
#endregion #endregion
@ -66,6 +66,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#region Cmd msg cache #region Cmd msg cache
public CarCanStart? CarCanStart { get; set; } public CarCanStart? CarCanStart { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -75,9 +76,9 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#region basic #region basic
private IMqttClient? MqttClient; private IMqttClient? MqttClient;
private List<IBaseHandler> handlers = new (); private List<IBaseHandler> handlers = new();
private static ushort _incrementId; private static ushort _incrementId;
@ -283,6 +284,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
break; break;
} }
} }
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -340,14 +342,15 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#endregion #endregion
#region 主动发送CMD #region 主动发送CMD
public void SendVehicleCertification(VehicleCertification vehicleCertification) public VehicleCertificationResp? SendVehicleCertification(VehicleCertification vehicleCertification,
TimeSpan timeSpan)
{ {
this.CarAuth.Req = vehicleCertification; this.CarAuth.Req = vehicleCertification;
this.Publish(vehicleCertification); this.Publish(vehicleCertification);
return CarAuth.GetResp(timeSpan);
} }
#endregion #endregion

@ -14,39 +14,54 @@ namespace Service.Cloud.Msg.Cloud.Resp
{ {
/// <summary> /// <summary>
/// 应答结果 /// 应答结果
/// 0:成功
/// 1:没找到匹配的车辆(未入网)
/// 2没有找到车辆匹配的 VIN
/// 3车辆已经进入黑名单
/// 4账户余额不足
/// 5: 未预约
/// 6没有招到对应的 rfid 卡号
/// </summary> /// </summary>
public int re { get; set; } public int re { get; set; }
/// <summary> /// <summary>
/// 认证方式 /// 认证方式
/// </summary> /// </summary>
public int ty { get; set; } public int ty { get; set; }
/// <summary> /// <summary>
/// 车牌号 /// 车牌号
/// </summary> /// </summary>
public string cn { get; set; } public string cn { get; set; }
/// <summary> /// <summary>
/// 卡号 /// 卡号
/// </summary> /// </summary>
public string rfid { get; set; } public string rfid { get; set; }
/// <summary> /// <summary>
/// 车辆识别号 /// 车辆识别号
/// </summary> /// </summary>
public string vi { get; set; } public string vi { get; set; }
/// <summary> /// <summary>
/// 订单号 /// 订单号
/// </summary> /// </summary>
public string on { get; set; } public string on { get; set; }
/// <summary> /// <summary>
/// Mac 地址 /// Mac 地址
/// </summary> /// </summary>
public string mac { get; set; } public string mac { get; set; }
/// <summary> /// <summary>
/// 站内外鉴权方式 /// 站内外鉴权方式
/// </summary> /// </summary>
public int mode { get; set; } public int mode { get; set; }
public string GetCmd() public string GetCmd()
{ {
return CloudConst.carAuthRes; return CloudConst.carAuthRes;
} }
} }
} }

@ -44,7 +44,7 @@ namespace Service.Cloud.Msg.Host.Req
/// <summary> /// <summary>
/// 车辆进入的时间 /// 车辆进入的时间
/// </summary> /// </summary>
public DateTime dt { get; set; } public DateTime? dt { get; set; }
/// <summary> /// <summary>
/// 车牌图片 /// 车牌图片
/// </summary> /// </summary>

@ -3,20 +3,44 @@ using Entity.DbModel.Station;
using log4net; using log4net;
using Service.Cloud.Client; using Service.Cloud.Client;
using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp;
using Service.Cloud.Msg.Host.Req;
using Service.Execute.Model; using Service.Execute.Model;
namespace Service.Execute.Api; namespace Service.Execute.Api;
public class CloudApi public class CloudApi
{ {
private const int TimeSpan = 30;
/// <summary> /// <summary>
/// 云平台车辆认证 /// 云平台车辆认证
/// </summary> /// </summary>
/// <param name="rfidReadModel"></param> /// <param name="rfidReadModel"></param>
/// <returns></returns> /// <returns></returns>
public static bool VehicleCheck(RfidReadModel rfidReadModel) public static int VehicleCheck(RfidReadModel rfidReadModel, SwapOrder swapOrder)
{ {
return true; VehicleCertification vehicleCertification = new()
{
ty = 1,
cn = rfidReadModel.VelNo,
vi = rfidReadModel.VelVin,
mac = rfidReadModel.VelMac,
en = 0,
dt = swapOrder.VehicleEnterTime,
mode = 0,
};
VehicleCertificationResp? sendVehicleCertification =
CloudClientMgr.CloudClient?.SendVehicleCertification(vehicleCertification,
global::System.TimeSpan.FromSeconds(TimeSpan));
if (sendVehicleCertification == null)
{
return -1;
}
return sendVehicleCertification.re;
} }
/// <summary> /// <summary>
@ -28,14 +52,13 @@ public class CloudApi
{ {
return; return;
} }
/// <summary> /// <summary>
/// 上报tbox数据 /// 上报车辆数据
/// </summary> /// </summary>
public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model) public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model)
{ {
return ; return;
} }
/// <summary> /// <summary>
@ -46,7 +69,7 @@ public class CloudApi
{ {
return CloudClientMgr.CloudClient.CarCanStart; return CloudClientMgr.CloudClient.CarCanStart;
} }
/// <summary> /// <summary>
/// 清除下发的换电指令 /// 清除下发的换电指令
/// </summary> /// </summary>
@ -54,6 +77,6 @@ public class CloudApi
public static bool ClearCarCanStartInfo() public static bool ClearCarCanStartInfo()
{ {
CloudClientMgr.CloudClient.CarCanStart = null; CloudClientMgr.CloudClient.CarCanStart = null;
return true; return true;
} }
} }

@ -23,9 +23,10 @@ public class CarPrepareState : IState
private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>(); private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>(); private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve<SwapOrderStepService>();
private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>(); private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve<SwapAmtOrderRepository>();
private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository = AppInfo.Container.Resolve<SwapOrderBatteryRepository>(); private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository =
AppInfo.Container.Resolve<SwapOrderBatteryRepository>();
public StateResult Handle(SwappingStateMachine machine) public StateResult Handle(SwappingStateMachine machine)
{ {
@ -147,18 +148,19 @@ public class CarPrepareState : IState
if (BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>( if (BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
int.Parse(StaticStationInfo.StationModel)) == StationConstant.StationModel.Remote) int.Parse(StaticStationInfo.StationModel)) == StationConstant.StationModel.Remote)
{ {
bool flag = CloudApi.VehicleCheck(machine.RfidReadModel); int vehicleCheck = CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
if (!flag) if (vehicleCheck != 0)
{ {
_log.Info("cloud check vehicle error"); _log.Info("cloud check vehicle error");
machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
} }
else else
{ {
machine.ExceptionReason = ExceptionReason.None; machine.ExceptionReason = ExceptionReason.None;
_log.Info("cloud check vehicle done"); _log.Info("cloud check vehicle done");
machine.CloudVelCheckFlag = true; machine.CloudVelCheckFlag = true;
machine.LedTool.WriteProgramContent("换电准备中:云平台车辆验证完成"); machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag, _swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
machine.StepSort++, machine.SwapOrder.Sn); machine.StepSort++, machine.SwapOrder.Sn);

Loading…
Cancel
Save