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

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>
/// 换电完成指令主题 /// 换电完成指令主题
/// </summary> /// </summary>

@ -4,7 +4,7 @@ using HybirdFrameworkCore.AutoTask;
using log4net; using log4net;
using Repository.Station; using Repository.Station;
namespace Service.Cloud.Client.MyTask; namespace Service.Cloud.MyTask;
[Scope] [Scope]
public class ChargeOrderUploadTask : ITask public class ChargeOrderUploadTask : ITask
@ -32,7 +32,7 @@ public class ChargeOrderUploadTask : ITask
Log.Info($"there are {chargeOrders?.Count ?? 0} to upload"); Log.Info($"there are {chargeOrders?.Count ?? 0} to upload");
if (chargeOrders is { Count: > 0 }) 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) foreach (var (k, v) in dictionary)
{ {
//CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1); //CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1);

@ -2,6 +2,7 @@ using Entity.Constant;
using Entity.DbModel.Station; using Entity.DbModel.Station;
using log4net; using log4net;
using Service.Cloud.Client; using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Host.Req; using Service.Cloud.Msg.Host.Req;
using Service.Execute.Model; using Service.Execute.Model;
using Service.Init; using Service.Init;
@ -29,7 +30,7 @@ public abstract class CloudApi
carNumber = carNumber, carNumber = carNumber,
}; };
string jsonString = JsonSerializer.Serialize(readyTopic); 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, SwapOrderSn = machineSwapOrder.Sn,
SwapOrderId = machineSwapOrder.Id, SwapOrderId = machineSwapOrder.Id,
CloudReportStatus = 0, CloudReportStatus = 0,
Cn = machineSwapOrder.VehicleNo,
Vin = machineSwapOrder.VehicleVin, 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); return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None);
} }
//上传云平台换电就绪
InvokeStatus uploadCloudReady = UploadCloudReady(machine);
if (InvokeStatus.Done != uploadCloudReady)
{
return SwappingStateMachine.ReturnWithInvokeErr(uploadCloudReady, ExceptionReason.None);
}
return new StateResult() return new StateResult()
{ {
SwappingState = SwappingState.CarCtrl SwappingState = SwappingState.SwapCanStart
}; };
} }
@ -349,4 +356,33 @@ public class CarPrepareState : IState
, false, () => { }, 10, InvokeStatus.None , 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) public StateResult Handle(SwappingStateMachine machine)
{ {
/*InvokeStatus swapCanStart = SwapCanStart(machine); InvokeStatus swapCanStart = SwapCanStart(machine);
if (InvokeStatus.Done != swapCanStart) if (InvokeStatus.Done != swapCanStart)
{ {
@ -36,8 +36,7 @@ public class SwapCanStartState : IState
return new StateResult() return new StateResult()
{ {
SwappingState = SwappingState.CarCtrl SwappingState = SwappingState.CarCtrl
};*/ };
return null;
} }
@ -45,8 +44,9 @@ public class SwapCanStartState : IState
/// 等待云平台下发换电 /// 等待云平台下发换电
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/*public InvokeStatus SwapCanStart(SwappingStateMachine machine) public InvokeStatus SwapCanStart(SwappingStateMachine machine)
{ {
return Invoker.Invoke("check swapCanStart", 1000, 50, machine.IsCanceled, return Invoker.Invoke("check swapCanStart", 1000, 50, machine.IsCanceled,
() => machine.CloudCarCanStartFlag, () => () => machine.CloudCarCanStartFlag, () =>
{ {
@ -55,38 +55,41 @@ public class SwapCanStartState : IState
BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>( BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
StaticStationInfo.StationModel)) StaticStationInfo.StationModel))
{ {
CarCanStart carCanStart = CloudApi.CarCanStart(); // CloudApi.UploadCloudReady(machine.plateNumber);
if (carCanStart != null) if (machine.swapStart != null)
{ {
//车牌号 if (machine.swapStart.command == "start")
if (carCanStart.cn.Equals(machine.BoxCarInfoModel.CarNo)) {
_log.Info("SwapCanStart start");
//更新换电订单
machine.SwapOrder.CloudSn = machine.swapStart.orderId;
//machine.SwapOrder.CloudSn = "1764482218541527041";
machine.CloudCarCanStartFlag = true;
}
// 其他非启动换电状态处理
else if (machine.swapStart.command == "stop"|| machine.swapStart.command == "reset")
{ {
//可以开始换电 _log.Info("SwapCanStart stop");
if (carCanStart.cs == 1) //语音提示云平台取消换电
{ StationSoftMgr.SwappingStateMachineCancel();
_log.Info("SwapCanStart ok"); machine.CloudCarCanStartFlag = false;
//更新换电订单
machine.SwapOrder.CloudSn = carCanStart.on;
_swapOrderRepository.Update(machine.SwapOrder.CloudSn);
machine.CloudCarCanStartFlag = true;
_swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag, }
machine.StepSort++, machine.SwapOrder.Sn); else if (machine.swapStart.command == "suspend")
} {
else _log.Info("SwapCanStart suspend");
{ machine.CloudCarCanStartFlag = false;
_log.Info("SwapCanStart cancel"); //语音提示云平台暂停换电
//语音提示云平台取消换电 }
machine.CloudCarCanStartFlag = false; else if (machine.swapStart.command == "continue")
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.CloudSendSwapCancel.GetLed()); {
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CloudSendSwapError); _log.Info("SwapCanStart continue");
machine.BusinessSwappingForCloudState = machine.CloudCarCanStartFlag = true;
InfoEnum.BusinessSwappingForCloudState.SwapReady; //语音提示云平台继续换电
// CloudApi.SendStateLog(machine.SwapOrder,
// machine.BusinessSwappingForCloudState);
}
} }
} }
} }
else else
{ {
@ -97,9 +100,8 @@ public class SwapCanStartState : IState
}, () => }, () =>
{ {
machine.ExceptionReason = ExceptionReason.CloudSendSwapError; machine.ExceptionReason = ExceptionReason.CloudSendSwapError;
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.CloudSendSwapError.GetLed());
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CloudSendSwapError); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.CloudSendSwapError);
}, false, () => { } }, false, () => { }
, 10, InvokeStatus.None); , 10, InvokeStatus.None);
}*/ }
} }

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

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

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

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