diff --git a/Service/Cloud/Common/CloudConst.cs b/Service/Cloud/Common/CloudConst.cs
index e921ea9..8ea53f1 100644
--- a/Service/Cloud/Common/CloudConst.cs
+++ b/Service/Cloud/Common/CloudConst.cs
@@ -12,6 +12,11 @@ public class CloudConst
//上位机推
+ ///
+ /// 换电就绪主题
+ ///
+ public static readonly string commandSubFind = "truck_topic_command_sub_find_2";
+
///
/// 换电完成指令主题
///
diff --git a/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs b/Service/Cloud/MyTask/ChargeOrderUploadTask.cs
similarity index 88%
rename from Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs
rename to Service/Cloud/MyTask/ChargeOrderUploadTask.cs
index 7da6534..50d8c75 100644
--- a/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs
+++ b/Service/Cloud/MyTask/ChargeOrderUploadTask.cs
@@ -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> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i=> i.ToList());
+ Dictionary> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i => i.ToList());
foreach (var (k, v) in dictionary)
{
//CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1);
diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs
index a2ea725..49b2f7e 100644
--- a/Service/Execute/Api/CloudApi.cs
+++ b/Service/Execute/Api/CloudApi.cs
@@ -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);
}
diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs
index 51bbdfb..e827050 100644
--- a/Service/Execute/Mgr/CommonMgr.cs
+++ b/Service/Execute/Mgr/CommonMgr.cs
@@ -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),
+
});
}
}
\ No newline at end of file
diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs
index 9373703..dbef2d6 100644
--- a/Service/Execute/Step/CarPrepareState.cs
+++ b/Service/Execute/Step/CarPrepareState.cs
@@ -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
};
}
@@ -348,5 +355,34 @@ public class CarPrepareState : IState
}
, false, () => { }, 10, InvokeStatus.None
);
- }
+ }
+
+
+ ///
+ /// 换电就绪上传云平台
+ ///
+ ///
+ ///
+ 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);
+ }
}
\ No newline at end of file
diff --git a/Service/Execute/Step/SwapCanStartState.cs b/Service/Execute/Step/SwapCanStartState.cs
index 0df7caa..61a574c 100644
--- a/Service/Execute/Step/SwapCanStartState.cs
+++ b/Service/Execute/Step/SwapCanStartState.cs
@@ -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
/// 等待云平台下发换电
///
///
- /*public InvokeStatus SwapCanStart(SwappingStateMachine machine)
+ public InvokeStatus SwapCanStart(SwappingStateMachine machine)
{
+
return Invoker.Invoke("check swapCanStart", 1000, 50, machine.IsCanceled,
() => machine.CloudCarCanStartFlag, () =>
{
@@ -55,38 +55,41 @@ public class SwapCanStartState : IState
BaseEnumExtensions.GetEnumByCode(
StaticStationInfo.StationModel))
{
- CarCanStart carCanStart = CloudApi.CarCanStart();
- if (carCanStart != null)
+ // CloudApi.UploadCloudReady(machine.plateNumber);
+ if (machine.swapStart != null)
{
- //车牌号
- if (carCanStart.cn.Equals(machine.BoxCarInfoModel.CarNo))
+ if (machine.swapStart.command == "start")
+ {
+ _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");
+ //语音提示云平台取消换电
+ StationSoftMgr.SwappingStateMachineCancel();
+ machine.CloudCarCanStartFlag = false;
+
+ }
+ else if (machine.swapStart.command == "suspend")
{
- //可以开始换电
- if (carCanStart.cs == 1)
- {
- _log.Info("SwapCanStart ok");
- //更新换电订单
- machine.SwapOrder.CloudSn = carCanStart.on;
- _swapOrderRepository.Update(machine.SwapOrder.CloudSn);
- machine.CloudCarCanStartFlag = true;
-
- _swapOrderStepService.InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep.CloudCarCanStartFlag,
- machine.StepSort++, machine.SwapOrder.Sn);
- }
- else
- {
- _log.Info("SwapCanStart cancel");
- //语音提示云平台取消换电
- 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);
- }
+ _log.Info("SwapCanStart suspend");
+ machine.CloudCarCanStartFlag = false;
+ //语音提示云平台暂停换电
+ }
+ else if (machine.swapStart.command == "continue")
+ {
+ _log.Info("SwapCanStart continue");
+ machine.CloudCarCanStartFlag = true;
+ //语音提示云平台继续换电
}
}
+
+
}
else
{
@@ -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);
- }*/
+ }
}
\ No newline at end of file
diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs
index 0bd1211..a8f3b4a 100644
--- a/Service/Execute/Step/SwapDoneState.cs
+++ b/Service/Execute/Step/SwapDoneState.cs
@@ -79,7 +79,7 @@ public class SwapDoneState : IState
Task.Run(() =>
{
//新增换电成功上报云平台数据
- //_CommonMgr.InsertCloudReportForSwapSuccess(machine);
+ _CommonMgr.InsertCloudReportForSwapSuccess(machine);
//换电成功关于bininfo表的更新
_CommonMgr.UpdateBinInfoForSwapSuccess(machine);
diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs
index f385ebe..77b1be9 100644
--- a/Service/Execute/SwappingStateMachine.cs
+++ b/Service/Execute/SwappingStateMachine.cs
@@ -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连接
diff --git a/Service/Mgr/SwapOrderMgr.cs b/Service/Mgr/SwapOrderMgr.cs
index 02a86b7..73c7923 100644
--- a/Service/Mgr/SwapOrderMgr.cs
+++ b/Service/Mgr/SwapOrderMgr.cs
@@ -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);
}
diff --git a/Service/MyTask/SwapOrderReportCloudTask.cs b/Service/MyTask/SwapOrderReportCloudTask.cs
index d3beca3..e2e4342 100644
--- a/Service/MyTask/SwapOrderReportCloudTask.cs
+++ b/Service/MyTask/SwapOrderReportCloudTask.cs
@@ -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;
///
-/// 充电结束上报云平台task
+/// 换电订单上报云平台task
///
[Scope]
public class SwapOrderReportCloudTask : ITask
@@ -44,7 +45,10 @@ public class SwapOrderReportCloudTask : ITask
}
List
- 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;
}
-}*/
\ No newline at end of file
+}
\ No newline at end of file