与云平台相关的换电流程修改

master
xjl 2 months ago
parent a0257a447b
commit ef8213098d

@ -12,6 +12,11 @@ public class CloudConst
//上位机推
/// <summary>
/// 换电就绪主题
/// </summary>
public static readonly string commandSubFind = "truck_topic_command_sub_find_2";
/// <summary>
/// 换电完成指令主题
/// </summary>

@ -4,7 +4,7 @@ using HybirdFrameworkCore.AutoTask;
using log4net;
using Repository.Station;
namespace Service.Cloud.Client.MyTask;
namespace Service.Cloud.MyTask;
[Scope]
public class ChargeOrderUploadTask : ITask
@ -32,7 +32,7 @@ public class ChargeOrderUploadTask : ITask
Log.Info($"there are {chargeOrders?.Count ?? 0} to upload");
if (chargeOrders is { Count: > 0 })
{
Dictionary<string,List<ChargeOrder>> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i=> i.ToList());
Dictionary<string, List<ChargeOrder>> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i => i.ToList());
foreach (var (k, v) in dictionary)
{
//CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1);

@ -2,6 +2,7 @@ using Entity.Constant;
using Entity.DbModel.Station;
using log4net;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Host.Req;
using Service.Execute.Model;
using Service.Init;
@ -29,7 +30,7 @@ public abstract class CloudApi
carNumber = carNumber,
};
string jsonString = JsonSerializer.Serialize(readyTopic);
return CloudClientMgr.Send("truck_topic_command_sub_find", jsonString);
return CloudClientMgr.Send(CloudConst.commandSubFind, jsonString);
}

@ -333,9 +333,9 @@ public class CommonMgr
SwapOrderSn = machineSwapOrder.Sn,
SwapOrderId = machineSwapOrder.Id,
CloudReportStatus = 0,
Cn = machineSwapOrder.VehicleNo,
Vin = machineSwapOrder.VehicleVin,
//TODO 云平台待修改
//Vtm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
});
}
}

@ -90,9 +90,16 @@ public class CarPrepareState : IState
return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None);
}
//上传云平台换电就绪
InvokeStatus uploadCloudReady = UploadCloudReady(machine);
if (InvokeStatus.Done != uploadCloudReady)
{
return SwappingStateMachine.ReturnWithInvokeErr(uploadCloudReady, ExceptionReason.None);
}
return new StateResult()
{
SwappingState = SwappingState.CarCtrl
SwappingState = SwappingState.SwapCanStart
};
}
@ -349,4 +356,33 @@ public class CarPrepareState : IState
, false, () => { }, 10, InvokeStatus.None
);
}
/// <summary>
/// 换电就绪上传云平台
/// </summary>
/// <param name="machine"></param>
/// <returns></returns>
public InvokeStatus UploadCloudReady(SwappingStateMachine machine)
{
return Invoker.Invoke("wait UploadCloudReady ", 1000, 2, machine.IsCanceled,
() => machine.CloudVelCheckFlag, () =>
{
if (!CloudApi.UploadCloudReady(machine.RfidReadModel.VelNo))
{
_log.Info("UploadCloudReady false");
}
else
{
machine.ExceptionReason = ExceptionReason.None;
_log.Info("UploadCloudReady true");
machine.CloudVelCheckFlag = true;
}
}, () => { //语音
}, true, () => { }, 2, InvokeStatus.TimeOut);
}
}

@ -26,7 +26,7 @@ public class SwapCanStartState : IState
public StateResult Handle(SwappingStateMachine machine)
{
/*InvokeStatus swapCanStart = SwapCanStart(machine);
InvokeStatus swapCanStart = SwapCanStart(machine);
if (InvokeStatus.Done != swapCanStart)
{
@ -36,8 +36,7 @@ public class SwapCanStartState : IState
return new StateResult()
{
SwappingState = SwappingState.CarCtrl
};*/
return null;
};
}
@ -45,8 +44,9 @@ public class SwapCanStartState : IState
/// 等待云平台下发换电
/// </summary>
/// <returns></returns>
/*public InvokeStatus SwapCanStart(SwappingStateMachine machine)
public InvokeStatus SwapCanStart(SwappingStateMachine machine)
{
return Invoker.Invoke("check swapCanStart", 1000, 50, machine.IsCanceled,
() => machine.CloudCarCanStartFlag, () =>
{
@ -55,39 +55,42 @@ public class SwapCanStartState : IState
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
StaticStationInfo.StationModel))
{
CarCanStart carCanStart = CloudApi.CarCanStart();
if (carCanStart != null)
{
//车牌号
if (carCanStart.cn.Equals(machine.BoxCarInfoModel.CarNo))
// CloudApi.UploadCloudReady(machine.plateNumber);
if (machine.swapStart != null)
{
//可以开始换电
if (carCanStart.cs == 1)
if (machine.swapStart.command == "start")
{
_log.Info("SwapCanStart ok");
_log.Info("SwapCanStart start");
//更新换电订单
machine.SwapOrder.CloudSn = carCanStart.on;
_swapOrderRepository.Update(machine.SwapOrder.CloudSn);
machine.SwapOrder.CloudSn = machine.swapStart.orderId;
//machine.SwapOrder.CloudSn = "1764482218541527041";
machine.CloudCarCanStartFlag = true;
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
machine.StepSort++, machine.SwapOrder.Sn);
}
else
// 其他非启动换电状态处理
else if (machine.swapStart.command == "stop"|| machine.swapStart.command == "reset")
{
_log.Info("SwapCanStart cancel");
_log.Info("SwapCanStart stop");
//语音提示云平台取消换电
StationSoftMgr.SwappingStateMachineCancel();
machine.CloudCarCanStartFlag = false;
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.CloudSendSwapCancel.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CloudSendSwapError);
machine.BusinessSwappingForCloudState =
InfoEnum.BusinessSwappingForCloudState.SwapReady;
// CloudApi.SendStateLog(machine.SwapOrder,
// machine.BusinessSwappingForCloudState);
}
else if (machine.swapStart.command == "suspend")
{
_log.Info("SwapCanStart suspend");
machine.CloudCarCanStartFlag = false;
//语音提示云平台暂停换电
}
else if (machine.swapStart.command == "continue")
{
_log.Info("SwapCanStart continue");
machine.CloudCarCanStartFlag = true;
//语音提示云平台继续换电
}
}
}
else
{
machine.CloudCarCanStartFlag = true;
@ -97,9 +100,8 @@ public class SwapCanStartState : IState
}, () =>
{
machine.ExceptionReason = ExceptionReason.CloudSendSwapError;
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.CloudSendSwapError.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CloudSendSwapError);
}, false, () => { }
, 10, InvokeStatus.None);
}*/
}
}

