|
|
@@ -3,6 +3,7 @@ using BPA.KitChen.GroupMeal.Application.Service.OneCard.Gate; |
|
|
|
using BPA.KitChen.GroupMeal.Core.Entity; |
|
|
|
using BPA.KitChen.GroupMeal.SqlSugar; |
|
|
|
using BPA.Message; |
|
|
|
using BPA.Message.API请求; |
|
|
|
using BPA.Message.IOT; |
|
|
|
using BPA.SAAS.KitChenManage.Application.Device.Dtos; |
|
|
|
using Furion.DependencyInjection; |
|
|
@@ -77,12 +78,13 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Services |
|
|
|
[HttpPost("/api/devicepushrecode/add")] |
|
|
|
public async Task<bool> Add(DevicePushRecodeDtoInput input) |
|
|
|
{ |
|
|
|
|
|
|
|
var data = input.Adapt<BPA_DevicePushRecode>(); |
|
|
|
string Topic = GetTopic(input.Type, input.DeviceAutoKey.ToString()); |
|
|
|
if (string.IsNullOrEmpty(Topic)) throw Oops.Oh("请配置相关topic"); |
|
|
|
data.Topic= Topic; |
|
|
|
data.DataResore = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<dynamic>(input.Data.ToString())); |
|
|
|
var res=await Push(Topic, new PushData() { Data=input.Data, DeviceId= input.DeviceAutoKey }); |
|
|
|
var res = await Push(Topic, new PushData() { Data = input.Data, DeviceId = input.DeviceAutoKey }); |
|
|
|
if (res) |
|
|
|
{ |
|
|
|
await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); |
|
|
@@ -116,7 +118,8 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Services |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Topic = TOPIC.GetInstance.GetBusinessTopic(x, storeInfo.FirstOrDefault(a => a.Id == item.OrgId).AutoKey) + "/" + item.AutoKey; |
|
|
|
BPAPackage bPAPackage = new BPAPackage |
|
|
|
{ |
|
|
@@ -129,9 +132,23 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Services |
|
|
|
}; |
|
|
|
//每次下发暂停200毫秒 by 王刚 2022-06-08 测试提出修改 |
|
|
|
// Thread.Sleep(200); |
|
|
|
//string aa = bPAPackage.Serialize(false); |
|
|
|
var applictionmessage = new MqttApplicationMessageBuilder().WithTopic(Topic).WithPayload(bPAPackage.Serialize(false)).WithAtLeastOnceQoS().Build(); |
|
|
|
await _mqttClient.PublishAsync(applictionmessage); |
|
|
|
string aa = bPAPackage.Serialize(false); |
|
|
|
|
|
|
|
var thisData = new |
|
|
|
{ |
|
|
|
MessageId = MessageID.TMC_PUSH_INGREDIENTS, |
|
|
|
ClientId = data.DeviceId, |
|
|
|
//ClientType = Procuct |
|
|
|
MessageVersion = 0x30, |
|
|
|
Timestamp = DateTime.Now, |
|
|
|
Message = data.Data.ToString() |
|
|
|
}; |
|
|
|
|
|
|
|
var applictionmessage = new MqttApplicationMessageBuilder() |
|
|
|
.WithTopic(Topic) |
|
|
|
.WithPayload(JsonConvert.SerializeObject(thisData)) |
|
|
|
.WithAtLeastOnceQoS().Build(); |
|
|
|
await _mqttClient.PublishAsync(applictionmessage); |
|
|
|
return true; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|