Browse Source

提交

master
gwbvipvip 6 months ago
parent
commit
8865f30e3b
13 changed files with 232 additions and 97 deletions
  1. +10
    -0
      BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs
  2. +20
    -4
      BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs
  3. +2
    -0
      BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs
  4. +44
    -7
      BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml
  5. +4
    -4
      BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs
  6. +0
    -1
      BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs
  7. +22
    -0
      BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs
  8. +99
    -67
      BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs
  9. +3
    -3
      BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs
  10. +11
    -6
      BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs
  11. +15
    -1
      BPA.SAAS.KitChenManage.Application/TestServices.cs
  12. +2
    -2
      BPA.SAAS.KitChenManage.Core/DbContext.cs
  13. +0
    -2
      BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs

+ 10
- 0
BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs View File

@@ -83,5 +83,15 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization
{
_authorizationService.CodeFirst();
}
/// <summary>
/// 查询店铺授权信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
[HttpGet("/api/authorization/getstoreauthorization")]
public async Task<BPA_StoreAuthorization> GetStoreAuthorization(string key)
{
return await _authorizationService.GetStoreAuthorization(key);
}
}
}

+ 20
- 4
BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs View File

@@ -1,6 +1,7 @@
using BPA.SAAS.KitChenManage.Application.Authorization.Dtos;
using BPA.SAAS.KitChenManage.Core.Base;
using BPA.SAAS.KitChenManage.Core.Model;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -38,7 +39,7 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
Key = a.Key,
StoreId = a.StoreId,
StoreName = b.Name,
UpdateAt = a.UpdateAt,
// UpdateAt = a.UpdateAt,
PeriodValidity = a.PeriodValidity,

})
@@ -68,7 +69,7 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
StoreId = input.StoreId,
Key = Guid.NewGuid().ToString(),
PeriodValidity = input.PeriodValidity,
UpdateAt=DateTime.Now,
// UpdateAt=DateTime.Now,

}).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();

@@ -88,7 +89,7 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
throw Oops.Oh("授权信息不存在");
}
data.Key = Guid.NewGuid().ToString();
data.UpdateAt = DateTime.Now;
//data.UpdateAt = DateTime.Now;

return await _db.Updateable(data).ExecuteCommandHasChangeAsync();
}
@@ -113,7 +114,7 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
}
data.Key = Guid.NewGuid().ToString();
data.PeriodValidity = input.PeriodValidity;
data.UpdateAt = DateTime.Now;
//data.UpdateAt = DateTime.Now;

return await _db.Updateable(data).ExecuteCommandHasChangeAsync();
}
@@ -166,5 +167,20 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services


}
/// <summary>
/// 查询店铺授权信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<BPA_StoreAuthorization> GetStoreAuthorization(string key)
{
var data = await _db.Queryable<BPA_StoreAuthorization>().FirstAsync(x => x.Key == key);
if (data == null)
{
throw Oops.Oh("授权信息不存在");
}

return data;
}
}
}

+ 2
- 0
BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs View File

@@ -1,6 +1,7 @@
using BPA.SAAS.KitChenManage.Application.Authorization.Dtos;
using BPA.SAAS.KitChenManage.Core.Base;
using BPA.SAAS.KitChenManage.Core.Model;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -51,5 +52,6 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
/// </summary>
/// <param name="tableNames"></param>
void CodeFirst();
Task<BPA_StoreAuthorization> GetStoreAuthorization(string key);
}
}

+ 44
- 7
BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml View File