@ -79,7 +79,7 @@ public class SwapDoneState : IState
Task.Run(() =>
{
//新增换电成功上报云平台数据
//_CommonMgr.InsertCloudReportForSwapSuccess(machine);
_CommonMgr.InsertCloudReportForSwapSuccess(machine);
//换电成功关于bininfo表的更新
_CommonMgr.UpdateBinInfoForSwapSuccess(machine);

@ -78,14 +78,11 @@ public class SwappingStateMachine : IDisposable
["0"] = new StepModel { StepNo = 0, Status = 0, StepName = "空闲" },
["1"] = new StepModel { StepNo = 1, Status = 0, StepName = "车辆到站(入口雷达检测到车辆驶入)" },
["2"] = new StepModel { StepNo = 2, Status = 0, StepName = "rfid扫描完成" },
//["3"] = new StepModel { StepNo = 3, Status = 0, StepName = "云平台车辆认证" },
["3"] = new StepModel { StepNo = 4, Status = 0, StepName = "车辆到位" },
// ["5"] = new StepModel { StepNo = 5, Status = 0, StepName = "云平台下发换电指令" },
["4"] = new StepModel { StepNo = 5, Status = 0, StepName = "车辆就绪和货箱举升到位" },
["5"] = new StepModel { StepNo = 5, Status = 0, StepName = "下高压完成" },
["6"] = new StepModel { StepNo = 5, Status = 0, StepName = "车辆解锁" },
//["6"] = new StepModel { StepNo = 6, Status = 0, StepName = "下发plc选包" },
["7"] = new StepModel { StepNo = 6, Status = 0, StepName = "开始换电" },
["8"] = new StepModel { StepNo = 7, Status = 0, StepName = "拆旧电池完成" },
["9"] = new StepModel { StepNo = 8, Status = 0, StepName = "入库旧电池完成" },
@ -109,7 +106,7 @@ public class SwappingStateMachine : IDisposable
//读rfid
public bool RfidReadFlag = false;
//云平台车辆
//换电就绪上传云平台
public bool CloudVelCheckFlag = false;
//Tbox连接

@ -80,22 +80,14 @@ public class SwapOrderMgr
i.SwapResult == 1 && i.SwapEndTime >= DateTime.Today && i.SwapEndTime < swapOrder.SwapEndTime);
swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value);
//TODO 云平台待修改
//var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType, value);
//if (uploadSwapOrder == 0)
//{
// swapOrder.CloudReportStatus = 1;
// updateDbOrder.Add(swapOrder);
// // value.CloudReportStatus = 1000;
// value.UploadTime = DateTime.Now;
//}
//else
//{
// //当 cloudReportStatus >=100 就不需要上传了
// value.CloudReportStatus++;
//}
CloudApi.UploadCloudSwapFinish(swapOrder.VehicleNo, swapOrder.CloudSn, swapOrderBattery.DownBatterySoc.ToString(), swapOrderBattery.UpBatterySoc.ToString());
swapOrder.CloudReportStatus = 1;
updateDbOrder.Add(swapOrder);
value.CloudReportStatus = 1;
value.UploadTime = DateTime.Now;
updateDbCloudReport.Add(value);
}

@ -1,16 +1,17 @@
/*using Entity.Constant;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Repository.Station;
using Service.Execute.Api;
using Service.Init;
using Service.Mgr;
namespace Service.MyTask;
/// <summary>
/// 充电结束上报云平台task
/// 换电订单上报云平台task
/// </summary>
[Scope]
public class SwapOrderReportCloudTask : ITask
@ -44,7 +45,10 @@ public class SwapOrderReportCloudTask : ITask
}
List<SwapOrderReportCloud>
list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 100);
list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus < 1);
SwapOrderMgr.UploadCloud(list, 1);
}
@ -68,4 +72,4 @@ public class SwapOrderReportCloudTask : ITask
{
_stop = false;
}
}*/
}
Loading…
Cancel
Save