Browse Source

提交

master
gwbvipvip 10 months ago
parent
commit
ab8eed329d
9 changed files with 41 additions and 31 deletions
  1. BIN
     
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. BIN
     
  6. +5
    -2
      BPA.KitChen.GroupMeal.Application/Service/Device/DevicePushRecodeServices.cs
  7. +0
    -18
      BPA.KitChen.GroupMeal.Application/Service/Device/Dtos/PushData.cs
  8. +34
    -10
      BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs
  9. +2
    -1
      BPA.KitChen.GroupMeal.Application/Service/Device/Services/IDevicePushRecodeService.cs

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 5
- 2
BPA.KitChen.GroupMeal.Application/Service/Device/DevicePushRecodeServices.cs View File

@@ -1,4 +1,7 @@
using BPA.KitChen.GroupMeal.Application.BaseDto;

using BPA.KitChen.GroupMeal.Application.BaseDto;
using BPA.KitChen.GroupMeal.Application.Service.Device;
using BPA.KitChen.GroupMeal.Application.Service.Device.Dtos;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using System;
@@ -7,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
namespace BPA.KitChen.GroupMeal.Application.Service
{
[ApiDescriptionSettings("DevicePushRecode", Tag = "设备下发")]
public class DevicePushRecodeServices: IDynamicApiController


+ 0
- 18
BPA.KitChen.GroupMeal.Application/Service/Device/Dtos/PushData.cs View File

@@ -1,18 +0,0 @@
using BPA.Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
{
public class PushData: IMessage
{
public object Data { get; set; }
/// <summary>
/// 设备AutoKey
/// </summary>
public int DeviceId { get; set; }
}
}

+ 34
- 10
BPA.KitChen.GroupMeal.Application/Service/Device/Services/DevicePushRecodeService.cs View File

@@ -1,4 +1,6 @@
using BPA.KitChen.GroupMeal.Application.BaseDto;

using BPA.KitChen.GroupMeal.Application.BaseDto;
using BPA.KitChen.GroupMeal.Application.Service.Device.Dtos;
using BPA.KitChen.GroupMeal.Core.Entity;
using BPA.KitChen.GroupMeal.Core.Enum;
using BPA.Message;
@@ -20,7 +22,7 @@ using System.Net.Http.Json;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
namespace BPA.KitChen.GroupMeal.Application.Service.Device
{
public class DevicePushRecodeService: IDevicePushRecodeService, ITransient
{
@@ -29,7 +31,7 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient)
{
_db = db;
_mqttClient = mqttClient;
_mqttClient=mqttClient;
}
/// <summary>
/// 分页
@@ -41,7 +43,7 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
RefAsync<int> total = 0;
var res = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Type == input.Type)
.WhereIF(!string.IsNullOrWhiteSpace(input.DeviceName), x => x.DeviceName.Contains(input.DeviceName))
.WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status) )
.WhereIF(!string.IsNullOrWhiteSpace(input.Status), x => x.Status == (CommonStatus)Convert.ToInt32(input.Status))
.Select(t => new
{
CreateAt = t.CreateAt,
@@ -79,20 +81,42 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
data.Topic= Topic;
data.Status = CommonStatus.ENABLE;
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 == "success" ? CommonStatus.ENABLE : CommonStatus.DISABLE;
await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
return res == "success";
data.DeviceAutoKey= input.DeviceAutoKey;
data.Description = "成功";
if (input.TopicsData.Count > 0)
{
var chaeck = input.TopicsData.Any(x => x.Topics.Trim() == topstr.Trim());
if (!chaeck)
{
data.Status = CommonStatus.DISABLE;
data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置";
}
}
else
{
data.Status = CommonStatus.DISABLE;
data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置";
}
if (data.Status == CommonStatus.ENABLE)
{
var respush = await Push(Topic, new PushData() { Data = data.DataResore, DeviceId = input.DeviceAutoKey });
if (respush != "success")
{
data.Description = respush;
data.Status = CommonStatus.DISABLE;
}
}
var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
return res>0;
}
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 });
data.Description = respush;
if (respush!= "success")
{
data.Description = respush;
data.Status = CommonStatus.DISABLE;
}
var res = await _db.Updateable(data).ExecuteCommandAsync();


+ 2
- 1
BPA.KitChen.GroupMeal.Application/Service/Device/Services/IDevicePushRecodeService.cs View File

@@ -1,12 +1,13 @@

using BPA.KitChen.GroupMeal.Application.BaseDto;
using BPA.KitChen.GroupMeal.Application.Service.Device.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.GroupMeal.Application.Service.Device.Dtos
namespace BPA.KitChen.GroupMeal.Application.Service.Device
{
public interface IDevicePushRecodeService
{


Loading…
Cancel
Save