@@ -44,6 +44,13 @@
</summary>
<param name="tableNames"></param>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.AuthorizationServices.GetStoreAuthorization(System.String)">
<summary>
查询店铺授权信息
</summary>
<param name="key"></param>
<returns></returns>
</member>
<member name="P:BPA.SAAS.KitChenManage.Application.Authorization.Dtos.CreateOrUpDateStoreAuthorizationDto.PeriodValidity">
<summary>
有效期 长期有效为空
@@ -89,6 +96,13 @@
</summary>
<param name="tableNames"></param>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.AuthorizationService.GetStoreAuthorization(System.String)">
<summary>
查询店铺授权信息
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.IAuthorizationService.PageStoreAuthorization(BPA.SAAS.KitChenManage.Core.Base.PageInputBase)">
<summary>
分页店铺授权码
@@ -129,13 +143,20 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.DevicePushRecodeServices.Add(System.Collections.Generic.List{BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput})">
<member name="M:BPA.SAAS.KitChenManage.Application.Device.DevicePushRecodeServices.Add(BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput)">
<summary>
添加
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.DevicePushRecodeServices.Add_alm(System.Collections.Generic.List{BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInputalm})">
<summary>
下发数据(对外接口)
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.DevicePushRecodeServices.Update(System.String)">
<summary>
修改
@@ -272,13 +293,27 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Add(System.Collections.Generic.List{BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput})">
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Add_alm(System.Collections.Generic.List{BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInputalm})">
<summary>
数据下发(外部调用)
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Add(BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput)">
<summary>
添加
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.Delete(System.Collections.Generic.List{System.String})">
<summary>
删除
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.CallBackDevicePushRecode(System.String,System.String)">
<summary>
数据下发回调更新数据
@@ -287,19 +322,21 @@
<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.CallBackDevicePushRecode_alm(System.Collections.Generic.List{System.String},System.String)">
<summary>
删除
数据下发回调更新数据(外部调用接口使用)
</summary>
<param name="input"></param>
<param name="messageId"></param>
<param name="groupId"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.BindMqReceived(System.String,System.String)">
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.DevicePushRecodeService.BindMqReceived(System.String,System.String,System.String)">
<summary>
监听订阅的topic主题
</summary>
<param name="messageId"></param>
<param name="groupId"></param>
<param name="callbackUrl"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.IDevicePushRecodeService.Page(BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoPageInput)">
@@ -309,7 +346,7 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.IDevicePushRecodeService.Add(System.Collections.Generic.List{BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput})">
<member name="M:BPA.SAAS.KitChenManage.Application.Device.Services.IDevicePushRecodeService.Add(BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoInput)">
<summary>
添加
</summary>


+ 4
- 4
BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs View File

@@ -17,9 +17,9 @@ namespace BPA.SAAS.KitChenManage.Application.Device
{
_devicePushRecodeService= devicePushRecodeService;
}
public async Task<string> Test()
public async Task Test()
{
return await _devicePushRecodeService.Test();
await _devicePushRecodeService.Test();
}
/// <summary>
/// 分页
@@ -37,7 +37,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/devicepushrecode/add")]
public async Task<bool> Add(List<DevicePushRecodeDtoInput> input)
public async Task<bool> Add(DevicePushRecodeDtoInput input)
{
return await _devicePushRecodeService.Add(input);
}
@@ -48,7 +48,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device
/// <returns></returns>
[HttpPost("/api/devicepushrecode/add_alm")]
[AllowAnonymous]
public async Task<bool> Add_alm(List<DevicePushRecodeDtoInput> input)
public async Task<bool> Add_alm(List<DevicePushRecodeDtoInputalm> input)
{
return await _devicePushRecodeService.Add_alm(input);
}


+ 0
- 1
BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs View File

