云平台认证车辆

master
lxw 6 months ago
parent 3a8de78a25
commit 920d8ecdd9

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

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

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

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

@ -3,20 +3,44 @@ using Entity.DbModel.Station;
using log4net;
using Service.Cloud.Client;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp;
using Service.Cloud.Msg.Host.Req;
using Service.Execute.Model;
namespace Service.Execute.Api;
public class CloudApi
{
private const int TimeSpan = 30;
/// <summary>
/// 云平台车辆认证
/// </summary>
/// <param name="rfidReadModel"></param>
/// <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>
@ -30,12 +54,11 @@ public class CloudApi
}
/// <summary>
/// 上报tbox数据
/// 上报车辆数据
/// </summary>
public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model)
{
return ;
return;
}
/// <summary>
@ -54,6 +77,6 @@ public class CloudApi
public static bool ClearCarCanStartInfo()
{
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 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)
{
@ -147,18 +148,19 @@ public class CarPrepareState : IState
if (BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
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");
machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
}
else
{
machine.ExceptionReason = ExceptionReason.None;
_log.Info("cloud check vehicle done");
machine.CloudVelCheckFlag = true;
machine.LedTool.WriteProgramContent("换电准备中:云平台车辆验证完成");
machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成");
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag,
machine.StepSort++, machine.SwapOrder.Sn);

Loading…
Cancel
Save