diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs index c5bc67e..a129072 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs @@ -48,7 +48,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services public async Task> GetProductList() { var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; - var data = await _db.Queryable().Where(x=>x.Status==0 && x.GroupId== groupId) .ToListAsync(); + var data = await _db.Queryable().Where(x=>x.Status==0) .ToListAsync(); return data; } /// diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs index cf0acd8..41b2406 100644 --- a/BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs +++ b/BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs @@ -40,5 +40,9 @@ namespace BPA.SAAS.Manage.Application.Org.Dtos.Company /// public CommonStatus Status { get; set; } = CommonStatus.ENABLE; public string SysRoleId { get; set; } + /// + /// 所属平台 0 团餐 1门店 2 后厨 3公共 + /// + public int Type { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs b/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs index 9e11c78..824647b 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs @@ -124,7 +124,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services public async Task UpdateCompany(CompanyDtoInput input) { var company = input.Adapt(); - + company.CreateAt= DateTime.Now; var check = _db.Queryable().Where(x => x.IsDeleted == 0).First(t => t.Id == company.Id); if (check == null) diff --git a/BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs b/BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs index ab1cb62..7d82ab8 100644 --- a/BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs +++ b/BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs @@ -49,7 +49,7 @@ namespace BPA.SAAS.Manage.Application.System.Dtos /// /// 所属平台 0 团餐 1门店 2 后厨 /// - public int Type { get; set; } + public string Type { get; set; } /// /// 是否超管菜单 0否 1是 /// diff --git a/BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs b/BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs index 6e5c88a..a584ec5 100644 --- a/BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs +++ b/BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs @@ -47,6 +47,8 @@ namespace BPA.SAAS.Manage.Application.System.Dtos /// 组件 /// public string Component { get; set; } + public string Type { get; set; } + public string TypeName { get; set; } public int IsAdmin{ get; set; } private List _Children; diff --git a/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs b/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs index 21e9379..c485aa5 100644 --- a/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs +++ b/BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs @@ -13,7 +13,9 @@ namespace BPA.SAAS.Manage.Application.System.Interface Task Add(MenuDtoInput input); Task Update(MenuDtoInput input); Task Delete(List input); - Task> MenuTree(string getType); + Task> MenuTree(); + Task> MenuTree(string GetType); + Task> MenuParmyTree(string GetType, string type); Task> DymicMenuTree(int type); Task Enable(string Id); Task Disable(string Id); diff --git a/BPA.SAAS.Manage.Application/System/MenuServices.cs b/BPA.SAAS.Manage.Application/System/MenuServices.cs index 14aa308..6c7cf52 100644 --- a/BPA.SAAS.Manage.Application/System/MenuServices.cs +++ b/BPA.SAAS.Manage.Application/System/MenuServices.cs @@ -2,6 +2,7 @@ using BPA.SAAS.Manage.Application.System.Interface; using System; using System.Collections.Generic; +using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -57,9 +58,19 @@ namespace BPA.SAAS.Manage.Application.System /// /// [HttpGet("/api/menu/menutrees")] - public async Task> MenuTree(string getType) + public async Task> MenuTree(string GetType) { - return await _menuService.MenuTree(getType); + return await _menuService.MenuTree(GetType); + } + [HttpGet("/api/menu/menutreesall")] + public async Task> MenuTree() + { + return await _menuService.MenuTree(); + } + [HttpGet("/api/menu/menuparmytrees")] + public async Task> MenuParmyTree(string GetType, string type) + { + return await _menuService.MenuParmyTree(GetType, type); } [HttpGet("/api/menu/menutree")] public async Task> DymicMenuTree(int type) diff --git a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs index 4605394..a3a960e 100644 --- a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs +++ b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs @@ -7,9 +7,11 @@ using BPA.SAAS.Manage.Core.System; using Furion.LinqBuilder; using Mapster.Utils; using NPOI.SS.Formula.Functions; +using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; @@ -54,6 +56,8 @@ namespace BPA.SAAS.Manage.Application.System.Services Component = t.Component, Status = t.Status, IsAdmin=t.IsAdmin, + Type= t.Type, + TypeName= GetTypeName(t.Type), Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeDtoOutput { Id = x.Id, @@ -67,6 +71,8 @@ namespace BPA.SAAS.Manage.Application.System.Services Component = x.Component, Status = x.Status, IsAdmin=x.IsAdmin, + Type = x.Type, + TypeName = GetTypeName(x.Type), Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeDtoOutput { Id = y.Id.ToString(), @@ -79,13 +85,44 @@ namespace BPA.SAAS.Manage.Application.System.Services Sort = y.Sort, Component = y.Component, Status = y.Status, - IsAdmin=y.IsAdmin + IsAdmin=y.IsAdmin, + Type = y.Type, + TypeName = GetTypeName(y.Type), }).ToList() }).ToList() }).ToList(); return data; } + public string GetTypeName(string type) + { + var ary = type.Split(','); + var name = ""; + for (int i = 0; i < ary.Length; i++) + { + if (ary[i] == "0") + { + name += "团餐"; + } + if (ary[i] == "1") + { + name += "门店"; + } + if (ary[i] == "2") + { + name += "后厨"; + } + if (ary[i] == "3") + { + name += "公共"; + } + if(i< ary.Length - 1) + { + name += ","; + } + } + return name; + } /// /// 新增菜单 /// @@ -124,6 +161,7 @@ namespace BPA.SAAS.Manage.Application.System.Services menu.Sort = input.Sort; menu.Icon = input.Icon; menu.IsAdmin= input.IsAdmin; + menu.Type = input.Type; return await _db.Updateable(menu).ExecuteCommandAsync()>0; } @@ -164,12 +202,12 @@ namespace BPA.SAAS.Manage.Application.System.Services { var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; - var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; - if (string.IsNullOrWhiteSpace(GroupId) || string.IsNullOrWhiteSpace(userId)) + // var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + if ( string.IsNullOrWhiteSpace(userId)) { return null; } - List dataRoles =await _db.Queryable().Where(a => a.GroupId == GroupId).ToListAsync(); + List dataRoles =await _db.Queryable().ToListAsync(); if (dataRoles.Count() <= 0) { return null; @@ -178,23 +216,23 @@ namespace BPA.SAAS.Manage.Application.System.Services var menus = _db.Queryable().Where(t => sysRoleId.Contains(t.SysRoleId)) .Select(x => x.SysMenuId).ToArray(); - var AllMenus = _db.Queryable().Where(t => t.IsDeleted == 0 && menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList(); + var AllMenus = _db.Queryable().Where(t => menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList(); var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput { Key = t.Id, Title = t.Name, - value = t.Name, + value = t.Id, Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput { Key = x.Id, Title = x.Name, - value = x.Name, + value = x.Id, Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput { Key = y.Id, Title = y.Name, - value = y.Name, + value = y.Id, }).ToList() }).ToList() }).ToList(); @@ -204,7 +242,62 @@ namespace BPA.SAAS.Manage.Application.System.Services } else { - var AllMenus = _db.Queryable().Where(t => t.IsDeleted == 0).OrderBy(t => t.Sort).ToList(); + var AllMenus = _db.Queryable().OrderBy(t => t.Sort).ToList(); + var data = AllMenus.Where((t => t.Pid == null || t.Pid == "")).Select(t => new MenuTreeOutput + { + Key = t.Id, + Title = t.Name, + value = t.Id, + Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput + { + Key = x.Id, + Title = x.Name, + value = x.Id, + Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput + { + Key = y.Id, + Title = y.Name, + value = y.Name, + }).ToList() + }).ToList() + }).ToList(); + var da = new List(); + data.ForEach(x => + { + if (x.Children.Count() > 0) + { + da.Add(x); + } + + }); + + + return da; + + } + + } + public async Task> MenuParmyTree(string GetType, string type) + { + if (!string.IsNullOrWhiteSpace(GetType) && GetType.ToLower() == "user") + { + + var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value; + // var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return null; + } + List dataRoles = await _db.Queryable().ToListAsync(); + if (dataRoles.Count() <= 0) + { + return null; + } + var sysRoleId = dataRoles.Select(a => a.Id).ToArray(); + var menus = _db.Queryable().Where(t => sysRoleId.Contains(t.SysRoleId)) + .Select(x => x.SysMenuId).ToArray(); + + var AllMenus = _db.Queryable().Where(t => menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList(); var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput { @@ -220,7 +313,7 @@ namespace BPA.SAAS.Manage.Application.System.Services { Key = y.Id, Title = y.Name, - value = y.Name, + value = y.Id, }).ToList() }).ToList() }).ToList(); @@ -228,7 +321,65 @@ namespace BPA.SAAS.Manage.Application.System.Services return data; } + else + { + var AllMenus = _db.Queryable().Where(t => (t.Type.Contains(type) || t.Type.Contains("3")) && t.IsAdmin == 0).OrderBy(t => t.Sort).ToList(); + var data = AllMenus.Where((t => t.Pid == null || t.Pid == "")).Select(t => new MenuTreeOutput + { + Key = t.Id, + Title = t.Name, + value = t.Id, + Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput + { + Key = x.Id, + Title = x.Name, + value = x.Id, + Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput + { + Key = y.Id, + Title = y.Name, + value = y.Name, + }).ToList() + }).ToList() + }).ToList(); + var da = new List(); + data.ForEach(x => + { + if (x.Children.Count() > 0) + { + da.Add(x); + } + }); + + + return da; + + } + + } + public async Task> MenuTree() + { + var AllMenus = _db.Queryable().OrderBy(t => t.Sort).ToList(); + var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput + { + Key = t.Id, + Title = t.Name, + value = t.Id, + Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput + { + Key = x.Id, + Title = x.Name, + value = x.Id, + Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput + { + Key = y.Id, + Title = y.Name, + value = y.Id, + }).ToList() + }).ToList() + }).ToList(); + return data; } /// /// 动态菜单(菜单树) diff --git a/BPA.SAAS.Manage.Core/DbContext.cs b/BPA.SAAS.Manage.Core/DbContext.cs index 1ac2dab..813b84d 100644 --- a/BPA.SAAS.Manage.Core/DbContext.cs +++ b/BPA.SAAS.Manage.Core/DbContext.cs @@ -37,7 +37,7 @@ namespace BPA.SAAS.Manage.Core { db.QueryFilter.AddTableFilter(it => it.IsDeleted == 0); //db.QueryFilter.AddTableFilter(it => it.Status == 0); - if (!IsSuperAdmin()) + if (!IsSuperAdmin() && App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value != null) { //非管理员账户过滤加盟商数据 var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; @@ -83,6 +83,7 @@ namespace BPA.SAAS.Manage.Core private static bool IsSuperAdmin() { if (App.User == null) return false; + var sd = App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value; return App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == "1"; } } diff --git a/BPA.SAAS.Manage.Core/Org/BPA_Company.cs b/BPA.SAAS.Manage.Core/Org/BPA_Company.cs index 3169d50..c17e96d 100644 --- a/BPA.SAAS.Manage.Core/Org/BPA_Company.cs +++ b/BPA.SAAS.Manage.Core/Org/BPA_Company.cs @@ -43,5 +43,9 @@ namespace BPA.SAAS.Manage.Core.Org /// 状态 【正常 停用】默认 正常 /// public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + /// + /// 所属平台 0 团餐 1门店 2 后厨 3公共 + /// + public int Type { get; set; } } } diff --git a/BPA.SAAS.Manage.Core/Product/BPA_Product.cs b/BPA.SAAS.Manage.Core/Product/BPA_Product.cs index 6044e32..0a27abf 100644 --- a/BPA.SAAS.Manage.Core/Product/BPA_Product.cs +++ b/BPA.SAAS.Manage.Core/Product/BPA_Product.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Core.Product { [SugarTable("bpa_product")] - public class BPA_Product : IBaseEntity, IGroupId + public class BPA_Product : IBaseEntity { public string Name { get; set; } public string Key { get; set; } @@ -18,7 +18,7 @@ namespace BPA.SAAS.Manage.Core.Product /// 状态 0启用 1禁用 /// public CommonStatus Status { get; set; } = CommonStatus.ENABLE; - public string GroupId { get; set; } + //public string GroupId { get; set; } public string Code { get; set; } /// /// 备注 diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs index 8468c91..d999347 100644 --- a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs +++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs @@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Product ///产品功能 /// [SugarTable("bpa_productfunction")] - public class BPA_ProductFunction : IBaseEntity, IGroupId + public class BPA_ProductFunction : IBaseEntity { /// /// 功能名称 @@ -26,7 +26,7 @@ namespace BPA.SAAS.Manage.Core.Product /// /// 加盟商id /// - public string GroupId { get; set; } + // public string GroupId { get; set; } /// /// 外键 /// diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs index 85643e8..effb20a 100644 --- a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs +++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Core.Product { - public class BPA_ProductFunctionAction : IBaseEntity, IGroupId + public class BPA_ProductFunctionAction : IBaseEntity { /// /// 功能id @@ -37,6 +37,6 @@ namespace BPA.SAAS.Manage.Core.Product /// 排序 /// public int Sort { get; set; } - public string GroupId { get; set; } + // public string GroupId { get; set; } } } diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs index 829c2a0..ebd30d9 100644 --- a/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs +++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Core.Product { [SugarTable("bpa_producttopics")] - public class BPA_ProductTopics : IBaseEntity, IGroupId + public class BPA_ProductTopics : IBaseEntity { /// /// Topics类 @@ -24,6 +24,6 @@ namespace BPA.SAAS.Manage.Core.Product /// public string Description { get; set; } public string ProductId { get; set; } - public string GroupId { get; set; } + //public string GroupId { get; set; } } } diff --git a/BPA.SAAS.Manage.Core/System/BPA_Menu.cs b/BPA.SAAS.Manage.Core/System/BPA_Menu.cs index e677305..03ea995 100644 --- a/BPA.SAAS.Manage.Core/System/BPA_Menu.cs +++ b/BPA.SAAS.Manage.Core/System/BPA_Menu.cs @@ -51,7 +51,7 @@ namespace BPA.SAAS.Manage.Core.System /// /// 所属平台 0 团餐 1门店 2 后厨 3公共 /// - public int Type { get; set; } + public string Type { get; set; } /// /// 是否超管菜单 0否 1是 /// diff --git a/BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj b/BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj index 4a00165..df24029 100644 --- a/BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj +++ b/BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj @@ -16,6 +16,7 @@ + diff --git a/BPA.SAAS.Manage.Web.Core/Startup.cs b/BPA.SAAS.Manage.Web.Core/Startup.cs index bf1814b..9f63800 100644 --- a/BPA.SAAS.Manage.Web.Core/Startup.cs +++ b/BPA.SAAS.Manage.Web.Core/Startup.cs @@ -1,4 +1,5 @@ -using BPA.SAAS.Manage.Application.System.Dtos; +using BPA.MQTTClient; +using BPA.SAAS.Manage.Application.System.Dtos; using BPA.SAAS.Manage.Core; using FluentValidation.AspNetCore; using Furion; @@ -6,7 +7,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; using Newtonsoft.Json; +using System; +using System.Threading.Tasks; namespace BPA.SAAS.Manage.Web.Core { @@ -29,6 +34,36 @@ namespace BPA.SAAS.Manage.Web.Core options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; }); + services.AddMqttClientHostedService(op => + { + op.Port = int.Parse(App.Configuration["dev1_brokerHostSettings:Port"]); + op.Server = App.Configuration["dev1_brokerHostSettings:Host"]; + op.UserName = App.Configuration["MqttClientSettings:UserName"]; + op.Password = App.Configuration["MqttClientSettings:Password"]; + op.mqttClientConnectedHandlerDelegate = new MqttClientConnectedHandlerDelegate(async e => + { + Console.WriteLine("MQTT连接成功"); + }); + op.mqttClientDisconnectedHandlerDelegate = new MqttClientDisconnectedHandlerDelegate(async e => + { + Console.WriteLine("MQTT断开连接"); + await Task.Delay(TimeSpan.FromSeconds(5)); + try + { + //var options = op.Server.GetService(); + //await op.Server.GetService().ConnectAsync(options); + } + catch (global::System.Exception) + { + + + } + }); + op.MqttApplicationMessageReceivedHandler = new MQTTnet.Client.Receiving.MqttApplicationMessageReceivedHandlerDelegate(async e => + { + + }); + }); services.AddCorsAccessor(); services.AddSqlsugarSetup(App.Configuration); services.AddControllers() diff --git a/BPA.SAAS.Manage.Web.Entry/appsettings.json b/BPA.SAAS.Manage.Web.Entry/appsettings.json index d489dad..e9b3b2b 100644 --- a/BPA.SAAS.Manage.Web.Entry/appsettings.json +++ b/BPA.SAAS.Manage.Web.Entry/appsettings.json @@ -22,6 +22,14 @@ "SecretId": "AKIDa4KQIvKUP6bw4ye6JI3a8lCPN7cswnV3", "SecretKey": "ObaLtCH9nCNPFrFQO7ex2sTqyxlLgnfJ" }, + "dev1_brokerHostSettings": { + "Port": 8083, + "Host": "10.2.1.21" + }, + "MqttClientSettings": { + "UserName": "emqx_u_block", + "Password": "emqx_p_admin8765490789" + }, "order_url": "http://order", "wechat_url": "http://wechat" } \ No newline at end of file