diff --git a/Entity/Constant/CloudEnum.cs b/Entity/Constant/CloudEnum.cs
new file mode 100644
index 0000000..82554bb
--- /dev/null
+++ b/Entity/Constant/CloudEnum.cs
@@ -0,0 +1,6 @@
+namespace Entity.Constant;
+
+public class CloudEnum
+{
+
+}
\ No newline at end of file
diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs
index 5ddfd4c..5e6f96b 100644
--- a/Service/Cloud/Client/CloudClient.cs
+++ b/Service/Cloud/Client/CloudClient.cs
@@ -58,7 +58,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
public int Encrypt { get; set; }
public string? AesKey { get; set; }
-
+
public bool Authed { get; set; }
#endregion
@@ -66,6 +66,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#region Cmd msg cache
public CarCanStart? CarCanStart { get; set; }
+
///
///
///
@@ -75,9 +76,9 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
#region basic
- private IMqttClient? MqttClient;
+ private IMqttClient? MqttClient;
- private List handlers = new ();
+ private List handlers = new();
private static ushort _incrementId;
@@ -283,6 +284,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
break;
}
}
+
return Task.CompletedTask;
}
@@ -340,14 +342,15 @@ 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
diff --git a/Service/Cloud/Msg/Cloud/Resp/VehicleCertificationResp.cs b/Service/Cloud/Msg/Cloud/Resp/VehicleCertificationResp.cs
index dd76693..f8ea230 100644
--- a/Service/Cloud/Msg/Cloud/Resp/VehicleCertificationResp.cs
+++ b/Service/Cloud/Msg/Cloud/Resp/VehicleCertificationResp.cs
@@ -14,39 +14,54 @@ namespace Service.Cloud.Msg.Cloud.Resp
{
///
/// 应答结果
+ /// 0:成功
+ /// 1:没找到匹配的车辆(未入网)
+ /// 2:没有找到车辆匹配的 VIN
+ /// 3:车辆已经进入黑名单
+ /// 4:账户余额不足
+ /// 5: 未预约
+ /// 6:没有招到对应的 rfid 卡号
///
public int re { get; set; }
+
///
/// 认证方式
///
public int ty { get; set; }
+
///
/// 车牌号
///
public string cn { get; set; }
+
///
/// 卡号
///
public string rfid { get; set; }
+
///
/// 车辆识别号
///
public string vi { get; set; }
+
///
/// 订单号
///
public string on { get; set; }
+
///
/// Mac 地址
///
public string mac { get; set; }
+
///
/// 站内外鉴权方式
///
public int mode { get; set; }
+
public string GetCmd()
{
return CloudConst.carAuthRes;
}
}
-}
+}
\ No newline at end of file
diff --git a/Service/Cloud/Msg/Host/Req/VehicleCertification.cs b/Service/Cloud/Msg/Host/Req/VehicleCertification.cs
index b60ad51..b61d9ca 100644
--- a/Service/Cloud/Msg/Host/Req/VehicleCertification.cs
+++ b/Service/Cloud/Msg/Host/Req/VehicleCertification.cs
@@ -44,7 +44,7 @@ namespace Service.Cloud.Msg.Host.Req
///
/// 车辆进入的时间
///
- public DateTime dt { get; set; }
+ public DateTime? dt { get; set; }
///
/// 车牌图片
///
diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs
index 8378017..164f620 100644
--- a/Service/Execute/Api/CloudApi.cs
+++ b/Service/Execute/Api/CloudApi.cs
@@ -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;
+
///
/// 云平台车辆认证
///
///
///
- 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;
}
///
@@ -28,14 +52,13 @@ public class CloudApi
{
return;
}
-
+
///
- /// 上报tbox数据
+ /// 上报车辆数据
///
-
public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model)
{
- return ;
+ return;
}
///
@@ -46,7 +69,7 @@ public class CloudApi
{
return CloudClientMgr.CloudClient.CarCanStart;
}
-
+
///
/// 清除下发的换电指令
///
@@ -54,6 +77,6 @@ public class CloudApi
public static bool ClearCarCanStartInfo()
{
CloudClientMgr.CloudClient.CarCanStart = null;
- return true;
+ return true;
}
}
\ No newline at end of file
diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs
index 81f5392..93f5cb5 100644
--- a/Service/Execute/Step/CarPrepareState.cs
+++ b/Service/Execute/Step/CarPrepareState.cs
@@ -23,9 +23,10 @@ public class CarPrepareState : IState
private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve();
private readonly SwapOrderStepService _swapOrderStepService = AppInfo.Container.Resolve();
- private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve();
+ private readonly SwapAmtOrderRepository _amtOrderRepository = AppInfo.Container.Resolve();
- private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository = AppInfo.Container.Resolve();
+ private readonly SwapOrderBatteryRepository _swapOrderBatteryRepository =
+ AppInfo.Container.Resolve();
public StateResult Handle(SwappingStateMachine machine)
{
@@ -147,18 +148,19 @@ public class CarPrepareState : IState
if (BaseEnumExtensions.GetEnumByCode(
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);