现场测试提交

zw
lxw 6 months ago
parent 8e0a780252
commit 7f7a9ad088

@ -237,38 +237,42 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
public void Publish<T>(T data) where T : ICmd public void Publish<T>(T data) where T : ICmd
{ {
Model<T> model = new Model<T> if (MqttClient.IsConnected)
{ {
Header = new Header() Model<T> model = new Model<T>
{ {
cmd = data.GetCmd(), Header = new Header()
cipherFlag = Encrypt, {
id = GetIncrementId(), cmd = data.GetCmd(),
sid = StationNo, cipherFlag = Encrypt,
timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000 id = GetIncrementId(),
}, sid = StationNo,
body = data timeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000
}; },
body = data
};
model.dataSign = "";//SignData(model); model.dataSign = "";//SignData(model);
var settings = new JsonSerializerSettings() var settings = new JsonSerializerSettings()
{ {
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
DateFormatString = "yyyy-MM-dd HH:mm:ss", DateFormatString = "yyyy-MM-dd HH:mm:ss",
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
}; };
Log.Info(JsonConvert.SerializeObject(model, settings)); Log.Info(JsonConvert.SerializeObject(model, settings));
var appMsg = new MqttApplicationMessage var appMsg = new MqttApplicationMessage
{ {
Topic = PubTopic, Topic = PubTopic,
Payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, settings)), Payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, settings)),
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce, QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce,
Retain = false Retain = false
}; };
MqttClient.PublishAsync(appMsg); MqttClient.PublishAsync(appMsg);
MqttClient.PublishAsync(appMsg); MqttClient.PublishAsync(appMsg);
}
} }
private string SignData<T>(Model<T> model) where T : ICmd private string SignData<T>(Model<T> model) where T : ICmd

@ -57,7 +57,7 @@ public abstract class CloudApi
UploadSwapOrder uploadSwapOrder = new() UploadSwapOrder uploadSwapOrder = new()
{ {
sn=StaticStationInfo.StationNo, sn=StaticStationInfo.StationNo,
son = swapOrder.CloudSn, son = swapOrder.Sn,
cn = swapOrder.VehicleNo, cn = swapOrder.VehicleNo,
so = seq, so = seq,
ct = swapOrder.VehicleEnterTime, ct = swapOrder.VehicleEnterTime,

@ -91,7 +91,12 @@ public class TBoxApi
{ {
Thread.Sleep(100); Thread.Sleep(100);
var unLockCar = await UnLockCar(carNo); var unLockCar = await UnLockCar(carNo);
bools.Add(unLockCar); if (unLockCar)
{
bools.Add(unLockCar);
}
} }
return bools.Select(i => i).Count() > _successTimes; return bools.Select(i => i).Count() > _successTimes;
@ -105,7 +110,11 @@ public class TBoxApi
{ {
Thread.Sleep(100); Thread.Sleep(100);
var unLockCar = await LockCar(carNo); var unLockCar = await LockCar(carNo);
bools.Add(unLockCar); if (unLockCar)
{
bools.Add(unLockCar);
}
} }
return bools.Select(i => i).Count() > _successTimes; return bools.Select(i => i).Count() > _successTimes;

Loading…
Cancel
Save