diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs index 2d499b2..3688969 100644 --- a/Service/Cloud/Client/CloudClient.cs +++ b/Service/Cloud/Client/CloudClient.cs @@ -237,38 +237,42 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR public void Publish(T data) where T : ICmd { - Model model = new Model + if (MqttClient.IsConnected) { - Header = new Header() + Model model = new Model { - cmd = data.GetCmd(), - cipherFlag = Encrypt, - id = GetIncrementId(), - sid = StationNo, - timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000 - }, - body = data - }; + Header = new Header() + { + cmd = data.GetCmd(), + cipherFlag = Encrypt, + id = GetIncrementId(), + sid = StationNo, + timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000 + }, + body = data + }; - model.dataSign = "";//SignData(model); + model.dataSign = "";//SignData(model); - var settings = new JsonSerializerSettings() - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DateFormatString = "yyyy-MM-dd HH:mm:ss", - NullValueHandling = NullValueHandling.Ignore - }; - Log.Info(JsonConvert.SerializeObject(model, settings)); - var appMsg = new MqttApplicationMessage - { - Topic = PubTopic, - Payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, settings)), - QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce, - Retain = false - }; + var settings = new JsonSerializerSettings() + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DateFormatString = "yyyy-MM-dd HH:mm:ss", + NullValueHandling = NullValueHandling.Ignore + }; + Log.Info(JsonConvert.SerializeObject(model, settings)); + var appMsg = new MqttApplicationMessage + { + Topic = PubTopic, + Payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, settings)), + QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce, + Retain = false + }; - MqttClient.PublishAsync(appMsg); - MqttClient.PublishAsync(appMsg); + MqttClient.PublishAsync(appMsg); + MqttClient.PublishAsync(appMsg); + } + } private string SignData(Model model) where T : ICmd diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs index 1ef9d97..636cb15 100644 --- a/Service/Execute/Api/CloudApi.cs +++ b/Service/Execute/Api/CloudApi.cs @@ -57,7 +57,7 @@ public abstract class CloudApi UploadSwapOrder uploadSwapOrder = new() { sn=StaticStationInfo.StationNo, - son = swapOrder.CloudSn, + son = swapOrder.Sn, cn = swapOrder.VehicleNo, so = seq, ct = swapOrder.VehicleEnterTime, diff --git a/Service/Execute/Api/TboxApi.cs b/Service/Execute/Api/TboxApi.cs index 9019585..203fff4 100644 --- a/Service/Execute/Api/TboxApi.cs +++ b/Service/Execute/Api/TboxApi.cs @@ -91,7 +91,12 @@ public class TBoxApi { Thread.Sleep(100); var unLockCar = await UnLockCar(carNo); - bools.Add(unLockCar); + if (unLockCar) + { + + bools.Add(unLockCar); + } + } return bools.Select(i => i).Count() > _successTimes; @@ -105,7 +110,11 @@ public class TBoxApi { Thread.Sleep(100); var unLockCar = await LockCar(carNo); - bools.Add(unLockCar); + if (unLockCar) + { + + bools.Add(unLockCar); + } } return bools.Select(i => i).Count() > _successTimes;