@@ -8,7 +8,6 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Dtos
{
public class DevicePushRecodeDtoInput
{
public string MessageId { get; set; }
public string DeviceId { get; set; }
public string ProductVersion { get; set; }
public string ProductKey { get; set; }


+ 22
- 0
BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs View File

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

namespace BPA.SAAS.KitChenManage.Application.Device.Dtos
{
public class DevicePushRecodeDtoInputalm
{
public string CallBackUrl { get; set; }
public string MessageId { get; set; }
public string DeviceId { get; set; }
public string ProductVersion { get; set; }
public string ProductKey { get; set; }
public string ProductName { get; set; }
public string DeviceName { get; set; }
public int DeviceAutoKey { get; set; }
public object Data { get; set; }
public int Type { get; set; }
}
}

+ 99
- 67
BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs View File

@@ -42,18 +42,11 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
_mqttClient = mqttClient;
mqttServer = new(mqttClient);
}
public async Task<string> Test()
public async Task Test()
{
var getGoodsAttributeurl = "http://localhost:5009/api/ExternalPlatform/Goods/GetGoodsPageList";//获取商品属性
var key = "47e5c071-6283-4d9d-8dcb-36ba95aa8db9";
var str = "current=1&pageSize=10&" + key;
var sign = MD5Encryption.Encrypt(str.ToUpper());
var respon = await getGoodsAttributeurl.SetHeaders(new
{
sign = sign,
key = key
}).SetHttpMethod(HttpMethod.Get).SetBody("{\"current\":1,\"pageSize\":10}", "application/json").PostAsStringAsync();
return respon;
string Topic = "2222";
var sd=await mqttServer.Publish(Topic, new PushData() { Data = "123456"}, "1");
//return respon;
}
/// <summary>
/// 分页
@@ -91,13 +84,20 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
};
return util;
}
public async Task<bool> Add_alm(List<DevicePushRecodeDtoInput> input)
/// <summary>
/// 数据下发(外部调用)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> Add_alm(List<DevicePushRecodeDtoInputalm> input)
{
var data = input.Adapt<List<BPA_DevicePushRecode>>();
string groupId = App.HttpContext.Request.Headers["groupId"].ToString();
if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商id不能为空");
List<string> messageids = new();
for (int i = 0; i < input.Count; i++)
{
messageids.Add(input[i].MessageId);
var DataResore = await commDefaultHandle.GetParm(input[i].Type, input[i].Data.ToString(), input[i].DeviceId, input[i].ProductName, input[i].ProductVersion, input[i].DeviceAutoKey.ToString());
if (DataResore == null) throw Oops.Oh("解析参数失败");
string Topic = DataResore.TopicsStr;
@@ -105,6 +105,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
//var maxmessageId=_db.Queryable<BPA_DevicePushRecode>().Max(x => x.MessageId);
if (string.IsNullOrWhiteSpace(input[i].MessageId)) input[i].MessageId = Guid.NewGuid().ToString();
// var messageId = Guid.NewGuid().ToString();
data[i].Id = Guid.NewGuid().ToString();
data[i].Topic = Topic;
data[i].Status = 0;
data[i].DataResore = JsonConvert.SerializeObject(DataResore.Data);
@@ -113,23 +114,31 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
data[i].MessageId = input[i].MessageId;
data[i].TopicRely = DataResore.TopicsStrRely;
data[i].DescriptionRely = "等待回调";
data[i].GroupId = groupId;
data[i].CreateAt = DateTime.Now;
var respush = await mqttServer.Publish(Topic, new PushData() { Data = data[i].DataResore, DeviceId = input[i].DeviceAutoKey }, input[i].MessageId);
if (respush != "success")
{
data[i].Description = respush;
data[i].Status = 2;
}
var res = await _db.Insertable(data).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
var res = await _db.Insertable(data).ExecuteCommandAsync();
// var getGoodsAttributeurl = "http://192.168.1.17:5006/api/hirdpartypush/updatethirdpartypushrecord";//获取商品属性
//bool status = true;
//var jsb = "{\"messageId\":\"" + data[i].MessageId + "\",\"deviceId\":\"" + input[i].DeviceId + "\",\"isPush\":true}";
//var resp = await getGoodsAttributeurl.SetHttpMethod(HttpMethod.Post).SetBody(jsb).PostAsStringAsync();
//周期性任务 (10 秒后执行1次任务)
var trigger = TriggerBuilder.Default.WithInterval(TimeSpan.FromSeconds(10)).WithRepeatCount(1).Build();
TaskServicesManager.GetOrAdd(input[i].MessageId.ToString(), async (provider, token) =>
{
await CallBackDevicePushRecode(input[i].MessageId.ToString(), groupId);
}, trigger);
//订阅回复数据下发topics
await mqttServer.Subscribe(DataResore.TopicsStrRely);
await BindMqReceived(input[i].MessageId.ToString(), groupId);
var callbackUrl = BaseServerUrl + "api/hirdpartypush/updatethirdpartypushrecord";//修改第三方订单的回调
await BindMqReceived(input[i].MessageId.ToString(), groupId, callbackUrl);
}
var trigger = TriggerBuilder.Default.WithInterval(TimeSpan.FromSeconds(100)).WithRepeatCount(1).Build();
var messageid = Guid.NewGuid().ToString();
TaskServicesManager.GetOrAdd(messageid, async (provider, token) => {
await CallBackDevicePushRecode_alm(messageids, groupId);
}, trigger);
return true;
}
/// <summary>
@@ -137,66 +146,46 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> Add(List<DevicePushRecodeDtoInput> input)
public async Task<bool> Add(DevicePushRecodeDtoInput input)
{
var data = input.Adapt<List<BPA_DevicePushRecode>>();
var data = input.Adapt<BPA_DevicePushRecode>();
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
for (int i = 0; i < input.Count; i++)
{
var DataResore = await commDefaultHandle.GetParm(input[i].Type, input[i].Data.ToString(), input[i].DeviceId, input[i].ProductName, input[i].ProductVersion, input[i].DeviceAutoKey.ToString());
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");
//var maxmessageId=_db.Queryable<BPA_DevicePushRecode>().Max(x => x.MessageId);
if (string.IsNullOrWhiteSpace(input[i].MessageId)) input[i].MessageId = Guid.NewGuid().ToString();
// var messageId = Guid.NewGuid().ToString();
data[i].Topic = Topic;
data[i].Status = 0;
data[i].DataResore = JsonConvert.SerializeObject(DataResore.Data);
data[i].DeviceAutoKey = input[i].DeviceAutoKey;
data[i].Description = "下发中,等待设备响应";
data[i].MessageId = input[i].MessageId;
data[i].TopicRely = DataResore.TopicsStrRely;
data[i].DescriptionRely = "等待回调";
var respush = await mqttServer.Publish(Topic, new PushData() { Data = data[i].DataResore, DeviceId = input[i].DeviceAutoKey }, input[i].MessageId);
// if (string.IsNullOrWhiteSpace(input.MessageId)) input.MessageId = Guid.NewGuid().ToString();
var messageId = Guid.NewGuid().ToString();
data.Topic = Topic;
data.Status = 0;
data.DataResore = JsonConvert.SerializeObject(DataResore.Data);
data.DeviceAutoKey = input.DeviceAutoKey;
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[i].Description = respush;
data[i].Status = 2;
data.Description = respush;
data.Status = 2;
}
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(input[i].MessageId.ToString(), async (provider, token) =>
{
await CallBackDevicePushRecode(input[i].MessageId.ToString(), groupId);
TaskServicesManager.GetOrAdd(messageId, async (provider, token) => {
await CallBackDevicePushRecode(messageId, groupId);
}, trigger);
//订阅回复数据下发topics
await mqttServer.Subscribe(DataResore.TopicsStrRely);
await BindMqReceived(input[i].MessageId.ToString(), groupId);
}
await BindMqReceived(messageId, groupId, "");
return true;
}
/// <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();
var status = false;
var getGoodsAttributeurl = BaseServerUrl + "api/device/updatethirdpartypushrecord";//获取商品属性
await getGoodsAttributeurl.SetHttpMethod(HttpMethod.Post).SetBody("{\"messageId\":" + messageId + ",\"isPush\":" + status + ",\"pushTime\":" + DateTime.Now + "}").PostAsStringAsync();
}
}
public async Task<bool> Update(string id)
{
var data = _db.Queryable<BPA_DevicePushRecode>().Where(x => x.Id == id).First();
@@ -218,7 +207,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
{
await CallBackDevicePushRecode(data.MessageId.ToString(), groupId);
}, trigger);
await BindMqReceived(data.MessageId.ToString(), groupId);
await BindMqReceived(data.MessageId.ToString(), groupId,"");
return res > 0;
}
/// <summary>
@@ -242,12 +231,53 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
}
}
/// <summary>
/// 数据下发回调更新数据
/// </summary>
/// <param name="messageId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
private 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();
}
}
/// <summary>
/// 数据下发回调更新数据(外部调用接口使用)
/// </summary>
/// <param name="messageId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
private async Task CallBackDevicePushRecode_alm(List<string> messageId, string groupId)
{
for (int i = 0; i < messageId.Count; i++)
{
var model = await _db.Queryable<BPA_DevicePushRecode>().Where(x => x.MessageId.ToString() == messageId[i].ToString() && x.GroupId == groupId).FirstAsync();
if (model.Status == 0)
{
model.Status = 1;
model.Description = "下发成功,设备未回调";
model.DescriptionRely = "响应数据失败";
_db.Updateable(model).ExecuteCommand();
var getGoodsAttributeurl = BaseServerUrl + "api/hirdpartypush/updatethirdpartypushrecord";//获取商品属性
var msg = "{\"messageId\":\"" + messageId[i] + "\",\"deviceId\":\"" + model.DeviceId + "\",\"isPush\":false}";
await getGoodsAttributeurl.SetHttpMethod(HttpMethod.Post).SetBody(msg).PostAsStringAsync();
}
}
}
/// <summary>
/// 监听订阅的topic主题
/// </summary>
/// <param name="messageId"></param>
/// <param name="groupId"></param>
/// <param name="callbackUrl"></param>
/// <returns></returns>
private async Task BindMqReceived(string messageId, string groupId)
private async Task BindMqReceived(string messageId,string groupId,string callbackUrl)
{
var status = true;
_mqttClient.UseApplicationMessageReceivedHandler(async e =>
@@ -287,10 +317,12 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
model.Status = 1;
model.Description = "下发成功";
model.DescriptionRely = "响应数据异常,异常信息:" + ex.Message;

}
var getGoodsAttributeurl = BaseServerUrl + "api/device/updatethirdpartypushrecord";//修改第三方订单的回调
await getGoodsAttributeurl.SetHttpMethod(HttpMethod.Post).SetBody("{\"messageId\":" + messageId + ",\"isPush\":" + status + ",\"pushTime\":" + DateTime.Now + "}").PostAsStringAsync();
if (!string.IsNullOrWhiteSpace(callbackUrl))
{
var msg = "{\"messageId\":\"" + messageId + "\",\"deviceId\":\"" + model.DeviceId + "\",\"isPush\":false}";
var sd=await callbackUrl.SetHttpMethod(HttpMethod.Post).SetBody(msg).PostAsStringAsync();
}
_db.Updateable(model).ExecuteCommand();
}
});


