@@ -19,6 +19,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Message" Version="1.0.105" /> | <PackageReference Include="BPA.Message" Version="1.0.105" /> | ||||
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | <PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | ||||
<PackageReference Include="Longbow.Tasks" Version="8.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -161,6 +161,14 @@ | |||||
<param name="input"></param> | <param name="input"></param> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </member> | ||||
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.CallBackDevicePushRecode(System.String,System.String)"> | |||||
<summary> | |||||
数据下发回调更新数据 | |||||
</summary> | |||||
<param name="messageId"></param> | |||||
<param name="groupId"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Delete(System.Collections.Generic.List{System.String})"> | <member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Delete(System.Collections.Generic.List{System.String})"> | ||||
<summary> | <summary> | ||||
删除 | 删除 | ||||
@@ -457,11 +465,72 @@ | |||||
属性值 | 属性值 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:BPA.SAAS.KitChenManage.Application.Push.Comm.MqttServer.Publish(System.String,BPA.SAAS.KitChenManage.Application.Device.Dtos.PushData,System.Int32)"> | |||||
<summary> | |||||
发布mq(发送数据) | |||||
</summary> | |||||
<param name="Topic"></param> | |||||
<param name="data"></param> | |||||
<param name="MessageId"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:BPA.SAAS.KitChenManage.Application.Push.Comm.MqttServer.Subscribe(System.String)"> | |||||
<summary> | |||||
订阅,mq | |||||
</summary> | |||||
<param name="topic"></param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData"> | <member name="T:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData"> | ||||
<summary> | <summary> | ||||
产品下发数据格式定义 | 产品下发数据格式定义 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.BatchingPushTopics"> | |||||
<summary> | |||||
物料下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.BatchingPushTopics_reply"> | |||||
<summary> | |||||
响应物料下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.TechnologyPushTopics"> | |||||
<summary> | |||||
工艺下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.TechnologyPushTopics_reply"> | |||||
<summary> | |||||
响应工艺下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.GoodsPushTopics"> | |||||
<summary> | |||||
商品下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.GoodsPushTopics_reply"> | |||||
<summary> | |||||
响应商品下发topics | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.BatchingData"> | |||||
<summary> | |||||
物料下发服务参数格式 | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.GoodsData"> | |||||
<summary> | |||||
商品下发服务参数格式 | |||||
</summary> | |||||
</member> | |||||
<member name="F:BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.ProductFunctionData.TechnologyData"> | |||||
<summary> | |||||
工艺下发服务参数格式 | |||||
</summary> | |||||
</member> | |||||
<member name="M:BPA.SAAS.KitChenManage.Application.Store.Services.IStoreService.Page(BPA.SAAS.KitChenManage.Application.Store.Dtos.StoreDtoPageInput)"> | <member name="M:BPA.SAAS.KitChenManage.Application.Store.Services.IStoreService.Page(BPA.SAAS.KitChenManage.Application.Store.Dtos.StoreDtoPageInput)"> | ||||
<summary> | <summary> | ||||
分页 | 分页 | ||||
@@ -537,6 +606,12 @@ | |||||
</summary> | </summary> | ||||
<returns></returns> | <returns></returns> | ||||
</member> | </member> | ||||
<member name="M:BPA.SAAS.KitChenManage.Application.Store.StoreServices.GetStoreList_alm"> | |||||
<summary> | |||||
查询所有店铺(外部调用) | |||||
</summary> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:BPA.SAAS.KitChenManage.Application.Store.StoreServices.Add(BPA.SAAS.KitChenManage.Application.Store.Dtos.StoreDtoInput)"> | <member name="M:BPA.SAAS.KitChenManage.Application.Store.StoreServices.Add(BPA.SAAS.KitChenManage.Application.Store.Dtos.StoreDtoInput)"> | ||||
<summary> | <summary> | ||||
添加 | 添加 | ||||
@@ -2,23 +2,29 @@ | |||||
using BPA.Message.IOT; | using BPA.Message.IOT; | ||||
using BPA.SAAS.KitChenManage.Application.Device.Dtos; | using BPA.SAAS.KitChenManage.Application.Device.Dtos; | ||||
using BPA.SAAS.KitChenManage.Application.Push.Comm; | using BPA.SAAS.KitChenManage.Application.Push.Comm; | ||||
using BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.Dto; | |||||
using BPA.SAAS.KitChenManage.Application.Store.Dtos; | using BPA.SAAS.KitChenManage.Application.Store.Dtos; | ||||
using BPA.SAAS.KitChenManage.Comm.Const; | using BPA.SAAS.KitChenManage.Comm.Const; | ||||
using BPA.SAAS.KitChenManage.Core.Base; | using BPA.SAAS.KitChenManage.Core.Base; | ||||
using BPA.SAAS.KitChenManage.Core.Model; | using BPA.SAAS.KitChenManage.Core.Model; | ||||
using Furion.LinqBuilder; | using Furion.LinqBuilder; | ||||
using Furion.RemoteRequest.Extensions; | using Furion.RemoteRequest.Extensions; | ||||
using Longbow.Tasks; | |||||
using Microsoft.CodeAnalysis.Operations; | using Microsoft.CodeAnalysis.Operations; | ||||
using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||
using MQTTnet; | using MQTTnet; | ||||
using MQTTnet.Client; | using MQTTnet.Client; | ||||
using MQTTnet.Client.Subscribing; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Net.Http.Json; | using System.Net.Http.Json; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
using System.Text.RegularExpressions; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using uPLibrary.Networking.M2Mqtt; | |||||
namespace BPA.SAAS.KitChenManage.Application.Device.Services | namespace BPA.SAAS.KitChenManage.Application.Device.Services | ||||
{ | { | ||||
@@ -26,11 +32,13 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services | |||||
{ | { | ||||
private readonly ISqlSugarClient _db; | private readonly ISqlSugarClient _db; | ||||
private readonly IMqttClient _mqttClient; | private readonly IMqttClient _mqttClient; | ||||
CommDefaultHandle requestParmsHeadlen = new(); | |||||
CommDefaultHandle commDefaultHandle = new(); | |||||
MqttServer mqttServer; | |||||
public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient) | public DevicePushRecodeService(ISqlSugarClient db, IMqttClient mqttClient) | ||||
{ | { | ||||
_db = db; | _db = db; | ||||
_mqttClient=mqttClient; | _mqttClient=mqttClient; | ||||
mqttServer = new(mqttClient); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 分页 | /// 分页 | ||||
@@ -55,6 +63,10 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services | |||||
DataResore=t.DataResore, | DataResore=t.DataResore, | ||||
Status=t.Status, | Status=t.Status, | ||||
Description=t.Description, | Description=t.Description, | ||||
MessageId=t.MessageId, | |||||
TopicRely=t.TopicRely, | |||||
DataResoreRely=t.DataResoreRely, | |||||
DescriptionRely=t.DescriptionRely, | |||||
}).OrderBy(x => x.CreateAt, OrderByType.Desc).ToPageListAsync(input.Current, input.PageSize, total); | }).OrderBy(x => x.CreateAt, OrderByType.Desc).ToPageListAsync(input.Current, input.PageSize, total); | ||||
PageUtil util = new PageUtil() | PageUtil util = new PageUtil() | ||||
{ | { | ||||
@@ -71,55 +83,77 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> Add(DevicePushRecodeDtoInput input) | public async Task<bool> Add(DevicePushRecodeDtoInput input) | ||||
{ | { | ||||
var DataResore =await requestParmsHeadlen.GetParm(input.Type, input.Data.ToString(), input.DeviceId, input.ProductName, input.ProductVersion); | |||||
var data = input.Adapt<BPA_DevicePushRecode>(); | var data = input.Adapt<BPA_DevicePushRecode>(); | ||||
string topstr = ""; | |||||
string Topic = GetTopic(input.Type, input.DeviceAutoKey.ToString(), input.ProductVersion, input.ProductKey, out topstr); | |||||
var DataResore =await commDefaultHandle.GetParm(input.Type, input.Data.ToString(), input.DeviceId, input.ProductName, input.ProductVersion, input.DeviceAutoKey.ToString()); | |||||
if(DataResore==null) throw Oops.Oh("解析参数失败"); | |||||
string Topic = DataResore.TopicsStr; | |||||
if (string.IsNullOrEmpty(Topic)) throw Oops.Oh("请配置相关topic"); | if (string.IsNullOrEmpty(Topic)) throw Oops.Oh("请配置相关topic"); | ||||
var maxmessageId=_db.Queryable<BPA_DevicePushRecode>().Max(x => x.MessageId); | |||||
int messageId = maxmessageId+1; | |||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
data.Topic= Topic; | data.Topic= Topic; | ||||
data.Status = 1; | |||||
data.DataResore = JsonConvert.SerializeObject(DataResore); | |||||
data.Status = 0; | |||||
data.DataResore = JsonConvert.SerializeObject(DataResore.Data); | |||||
data.DeviceAutoKey= input.DeviceAutoKey; | 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 =2; | |||||
data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置"; | |||||
} | |||||
} | |||||
else | |||||
data.Description = "下发中,等待设备响应"; | |||||
data.MessageId= messageId; | |||||
data.TopicRely = DataResore.TopicsStrRely; | |||||
data.DescriptionRely = "等待回调"; | |||||
var respush = await mqttServer.Publish(Topic, new PushData() { Data = data.DataResore, DeviceId = input.DeviceAutoKey }, messageId); | |||||
if (respush != "success") | |||||
{ | { | ||||
data.Description = respush; | |||||
data.Status = 2; | data.Status = 2; | ||||
data.Description = "下发数据失败,该产品还未配置对应的topic,请联系管理员进行配置"; | |||||
} | } | ||||
if (data.Status == 1) | |||||
{ | |||||
var respush = await Push(Topic, new PushData() { Data = data.DataResore, DeviceId = input.DeviceAutoKey }); | |||||
if (respush != "success") | |||||
{ | |||||
data.Description = respush; | |||||
data.Status =2; | |||||
} | |||||
} | |||||
// return true; | |||||
var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); | var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); | ||||
//周期性任务 (10 秒后执行1次任务) | |||||
var trigger = TriggerBuilder.Default.WithInterval(TimeSpan.FromSeconds(10)).WithRepeatCount(1).Build(); | |||||
TaskServicesManager.GetOrAdd(messageId.ToString(), async (provider, token) => { | |||||
await CallBackDevicePushRecode(messageId.ToString(), groupId); | |||||
}, trigger); | |||||
//订阅回复数据下发topics | |||||
await mqttServer.Subscribe(DataResore.TopicsStrRely); | |||||
await BindMqReceived(messageId.ToString(), groupId); | |||||
return res>0; | return res>0; | ||||
} | } | ||||
/// <summary> | |||||
/// 数据下发回调更新数据 | |||||
/// </summary> | |||||
/// <param name="messageId"></param> | |||||
/// <param name="groupId"></param> | |||||
/// <returns></returns> | |||||
public async Task CallBackDevicePushRecode(string messageId,string groupId) | |||||
{ | |||||
var model = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.MessageId.ToString() == messageId.ToString() && x.GroupId == groupId).FirstAsync(); | |||||
if (model.Status == 0) | |||||
{ | |||||
model.Status = 1; | |||||
model.Description = "下发成功,设备未回调"; | |||||
model.DescriptionRely = "响应数据失败"; | |||||
_db.Updateable(model).ExecuteCommand(); | |||||
} | |||||
} | |||||
public async Task<bool> Update(string id) | public async Task<bool> Update(string id) | ||||
{ | { | ||||
var data = _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Id == id).First(); | var data = _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Id == id).First(); | ||||
data.Status = 1; | |||||
var respush = await Push(data.Topic, new PushData() { Data = data.DataResore, DeviceId = data.DeviceAutoKey }); | |||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
data.Status = 0; | |||||
data.Description = "下发中,等待设备响应"; | |||||
data.DescriptionRely = "等待回调"; | |||||
data.DataResoreRely = ""; | |||||
// data.MessageId= messageId; | |||||
var respush = await mqttServer.Publish(data.Topic, new PushData() { Data = data.DataResore, DeviceId = data.DeviceAutoKey }, data.MessageId); | |||||
if (respush!= "success") | if (respush!= "success") | ||||
{ | { | ||||
data.Description = respush; | data.Description = respush; | ||||
data.Status = 2; | data.Status = 2; | ||||
} | } | ||||
var res = await _db.Updateable(data).ExecuteCommandAsync(); | var res = await _db.Updateable(data).ExecuteCommandAsync(); | ||||
var trigger = TriggerBuilder.Default.WithInterval(TimeSpan.FromSeconds(10)).WithRepeatCount(1).Build(); | |||||
TaskServicesManager.GetOrAdd(data.MessageId.ToString(), async (provider, token) => { | |||||
await CallBackDevicePushRecode(data.MessageId.ToString(), groupId); | |||||
}, trigger); | |||||
await BindMqReceived(data.MessageId.ToString(), groupId); | |||||
return res > 0; | return res > 0; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -142,53 +176,49 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services | |||||
throw Oops.Oh("删除失败"); | throw Oops.Oh("删除失败"); | ||||
} | } | ||||
} | } | ||||
private async Task<string> Push(string Topic,PushData data) | |||||
private async Task BindMqReceived(string messageId,string groupId) | |||||
{ | { | ||||
try | |||||
_mqttClient.UseApplicationMessageReceivedHandler(async e => | |||||
{ | { | ||||
// Topic = TOPIC.GetInstance.GetBusinessTopic(x, storeInfo.FirstOrDefault(a => a.Id == item.OrgId).AutoKey) + "/" + item.AutoKey; | |||||
BPAPackage bPAPackage = new BPAPackage | |||||
var model = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.MessageId.ToString() == messageId.ToString() && x.GroupId == groupId).FirstAsync(); | |||||
if (model != null && model.Status == 0) | |||||
{ | { | ||||
MessageId = MessageID.TMC_PUSH_INGREDIENTS, | |||||
ClientId = data.DeviceId, | |||||
//ClientType = Procuct | |||||
MessageVersion = 0x30, | |||||
Timestamp = DateTime.Now, | |||||
Message = data | |||||
}; | |||||
//每次下发暂停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); | |||||
return "success"; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return "下发错误,错误信息:" + e.Message; | |||||
} | |||||
} | |||||
private string GetTopic(int type,string deviceKey, string productVersion, string productKey,out string topstr ) | |||||
{ | |||||
string topic = ""; | |||||
topstr = ""; | |||||
switch (type) | |||||
{ | |||||
case 1: //商品下发 | |||||
topic = $"/{productKey}/{productVersion}/{deviceKey}/defaul/goodspush"; | |||||
topstr = "/"+productKey+"/"+productVersion+"/${deviceKey}/defaul/goodspush"; | |||||
break; | |||||
case 2://物料下发 | |||||
topic = $"/{productKey}/{productVersion}/{deviceKey}/defaul/batvhingpush"; | |||||
topstr = "/" + productKey + "/" + productVersion + "/${deviceKey}/defaul/batvhingpush"; | |||||
break; | |||||
case 4: | |||||
topic = $"/{productKey}/{productVersion}/{deviceKey}/defaul/chnologypush"; | |||||
topstr = "/" + productKey + "/" + productVersion + "/${deviceKey}/defaul/chnologypush"; | |||||
break; | |||||
} | |||||
return topic; | |||||
var str = Encoding.UTF8.GetString(e.ApplicationMessage.Payload ?? Array.Empty<byte>()).Replace("\r", "").Replace("\n", "").Replace("\t", ""); | |||||
model.DataResoreRely = str; | |||||
model.Description = "下发成功,设备已回调"; | |||||
try | |||||
{ | |||||
var re = JsonConvert.DeserializeObject<ReplyBaseDto>(str); | |||||
if (re.MessageId != messageId.ToString()) | |||||
{ | |||||
model = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.MessageId.ToString() == re.MessageId && x.GroupId == groupId).FirstAsync(); | |||||
model.DataResoreRely = str; | |||||
model.Description = "下发成功,设备已回调"; | |||||
} | |||||
if (model != null) | |||||
{ | |||||
if (re.Success) | |||||
{ | |||||
model.Status = 1; | |||||
model.DescriptionRely = "回调成功"; | |||||
} | |||||
else | |||||
{ | |||||
model.Status = 1; | |||||
model.DescriptionRely = re.Errors; | |||||
} | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
model.Status = 1; | |||||
model.Description = "下发成功"; | |||||
model.DescriptionRely = "响应数据异常,异常信息:" + ex.Message; | |||||
} | |||||
_db.Updateable(model).ExecuteCommand(); | |||||
} | |||||
}); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,9 +1,9 @@ | |||||
using BPA.Message; | using BPA.Message; | ||||
using BPA.SAAS.KitChenManage.Application.Device.PushDto.ProductFunction; | using BPA.SAAS.KitChenManage.Application.Device.PushDto.ProductFunction; | ||||
using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto; | |||||
using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.Batching; | using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.Batching; | ||||
using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.Goods; | using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.Goods; | ||||
using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.GoodsTechnology; | using BPA.SAAS.KitChenManage.Application.Push.Comm.Dto.GoodsTechnology; | ||||
using BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1; | |||||
using BPA.SAAS.KitChenManage.Comm.Const; | using BPA.SAAS.KitChenManage.Comm.Const; | ||||
using BPA.SAAS.KitChenManage.Core.Base; | using BPA.SAAS.KitChenManage.Core.Base; | ||||
using Furion.JsonSerialization; | using Furion.JsonSerialization; | ||||
@@ -25,28 +25,36 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm | |||||
public class CommDefaultHandle | public class CommDefaultHandle | ||||
{ | { | ||||
private string BaseServerUrl = App.GetConfig<string>("baseurl"); | private string BaseServerUrl = App.GetConfig<string>("baseurl"); | ||||
public async Task<dynamic> GetParm(int type, string data, string deviceId,string productName, string productVersion) | |||||
public async Task<BaseParmDto> GetParm(int type, string data, string deviceId,string productName, string productVersion, string deviceAutoKey) | |||||
{ | { | ||||
string strTopics = ""; | |||||
string TopicsStrRely = ""; | |||||
dynamic obj = null; | dynamic obj = null; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case 1: //商品下发 | case 1: //商品下发 | ||||
var GoodsData = GetProduct_VersionData(productName, productVersion, "GoodsData"); | |||||
if (string.IsNullOrWhiteSpace(GoodsData)) throw Oops.Oh("系统还未开发【产品名称:" + productName + "-版本号:" + productVersion + "】的商品数据下发功能"); | |||||
var GoodsData = GetProduct_VersionData(productName, productVersion, "GoodsData"); ;//获取对应版本的下发数据参数 | |||||
strTopics = GetProduct_VersionData(productName, productVersion, "GoodsPushTopics").Replace("${deviceKey}", deviceAutoKey); //获取对应版本的下发topics | |||||
TopicsStrRely = GetProduct_VersionData(productName, productVersion, "GoodsPushTopics_reply").Replace("${deviceKey}", deviceAutoKey);//获取对应版本的下发topics | |||||
if (string.IsNullOrWhiteSpace(GoodsData)) throw Oops.Oh("系统还未开发【产品名称:" + productName + " 版本号:" + productVersion + "】的商品数据下发功能"); | |||||
obj = await GetGoods(data, GoodsData); | obj = await GetGoods(data, GoodsData); | ||||
break; | break; | ||||
case 2://物料下发 | case 2://物料下发 | ||||
var BatchingData = GetProduct_VersionData(productName, productVersion, "BatchingData"); | |||||
if (string.IsNullOrWhiteSpace(BatchingData)) throw Oops.Oh("系统还未开发【产品名称:"+ productName + "-版本号:"+ productVersion + "】的物料数据下发功能"); | |||||
var BatchingData = GetProduct_VersionData(productName, productVersion, "BatchingData");//获取对应版本的下发数据参数 | |||||
strTopics = GetProduct_VersionData(productName, productVersion, "BatchingPushTopics").Replace("${deviceKey}", deviceAutoKey);//获取对应版本的下发topics | |||||
TopicsStrRely= GetProduct_VersionData(productName, productVersion, "BatchingPushTopics_reply").Replace("${deviceKey}", deviceAutoKey);//获取对应版本的下发topics | |||||
if (string.IsNullOrWhiteSpace(BatchingData)) throw Oops.Oh("系统还未开发【产品名称:"+ productName + " 版本号:"+ productVersion + "】的物料数据下发功能"); | |||||
obj = await GetBatching(data, BatchingData); | obj = await GetBatching(data, BatchingData); | ||||
break; | break; | ||||
case 4: | |||||
var TechnologyData = GetProduct_VersionData(productName, productVersion, "TechnologyData"); | |||||
if (string.IsNullOrWhiteSpace(TechnologyData)) throw Oops.Oh("系统还未开发【产品名称:" + productName + "-版本号:" + productVersion + "】的工艺数据下发功能"); | |||||
case 4://工艺下发 | |||||
var TechnologyData = GetProduct_VersionData(productName, productVersion, "TechnologyData"); ;//获取对应版本的下发数据参数 | |||||
strTopics = GetProduct_VersionData(productName, productVersion, "TechnologyPushTopics").Replace("${deviceKey}", deviceAutoKey);//获取对应版本的下发topics | |||||
TopicsStrRely = GetProduct_VersionData(productName, productVersion, "TechnologyPushTopics_reply").Replace("${deviceKey}", deviceAutoKey);//获取对应版本的下发topics | |||||
if (string.IsNullOrWhiteSpace(TechnologyData)) throw Oops.Oh("系统还未开发【产品名称:" + productName + " 版本号:" + productVersion + "】的工艺数据下发功能"); | |||||
obj = await GetGoodsTechnology(data, deviceId, TechnologyData); | obj = await GetGoodsTechnology(data, deviceId, TechnologyData); | ||||
break; | break; | ||||
} | } | ||||
return obj; | |||||
return new BaseParmDto() {Data= obj,TopicsStr= strTopics,TopicsStrRely= TopicsStrRely }; | |||||
} | } | ||||
private async Task<dynamic> GetGoods(string data, string productFunctionData) | private async Task<dynamic> GetGoods(string data, string productFunctionData) | ||||
{ | { | ||||
@@ -201,6 +209,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 映射数据 | /// 映射数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -266,8 +275,9 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm | |||||
/// <returns></returns> | /// <returns></returns> | ||||
private string GetProduct_VersionData(string productName, string productVersion,string attrubiteName) | private string GetProduct_VersionData(string productName, string productVersion,string attrubiteName) | ||||
{ | { | ||||
string namespaceName = "BPA.SAAS.KitChenManage.Application.Push."+ productName + "_"+ productVersion; // 要查询的命名空间名称 | |||||
Assembly assembly = typeof(CommDefaultHandle).Assembly; // 当前程序集(或者其他需要查询的程序集) | |||||
//判断当前产品版本是否存在下发数据格式定义的类 如果存在则根据属性取出里面定义的数据格式 | |||||
string namespaceName = "BPA.SAAS.KitChenManage.Application.Push."+ productName + "_"+ productVersion; | |||||
Assembly assembly = typeof(CommDefaultHandle).Assembly; | |||||
Type[] typesInNamespace = assembly.GetTypes().Where(t => t.Namespace == namespaceName).ToArray(); | Type[] typesInNamespace = assembly.GetTypes().Where(t => t.Namespace == namespaceName).ToArray(); | ||||
var value = ""; | var value = ""; | ||||
foreach (Type type in typesInNamespace) | foreach (Type type in typesInNamespace) | ||||
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.KitChenManage.Application.Push.Comm.Dto | |||||
{ | |||||
public class BaseParmDto | |||||
{ | |||||
public dynamic Data { get; set; } | |||||
public string TopicsStr { get; set; } | |||||
public string TopicsStrRely { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,103 @@ | |||||
using BPA.Message; | |||||
using BPA.SAAS.KitChenManage.Application.Device.Dtos; | |||||
using MQTTnet.Client.Subscribing; | |||||
using MQTTnet; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using MQTTnet.Client; | |||||
using uPLibrary.Networking.M2Mqtt; | |||||
namespace BPA.SAAS.KitChenManage.Application.Push.Comm | |||||
{ | |||||
public class MqttServer | |||||
{ | |||||
private readonly IMqttClient _mqttClient; | |||||
public MqttServer(IMqttClient mqttClient) | |||||
{ | |||||
_mqttClient=mqttClient; | |||||
} | |||||
/// <summary> | |||||
/// 发布mq(发送数据) | |||||
/// </summary> | |||||
/// <param name="Topic"></param> | |||||
/// <param name="data"></param> | |||||
/// <param name="MessageId"></param> | |||||
/// <returns></returns> | |||||
public async Task<string> Publish(string Topic, PushData data, int MessageId) | |||||
{ | |||||
try | |||||
{ | |||||
if (string.IsNullOrEmpty(Topic)) | |||||
{ | |||||
throw Oops.Oh("订阅主题不能为空!"); | |||||
} | |||||
// 判断客户端是否连接 | |||||
if (!_mqttClient.IsConnected) | |||||
{ | |||||
throw Oops.Oh("MQTT 客户端尚未连接!"); | |||||
} | |||||
// Topic = TOPIC.GetInstance.GetBusinessTopic(x, storeInfo.FirstOrDefault(a => a.Id == item.OrgId).AutoKey) + "/" + item.AutoKey; | |||||
BPAPackage bPAPackage = new BPAPackage | |||||
{ | |||||
MessageId = MessageId,// MessageID.TMC_PUSH_INGREDIENTS, | |||||
ClientId = data.DeviceId, | |||||
//ClientType = Procuct | |||||
MessageVersion = 0x30, | |||||
Timestamp = DateTime.Now, | |||||
Message = data | |||||
}; | |||||
//每次下发暂停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); | |||||
return "success"; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return "下发错误,错误信息:" + e.Message; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 订阅,mq | |||||
/// </summary> | |||||
/// <param name="topic"></param> | |||||
/// <returns></returns> | |||||
public async Task<string> Subscribe(string topic) | |||||
{ | |||||
string str = "success"; | |||||
try | |||||
{ | |||||
topic = topic.Trim(); | |||||
if (string.IsNullOrEmpty(topic)) | |||||
{ | |||||
throw Oops.Oh("订阅主题不能为空!"); | |||||
} | |||||
// 判断客户端是否连接 | |||||
if (!_mqttClient.IsConnected) | |||||
{ | |||||
throw Oops.Oh("MQTT 客户端尚未连接!"); | |||||
} | |||||
// 设置订阅参数 | |||||
var subscribeOptions = new MqttClientSubscribeOptionsBuilder() | |||||
.WithTopicFilter(topic) | |||||
.Build(); | |||||
await _mqttClient.SubscribeAsync(subscribeOptions, CancellationToken.None); | |||||
return str; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return "下发错误,错误信息:" + e.Message; | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,34 @@ | |||||
using BPA.SAAS.KitChenManage.Application.Device.Services; | |||||
using Longbow.Tasks; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using MQTTnet.Client; | |||||
using MQTTnet.Server; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using uPLibrary.Networking.M2Mqtt; | |||||
namespace BPA.SAAS.KitChenManage.Application.Push.Comm | |||||
{ | |||||
public class WorkTask : ITask, ITransient | |||||
{ | |||||
// IMqttClient mqttServermqttClient; | |||||
IDevicePushRecodeService devicePushRecodeService; | |||||
//MqttServer mqttClient; | |||||
public async Task Execute(IServiceProvider provider, CancellationToken cancellationToken) | |||||
{ | |||||
// mqttServermqttClient = provider.GetService<IMqttClient>(); | |||||
devicePushRecodeService = provider.GetService<IDevicePushRecodeService>(); | |||||
//mqttClient = new(mqttServermqttClient); | |||||
//cancellationToken.Register(devicePushRecodeService.CallBackDevicePushRecode()) | |||||
//await devicePushRecodeService.CallBackDevicePushRecode(); | |||||
// Console.WriteLine($"订阅消息返回:"+ str); | |||||
// return Task.CompletedTask; | |||||
} | |||||
} | |||||
} |
@@ -11,8 +11,41 @@ namespace BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1 | |||||
/// </summary> | /// </summary> | ||||
public class ProductFunctionData | public class ProductFunctionData | ||||
{ | { | ||||
/// <summary> | |||||
/// 物料下发topics | |||||
/// </summary> | |||||
public const string BatchingPushTopics = "/120078739409565e0/v1/${deviceKey}/defaul/batvhingpush"; | |||||
/// <summary> | |||||
/// 响应物料下发topics | |||||
/// </summary> | |||||
public const string BatchingPushTopics_reply= "/120078739409565e0/v1/${deviceKey}/defaul/batvhingpush_reply"; | |||||
/// <summary> | |||||
/// 工艺下发topics | |||||
/// </summary> | |||||
public const string TechnologyPushTopics = "/120078739409565e0/v1/${deviceKey}/defaul/chnologypush"; | |||||
/// <summary> | |||||
/// 响应工艺下发topics | |||||
/// </summary> | |||||
public const string TechnologyPushTopics_reply = "/120078739409565e0/v1/${deviceKey}/defaul/chnologypush_reply"; | |||||
/// <summary> | |||||
/// 商品下发topics | |||||
/// </summary> | |||||
public const string GoodsPushTopics = "/120078739409565e0/v1/${deviceKey}/defaul/goodspush"; | |||||
/// <summary> | |||||
///响应商品下发topics | |||||
/// </summary> | |||||
public const string GoodsPushTopics_reply = "/120078739409565e0/v1/${deviceKey}/defaul/goodspush_reply"; | |||||
/// <summary> | |||||
/// 物料下发服务参数格式 | |||||
/// </summary> | |||||
public const string BatchingData = "{\r\n\t\"batchinginfo\": [{\r\n\t\t\"id\": \"物料ID\",\r\n\t\t\"name\": \"物料名称\",\r\n\t\t\"typeid\": \"物料类型ID\",\r\n\t\t\"typename\": \"物料类型名称\",\r\n\t\t\"unit\": \"单位\",\r\n\t\t\"createAt\": \"创建时间\"\r\n\t}],\r\n\t\"batchingTypeinfo\": [{\r\n\t\t\"id\": \"ID\",\r\n\t\t\"name\": \"物料类型名称\"\r\n\t}],\r\n\t\"batchingUnitinfo\": [{\r\n\t\t\"id\": \"ID\",\r\n\t\t\"name\": \"物料单位名称\"\r\n\t}]\r\n}"; | public const string BatchingData = "{\r\n\t\"batchinginfo\": [{\r\n\t\t\"id\": \"物料ID\",\r\n\t\t\"name\": \"物料名称\",\r\n\t\t\"typeid\": \"物料类型ID\",\r\n\t\t\"typename\": \"物料类型名称\",\r\n\t\t\"unit\": \"单位\",\r\n\t\t\"createAt\": \"创建时间\"\r\n\t}],\r\n\t\"batchingTypeinfo\": [{\r\n\t\t\"id\": \"ID\",\r\n\t\t\"name\": \"物料类型名称\"\r\n\t}],\r\n\t\"batchingUnitinfo\": [{\r\n\t\t\"id\": \"ID\",\r\n\t\t\"name\": \"物料单位名称\"\r\n\t}]\r\n}"; | ||||
/// <summary> | |||||
/// 商品下发服务参数格式 | |||||
/// </summary> | |||||
public const string GoodsData = "{\r\n\t\"goodsinfo\": [{\r\n\t\t\"id\": \"商品ID\",\r\n\t\t\"name\": \"商品名称\",\r\n\t\t\"goodsTypeId\": \"商品类型ID\",\r\n\t\t\"goodsTypeName\": \"商品类型名称\",\r\n\t\t\"goodsUintId\": \"单位Id\",\r\n\t\t\"goodsUintName\": \"单位名称\",\r\n\t\t\"createAt\": \"创建时间\",\r\n\t\t\"imgUrl\": \"商品图片路径\",\r\n\t\t\"price\": \"价格\",\r\n\t\t\"design\": \"描述\"\r\n\t}],\r\n\t\"goodsTypeInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"分类名称\",\r\n\t\t\"PId\": \"父级id\"\r\n\t}],\r\n\t\"goodsUnitInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"单位名称\"\r\n\t}],\r\n\t\"goodsAttribute\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"attributeName\": \"属性名称\",\r\n\t\t\"goodsTypeId\": \"商品分类id\",\r\n\t\t\"attributeValueList\": [{\r\n\t\t\t\"id\": \"id\",\r\n\t\t\t\"goodsAttributeId\": \"商品属性id\",\r\n\t\t\t\"attributeValue\": \"商品属性值\"\r\n\t\t}]\r\n\t}]\r\n}"; | public const string GoodsData = "{\r\n\t\"goodsinfo\": [{\r\n\t\t\"id\": \"商品ID\",\r\n\t\t\"name\": \"商品名称\",\r\n\t\t\"goodsTypeId\": \"商品类型ID\",\r\n\t\t\"goodsTypeName\": \"商品类型名称\",\r\n\t\t\"goodsUintId\": \"单位Id\",\r\n\t\t\"goodsUintName\": \"单位名称\",\r\n\t\t\"createAt\": \"创建时间\",\r\n\t\t\"imgUrl\": \"商品图片路径\",\r\n\t\t\"price\": \"价格\",\r\n\t\t\"design\": \"描述\"\r\n\t}],\r\n\t\"goodsTypeInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"分类名称\",\r\n\t\t\"PId\": \"父级id\"\r\n\t}],\r\n\t\"goodsUnitInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"单位名称\"\r\n\t}],\r\n\t\"goodsAttribute\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"attributeName\": \"属性名称\",\r\n\t\t\"goodsTypeId\": \"商品分类id\",\r\n\t\t\"attributeValueList\": [{\r\n\t\t\t\"id\": \"id\",\r\n\t\t\t\"goodsAttributeId\": \"商品属性id\",\r\n\t\t\t\"attributeValue\": \"商品属性值\"\r\n\t\t}]\r\n\t}]\r\n}"; | ||||
/// <summary> | |||||
/// 工艺下发服务参数格式 | |||||
/// </summary> | |||||
public const string TechnologyData = "{\r\n\t\"technologysInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"工艺步骤名称\",\r\n\t\t\"DeviceVersionId\": \"设备版本id\",\r\n\t\t\"technologyActionInfo\": [{\r\n\t\t\t\"id\": \"id\",\r\n\t\t\t\"technologyId\": \"工艺步骤id\",\r\n\t\t\t\"actionName\": \"模型名称\",\r\n\t\t\t\"actionValue\": \"模型数据\",\r\n\t\t\t\"actionType\": \"数据类型\",\r\n\t\t\t\"technologyType\": \"工艺模型类型(标识是否物料 1标识物料 0标识其他)\"\r\n\t\t}],\r\n\t}],\r\n\t\r\n\t\"goodsTechnologysInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"stepName\": \"工艺步骤名称\",\r\n\t\t\"actionJson\": \"工艺模型json\",\r\n\t\t\"goodsAttributeId\": \"商品属性值id组合\",\r\n\t\t\"chnologyId\": \"工艺id\",\r\n\t\t\"goodsId\": \"商品id\",\r\n\t\t\"deviceId\": \"设备id\",\r\n\t\t\"createAt\": \"创建时间\"\r\n\t}]\r\n}"; | public const string TechnologyData = "{\r\n\t\"technologysInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"name\": \"工艺步骤名称\",\r\n\t\t\"DeviceVersionId\": \"设备版本id\",\r\n\t\t\"technologyActionInfo\": [{\r\n\t\t\t\"id\": \"id\",\r\n\t\t\t\"technologyId\": \"工艺步骤id\",\r\n\t\t\t\"actionName\": \"模型名称\",\r\n\t\t\t\"actionValue\": \"模型数据\",\r\n\t\t\t\"actionType\": \"数据类型\",\r\n\t\t\t\"technologyType\": \"工艺模型类型(标识是否物料 1标识物料 0标识其他)\"\r\n\t\t}],\r\n\t}],\r\n\t\r\n\t\"goodsTechnologysInfo\": [{\r\n\t\t\"id\": \"id\",\r\n\t\t\"stepName\": \"工艺步骤名称\",\r\n\t\t\"actionJson\": \"工艺模型json\",\r\n\t\t\"goodsAttributeId\": \"商品属性值id组合\",\r\n\t\t\"chnologyId\": \"工艺id\",\r\n\t\t\"goodsId\": \"商品id\",\r\n\t\t\"deviceId\": \"设备id\",\r\n\t\t\"createAt\": \"创建时间\"\r\n\t}]\r\n}"; | ||||
} | } | ||||
} | } |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.KitChenManage.Application.Push.奶茶机_v1.Dto | |||||
{ | |||||
public class ReplyBaseDto | |||||
{ | |||||
public string MessageId { get; set; } | |||||
public bool Success { get; set; } | |||||
public string Errors { get; set; } | |||||
} | |||||
} |
@@ -21,6 +21,7 @@ namespace BPA.SAAS.KitChenManage.Application.Store.Services | |||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<List<StoreDtoOutput>> GetStoreList(); | Task<List<StoreDtoOutput>> GetStoreList(); | ||||
Task<List<StoreDtoOutput>> GetStoreList_alm(); | |||||
/// <summary> | /// <summary> | ||||
/// 添加 | /// 添加 | ||||
/// </summary> | /// </summary> | ||||
@@ -66,6 +66,25 @@ namespace BPA.SAAS.KitChenManage.Application.Store.Services | |||||
return res; | return res; | ||||
} | } | ||||
public async Task<List<StoreDtoOutput>> GetStoreList_alm() | |||||
{ | |||||
string groupId = App.HttpContext.Request.Headers["groupId"].ToString(); | |||||
if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商id不能为空"); | |||||
var res = await _db.Queryable<BPA_Store>().Where(x=>x.GroupId== groupId) | |||||
.Select(t => new StoreDtoOutput | |||||
{ | |||||
CreateAt = t.CreateAt, | |||||
Id = t.Id, | |||||
Name = t.Name, | |||||
Phone = t.Phone, | |||||
Description = t.Description, | |||||
OrgName = t.OrgName, | |||||
OrgId = t.OrgId, | |||||
Sort = t.Sort, | |||||
}).OrderBy(t => t.Sort).OrderBy(x => x.CreateAt, OrderByType.Desc).ToListAsync(); | |||||
return res; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 添加 | /// 添加 | ||||
/// </summary> | /// </summary> | ||||
@@ -38,6 +38,15 @@ namespace BPA.SAAS.KitChenManage.Application.Store | |||||
return await _storeService.GetStoreList(); | return await _storeService.GetStoreList(); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 查询所有店铺(外部调用) | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
[HttpGet("/api/store/getstorelist_alm")] | |||||
public async Task<List<StoreDtoOutput>> GetStoreList_alm() | |||||
{ | |||||
return await _storeService.GetStoreList_alm(); | |||||
} | |||||
/// <summary> | |||||
/// 添加 | /// 添加 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="input"></param> | /// <param name="input"></param> | ||||
@@ -14,9 +14,9 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.23" /> | |||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.23" /> | |||||
<PackageReference Include="Furion.Pure" Version="4.9.1.23" /> | |||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.35" /> | |||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.35" /> | |||||
<PackageReference Include="Furion.Pure" Version="4.9.1.35" /> | |||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" /> | <PackageReference Include="SqlSugarCore" Version="5.1.4.67" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -67,7 +67,7 @@ | |||||
</member> | </member> | ||||
<member name="P:BPA.SAAS.KitChenManage.Core.Model.BPA_DevicePushRecode.Status"> | <member name="P:BPA.SAAS.KitChenManage.Core.Model.BPA_DevicePushRecode.Status"> | ||||
<summary> | <summary> | ||||
下发状态 1成功 2失败 | |||||
下发状态 0下发中 1成功 2失败 | |||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.SAAS.KitChenManage.Core.Model.BPA_FoodMenuGoods.FoodMenuId"> | <member name="P:BPA.SAAS.KitChenManage.Core.Model.BPA_FoodMenuGoods.FoodMenuId"> | ||||
@@ -38,7 +38,7 @@ namespace BPA.SAAS.KitChenManage.Core | |||||
//过滤已删除数据 | //过滤已删除数据 | ||||
db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0); | db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0); | ||||
//db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0); | //db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0); | ||||
if (App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value != null) | |||||
if (App.User?.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value != null) | |||||
{ | { | ||||
//非管理员账户过滤加盟商数据 | //非管理员账户过滤加盟商数据 | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | ||||
@@ -21,10 +21,14 @@ namespace BPA.SAAS.KitChenManage.Core.Model | |||||
public string Topic { get; set; } | public string Topic { get; set; } | ||||
public string DataResore { get; set; } | public string DataResore { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 下发状态 1成功 2失败 | |||||
/// 下发状态 0下发中 1成功 2失败 | |||||
/// </summary> | /// </summary> | ||||
public int Status { get; set; } | public int Status { get; set; } | ||||
public int DeviceAutoKey { get; set; } | public int DeviceAutoKey { get; set; } | ||||
public string Description { get; set; } | public string Description { get; set; } | ||||
public int MessageId { get; set; } | |||||
public string TopicRely { get; set; } | |||||
public string DataResoreRely { get; set; } | |||||
public string DescriptionRely { get; set; } | |||||
} | } | ||||
} | } |
@@ -17,6 +17,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | <PackageReference Include="BPA.MQTTClient" Version="1.0.11" /> | ||||
<PackageReference Include="Longbow.Tasks" Version="8.0.0" /> | |||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection; | |||||
using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||
using MQTTnet.Client.Connecting; | using MQTTnet.Client.Connecting; | ||||
using MQTTnet.Client.Disconnecting; | using MQTTnet.Client.Disconnecting; | ||||
using ProtoBuf.Meta; | |||||
using System; | using System; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -50,6 +51,7 @@ namespace BPA.SAAS.KitChenManage.Web.Core | |||||
}); | }); | ||||
}); | }); | ||||
// services.GetService<IMqttClientOptions>(); | // services.GetService<IMqttClientOptions>(); | ||||
services.AddTaskServices(); | |||||
services.AddCorsAccessor(); | services.AddCorsAccessor(); | ||||
services.AddRemoteRequest(); | services.AddRemoteRequest(); | ||||
services.AddSqlsugarSetup(App.Configuration); | services.AddSqlsugarSetup(App.Configuration); | ||||