From cbfc06dfd001752df0439902918e7dac65c97599 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Mon, 25 Mar 2024 10:48:00 +0800 Subject: [PATCH] z --- .../Authorization/AuthorizationServices.cs | 10 ++ .../Services/AuthorizationService.cs | 24 ++- .../Services/IAuthorizationService.cs | 2 + .../BPA.SAAS.KitChenManage.Application.xml | 51 +++++- .../Device/DevicePushRecodeServices.cs | 4 +- .../Device/Dtos/DevicePushRecodeDtoInput.cs | 1 - .../Dtos/DevicePushRecodeDtoInputalm.cs | 22 +++ .../Services/DevicePushRecodeService.cs | 149 +++++++++++------- .../Services/IDevicePushRecodeService.cs | 4 +- .../Push/Comm/CommDefaultHandle.cs | 17 +- .../TestServices.cs | 16 +- BPA.SAAS.KitChenManage.Core/DbContext.cs | 4 +- .../Model/BPA_StoreAuthorization.cs | 2 - .../Properties/launchSettings.json | 2 +- .../appsettings.json | 2 +- 15 files changed, 227 insertions(+), 83 deletions(-) create mode 100644 BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs index 8af3d61..13e19b5 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs @@ -83,5 +83,15 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization { _authorizationService.CodeFirst(); } + /// + /// 查询店铺授权信息 + /// + /// + /// + [HttpGet("/api/authorization/getstoreauthorization")] + public async Task GetStoreAuthorization(string key) + { + return await _authorizationService.GetStoreAuthorization(key); + } } } diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs index 451a3df..fcf7856 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs @@ -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 } + /// + /// 查询店铺授权信息 + /// + /// + /// + public async Task GetStoreAuthorization(string key) + { + var data = await _db.Queryable().FirstAsync(x => x.Key == key); + if (data == null) + { + throw Oops.Oh("授权信息不存在"); + } + + return data; + } } } diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs index 8e96a1e..377b513 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs @@ -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 /// /// void CodeFirst(); + Task GetStoreAuthorization(string key); } } diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml index 3b9b4b1..7593f6c 100644 --- a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml +++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml @@ -44,6 +44,13 @@ + + + 查询店铺授权信息 + + + + 有效期 长期有效为空 @@ -89,6 +96,13 @@ + + + 查询店铺授权信息 + + + + 分页店铺授权码 @@ -129,13 +143,20 @@ - + 添加 + + + 下发数据(对外接口) + + + + 修改 @@ -272,13 +293,27 @@ - + + + 数据下发(外部调用) + + + + + 添加 + + + 删除 + + + + 数据下发回调更新数据 @@ -287,19 +322,21 @@ - + - 删除 + 数据下发回调更新数据(外部调用接口使用) - + + - + 监听订阅的topic主题 + @@ -309,7 +346,7 @@ - + 添加 diff --git a/BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs b/BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs index f170dec..4c34bf7 100644 --- a/BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs +++ b/BPA.SAAS.KitChenManage.Application/Device/DevicePushRecodeServices.cs @@ -37,7 +37,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device /// /// [HttpPost("/api/devicepushrecode/add")] - public async Task Add(List input) + public async Task Add(DevicePushRecodeDtoInput input) { return await _devicePushRecodeService.Add(input); } @@ -48,7 +48,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device /// [HttpPost("/api/devicepushrecode/add_alm")] [AllowAnonymous] - public async Task Add_alm(List input) + public async Task Add_alm(List input) { return await _devicePushRecodeService.Add_alm(input); } diff --git a/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs b/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs index 57371a3..2d88b54 100644 --- a/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs +++ b/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInput.cs @@ -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; } diff --git a/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs b/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs new file mode 100644 index 0000000..7a0a34c --- /dev/null +++ b/BPA.SAAS.KitChenManage.Application/Device/Dtos/DevicePushRecodeDtoInputalm.cs @@ -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; } + } +} diff --git a/BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs b/BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs index 8772889..888aa61 100644 --- a/BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs +++ b/BPA.SAAS.KitChenManage.Application/Device/Services/DevicePushRecodeService.cs @@ -91,13 +91,20 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services }; return util; } - public async Task Add_alm(List input) + /// + /// 数据下发(外部调用) + /// + /// + /// + public async Task Add_alm(List input) { var data = input.Adapt>(); string groupId = App.HttpContext.Request.Headers["groupId"].ToString(); if (string.IsNullOrWhiteSpace(groupId)) throw Oops.Oh("加盟商id不能为空"); + List 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 +112,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services //var maxmessageId=_db.Queryable().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,22 +121,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; } /// @@ -136,65 +153,46 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services /// /// /// - public async Task Add(List input) + public async Task Add(DevicePushRecodeDtoInput input) { - var data = input.Adapt>(); + var data = input.Adapt(); 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().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; } - /// - /// 数据下发回调更新数据 - /// - /// - /// - /// - public async Task CallBackDevicePushRecode(string messageId,string groupId) - { - var model = await _db.Queryable().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 Update(string id) { var data = _db.Queryable().Where(x => x.Id == id).First(); @@ -215,7 +213,7 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services TaskServicesManager.GetOrAdd(data.MessageId.ToString(), async (provider, token) => { await CallBackDevicePushRecode(data.MessageId.ToString(), groupId); }, trigger); - await BindMqReceived(data.MessageId.ToString(), groupId); + await BindMqReceived(data.MessageId.ToString(), groupId,""); return res > 0; } /// @@ -239,12 +237,53 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services } } /// + /// 数据下发回调更新数据 + /// + /// + /// + /// + private async Task CallBackDevicePushRecode(string messageId, string groupId) + { + var model = await _db.Queryable().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(); + } + } + /// + /// 数据下发回调更新数据(外部调用接口使用) + /// + /// + /// + /// + private async Task CallBackDevicePushRecode_alm(List messageId, string groupId) + { + for (int i = 0; i < messageId.Count; i++) + { + var model = await _db.Queryable().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(); + } + } + } + /// /// 监听订阅的topic主题 /// /// /// + /// /// - 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 => @@ -284,10 +323,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(); } }); diff --git a/BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs b/BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs index 1bfbace..2ed832a 100644 --- a/BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs +++ b/BPA.SAAS.KitChenManage.Application/Device/Services/IDevicePushRecodeService.cs @@ -17,13 +17,13 @@ namespace BPA.SAAS.KitChenManage.Application.Device.Services /// /// Task Page(DevicePushRecodeDtoPageInput input); - Task Add_alm(List input); + Task Add_alm(List input); /// /// 添加 /// /// /// - Task Add(List input); + Task Add(DevicePushRecodeDtoInput input); /// /// 更新 /// diff --git a/BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs b/BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs index baae0ee..414df1a 100644 --- a/BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs +++ b/BPA.SAAS.KitChenManage.Application/Push/Comm/CommDefaultHandle.cs @@ -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>(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(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(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(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(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(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(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(responseUnit); if (resUnit.statusCode != "200") throw Oops.Oh("获取物料单位数据失败"); diff --git a/BPA.SAAS.KitChenManage.Application/TestServices.cs b/BPA.SAAS.KitChenManage.Application/TestServices.cs index 5f0a775..ba537f8 100644 --- a/BPA.SAAS.KitChenManage.Application/TestServices.cs +++ b/BPA.SAAS.KitChenManage.Application/TestServices.cs @@ -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 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; + } } } diff --git a/BPA.SAAS.KitChenManage.Core/DbContext.cs b/BPA.SAAS.KitChenManage.Core/DbContext.cs index de697d7..00c8677 100644 --- a/BPA.SAAS.KitChenManage.Core/DbContext.cs +++ b/BPA.SAAS.KitChenManage.Core/DbContext.cs @@ -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(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) diff --git a/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs index 0123745..2fa726d 100644 --- a/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs +++ b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs @@ -19,7 +19,5 @@ namespace BPA.SAAS.KitChenManage.Core.Model /// 有效期 长期有效为空 /// public DateTime? PeriodValidity { get; set; } - - public DateTime UpdateAt { get; set; } } } diff --git a/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json index 8f67248..470db2e 100644 --- a/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json +++ b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json @@ -22,7 +22,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "", - "applicationUrl": "http://localhost:5007", + "applicationUrl": "http://192.168.1.19:5007", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json index 89e109c..2b2e5b1 100644 --- a/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json +++ b/BPA.SAAS.KitChenManage.Web.Entry/appsettings.json @@ -8,7 +8,7 @@ } }, "AllowedHosts": "*", - "baseurl": "http://localhost:5006/", + "baseurl": "http://192.168.1.19:5006/", "ConnectionConfigs": [ { "ConnectionString": "server=10.2.1.21;Database=bpa_kitchen_kitchenmanage;Uid=root;Pwd=cygadmin;Allow Zero Datetime=True;Convert Zero Datetime=True;",