+ 3
- 3
BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs View File

@@ -10,20 +10,20 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services
{
public interface IDevicePushRecodeService
{
Task<string> Test();
Task Test();
/// <summary>
/// 分页
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<PageUtil> Page(DevicePushRecodeDtoPageInput input);
Task<bool> Add_alm(List<DevicePushRecodeDtoInput> input);
Task<bool> Add_alm(List<DevicePushRecodeDtoInputalm> input);
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<bool> Add(List<DevicePushRecodeDtoInput> input);
Task<bool> Add(DevicePushRecodeDtoInput input);
/// <summary>
/// 更新
/// </summary>


+ 11
- 6
BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs View File

@@ -17,6 +17,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;

@@ -53,6 +54,9 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
if (string.IsNullOrWhiteSpace(TechnologyData)) throw Oops.Oh("系统还未开发【产品名称:" + productName + " 版本号:" + productVersion + "】的工艺数据下发功能");
obj = await GetGoodsTechnology(data, deviceId, TechnologyData);
break;
default:
throw Oops.Oh("设备不支持的数据下发");

}
return new BaseParmDto() {Data= obj,TopicsStr= strTopics,TopicsStrRely= TopicsStrRely };
}
@@ -62,7 +66,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
{
//商品信息
var goodsData = JsonConvert.DeserializeObject<List<GoodsInfoDto>>(data);
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value != null ? App.User?.FindFirst(ClaimConst.GroupId)?.Value : App.HttpContext.Request.Headers["groupId"].ToString();
var cpjson = productFunctionData.Replace("\r", "").Replace("\n", "").Replace("\t", "");
var DynamicObject = JsonConvert.DeserializeObject<dynamic>(cpjson);
//商品信息
@@ -78,7 +82,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
var getGoodsAttributeurl = BaseServerUrl + "api/goodsattribute/getgoodsattributelist_alm";//获取商品属性
var responseGoodsAttribute = await getGoodsAttributeurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
groupId = groupId
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsAttribute = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsAttribute);
if (resGoodsAttribute.statusCode != "200") throw Oops.Oh("获取商品属性数据失败");
@@ -93,7 +97,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
var getGoodsUinturl = BaseServerUrl + "api/goods/getgoodsuintlist_alm";//获商品单位
var responseGoodsUint = await getGoodsUinturl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
groupId = groupId
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsUint = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsUint);
if (resGoodsUint.statusCode != "200") throw Oops.Oh("获取商品单位数据失败");
@@ -108,7 +112,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
var getGoodsTypeturl = BaseServerUrl + "api/goodstype/getgoodstypelist_alm";//获取商品分类
var responseGoodsType = await getGoodsTypeturl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
groupId = groupId
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resGoodsType = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsType);
if (resGoodsType.statusCode != "200") throw Oops.Oh("获取商品分类数据失败");
@@ -128,6 +132,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
{
try
{
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value!=null? App.User?.FindFirst(ClaimConst.GroupId)?.Value:App.HttpContext.Request.Headers["groupId"].ToString();
var cpjson = productFunctionData.Replace("\r", "").Replace("\n", "").Replace("\t", "");
var DynamicObject = JsonConvert.DeserializeObject<dynamic>(cpjson);
if (IsPropertyExist(DynamicObject, ProductParametersConst_Batching.batchinginfo))
@@ -143,7 +148,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
var getTypeurl = BaseServerUrl + "api/batching/getbatchingtypelist_alm";//获取物料分类
var responseType = await getTypeurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
groupId = groupId
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resType = JsonConvert.DeserializeObject<ResponDataBase>(responseType);
if (resType.statusCode != "200") throw Oops.Oh("获取物料分类数据失败");
@@ -157,7 +162,7 @@ namespace BPA.SAAS.KitChenManage.Application.Push.Comm
var getuinurl = BaseServerUrl + "api/batching/getbatchinguintList_alm";//获取物料单位
var responseUnit = await getuinurl.SetHeaders(new
{
groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
groupId = groupId
}).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
var resUnit = JsonConvert.DeserializeObject<ResponDataBase>(responseUnit);
if (resUnit.statusCode != "200") throw Oops.Oh("获取物料单位数据失败");


+ 15
- 1
BPA.SAAS.KitChenManage.Application/TestServices.cs View File

@@ -1,4 +1,5 @@
using System;
using Furion.RemoteRequest.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,5 +9,18 @@ namespace BPA.SAAS.KitChenManage.Application
{
public class TestServices: IDynamicApiController
{
public async Task<string> Test()
{
var getGoodsAttributeurl = "http://localhost:5006/api/ExternalPlatform/Goods/GetGoodsPageList";//获取商品属性
var key = "47e5c071-6283-4d9d-8dcb-36ba95aa8db9";
var str = "current=1&pageSize=10&" + key;
var sign = MD5Encryption.Encrypt(str.ToUpper());
var respon = await getGoodsAttributeurl.SetHeaders(new
{
sign = sign,
key = key
}).SetHttpMethod(HttpMethod.Get).SetBody("{\"current\":1,\"pageSize\":10}", "application/json").PostAsStringAsync();
return respon;
}
}
}

+ 2
- 2
BPA.SAAS.KitChenManage.Core/DbContext.cs View File

@@ -41,13 +41,13 @@ namespace BPA.SAAS.KitChenManage.Core
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 != null ? App.User?.FindFirst(ClaimConst.GroupId)?.Value : App.HttpContext.Request.Headers["groupId"].ToString();
db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == groupId);
}
db.Aop.DataExecuting = (oldValue, entityInfo) =>
{
//新增添加加盟商id赋值
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value != null ? App.User?.FindFirst(ClaimConst.GroupId)?.Value : App.HttpContext?.Request.Headers["groupId"].ToString();
if (entityInfo.PropertyName == "GroupId" && entityInfo.OperationType == DataFilterType.InsertByObject)
{
if (oldValue == null || oldValue == Convert.DBNull)


+ 0
- 2
BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs View File

@@ -19,7 +19,5 @@ namespace BPA.SAAS.KitChenManage.Core.Model
/// 有效期 长期有效为空
/// </summary>
public DateTime? PeriodValidity { get; set; }

public DateTime UpdateAt { get; set; }
}
}

Loading…
Cancel
Save