瀏覽代碼

提交

master
gwbvipvip 8 月之前
父節點
當前提交
997a98ef8b
共有 4 個檔案被更改,包括 34 行新增25 行删除
  1. +2
    -1
      BPA.KitChen.StoreManagement.Application/Service/Device/DevicePushRecodeServices.cs
  2. +0
    -12
      BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs
  3. +31
    -10
      BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs
  4. +1
    -2
      BPA.KitChen.StoreManagement.Application/Service/Device/Services/IDevicePushRecodeService.cs

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

@@ -1,4 +1,5 @@
using BPA.KitChen.StoreManagement.Application.BaseDto;

using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device;
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using Furion.DynamicApiController;


+ 0
- 12
BPA.KitChen.StoreManagement.Application/Service/Device/Dtos/Class1.cs 查看文件

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

namespace BPA.KitChen.StoreManagement.Application.Service.Device.Dtos
{
internal class Class1
{
}
}

+ 31
- 10
BPA.KitChen.StoreManagement.Application/Service/Device/Services/DevicePushRecodeService.cs 查看文件

@@ -1,5 +1,4 @@

using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using BPA.KitChen.StoreManagement.Core.Entity;
using BPA.KitChen.StoreManagement.Core.Enum;
@@ -31,7 +30,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient)
{
_db = db;
_mqttClient = mqttClient;
_mqttClient=mqttClient;
}
/// <summary>
/// 分页
@@ -43,7 +42,7 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
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,
@@ -81,20 +80,42 @@ namespace BPA.KitChen.StoreManagement.Application.Service.Device
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();


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

@@ -1,5 +1,4 @@

using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.BaseDto;
using BPA.KitChen.StoreManagement.Application.Service.Device.Dtos;
using System;
using System.Collections.Generic;


Loading…
取消
儲存