using Entity.Constant; 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; using Service.Init; namespace Service.Execute.Api; public abstract class CloudApi { private const int TimeSpan = 60; /// /// 云平台车辆认证 /// /// /// public static VehicleCertificationResp VehicleCheck(RfidReadModel rfidReadModel, SwapOrder swapOrder) { 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)); return sendVehicleCertification; /*if (sendVehicleCertification == null) { return -1; } return sendVehicleCertification.re;*/ } /// /// 上报换电订单 /// /// /// /// public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType) { UploadSwapOrder uploadSwapOrder = new() { sn=StaticStationInfo.StationNo, son = swapOrder.CloudSn, cn = swapOrder.VehicleNo, so = seq, ct = swapOrder.VehicleEnterTime, st = swapOrder.SwapBeginTime, dbid = swapOrderBattery.UpBatteryNo, deno = swapOrderBattery.UpBatteryBinNo, dsoc = swapOrderBattery.UpBatterySoc.ToInt(), dsoe = swapOrderBattery.UpBatterySoe.ToInt(), et = swapOrder.SwapEndTime, od = 0, ot = swapOrder.VehicleLeaveTime, rs = 0, sflx = 0, sfs = uploadType, ubid = swapOrderBattery.DownBatteryNo, ueno = swapOrderBattery.DownBatteryBinNo, usoc = swapOrderBattery.DownBatterySoc.ToInt(), usoe = swapOrderBattery.DownBatterySoe.ToInt(), vin = swapOrder.VehicleVin, wt = new TimeSpan((swapOrder.SwapEndTime.ToDateTime().Ticks - swapOrder.SwapBeginTime.ToDateTime().Ticks)) .TotalSeconds.ToInt(), }; UploadSwapOrderResp? sendUploadPowerChangeOrder = CloudClientMgr.CloudClient?.SendUploadPowerChangeOrder( uploadSwapOrder, global::System.TimeSpan.FromSeconds(TimeSpan)); if (sendUploadPowerChangeOrder == null) { return -1; } return sendUploadPowerChangeOrder.re; } /// /// 上报换电步序到云端 /// /// /// public static void SendStateLog(SwapOrder swapOrder, InfoEnum.BusinessSwappingForCloudState state) { ChannelStatusReporting channelStatusReporting = new() { }; CloudClientMgr.CloudClient?.SendChannelStatusReporting(channelStatusReporting, global::System.TimeSpan.FromSeconds(TimeSpan)); return; } /// /// 上报车辆数据 /// public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model) { return; } /// /// 云平台下发换电指令 /// /// public static CarCanStart CarCanStart() { return CloudClientMgr.CloudClient.CarCanStart; } /// /// 清除下发的换电指令 /// /// public static bool ClearCarCanStartInfo() { CloudClientMgr.CloudClient.CarCanStart = null; return true; } }