|
|
|
using Entity.Constant;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using log4net;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Service.Cloud.Client;
|
|
|
|
using Service.Cloud.Msg.Cloud.Req;
|
|
|
|
using Service.Cloud.Msg.Cloud.Resp;
|
|
|
|
using Service.Cloud.Msg.Host.Req;
|
|
|
|
using Service.Cloud.Msg.Host.Req.OutCharger;
|
|
|
|
using Service.Execute.Model;
|
|
|
|
using Service.Execute.Model.Tbox;
|
|
|
|
using Service.Init;
|
|
|
|
|
|
|
|
namespace Service.Execute.Api;
|
|
|
|
|
|
|
|
public abstract class CloudApi
|
|
|
|
{
|
|
|
|
private const int TimeSpan = 10;
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger("CloudApi");
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 云平台车辆认证
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rfidReadModel"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static VehicleCertificationResp? VehicleCheck(RfidReadModel rfidReadModel, SwapOrder swapOrder)
|
|
|
|
|
|
|
|
{
|
|
|
|
VehicleCertification vehicleCertification = new()
|
|
|
|
{
|
|
|
|
ty = 2,
|
|
|
|
rfid = rfidReadModel.VelVin,
|
|
|
|
cn = rfidReadModel.VelNo,
|
|
|
|
vi = rfidReadModel.VelVin,
|
|
|
|
// mac = rfidReadModel.VelMac,
|
|
|
|
en = 0,
|
|
|
|
dt = swapOrder.VehicleEnterTime,
|
|
|
|
mode = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi VehicleCheck SendVehicleCertification param={JsonConvert.SerializeObject(vehicleCertification)}");
|
|
|
|
VehicleCertificationResp? sendVehicleCertification =
|
|
|
|
CloudClientMgr.CloudClient?.SendVehicleCertification(vehicleCertification,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi VehicleCheck SendVehicleCertification resp={JsonConvert.SerializeObject(sendVehicleCertification)}");
|
|
|
|
|
|
|
|
|
|
|
|
return sendVehicleCertification;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 上报换电订单
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rfidReadModel"></param>
|
|
|
|
/// <param name="swapOrder"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static int UploadSwapOrder(SwapOrder swapOrder, int seq, SwapOrderBattery swapOrderBattery, int uploadType
|
|
|
|
,SwapOrderReportCloud orderReportCloud)
|
|
|
|
|
|
|
|
{
|
|
|
|
UploadSwapOrder uploadSwapOrder = new()
|
|
|
|
{
|
|
|
|
rfid = swapOrder.VehicleVin,
|
|
|
|
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(),
|
|
|
|
vtm=orderReportCloud.Vtm,
|
|
|
|
};
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi UploadSwapOrder seq={seq} SendUploadPowerChangeOrder param={JsonConvert.SerializeObject(uploadSwapOrder)}");
|
|
|
|
|
|
|
|
UploadSwapOrderResp? sendUploadPowerChangeOrder = CloudClientMgr.CloudClient?.SendUploadPowerChangeOrder(
|
|
|
|
uploadSwapOrder,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi UploadSwapOrder seq={seq} SendUploadPowerChangeOrder resp={JsonConvert.SerializeObject(sendUploadPowerChangeOrder)}");
|
|
|
|
|
|
|
|
if (sendUploadPowerChangeOrder == null)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sendUploadPowerChangeOrder.re;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 上报换电步序到云端
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="swapOrder"></param>
|
|
|
|
/// <param name="state"></param>
|
|
|
|
public static void SendStateLog(SwapOrder swapOrder, InfoEnum.BusinessSwappingForCloudState state)
|
|
|
|
{
|
|
|
|
ChannelStatusReporting channelStatusReporting = new()
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
CloudClientMgr.CloudClient?.SendChannelStatusReporting(channelStatusReporting,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 上报车辆数据
|
|
|
|
/// </summary>
|
|
|
|
public static void UploadTBoxCarInfo(SwapOrder swapOrder, TboxCarInfoModel model)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 云平台下发换电指令
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static CarCanStart CarCanStart()
|
|
|
|
{
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi CarCanStart ");
|
|
|
|
var cloudClientCarCanStart = CloudClientMgr.CloudClient.CarCanStart;
|
|
|
|
Log.Info(
|
|
|
|
$" CloudApi CarCanStart resp= {JsonConvert.SerializeObject(cloudClientCarCanStart)}");
|
|
|
|
return cloudClientCarCanStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 清除下发的换电指令
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool ClearCarCanStartInfo()
|
|
|
|
{
|
|
|
|
CloudClientMgr.CloudClient.CarCanStart = null;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 9.2.1.3 站控上报充电枪充电结束事件
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
public static void SendPileEndCharge(PileEndCharge req)
|
|
|
|
{
|
|
|
|
CloudClientMgr.CloudClient?.SendPileEndCharge(req,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 9.2.1.7 站控上报充电枪充电遥测数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
public static void SendPileChargeRealtime(PileChargeRealtime req)
|
|
|
|
{
|
|
|
|
CloudClientMgr.CloudClient?.SendPileChargeRealtime(req,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 9.2.1.5 站控上报充电枪实时数据上报
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
public static void SendPileRealtime(PileRealtime req)
|
|
|
|
{
|
|
|
|
CloudClientMgr.CloudClient?.SendPileRealtime(req,
|
|
|
|
global::System.TimeSpan.FromSeconds(TimeSpan));
|
|
|
|
}
|
|
|
|
}
|