Browse Source

提交

master
gwbvipvip 11 months ago
parent
commit
11a9e63ce6
5 changed files with 23 additions and 9 deletions
  1. BIN
     
  2. BIN
     
  3. +0
    -4
      BPA.KitChen.GroupMeal.Application/BPA.KitChen.GroupMeal.Application.csproj
  4. +22
    -5
      BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs
  5. +1
    -0
      BPA.KitChen.GroupMeal.Core/Entity/BPA_DevicePushRecode.cs

BIN
View File


BIN
View File


+ 0
- 4
BPA.KitChen.GroupMeal.Application/BPA.KitChen.GroupMeal.Application.csproj View File

@@ -7,10 +7,6 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.105" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPA.KitChen.GroupMeal.Core\BPA.KitChen.GroupMeal.Core.csproj" />
<ProjectReference Include="..\BPA.KitChen.GroupMeal.SqlSugar\BPA.KitChen.GroupMeal.SqlSugar.csproj" />


+ 22
- 5
BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs View File

@@ -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)


+ 1
- 0
BPA.KitChen.GroupMeal.Core/Entity/BPA_DevicePushRecode.cs View File

@@ -20,6 +20,7 @@ namespace BPA.KitChen.GroupMeal.Core.Entity
public int Type { get; set; }
public string GroupId { get; set; }
public string Topic { get; set; }
[SugarColumn(ColumnDataType = "varchar(1000)")]
public string DataResore { get; set; }
}
}

Loading…
Cancel
Save