Browse Source

提交

master
gwbvipvip 10 months ago
parent
commit
b369f3a6fc
9 changed files with 39 additions and 6 deletions
  1. BIN
     
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. BIN
     
  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

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 12
- 1
BPA.KitChen.GroupMeal.Application/Service/Device/DevicePushRecodeServices.cs View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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; }
}
}

Loading…
Cancel
Save