浏览代码

提交

master
gwbvipvip 10 个月前
父节点
当前提交
b369f3a6fc
共有 9 个文件被更改,包括 39 次插入6 次删除
  1. 二进制
     
  2. 二进制
     
  3. 二进制
     
  4. 二进制
     
  5. 二进制
     
  6. +12
    -1
      BPA.KitChen.GroupMeal.Application/Service/Device/DevicePushRecodeServices.cs
  7. +22
    -5
      BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs
  8. +2
    -0
      BPA.KitChen.GroupMeal.Application/Service/Device/Services/IDevicePushRecodeService.cs
  9. +3
    -0
      BPA.KitChen.GroupMeal.Core/Entity/BPA_DevicePushRecode.cs

二进制
查看文件


二进制
查看文件


二进制
查看文件


二进制
查看文件


二进制
查看文件


+ 12
- 1
BPA.KitChen.GroupMeal.Application/Service/Device/DevicePushRecodeServices.cs 查看文件

@@ -37,7 +37,18 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
{
return await _devicePushRecodeService.Add(input);
}

/// <summary>
/// 修改
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/devicepushrecode/update")]
public async Task<bool> Update(string id)
{
return await _devicePushRecodeService.Update(id);
}

/// <summary>
/// 删除
/// </summary>


+ 22
- 5
BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs 查看文件

@@ -72,11 +72,28 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
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 });
data.Status = res ? CommonStatus.ENABLE : CommonStatus.DISABLE;
data.Status = res == "success" ? CommonStatus.ENABLE : CommonStatus.DISABLE;
await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
return res;
return res == "success";
}

public async Task<bool> Update(string id)
{
var data = _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Id == id).First();
data.Status = CommonStatus.ENABLE;
var respush = await Push(data.Topic, new PushData() { Data = data.DataResore, DeviceId = data.DeviceAutoKey });
if (respush != "success")
{
data.Description = respush;
data.Status = CommonStatus.DISABLE;
}
var res = await _db.Updateable(data).ExecuteCommandAsync();
return res > 0;
}



/// <summary>
/// 删除
/// </summary>
@@ -97,7 +114,7 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
throw Oops.Oh("删除失败");
}
}
private async Task<bool> Push(string Topic,PushData data)
private async Task<string> Push(string Topic,PushData data)
{
try
{
@@ -117,11 +134,11 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
//string aa = bPAPackage.Serialize(false);
var applictionmessage = new MqttApplicationMessageBuilder().WithTopic(Topic).WithPayload(bPAPackage.Serialize(false)).WithAtLeastOnceQoS().Build();
await _mqttClient.PublishAsync(applictionmessage);
return true;
return "success";
}
catch (Exception e)
{
throw Oops.Oh("下发错误,错误信息:"+e.Message);
return "下发错误,错误信息:" + e.Message;
}
}
private string GetTopic(int type,string deviceKey)


+ 2
- 0
BPA.KitChen.GroupMeal.Application/Service/Device/Services/IDevicePushRecodeService.cs 查看文件

@@ -22,6 +22,8 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
/// <returns></returns>
Task<bool> Add(DevicePushRecodeDtoInput input);


Task<bool> Update(string id);
/// <summary>
/// 删除
/// </summary>


+ 3
- 0
BPA.KitChen.GroupMeal.Core/Entity/BPA_DevicePushRecode.cs 查看文件

@@ -22,5 +22,8 @@ namespace BPA.KitChen.GroupMeal.Core.Entity
public string Topic { get; set; }
[SugarColumn(ColumnDataType = "varchar(1000)")]
public string DataResore { get; set; }

public int DeviceAutoKey { get; set; }
public string Description { get; set; }
}
}

正在加载...
取消
保存