From 3de92dab065927024fc612e2b2afe67c9b04ee6b Mon Sep 17 00:00:00 2001 From: pofi Date: Fri, 24 Mar 2023 09:37:07 +0800 Subject: [PATCH] merge from 2023-03-14 --- Tnb.Server.sln | 12 + .../Extensions/LoggingConfigureExtensions.cs | 7 + apihost/Tnb.API.Entry/Startup.cs | 27 +- .../Tnb.Common.Core}/Handlers/IMHandler.cs | 2 +- .../Manager/User/UserManager.cs | 624 ++++++++++++------ common/Tnb.Common.Core/Tnb.Common.Core.csproj | 2 + .../Attributes/CodeGenUploadAttribute.cs | 56 +- common/Tnb.Common/Enums/ErrorCode.cs | 18 + common/Tnb.Common/Models/SuperQueryModel.cs | 5 + common/Tnb.Common/Security/CodeGenHelper.cs | 16 +- .../Dto/Customer/CustomerListOutput.cs | 41 ++ .../Dto/Product/ProductCrInput.cs | 3 +- .../Dto/ProductEntry/ProductEntryCrInput.cs | 60 ++ .../ProductEntry/ProductEntryInfoOutput.cs | 5 + .../ProductGoods/ProductGoodsListOutput.cs | 50 ++ .../ProductGoodsListQueryInput.cs | 26 + .../Entity/BigDataEntity.cs | 3 +- .../Entity/CustomerEntity.cs | 59 ++ .../Entity/DocumentEntity.cs | 3 +- .../Entity/DocumentShareEntity.cs | 3 +- .../Entity/EmailConfigEntity.cs | 3 +- .../Entity/EmailReceiveEntity.cs | 3 +- .../Entity/EmailSendEntity.cs | 3 +- .../Entity/EmployeeEntity.cs | 3 +- .../Tnb.Extend.Entitys/Entity/OrderEntity.cs | 3 +- .../Entity/OrderEntryEntity.cs | 3 +- .../Entity/OrderReceivableEntity.cs | 3 +- .../Entity/ProductClassifyEntity.cs | 26 +- .../Entity/ProductEntity.cs | 8 +- .../Entity/ProjectGanttEntity.cs | 3 +- .../Entity/ScheduleEntity.cs | 3 +- .../Entity/TableExampleEntity.cs | 3 +- .../Entity/WorkLogEntity.cs | 3 +- .../Entity/WorkLogShareEntity.cs | 3 +- extend/Tnb.Extend/ProductClassifyService.cs | 2 +- extend/Tnb.Extend/ProductService.cs | 153 ++++- message/Tnb.Message/Service/ImReplyService.cs | 4 +- message/Tnb.Message/Service/MessageService.cs | 7 +- message/Tnb.Message/Tnb.Message.csproj | 1 - .../Permission/AuthorizeService.cs | 133 +++- .../Permission/UsersCurrentService.cs | 7 + system/Tnb.Systems/Permission/UsersService.cs | 11 + .../System/DataInterfaceService.cs | 7 +- system/Tnb.Systems/System/SystemService.cs | 116 +++- .../CodeGen/CodeGenWay.cs | 27 +- .../Model/CodeGen/TableColumnConfigModel.cs | 9 +- .../Tnb.VisualDev.Engine/Model/ConfigModel.cs | 6 + .../Model/EntityFieldModel.cs | 2 +- .../Tnb.VisualDev.Engine/Model/FieldsModel.cs | 5 + .../BackEnd/CodeGenControlsAttributeHelper.cs | 24 +- .../Security/CodeGenUnifiedHandlerHelper.cs | 37 ++ .../CodeGenFormControlDesignHelper.cs | 4 + .../CodeGen/DataParsing/ControlParsing.cs | 117 ++-- .../ExportImport/ExportImportDataHelper.cs | 235 +++++-- visualdev/Tnb.VisualDev/CodeGenService.cs | 3 +- visualdev/Tnb.VisualDev/VisualDevService.cs | 58 +- .../Repository/FlowTaskRepository.cs | 6 +- 57 files changed, 1538 insertions(+), 528 deletions(-) rename {message/Tnb.Message => common/Tnb.Common.Core}/Handlers/IMHandler.cs (99%) create mode 100644 extend/Tnb.Extend.Entitys/Dto/Customer/CustomerListOutput.cs create mode 100644 extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryCrInput.cs create mode 100644 extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListOutput.cs create mode 100644 extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListQueryInput.cs create mode 100644 extend/Tnb.Extend.Entitys/Entity/CustomerEntity.cs diff --git a/Tnb.Server.sln b/Tnb.Server.sln index 9c4fd3a3..524e1e4b 100644 --- a/Tnb.Server.sln +++ b/Tnb.Server.sln @@ -87,6 +87,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tnb.Extend.Entitys", "exten EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tnb.Extend.Interfaces", "extend\Tnb.Extend.Interfaces\Tnb.Extend.Interfaces.csproj", "{2E9F8B23-37B9-42BD-A62F-140A38C43A89}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tnb.Core", "..\Tnb.Core\src\Tnb.Core\Tnb.Core.csproj", "{6CE14DF1-4AC2-4E21-8910-1898BF7C2C6E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tnb.SqlSugar", "..\Tnb.Core\src\Tnb.SqlSugar\Tnb.SqlSugar.csproj", "{8144C78D-AF9A-4C1B-8A18-CCD78B26D870}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -209,6 +213,14 @@ Global {2E9F8B23-37B9-42BD-A62F-140A38C43A89}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E9F8B23-37B9-42BD-A62F-140A38C43A89}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E9F8B23-37B9-42BD-A62F-140A38C43A89}.Release|Any CPU.Build.0 = Release|Any CPU + {6CE14DF1-4AC2-4E21-8910-1898BF7C2C6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CE14DF1-4AC2-4E21-8910-1898BF7C2C6E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CE14DF1-4AC2-4E21-8910-1898BF7C2C6E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CE14DF1-4AC2-4E21-8910-1898BF7C2C6E}.Release|Any CPU.Build.0 = Release|Any CPU + {8144C78D-AF9A-4C1B-8A18-CCD78B26D870}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8144C78D-AF9A-4C1B-8A18-CCD78B26D870}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8144C78D-AF9A-4C1B-8A18-CCD78B26D870}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8144C78D-AF9A-4C1B-8A18-CCD78B26D870}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/apihost/Tnb.API.Entry/Extensions/LoggingConfigureExtensions.cs b/apihost/Tnb.API.Entry/Extensions/LoggingConfigureExtensions.cs index 71001cb9..02a3bd50 100644 --- a/apihost/Tnb.API.Entry/Extensions/LoggingConfigureExtensions.cs +++ b/apihost/Tnb.API.Entry/Extensions/LoggingConfigureExtensions.cs @@ -28,6 +28,13 @@ public static class LoggingConfigureExtensions writeError.UseRollbackFileName(Path.GetFileNameWithoutExtension(writeError.CurrentFileName) + "-oops" + Path.GetExtension(writeError.CurrentFileName)); }; }); + // 日志监听 + // services.AddMonitorLogging(options => + //{ + // options.IgnorePropertyNames = new[] { "Byte" }; + // options.IgnorePropertyTypes = new[] { typeof(byte[]) }; + //}); + return services; } private static string LoggerLevelName(LogLevel level) diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index 20ce7f93..58552448 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -1,31 +1,26 @@ -using JNPF.API.Entry.Handlers; +using IGeekFan.AspNetCore.Knife4jUI; +using JNPF.API.Entry.Handlers; using JNPF.Common.Cache; using JNPF.Common.Core.Filter; +using JNPF.Common.Core.Handlers; +using JNPF.Common.Security; using JNPF.DatabaseAccessor; using JNPF.EventHandler; using JNPF.JsonSerialization; -using JNPF.Message.Handlers; +using JNPF.SpecificationDocument; using JNPF.TaskScheduler.Interfaces.TaskScheduler; using JNPF.UnifyResult; +using JNPF.VisualDev; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Options; -using Newtonsoft.Json.Serialization; using Newtonsoft.Json; -using Senparc.CO2NET.RegisterServices; +using Newtonsoft.Json.Serialization; using Senparc.CO2NET; +using Senparc.CO2NET.RegisterServices; using Senparc.Weixin; using Senparc.Weixin.Entities; using Senparc.Weixin.RegisterServices; using SqlSugar; -using IGeekFan.AspNetCore.Knife4jUI; -using JNPF.SpecificationDocument; -using JNPF.Logging; -using System.Xml; -using System; -using System.Text; -using Top.Api; -using JNPF.Common.Security; -using JNPF.VisualDev; namespace JNPF.API.Entry; @@ -137,12 +132,6 @@ public class Startup : AppStartup services.AddMemoryCache(); // 使用本地缓存必须添加 services.LoggingConfigure(); - // 日志监听 - // services.AddMonitorLogging(options => - //{ - // options.IgnorePropertyNames = new[] { "Byte" }; - // options.IgnorePropertyTypes = new[] { typeof(byte[]) }; - //}); services.AddUnitOfWork(); diff --git a/message/Tnb.Message/Handlers/IMHandler.cs b/common/Tnb.Common.Core/Handlers/IMHandler.cs similarity index 99% rename from message/Tnb.Message/Handlers/IMHandler.cs rename to common/Tnb.Common.Core/Handlers/IMHandler.cs index bf91863a..0463f5eb 100644 --- a/message/Tnb.Message/Handlers/IMHandler.cs +++ b/common/Tnb.Common.Core/Handlers/IMHandler.cs @@ -20,7 +20,7 @@ using JNPF.WebSockets; using Mapster; using SqlSugar; -namespace JNPF.Message.Handlers; +namespace JNPF.Common.Core.Handlers; /// /// IM 处理程序. diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.cs b/common/Tnb.Common.Core/Manager/User/UserManager.cs index 3f9c44d5..3d47bf3a 100644 --- a/common/Tnb.Common.Core/Manager/User/UserManager.cs +++ b/common/Tnb.Common.Core/Manager/User/UserManager.cs @@ -13,7 +13,6 @@ using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using Microsoft.AspNetCore.Http; using SqlSugar; -using System.Net.Http; using System.Security.Claims; namespace JNPF.Common.Core.Manager; @@ -206,7 +205,7 @@ public class UserManager : IUserManager, IScoped UserAgent userAgent = new UserAgent(_httpContext); var data = new UserInfoModel(); var ipAddress = NetHelper.Ip; - //var ipAddressName = await NetHelper.GetLocation(ipAddress); + var ipAddressName = await NetHelper.GetLocation(ipAddress); var userDataScope = await GetUserDataScopeAsync(UserId); var sysConfigInfo = await _repository.AsSugarClient().Queryable().FirstAsync(s => s.Category.Equals("SysConfig") && s.Key.ToLower().Equals("tokentimeout")); data = await _repository.AsQueryable().Where(it => it.Id == UserId) @@ -252,8 +251,8 @@ public class UserManager : IUserManager, IScoped data.loginTime = DateTime.Now; data.prevLogin = (await _repository.AsSugarClient().Queryable().FirstAsync(x => x.Category.Equals("SysConfig") && x.Key.ToLower().Equals("lastlogintimeswitch"))).Value.ParseToInt(); data.loginIPAddress = ipAddress; - //data.loginIPAddressName = ipAddressName; - //data.prevLoginIPAddressName = await NetHelper.GetLocation(data.prevLoginIPAddress); + data.loginIPAddressName = ipAddressName; + data.prevLoginIPAddressName = await NetHelper.GetLocation(data.prevLoginIPAddress); data.loginPlatForm = userAgent.RawValue; data.subsidiary = await GetSubsidiaryAsync(data.organizeId, data.isAdministrator); data.subordinates = await this.GetSubordinatesAsync(UserId); @@ -501,11 +500,13 @@ public class UserManager : IUserManager, IScoped var itemValue = fieldItem.Value; var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op); + var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); + if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like; + if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike; switch (itemValue) { case "@userId": // 当前用户 { - var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.userId); switch (conditionItem.Logic) { case "and": @@ -524,17 +525,29 @@ public class UserManager : IUserManager, IScoped { var ids = new List() { userInfo.userId }; ids.AddRange(userInfo.subordinates); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } @@ -543,7 +556,6 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(userInfo.organizeId)) { - var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.organizeId); switch (conditionItem.Logic) { case "and": @@ -554,7 +566,6 @@ public class UserManager : IUserManager, IScoped break; } } - } break; @@ -564,17 +575,29 @@ public class UserManager : IUserManager, IScoped { var ids = new List() { userInfo.organizeId }; ids.AddRange(userInfo.subsidiary); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } } @@ -583,43 +606,79 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganize": // 当前分管组织 { - var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); - if (orgId != null) + var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); + if (ids != null) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } + else + { + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = "jnpf", ConditionalType = (int)ConditionalType.Equal } }); + } } break; case "@branchManageOrganizeAndSub": // 当前分管组织及子组织 { - var subOrgIds = new List(); + var ids = new List(); DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList() - .ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); + .ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); - if (subOrgIds.Any()) + if (ids.Any()) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } + else + { + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = "jnpf", ConditionalType = (int)ConditionalType.Equal } }); + } } break; @@ -628,9 +687,9 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(itemValue)) { - var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); - if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like; - if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike; + var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); + if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like; + if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike; switch (conditionItem.Logic) { case "and": @@ -646,6 +705,8 @@ public class UserManager : IUserManager, IScoped break; } + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } }); } if (conditionalList.Any()) @@ -749,19 +810,21 @@ public class UserManager : IUserManager, IScoped var itemValue = fieldItem.Value; var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op); + var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); + if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like; + if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike; switch (itemValue) { case "@userId": // 当前用户 { - var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.userId); switch (conditionItem.Logic) { case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = userInfo.userId, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = UserId, ConditionalType = (int)cmodel.ConditionalType } }); break; case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = userInfo.userId, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = UserId, ConditionalType = (int)cmodel.ConditionalType } }); break; } @@ -770,59 +833,81 @@ public class UserManager : IUserManager, IScoped break; case "@userAraSubordinates": // 当前用户集下属 { - var ids = new List() { userInfo.userId }; - ids.AddRange(userInfo.subordinates); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + var ids = new List() { UserId }; + ids.AddRange(Subordinates); + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } break; case "@organizeId": // 当前组织 { - if (!string.IsNullOrEmpty(userInfo.organizeId)) + if (!string.IsNullOrEmpty(User.OrganizeId)) { - var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.organizeId); switch (conditionItem.Logic) { case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = userInfo.organizeId, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = User.OrganizeId, ConditionalType = (int)cmodel.ConditionalType } }); break; case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = userInfo.organizeId, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = User.OrganizeId, ConditionalType = (int)cmodel.ConditionalType } }); break; } } - } break; case "@organizationAndSuborganization": // 当前组织及子组织 { - if (!string.IsNullOrEmpty(userInfo.organizeId)) + if (!string.IsNullOrEmpty(User.OrganizeId)) { - var ids = new List() { userInfo.organizeId }; - ids.AddRange(userInfo.subsidiary); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + var ids = new List() { User.OrganizeId }; + ids.AddRange(Subsidiary); + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } } @@ -831,18 +916,32 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganize": // 当前分管组织 { - var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); - if (orgId != null) + var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); + if (ids != null) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -855,21 +954,35 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganizeAndSub": // 当前分管组织及子组织 { - var subOrgIds = new List(); + var ids = new List(); DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList() - .ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); + .ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); - if (subOrgIds.Any()) + if (ids.Any()) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -884,16 +997,16 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(itemValue)) { - var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); - if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like; - if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike; + var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); + if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like; + if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike; switch (conditionItem.Logic) { case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; } } @@ -902,6 +1015,8 @@ public class UserManager : IUserManager, IScoped break; } + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } }); } if (conditionalList.Any()) @@ -1048,11 +1163,13 @@ public class UserManager : IUserManager, IScoped var itemValue = fieldItem.Value; var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op); + var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); + if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like; + if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike; switch (itemValue) { case "@userId": // 当前用户 { - var cmodel = GetConditionalModel(itemMethod, itemField, UserId); switch (conditionItem.Logic) { case "and": @@ -1070,19 +1187,30 @@ public class UserManager : IUserManager, IScoped case "@userAraSubordinates": // 当前用户集下属 { var ids = new List() { UserId }; - var subordinates = await this.GetSubordinatesAsync(UserId); - ids.AddRange(subordinates); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + ids.AddRange(Subordinates); + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } @@ -1091,7 +1219,6 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(User.OrganizeId)) { - var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); switch (conditionItem.Logic) { case "and": @@ -1108,23 +1235,33 @@ public class UserManager : IUserManager, IScoped break; case "@organizationAndSuborganization": // 当前组织及子组织 { - var userInfo = User; - if (!string.IsNullOrEmpty(userInfo.OrganizeId)) + if (!string.IsNullOrEmpty(User.OrganizeId)) { - var subsidiary = await GetSubsidiaryAsync(userInfo.OrganizeId, userInfo.IsAdministrator.Equals(1)); - var ids = new List() { userInfo.OrganizeId }; - ids.AddRange(subsidiary); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + var ids = new List() { User.OrganizeId }; + ids.AddRange(Subsidiary); + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } } @@ -1133,18 +1270,32 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganize": // 当前分管组织 { - var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); - if (orgId != null) + var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); + if (ids != null) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -1157,21 +1308,35 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganizeAndSub": // 当前分管组织及子组织 { - var subOrgIds = new List(); + var ids = new List(); DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList() - .ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); + .ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); - if (subOrgIds.Any()) + if (ids.Any()) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -1186,24 +1351,25 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(itemValue)) { - var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); - if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like; - if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike; + var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); + if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like; + if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike; switch (conditionItem.Logic) { case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; } } - } break; } + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } }); codeGenConditionalObject.Find(it => it.FieldRule == fieldRule && it.TableName.Equals(tableName)).conditionalModel.AddRange(conditionalList); } @@ -1329,11 +1495,13 @@ public class UserManager : IUserManager, IScoped var itemValue = fieldItem.Value; var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op); + var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); + if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like; + if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike; switch (itemValue) { case "@userId": // 当前用户 { - var cmodel = GetConditionalModel(itemMethod, itemField, UserId); switch (conditionItem.Logic) { case "and": @@ -1352,17 +1520,29 @@ public class UserManager : IUserManager, IScoped { var ids = new List() { UserId }; ids.AddRange(Subordinates); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } @@ -1371,7 +1551,6 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(User.OrganizeId)) { - var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId); switch (conditionItem.Logic) { case "and": @@ -1382,7 +1561,6 @@ public class UserManager : IUserManager, IScoped break; } } - } break; @@ -1392,17 +1570,29 @@ public class UserManager : IUserManager, IScoped { var ids = new List() { User.OrganizeId }; ids.AddRange(Subsidiary); - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + if(i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } }); + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); - break; + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } } @@ -1411,18 +1601,32 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganize": // 当前分管组织 { - var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); - if (orgId != null) + var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList(); + if (ids != null) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if(itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -1435,21 +1639,35 @@ public class UserManager : IUserManager, IScoped case "@branchManageOrganizeAndSub": // 当前分管组织及子组织 { - var subOrgIds = new List(); + var ids = new List(); DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList() - .ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); + .ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList())); - if (subOrgIds.Any()) + if (ids.Any()) { - var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds)); - switch (conditionItem.Logic) + for (int i = 0; i < ids.Count; i++) { - case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; - case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } }); - break; + if (i == 0) + { + switch (conditionItem.Logic) + { + case "and": + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + case "or": + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + + break; + } + } + else + { + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + else + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } }); + } } } else @@ -1464,16 +1682,16 @@ public class UserManager : IUserManager, IScoped { if (!string.IsNullOrEmpty(itemValue)) { - var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); - if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like; - if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike; + var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type); + if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like; + if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike; switch (conditionItem.Logic) { case "and": - conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; case "or": - conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } }); + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } }); break; } } @@ -1482,6 +1700,8 @@ public class UserManager : IUserManager, IScoped break; } + if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded)) + conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } }); } if (conditionalList.Any()) @@ -1691,12 +1911,14 @@ public class UserManager : IUserManager, IScoped // 包含 case QueryType.In: - case QueryType.Included: return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.In, FieldValue = fieldValue }; + case QueryType.Included: + return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.Like, FieldValue = fieldValue }; // 不包含 case QueryType.NotIn: + return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.In, FieldValue = fieldValue }; case QueryType.NotIncluded: - return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.NotIn, FieldValue = fieldValue }; + return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.NoLike, FieldValue = fieldValue }; } return new ConditionalModel(); diff --git a/common/Tnb.Common.Core/Tnb.Common.Core.csproj b/common/Tnb.Common.Core/Tnb.Common.Core.csproj index ec8977f0..54f913dd 100644 --- a/common/Tnb.Common.Core/Tnb.Common.Core.csproj +++ b/common/Tnb.Common.Core/Tnb.Common.Core.csproj @@ -14,8 +14,10 @@ + + diff --git a/common/Tnb.Common/CodeGenUpload/Attributes/CodeGenUploadAttribute.cs b/common/Tnb.Common/CodeGenUpload/Attributes/CodeGenUploadAttribute.cs index 913267e8..08e67d97 100644 --- a/common/Tnb.Common/CodeGenUpload/Attributes/CodeGenUploadAttribute.cs +++ b/common/Tnb.Common/CodeGenUpload/Attributes/CodeGenUploadAttribute.cs @@ -86,12 +86,14 @@ public class CodeGenUploadAttribute : Attribute /// 构造函数 /// "popupSelect". /// - public CodeGenUploadAttribute(string Model, string SecondParameter, string ThreeParameters, string FourParameters, string Config) + public CodeGenUploadAttribute(string Model, string dataConversionModel, string SecondParameter, string ThreeParameters, string FourParameters, string ShowField, string Config) { __Model__ = Model; + __vModel__ = dataConversionModel; interfaceId = SecondParameter; propsValue = ThreeParameters; relationField = FourParameters; + showField = ShowField; __config__ = Config.ToObject(); } @@ -135,9 +137,7 @@ public class CodeGenUploadAttribute : Attribute /// /// 构造函数 /// "treeSelect" - /// "usersSelect": - /// "depSelect": - /// "relationForm". + /// "depSelect":. /// public CodeGenUploadAttribute(string Model, bool Multiple, string ThreeParameters, string FourParameters, string Config) { @@ -146,18 +146,10 @@ public class CodeGenUploadAttribute : Attribute __config__ = Config.ToObject(); switch (__config__.jnpfKey) { - case JnpfKeyConst.RELATIONFORM: - modelId = ThreeParameters; - relationField = FourParameters; - break; case JnpfKeyConst.DEPSELECT: selectType = ThreeParameters; ableDepIds = FourParameters?.ToObject>(); break; - case JnpfKeyConst.USERSSELECT: - selectType = ThreeParameters; - ableIds = FourParameters?.ToObject>(); - break; default: props = ThreeParameters?.ToObject(); options = FourParameters?.ToObject>(); @@ -165,10 +157,25 @@ public class CodeGenUploadAttribute : Attribute } } + /// + /// 构造函数 + /// "usersSelect":. + /// + public CodeGenUploadAttribute(string Model, string dataConversionModel, bool Multiple, string ThreeParameters, string FourParameters, string Config) + { + __Model__ = Model; + __vModel__ = dataConversionModel; + multiple = Multiple; + __config__ = Config.ToObject(); + selectType = ThreeParameters; + ableIds = FourParameters?.ToObject>(); + } + /// /// 构造函数 /// "cascader" /// "posSelect": + /// "relationForm" /// "popupTableSelect". /// public CodeGenUploadAttribute(string Model, bool Multiple, string InterfaceId, string PropsValue, string RelationField, string Config) @@ -196,6 +203,21 @@ public class CodeGenUploadAttribute : Attribute } } + /// + /// 构造函数 + /// "relationForm". + /// + public CodeGenUploadAttribute(string Model, string dataConversionModel, bool Multiple, string InterfaceId, string PropsValue, string RelationField, string Config) + { + __Model__ = Model; + __vModel__ = dataConversionModel; + multiple = Multiple; + __config__ = Config.ToObject(); + modelId = InterfaceId; + relationField = PropsValue; + showField = RelationField; + } + /// /// 构造函数 /// "userSelect":. @@ -218,6 +240,11 @@ public class CodeGenUploadAttribute : Attribute /// public string __Model__ { get; set; } + /// + /// 数据转换. + /// + public string __vModel__ { get; set; } + /// /// 最小值. /// @@ -332,4 +359,9 @@ public class CodeGenUploadAttribute : Attribute /// 新用户选择控件. /// public List ableIds { get; set; } + + /// + /// 展示字段. + /// + public string showField { get; set; } } \ No newline at end of file diff --git a/common/Tnb.Common/Enums/ErrorCode.cs b/common/Tnb.Common/Enums/ErrorCode.cs index 0e9eef80..4f57761b 100644 --- a/common/Tnb.Common/Enums/ErrorCode.cs +++ b/common/Tnb.Common/Enums/ErrorCode.cs @@ -222,6 +222,18 @@ public enum ErrorCode [ErrorCodeItemMetadata("登录票据已失效")] D1035, + /// + /// 主系统不允许禁用. + /// + [ErrorCodeItemMetadata("主系统不允许禁用")] + D1036, + + /// + /// 主系统不允许更改应用编码. + /// + [ErrorCodeItemMetadata("主系统不允许更改应用编码")] + D1037, + #endregion #region 机构 2 @@ -504,6 +516,12 @@ public enum ErrorCode [ErrorCodeItemMetadata("当前导入菜单为Web端菜单,请在对应模块下导入!")] D4013, + /// + /// 该系统已被禁用 + /// + [ErrorCodeItemMetadata("切换失败,当前系统已被管理员禁用")] + D4014, + #endregion #region 用户 5 diff --git a/common/Tnb.Common/Models/SuperQueryModel.cs b/common/Tnb.Common/Models/SuperQueryModel.cs index 4f3650c3..4d138404 100644 --- a/common/Tnb.Common/Models/SuperQueryModel.cs +++ b/common/Tnb.Common/Models/SuperQueryModel.cs @@ -83,4 +83,9 @@ public class ConvertSuperQuery /// 是否主条件. /// public bool mainWhere { get; set; } + + /// + /// 象征. + /// + public string symbol { get; set; } } \ No newline at end of file diff --git a/common/Tnb.Common/Security/CodeGenHelper.cs b/common/Tnb.Common/Security/CodeGenHelper.cs index 8fe07edb..e06dad23 100644 --- a/common/Tnb.Common/Security/CodeGenHelper.cs +++ b/common/Tnb.Common/Security/CodeGenHelper.cs @@ -22,14 +22,14 @@ public static class CodeGenHelper case "nchar": case "timestamp": case "string": - return "string"; + return "string?"; case "int": case "smallint": - return "int"; + return "int?"; case "tinyint": - return "byte"; + return "byte?"; case "bigint": // sqlite数据库 @@ -43,10 +43,10 @@ public static class CodeGenHelper case "smallmoney": case "numeric": case "decimal": - return "decimal"; + return "decimal?"; case "real": - return "Single"; + return "Single?"; case "datetime": case "datetime2": @@ -55,7 +55,7 @@ public static class CodeGenHelper return "DateTime?"; case "float": - return "double"; + return "double?"; case "image": case "binary": @@ -218,7 +218,7 @@ public static class CodeGenHelper result.Add(label, "系统自动生成"); break; case JnpfKeyConst.COMSELECT: - result.Add(label, multiple ? "例:拓通智联/产品部,拓通智联/技术部" : "例:拓通智联/技术部"); + result.Add(label, multiple ? "例:引迈信息/产品部,引迈信息/技术部" : "例:引迈信息/技术部"); break; case JnpfKeyConst.DEPSELECT: result.Add(label, multiple ? "例:产品部/部门编码,技术部/部门编码" : "例:技术部/部门编码"); @@ -230,7 +230,7 @@ public static class CodeGenHelper result.Add(label, multiple ? "例:张三/账号,李四/账号" : "例:张三/账号"); break; case JnpfKeyConst.USERSSELECT: - result.Add(label, multiple ? "例:拓通智联/产品部,产品部/部门编码,技术经理/岗位编码,研发人员/角色编码,A分组/分组编码,张三/账号" : "例:李四/账号"); + result.Add(label, multiple ? "例:引迈信息/产品部,产品部/部门编码,技术经理/岗位编码,研发人员/角色编码,A分组/分组编码,张三/账号" : "例:李四/账号"); break; case JnpfKeyConst.ROLESELECT: result.Add(label, multiple ? "例:研发人员/角色编码,测试人员/角色编码" : "例:研发人员/角色编码"); diff --git a/extend/Tnb.Extend.Entitys/Dto/Customer/CustomerListOutput.cs b/extend/Tnb.Extend.Entitys/Dto/Customer/CustomerListOutput.cs new file mode 100644 index 00000000..cfff8590 --- /dev/null +++ b/extend/Tnb.Extend.Entitys/Dto/Customer/CustomerListOutput.cs @@ -0,0 +1,41 @@ +using JNPF.DependencyInjection; +using SqlSugar; + +namespace JNPF.Extend.Entitys.Dto.Customer; + +/// +/// 客户信息. +/// +[SuppressSniffer] +public class CustomerListOutput +{ + /// + /// 主键. + /// + public string id { get; set; } + + /// + /// 客户编号. + /// + public string code { get; set; } + + /// + /// 客户名称. + /// + public string customerName { get; set; } + + /// + /// 地址. + /// + public string address { get; set; } + + /// + /// 名称. + /// + public string name { get; set; } + + /// + /// 联系方式. + /// + public string contactTel { get; set; } +} diff --git a/extend/Tnb.Extend.Entitys/Dto/Product/ProductCrInput.cs b/extend/Tnb.Extend.Entitys/Dto/Product/ProductCrInput.cs index 75677db2..9bcb2455 100644 --- a/extend/Tnb.Extend.Entitys/Dto/Product/ProductCrInput.cs +++ b/extend/Tnb.Extend.Entitys/Dto/Product/ProductCrInput.cs @@ -1,4 +1,5 @@ using JNPF.DependencyInjection; +using JNPF.Extend.Entitys.Dto.ProductEntry; namespace JNPF.Extend.Entitys.Dto.Product; @@ -106,5 +107,5 @@ public class ProductCrInput /// /// 子表数据. /// - public List productEntryList { get; set; } + public List productEntryList { get; set; } } \ No newline at end of file diff --git a/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryCrInput.cs b/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryCrInput.cs new file mode 100644 index 00000000..a9462b1f --- /dev/null +++ b/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryCrInput.cs @@ -0,0 +1,60 @@ +using JNPF.DependencyInjection; + +namespace JNPF.Extend.Entitys.Dto.ProductEntry; + +/// +/// 新建产品明细. +/// +[SuppressSniffer] +public class ProductEntryCrInput +{ + /// + /// 主键. + /// + public string? id { get; set; } + + /// + /// 产品编号. + /// + public string productCode { get; set; } + + /// + /// 产品名称. + /// + public string productName { get; set; } + + /// + /// 产品规格. + /// + public string productSpecification { get; set; } + + /// + /// 数量. + /// + public int qty { get; set; } + + /// + /// 订货类型. + /// + public string type { get; set; } + + /// + /// 单价. + /// + public decimal money { get; set; } + + /// + /// 折后单价. + /// + public decimal price { get; set; } + + /// + /// 金额. + /// + public decimal amount { get; set; } + + /// + /// 备注. + /// + public string description { get; set; } +} \ No newline at end of file diff --git a/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryInfoOutput.cs b/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryInfoOutput.cs index a608904c..810e75c6 100644 --- a/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryInfoOutput.cs +++ b/extend/Tnb.Extend.Entitys/Dto/ProductEntry/ProductEntryInfoOutput.cs @@ -8,6 +8,11 @@ namespace JNPF.Extend.Entitys.Dto.ProductEntry; [SuppressSniffer] public class ProductEntryInfoOutput { + /// + /// 主键. + /// + public string id { get; set; } + /// /// 产品编号. /// diff --git a/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListOutput.cs b/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListOutput.cs new file mode 100644 index 00000000..83266e20 --- /dev/null +++ b/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListOutput.cs @@ -0,0 +1,50 @@ +using JNPF.DependencyInjection; + +namespace JNPF.Extend.Entitys.Dto.ProductGoods; + +/// +/// 产品列表. +/// +[SuppressSniffer] +public class ProductGoodsListOutput +{ + /// + /// 主键. + /// + public string id { get; set; } + + /// + /// 分类主键. + /// + public string classifyId { get; set; } + + /// + /// 订单编号. + /// + public string code { get; set; } + + /// + /// 订单名称. + /// + public string fullName { get; set; } + + /// + /// 订单名称. + /// + public int qty { get; set; } + + /// + /// 订货类型. + /// + public string type { get; set; } + + /// + /// 金额. + /// + public string amount { get; set; } + + /// + /// 单价. + /// + public string money { get; set; } +} \ No newline at end of file diff --git a/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListQueryInput.cs b/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListQueryInput.cs new file mode 100644 index 00000000..24999ed2 --- /dev/null +++ b/extend/Tnb.Extend.Entitys/Dto/ProductGoods/ProductGoodsListQueryInput.cs @@ -0,0 +1,26 @@ +using JNPF.Common.Filter; +using JNPF.DependencyInjection; + +namespace JNPF.Extend.Entitys.Dto.ProductGoods; + +/// +/// 产品列表. +/// +[SuppressSniffer] +public class ProductGoodsListQueryInput : PageInputBase +{ + /// + /// 订单编号. + /// + public string code { get; set; } + + /// + /// 产品名称. + /// + public string fullName { get; set; } + + /// + /// 分类ID. + /// + public string classifyId { get; set; } +} diff --git a/extend/Tnb.Extend.Entitys/Entity/BigDataEntity.cs b/extend/Tnb.Extend.Entitys/Entity/BigDataEntity.cs index adf11b38..5be87cd3 100644 --- a/extend/Tnb.Extend.Entitys/Entity/BigDataEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/BigDataEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 大数据测试 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_BIGDATA")] diff --git a/extend/Tnb.Extend.Entitys/Entity/CustomerEntity.cs b/extend/Tnb.Extend.Entitys/Entity/CustomerEntity.cs new file mode 100644 index 00000000..c7bee238 --- /dev/null +++ b/extend/Tnb.Extend.Entitys/Entity/CustomerEntity.cs @@ -0,0 +1,59 @@ +using JNPF.Common.Contracts; +using SqlSugar; + +namespace JNPF.Extend.Entitys.Entity; + +/// +/// 客户信息. +/// +[SugarTable("ext_customer", TableDescription = "客户信息")] +public class CustomerEntity : CLEntityBase +{ + /// + /// 编码. + /// + [SugarColumn(ColumnName = "F_Code")] + public string Code { get; set; } + + /// + /// 客户名称. + /// + [SugarColumn(ColumnName = "F_CustomerName")] + public string Customername { get; set; } + + /// + /// 地址. + /// + [SugarColumn(ColumnName = "F_Address")] + public string Address { get; set; } + + /// + /// 名称. + /// + [SugarColumn(ColumnName = "F_Name")] + public string Name { get; set; } + + /// + /// 联系方式. + /// + [SugarColumn(ColumnName = "F_ContactTel")] + public string ContactTel { get; set; } + + /// + /// 删除标志. + /// + [SugarColumn(ColumnName = "F_DeleteMark")] + public float Deletemark { get; set; } + + /// + /// 删除时间. + /// + [SugarColumn(ColumnName = "F_DeleteTime")] + public DateTime Deletetime { get; set; } + + /// + /// 删除用户. + /// + [SugarColumn(ColumnName = "F_DeleteUserId")] + public string Deleteuserid { get; set; } +} \ No newline at end of file diff --git a/extend/Tnb.Extend.Entitys/Entity/DocumentEntity.cs b/extend/Tnb.Extend.Entitys/Entity/DocumentEntity.cs index 2ef0c950..e3fb9113 100644 --- a/extend/Tnb.Extend.Entitys/Entity/DocumentEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/DocumentEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 知识文档 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_DOCUMENT")] diff --git a/extend/Tnb.Extend.Entitys/Entity/DocumentShareEntity.cs b/extend/Tnb.Extend.Entitys/Entity/DocumentShareEntity.cs index 27f4a574..6b2947c2 100644 --- a/extend/Tnb.Extend.Entitys/Entity/DocumentShareEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/DocumentShareEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 知识文档共享 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_DOCUMENTSHARE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/EmailConfigEntity.cs b/extend/Tnb.Extend.Entitys/Entity/EmailConfigEntity.cs index 0f5851a4..6610c764 100644 --- a/extend/Tnb.Extend.Entitys/Entity/EmailConfigEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/EmailConfigEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 邮件配置 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_EMAILCONFIG")] diff --git a/extend/Tnb.Extend.Entitys/Entity/EmailReceiveEntity.cs b/extend/Tnb.Extend.Entitys/Entity/EmailReceiveEntity.cs index c8f4ed80..c77b8034 100644 --- a/extend/Tnb.Extend.Entitys/Entity/EmailReceiveEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/EmailReceiveEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 邮件接收 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_EMAILRECEIVE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/EmailSendEntity.cs b/extend/Tnb.Extend.Entitys/Entity/EmailSendEntity.cs index d393b048..555ddb97 100644 --- a/extend/Tnb.Extend.Entitys/Entity/EmailSendEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/EmailSendEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 邮件发送 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_EMAILSEND")] diff --git a/extend/Tnb.Extend.Entitys/Entity/EmployeeEntity.cs b/extend/Tnb.Extend.Entitys/Entity/EmployeeEntity.cs index 1fa02713..1b30c7d9 100644 --- a/extend/Tnb.Extend.Entitys/Entity/EmployeeEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/EmployeeEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 职员信息 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_EMPLOYEE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/OrderEntity.cs b/extend/Tnb.Extend.Entitys/Entity/OrderEntity.cs index f0e6b209..625c48da 100644 --- a/extend/Tnb.Extend.Entitys/Entity/OrderEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/OrderEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 订单信息 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_ORDER")] diff --git a/extend/Tnb.Extend.Entitys/Entity/OrderEntryEntity.cs b/extend/Tnb.Extend.Entitys/Entity/OrderEntryEntity.cs index f16920ff..ec6855ff 100644 --- a/extend/Tnb.Extend.Entitys/Entity/OrderEntryEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/OrderEntryEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 订单明细 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_ORDERENTRY")] diff --git a/extend/Tnb.Extend.Entitys/Entity/OrderReceivableEntity.cs b/extend/Tnb.Extend.Entitys/Entity/OrderReceivableEntity.cs index d5ad5580..e3896c50 100644 --- a/extend/Tnb.Extend.Entitys/Entity/OrderReceivableEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/OrderReceivableEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 订单收款 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_ORDERRECEIVABLE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/ProductClassifyEntity.cs b/extend/Tnb.Extend.Entitys/Entity/ProductClassifyEntity.cs index e719c7ac..c5ddb11d 100644 --- a/extend/Tnb.Extend.Entitys/Entity/ProductClassifyEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/ProductClassifyEntity.cs @@ -9,14 +9,8 @@ namespace JNPF.Extend.Entitys; /// [SugarTable("ext_productclassify")] [Tenant(ClaimConst.TENANTID)] -public class ProductClassifyEntity : CLDEntityBase +public class ProductClassifyEntity : CLEntityBase { - /// - /// 主键. - /// - [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] - public string Id { get; set; } - /// /// 上级. /// @@ -28,4 +22,22 @@ public class ProductClassifyEntity : CLDEntityBase /// [SugarColumn(ColumnName = "F_FULLNAME")] public string FullName { get; set; } + + /// + /// 获取或设置 删除标志. + /// + [SugarColumn(ColumnName = "F_DeleteMark", ColumnDescription = "删除标志")] + public int? DeleteMark { get; set; } + + /// + /// 获取或设置 删除时间. + /// + [SugarColumn(ColumnName = "F_DeleteTime", ColumnDescription = "删除时间")] + public DateTime? DeleteTime { get; set; } + + /// + /// 获取或设置 删除用户. + /// + [SugarColumn(ColumnName = "F_DeleteUserId", ColumnDescription = "删除用户")] + public string DeleteUserId { get; set; } } \ No newline at end of file diff --git a/extend/Tnb.Extend.Entitys/Entity/ProductEntity.cs b/extend/Tnb.Extend.Entitys/Entity/ProductEntity.cs index a1e1bb6f..a0c4ccfa 100644 --- a/extend/Tnb.Extend.Entitys/Entity/ProductEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/ProductEntity.cs @@ -9,14 +9,8 @@ namespace JNPF.Extend.Entitys; /// [SugarTable("ext_product")] [Tenant(ClaimConst.TENANTID)] -public class ProductEntity +public class ProductEntity : EntityBase { - /// - /// 自然主键. - /// - [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] - public string Id { get; set; } - /// /// 订单编号. /// diff --git a/extend/Tnb.Extend.Entitys/Entity/ProjectGanttEntity.cs b/extend/Tnb.Extend.Entitys/Entity/ProjectGanttEntity.cs index 4633cc20..0e74111b 100644 --- a/extend/Tnb.Extend.Entitys/Entity/ProjectGanttEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/ProjectGanttEntity.cs @@ -7,7 +7,8 @@ namespace JNPF.Extend.Entitys; /// /// 项目计划 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.yinmaisoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_PROJECTGANTT")] diff --git a/extend/Tnb.Extend.Entitys/Entity/ScheduleEntity.cs b/extend/Tnb.Extend.Entitys/Entity/ScheduleEntity.cs index 88fa843e..e52c5cef 100644 --- a/extend/Tnb.Extend.Entitys/Entity/ScheduleEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/ScheduleEntity.cs @@ -7,7 +7,8 @@ namespace JNPF.Extend.Entitys; /// /// 日程安排 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [SugarTable("EXT_SCHEDULE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/TableExampleEntity.cs b/extend/Tnb.Extend.Entitys/Entity/TableExampleEntity.cs index 27addb9f..1517173e 100644 --- a/extend/Tnb.Extend.Entitys/Entity/TableExampleEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/TableExampleEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 表格示例数据 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_TABLEEXAMPLE")] diff --git a/extend/Tnb.Extend.Entitys/Entity/WorkLogEntity.cs b/extend/Tnb.Extend.Entitys/Entity/WorkLogEntity.cs index b1b86136..9b84eabc 100644 --- a/extend/Tnb.Extend.Entitys/Entity/WorkLogEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/WorkLogEntity.cs @@ -6,7 +6,8 @@ namespace JNPF.Extend.Entitys; /// /// 工作日志 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_WORKLOG")] diff --git a/extend/Tnb.Extend.Entitys/Entity/WorkLogShareEntity.cs b/extend/Tnb.Extend.Entitys/Entity/WorkLogShareEntity.cs index ea928c4c..d6e27124 100644 --- a/extend/Tnb.Extend.Entitys/Entity/WorkLogShareEntity.cs +++ b/extend/Tnb.Extend.Entitys/Entity/WorkLogShareEntity.cs @@ -7,7 +7,8 @@ namespace JNPF.Extend.Entitys; /// /// 工作日志分享 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01 . /// [SugarTable("EXT_WORKLOGSHARE")] diff --git a/extend/Tnb.Extend/ProductClassifyService.cs b/extend/Tnb.Extend/ProductClassifyService.cs index 0b0f20c8..ce8eba2b 100644 --- a/extend/Tnb.Extend/ProductClassifyService.cs +++ b/extend/Tnb.Extend/ProductClassifyService.cs @@ -59,7 +59,7 @@ public class ProductClassifyService : IDynamicApiController, ITransient [HttpGet("{id}")] public async Task GetInfo(string id) { - return (await _repository.AsQueryable().FirstAsync(a => a.Id.Equals(id))).Adapt(); + return (await _repository.AsQueryable().FirstAsync(a => a.Id.Equals(id) && a.DeleteMark == null)).Adapt(); } #endregion diff --git a/extend/Tnb.Extend/ProductService.cs b/extend/Tnb.Extend/ProductService.cs index 907f1b9d..505f07e9 100644 --- a/extend/Tnb.Extend/ProductService.cs +++ b/extend/Tnb.Extend/ProductService.cs @@ -1,13 +1,16 @@ -using System.Collections.Generic; -using JNPF.Common.Core.Manager; +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; using JNPF.Common.Filter; using JNPF.Common.Security; +using JNPF.DatabaseAccessor; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Extend.Entitys; using JNPF.Extend.Entitys.Dto.Product; using JNPF.Extend.Entitys.Dto.ProductEntry; using JNPF.Extend.Entitys.Model; +using JNPF.FriendlyException; +using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; @@ -31,17 +34,26 @@ public class ProductService : IDynamicApiController, ITransient /// private readonly IUserManager _userManager; + /// + /// 单据规则服务. + /// + private readonly IBillRullService _billRullService; + /// /// 初始化一个类型的新实例. /// public ProductService( ISqlSugarRepository extProductRepository, + IBillRullService billRullService, IUserManager userManager) { _repository = extProductRepository; + _billRullService = billRullService; _userManager = userManager; } + #region Get + /// /// 获取订单示例. /// @@ -51,7 +63,7 @@ public class ProductService : IDynamicApiController, ITransient public async Task GetInfo(string id) { return (await _repository.AsQueryable() - .Includes(x => x.productEntryList.Select(it => new ProductEntryEntity + .Includes(x => x.productEntryList.Where(it => it.DeleteMark == null).Select(it => new ProductEntryEntity { ProductCode = it.ProductCode, ProductName = it.ProductName, @@ -62,7 +74,7 @@ public class ProductService : IDynamicApiController, ITransient Price = it.Price, Amount = it.Amount, Description = it.Description - }).ToList()).Where(a => a.Id.Equals(id)) + }).ToList()).Where(a => a.Id.Equals(id) && a.DeleteMark == null) .ToListAsync(it => new ProductInfoOutput { id = it.Id, @@ -96,10 +108,15 @@ public class ProductService : IDynamicApiController, ITransient [HttpGet("")] public async Task GetList([FromQuery] ProductListQueryInput input) { + if (input.auditState == "0") + input.auditState = null; + if (input.closeState == "0") + input.closeState = null; var data = await _repository.AsQueryable() + .Where(it => it.DeleteMark == null) .WhereIF(!string.IsNullOrEmpty(input.code), it => it.Code.Contains(input.code)) - .WhereIF(!string.IsNullOrEmpty(input.customerName), it => it.Type.Contains(input.customerName)) - .WhereIF(!string.IsNullOrEmpty(input.contactTel), it => it.CustomerId.Contains(input.contactTel)) + .WhereIF(!string.IsNullOrEmpty(input.customerName), it => it.CustomerName.Contains(input.customerName)) + .WhereIF(!string.IsNullOrEmpty(input.contactTel), it => it.ContactTel.Contains(input.contactTel)) .WhereIF(!string.IsNullOrEmpty(input.auditState), it => it.AuditState.Equals(input.auditState)) .WhereIF(!string.IsNullOrEmpty(input.closeState), it => it.CloseState.Equals(input.closeState)) .Select(it => new ProductListOutput @@ -130,7 +147,7 @@ public class ProductService : IDynamicApiController, ITransient { string data = "[{\"id\":\"37c995b4044541009fb7e285bcf9845d\",\"productSpecification\":\"120ml\",\"qty\":16,\"money\":510,\"price\":120,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"2dbb11d3cde04c299985ac944d130ba0\",\"productSpecification\":\"150ml\",\"qty\":15,\"money\":520,\"price\":310,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"f8ec261ccdf045e5a2e1f0e5485cda76\",\"productSpecification\":\"40ml\",\"qty\":13,\"money\":530,\"price\":140,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"6c110b57ae56445faa8ce9be501c8997\",\"productSpecification\":\"103ml\",\"qty\":2,\"money\":504,\"price\":150,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"f2ee981aaf934147a4d090a0eed2203f\",\"productSpecification\":\"120ml\",\"qty\":21,\"money\":550,\"price\":160,\"commandType\":\"唯一码\",\"util\":\"盒\"}]"; List dataAll = data.ToObject>(); - List productEntryList = await _repository.AsSugarClient().Queryable().Where(it => it.ProductId.Equals(id)).Select(it => new ProductEntryListOutput + List productEntryList = await _repository.AsSugarClient().Queryable().Where(it => it.ProductId.Equals(id) && it.DeleteMark == null).Select(it => new ProductEntryListOutput { productCode = it.ProductCode, productName = it.ProductName, @@ -155,4 +172,126 @@ public class ProductService : IDynamicApiController, ITransient return new { list = productEntryList }; } + + #endregion + + #region POST + + /// + /// 新建. + /// + /// 请求参数. + /// + [HttpPost("")] + [UnitOfWork] + public async Task Create([FromBody] ProductCrInput input) + { + var entity = input.Adapt(); + entity.Code = await _billRullService.GetBillNumber("OrderNumber", false); + entity.Id = SnowflakeIdHelper.NextId(); + entity.CreatorTime = DateTime.Now; + entity.CreatorUserId = _userManager.UserId; + + var productEntryList = input.productEntryList.Adapt>(); + if (productEntryList != null) + { + productEntryList.ForEach(item => + { + item.Id = SnowflakeIdHelper.NextId(); + item.ProductId = entity.Id; + item.CreatorTime = DateTime.Now; + item.CreatorUserId = _userManager.UserId; + }); + entity.productEntryList = productEntryList; + } + + var isOk = await _repository.AsSugarClient().InsertNav(entity) + .Include(it => it.productEntryList).ExecuteCommandAsync(); + if (!isOk) + throw Oops.Oh(ErrorCode.COM1000); + } + + /// + /// 更新订单示例. + /// + /// 主键值. + /// 参数. + /// + [HttpPut("{id}")] + [UnitOfWork] + public async Task Update(string id, [FromBody] ProductUpInput input) + { + var entity = input.Adapt(); + entity.LastModifyTime = DateTime.Now; + entity.LastModifyUserId = _userManager.UserId; + + await _repository.AsSugarClient().Updateable() + .Where(it => it.ProductId.Equals(entity.Id) && !input.productEntryList.Select(a => a.id).ToList().Contains(it.Id)) + .SetColumns(it => new ProductEntryEntity() + { + DeleteMark = 1, + DeleteUserId = _userManager.UserId, + DeleteTime = SqlFunc.GetDate() + }).ExecuteCommandAsync(); + + var productEntryList = input.productEntryList.Adapt>(); + productEntryList.ForEach(item => + { + item.Id = item.Id == null ? SnowflakeIdHelper.NextId() : item.Id; + item.ProductId = entity.Id; + }); + + await _repository.AsSugarClient().Storageable(productEntryList).ExecuteCommandAsync(); + + var isOk = await _repository.AsUpdateable(entity).UpdateColumns(it => new + { + it.Code, + it.CustomerName, + it.ContactTel, + it.Address, + it.GoodsWarehouse, + it.Business, + it.GatheringType, + it.PartPrice, + it.ReducedPrice, + it.DiscountPrice, + it.Description, + it.LastModifyUserId, + it.LastModifyTime + }).ExecuteCommandAsync(); + if (!(isOk > 0)) + throw Oops.Oh(ErrorCode.COM1001); + } + + /// + /// 删除订单示例. + /// + /// + [HttpDelete("{id}")] + [UnitOfWork] + public async Task Delete(string id) + { + await _repository.AsSugarClient().Updateable() + .Where(it => it.ProductId.Equals(id)) + .SetColumns(it => new ProductEntryEntity() + { + DeleteMark = 1, + DeleteUserId = _userManager.UserId, + DeleteTime = SqlFunc.GetDate() + }).ExecuteCommandAsync(); + + var isOk = await _repository.AsUpdateable() + .Where(it => it.Id.Equals(id)) + .SetColumns(it => new ProductEntity() + { + DeleteMark = 1, + DeleteUserId = _userManager.UserId, + DeleteTime = SqlFunc.GetDate() + }).ExecuteCommandAsync(); + if (!(isOk > 0)) + throw Oops.Oh(ErrorCode.COM1002); + } + + #endregion + } \ No newline at end of file diff --git a/message/Tnb.Message/Service/ImReplyService.cs b/message/Tnb.Message/Service/ImReplyService.cs index c9608264..cff13fc2 100644 --- a/message/Tnb.Message/Service/ImReplyService.cs +++ b/message/Tnb.Message/Service/ImReplyService.cs @@ -1,10 +1,10 @@ -using JNPF.Common.Core.Manager; +using JNPF.Common.Core.Handlers; +using JNPF.Common.Core.Manager; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Message.Entitys; using JNPF.Message.Entitys.Dto.ImReply; -using JNPF.Message.Handlers; using JNPF.Message.Interfaces; using JNPF.Systems.Entitys.Permission; using Mapster; diff --git a/message/Tnb.Message/Service/MessageService.cs b/message/Tnb.Message/Service/MessageService.cs index 9c1ca81a..a9df9431 100644 --- a/message/Tnb.Message/Service/MessageService.cs +++ b/message/Tnb.Message/Service/MessageService.cs @@ -1,4 +1,5 @@ -using JNPF.Common.Core.Manager; +using JNPF.Common.Core.Handlers; +using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.Common.Filter; @@ -12,7 +13,6 @@ using JNPF.LinqBuilder; using JNPF.Message.Entitys; using JNPF.Message.Entitys.Dto.Message; using JNPF.Message.Entitys.Entity; -using JNPF.Message.Handlers; using JNPF.Message.Interfaces.Message; using JNPF.RemoteRequest.Extensions; using JNPF.Systems.Entitys.Permission; @@ -26,7 +26,8 @@ namespace JNPF.Message; /// /// 系统消息 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [ApiDescriptionSettings(Tag = "Message", Name = "message", Order = 240)] diff --git a/message/Tnb.Message/Tnb.Message.csproj b/message/Tnb.Message/Tnb.Message.csproj index bfbdd5cb..0567e028 100644 --- a/message/Tnb.Message/Tnb.Message.csproj +++ b/message/Tnb.Message/Tnb.Message.csproj @@ -10,7 +10,6 @@ - diff --git a/system/Tnb.Systems/Permission/AuthorizeService.cs b/system/Tnb.Systems/Permission/AuthorizeService.cs index af276246..da29fb93 100644 --- a/system/Tnb.Systems/Permission/AuthorizeService.cs +++ b/system/Tnb.Systems/Permission/AuthorizeService.cs @@ -1,6 +1,9 @@ -using JNPF.Common.Core.Manager; +using JNPF.Common.Const; +using JNPF.Common.Core.Handlers; +using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; +using JNPF.Common.Manager; using JNPF.Common.Models.User; using JNPF.Common.Security; using JNPF.DatabaseAccessor; @@ -36,15 +39,29 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans /// private readonly IUserManager _userManager; + /// + /// 缓存管理器. + /// + private readonly ICacheManager _cacheManager; + + /// + /// IM中心处理程序. + /// + private IMHandler _imHandler; + /// /// 初始化一个类型的新实例. /// public AuthorizeService( ISqlSugarRepository authorizeRepository, - IUserManager userManager) + ICacheManager cacheManager, + IUserManager userManager, + IMHandler imHandler) { _authorizeRepository = authorizeRepository; + _cacheManager = cacheManager; _userManager = userManager; + _imHandler = imHandler; } #region Get @@ -391,42 +408,52 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans /// /// [HttpPut("Model/{itemId}")] - [UnitOfWork] public async Task UpdateModel(string itemId, [FromBody] AuthorizeModelInput input) { List? authorizeList = new List(); - // 角色ID不为空 - if (input.objectId.Count > 0) + try { - input.objectId.ForEach(item => + _authorizeRepository.AsSugarClient().Ado.BeginTran(); + + // 角色ID不为空 + if (input.objectId.Count > 0) { - AuthorizeEntity? entity = new AuthorizeEntity(); - entity.Id = SnowflakeIdHelper.NextId(); - entity.CreatorTime = DateTime.Now; - entity.CreatorUserId = _userManager.UserId; - entity.ItemId = itemId; - entity.ItemType = input.itemType; - entity.ObjectId = item; - entity.ObjectType = input.objectType; - entity.SortCode = input.objectId.IndexOf(item); - authorizeList.Add(entity); - }); + input.objectId.ForEach(item => + { + AuthorizeEntity? entity = new AuthorizeEntity(); + entity.Id = SnowflakeIdHelper.NextId(); + entity.CreatorTime = DateTime.Now; + entity.CreatorUserId = _userManager.UserId; + entity.ItemId = itemId; + entity.ItemType = input.itemType; + entity.ObjectId = item; + entity.ObjectType = input.objectType; + entity.SortCode = input.objectId.IndexOf(item); + authorizeList.Add(entity); + }); - // 删除除了门户外的相关权限 - await _authorizeRepository.DeleteAsync(a => a.ItemId == itemId); + // 删除除了门户外的相关权限 + await _authorizeRepository.DeleteAsync(a => a.ItemId == itemId); - // 新增权限 - await _authorizeRepository.AsSugarClient().Insertable(authorizeList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync(); + // 新增权限 + await _authorizeRepository.AsSugarClient().Insertable(authorizeList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync(); - // 编辑角色权限退出角色的登录用户 - await ForcedOffline(input.objectId); + } + else + { + // 删除除了门户外的相关权限 + await _authorizeRepository.DeleteAsync(a => a.ItemId == itemId); + } + + _authorizeRepository.AsSugarClient().Ado.CommitTran(); } - else + catch { - // 删除除了门户外的相关权限 - await _authorizeRepository.DeleteAsync(a => a.ItemId == itemId); + _authorizeRepository.AsSugarClient().Ado.RollbackTran(); } + + if(input.objectId.Any()) await ForcedOffline(input.objectId); // 编辑角色权限退出角色的登录用户 } /// @@ -754,14 +781,17 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans { // 查找该角色下的所有成员id var roleUserIds = await _authorizeRepository.AsSugarClient().Queryable().Where(x => x.ObjectType == "Role" && roleId.Contains(x.ObjectId)).Select(x => x.UserId).ToListAsync(); - Scoped.Create((_, scope) => + roleUserIds.ForEach(async id => { - roleUserIds.ForEach(id => + var tenantId = _userManager.TenantId; + var list = await GetOnlineUserList(tenantId); + var user = list.Find(it => it.tenantId == tenantId && it.userId == id); + if (user != null) { - var services = scope.ServiceProvider; - var _onlineuser = App.GetService(services); - _onlineuser.ForcedOffline(id); - }); + await _imHandler.SendMessageAsync(user.connectionId, new { method = "logout", msg = "此账号已在其他地方登陆" }.ToJsonString()); + await DelOnlineUser(tenantId, user.userId); + await DelUserInfo(tenantId, user.userId); + } }); } #endregion @@ -1018,5 +1048,44 @@ public class AuthorizeService : IAuthorizeService, IDynamicApiController, ITrans return output; } + + /// + /// 获取在线用户列表. + /// + /// 租户ID. + /// + public async Task> GetOnlineUserList(string tenantId) + { + var cacheKey = string.Format("{0}{1}", CommonConst.CACHEKEYONLINEUSER, tenantId); + return await _cacheManager.GetAsync>(cacheKey); + } + + /// + /// 删除在线用户ID. + /// + /// 租户ID. + /// 用户ID. + /// + private async Task DelOnlineUser(string tenantId, string userId) + { + var cacheKey = string.Format("{0}{1}", CommonConst.CACHEKEYONLINEUSER, tenantId); + var list = await _cacheManager.GetAsync>(cacheKey); + var online = list.Find(it => it.userId == userId); + list.RemoveAll((x) => x.connectionId == online.connectionId); + return await _cacheManager.SetAsync(cacheKey, list); + } + + /// + /// 删除用户登录信息缓存. + /// + /// 租户ID. + /// 用户ID. + /// + private async Task DelUserInfo(string tenantId, string userId) + { + var cacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, userId); + return await _cacheManager.DelAsync(cacheKey); + } + #endregion } \ No newline at end of file diff --git a/system/Tnb.Systems/Permission/UsersCurrentService.cs b/system/Tnb.Systems/Permission/UsersCurrentService.cs index c7ee75af..6caad7e8 100644 --- a/system/Tnb.Systems/Permission/UsersCurrentService.cs +++ b/system/Tnb.Systems/Permission/UsersCurrentService.cs @@ -474,6 +474,13 @@ public class UsersCurrentService : IUsersCurrentService, IDynamicApiController, } else { + // 当前系统已被管理员禁用. + var switchSystem = await _repository.AsSugarClient().Queryable() + .Where(it => input.majorId.Equals(it.Id) && it.DeleteMark == null) + .FirstAsync(); + if (switchSystem != null && !switchSystem.EnabledMark.Equals(1)) + throw Oops.Oh(ErrorCode.D4014); + // 系统下没有菜单不允许切换. var mList = await _repository.AsSugarClient().Queryable().Where(x => x.SystemId.Equals(input.majorId) && x.DeleteMark == null && x.Category.Equals("Web")).Select(x => x.Id).ToListAsync(); if (!mList.Any()) throw Oops.Oh(ErrorCode.D4009); diff --git a/system/Tnb.Systems/Permission/UsersService.cs b/system/Tnb.Systems/Permission/UsersService.cs index eacfda3f..8c6cf244 100644 --- a/system/Tnb.Systems/Permission/UsersService.cs +++ b/system/Tnb.Systems/Permission/UsersService.cs @@ -6,6 +6,7 @@ using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.Common.Filter; using JNPF.Common.Helper; +using JNPF.Common.Manager; using JNPF.Common.Models.NPOI; using JNPF.Common.Models.User; using JNPF.Common.Security; @@ -69,6 +70,11 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient /// private readonly IFileManager _fileManager; + /// + /// 缓存管理. + /// + private readonly ICacheManager _cacheManager; + /// /// 用户管理. /// @@ -83,6 +89,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient IUserRelationService userRelationService, ISysConfigService sysConfigService, ISynThirdInfoService synThirdInfoService, + ICacheManager cacheManager, IFileManager fileService, IUserManager userManager) { @@ -91,6 +98,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient _userRelationService = userRelationService; _sysConfigService = sysConfigService; _userManager = userManager; + _cacheManager = cacheManager; _synThirdInfoService = synThirdInfoService; _fileManager = fileService; } @@ -1522,6 +1530,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient fs.Close(); } + _cacheManager.Set(excelconfig.FileName, string.Empty); return new { name = excelconfig.FileName, url = "/api/file/Download?encryption=" + DESCEncryption.Encrypt(_userManager.UserId + "|" + excelconfig.FileName + "|" + addPath, "JNPF") }; } @@ -1551,6 +1560,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient string? addPath = Path.Combine(FileVariable.TemporaryFilePath, excelconfig.FileName); ExcelExportHelper.Export(dataList, excelconfig, addPath); + _cacheManager.Set(excelconfig.FileName, string.Empty); return new { name = excelconfig.FileName, url = "/api/file/Download?encryption=" + DESCEncryption.Encrypt(_userManager.UserId + "|" + excelconfig.FileName + "|" + addPath, "JNPF") }; } @@ -1631,6 +1641,7 @@ public class UsersService : IUsersService, IDynamicApiController, ITransient string? addPath = Path.Combine(FileVariable.TemporaryFilePath, excelconfig.FileName); ExcelExportHelper.Export(errorlist, excelconfig, addPath); + _cacheManager.Set(excelconfig.FileName, string.Empty); return new { name = excelconfig.FileName, url = "/api/file/Download?encryption=" + DESCEncryption.Encrypt(_userManager.UserId + "|" + excelconfig.FileName + "|" + addPath, "JNPF") }; } diff --git a/system/Tnb.Systems/System/DataInterfaceService.cs b/system/Tnb.Systems/System/DataInterfaceService.cs index ce16b12a..9ca5c55b 100644 --- a/system/Tnb.Systems/System/DataInterfaceService.cs +++ b/system/Tnb.Systems/System/DataInterfaceService.cs @@ -46,7 +46,8 @@ namespace JNPF.Systems; /// /// 数据接口 /// 版 本:V3.2 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) +/// 作 者:JNPF开发平台组 /// 日 期:2021-06-01. /// [ApiDescriptionSettings(Tag = "System", Name = "DataInterface", Order = 204)] @@ -345,7 +346,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController { string sheetData = Regex.Match(info.DataProcessing, @"\{(.*)\}", RegexOptions.Singleline).Groups[1].Value; var scriptStr = "var result = function(data){data = JSON.parse(data);" + sheetData + "}"; - return JsEngineUtil.CallFunction(scriptStr, output.ToJsonString()); + return JsEngineUtil.CallFunction(scriptStr, output.ToJsonString(CommonConst.options));//此处时间非时间戳 } } @@ -732,7 +733,7 @@ public class DataInterfaceService : IDataInterfaceService, IDynamicApiController list = await GetDynamicDataCache(dynamic.Id); - if (list == null) + if (list == null || list.Count == 0) { list = new List(); // 远端数据 配置参数 diff --git a/system/Tnb.Systems/System/SystemService.cs b/system/Tnb.Systems/System/SystemService.cs index cd5d7fc7..c81e0ca4 100644 --- a/system/Tnb.Systems/System/SystemService.cs +++ b/system/Tnb.Systems/System/SystemService.cs @@ -1,7 +1,12 @@ -using JNPF.Common.Core.Manager; +using JNPF.Common.Const; +using JNPF.Common.Core.Handlers; +using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.Common.Filter; +using JNPF.Common.Manager; +using JNPF.Common.Models.User; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; @@ -27,6 +32,16 @@ public class SystemService : IDynamicApiController, ITransient /// private readonly ISqlSugarRepository _repository; + /// + /// 缓存管理器. + /// + private readonly ICacheManager _cacheManager; + + /// + /// IM中心处理程序. + /// + private IMHandler _imHandler; + /// /// 用户管理. /// @@ -37,9 +52,13 @@ public class SystemService : IDynamicApiController, ITransient /// public SystemService( ISqlSugarRepository repository, + ICacheManager cacheManager, + IMHandler imHandler, IUserManager userManager) { _repository = repository; + _cacheManager = cacheManager; + _imHandler = imHandler; _userManager = userManager; } @@ -108,10 +127,99 @@ public class SystemService : IDynamicApiController, ITransient { if (await _repository.IsAnyAsync(x => x.Id != id && (x.EnCode == input.enCode || x.FullName == input.fullName) && x.DeleteMark == null)) throw Oops.Oh(ErrorCode.COM1004); - var entity = input.Adapt(); - var isOk = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync(); - if (!isOk) + + var mainSystem = await _repository.GetFirstAsync(it => it.IsMain.Equals(1) && it.EnabledMark.Equals(1) && it.DeleteMark == null); + + // 判断主系统是否被禁用. + if (input.id.Equals(mainSystem.Id) && input.enabledMark.Equals(0)) + throw Oops.Oh(ErrorCode.D1036); + + // 判断主系统是否有修改系统编码. + if (input.id.Equals(mainSystem.Id) && !input.enCode.Equals(mainSystem.EnCode)) + throw Oops.Oh(ErrorCode.D1037); + + var isOk = await _repository.AsUpdateable().SetColumns(it => new SystemEntity() + { + FullName = input.fullName, + EnCode = input.enCode, + Icon = input.icon, + SortCode = input.sortCode, + Description = input.description, + EnabledMark = input.enabledMark, + LastModifyUserId = _userManager.UserId, + LastModifyTime = SqlFunc.GetDate(), + }).Where(it => it.Id.Equals(id)).ExecuteCommandAsync(); + if (!(isOk > 0)) throw Oops.Oh(ErrorCode.COM1001); + + // 当用户的子系统被禁用时,更换成其他未被禁用的系统. + if (!input.id.Equals(mainSystem.Id) && input.enabledMark.Equals(0)) + { + var systemUser = await _repository.AsSugarClient().Queryable() + .Where(it => it.DeleteMark == null && input.id.Equals(it.SystemId)) + .Select(x => new UserEntity() + { + Id = x.Id, + SystemId = x.SystemId + }).ToListAsync(); + + // 获取用户所有角色id. + var userRoleIdList = await _repository.AsSugarClient().Queryable() + .Where(it => systemUser.Select(s => s.Id).ToList().Contains(it.UserId) && it.ObjectType.Equals("Role")) + .Select(x => x.ObjectId) + .ToListAsync(); + var authorizeList = await _repository.AsSugarClient().Queryable() + .Where(it => it.ItemType.Equals("module") && it.ObjectType.Equals("Role")) + .ToListAsync(); + var moduleList = await _repository.AsSugarClient().Queryable() + .Where(it => !it.SystemId.Equals(mainSystem.Id) && !it.SystemId.Equals(input.id) && it.DeleteMark == null) + .ToListAsync(); + + systemUser.ForEach(async item => + { + // 获取用户所有角色的菜单. + var moduleIdList = authorizeList + .Where(x => userRoleIdList.Contains(x.ObjectId)) + .Select(s => s.ItemId); + + // 获取用户所有有权限的系统id. + var systemId = moduleList + .Where(x => moduleIdList.Contains(x.Id)) + .Select(s => s.SystemId).FirstOrDefault(); + + if (systemId == null) + systemId = mainSystem.Id; + + // 更新用户的系统id. + var res = await _repository.AsSugarClient().Updateable() + .Where(x => item.Id.Equals(x.Id)) + .SetColumns(x => new UserEntity() + { + SystemId = systemId + }).ExecuteCommandAsync(); + + if (!(res > 0)) + throw Oops.Oh(ErrorCode.COM1001); + }); + + var tenantId = _userManager.TenantId; + var cacheKey = string.Format("{0}{1}", CommonConst.CACHEKEYONLINEUSER, tenantId); + var allUserOnlineList = await _cacheManager.GetAsync>(cacheKey); + + var userOnlineList = allUserOnlineList.FindAll(it => systemUser.Select(s => s.Id).ToList().Contains(it.userId)); + userOnlineList.ForEach(async item => + { + await _imHandler.SendMessageAsync(item.connectionId, new { method = "logout", msg = "此系统已被禁用" }.ToJsonString()); + + // 删除在线用户ID. + allUserOnlineList.RemoveAll((x) => x.connectionId == item.connectionId); + + // 删除用户登录信息缓存. + var mCacheKey = string.Format("{0}{1}_{2}", CommonConst.CACHEKEYUSER, tenantId, item.userId); + await _cacheManager.DelAsync(mCacheKey); + }); + await _cacheManager.SetAsync(cacheKey, allUserOnlineList); + } } /// diff --git a/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs b/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs index 91bd0d7d..d7bbce5b 100644 --- a/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs +++ b/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs @@ -106,8 +106,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; default: @@ -149,8 +147,7 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), + ShowField = control.relational, }); break; } @@ -292,6 +289,7 @@ public class CodeGenWay ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), IsImportField = isImportField.ParseToBool(), ChildControlKey = controlId, + ShowField = control.relational, }); break; case false: @@ -426,8 +424,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField == null ? false : (bool)isImportField, ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; default: @@ -465,8 +461,7 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField == null ? false : (bool)isImportField, ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), + ShowField = control.relational, }); break; } @@ -580,8 +575,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; default: @@ -621,8 +614,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; } @@ -740,8 +731,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)) == null ? false : (bool)columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; default: @@ -781,8 +770,7 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)) == null ? false : (bool)columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), + ShowField = control.relational, }); break; } @@ -893,8 +881,6 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), }); break; default: @@ -932,8 +918,7 @@ public class CodeGenWay ControlLabel = control.__config__.label, IsImportField = isImportField.ParseToBool(), ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName), - ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)), - ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls), + ShowField = control.relational, }); break; } @@ -1214,7 +1199,7 @@ public class CodeGenWay var isAdd = indexTopButton.Any(it => it.Value == "add"); var isTreeRelation = !string.IsNullOrEmpty(columnDesignModel?.treeRelation); var isRelationForm = formControlList.Any(it => it.IsRelationForm); - var isFixed = columnDesignModel.childTableStyle == 1 ? indexColumnDesign.Any(it => it.Fixed.Any()) : false; + var isFixed = columnDesignModel.childTableStyle == 1 ? indexColumnDesign.Any(it => it.Fixed.Equals("fixed='left' ") && !it.Name.Equals(columnDesignModel.groupField)) : false; switch (logic) { diff --git a/visualdev/Tnb.VisualDev.Engine/Model/CodeGen/TableColumnConfigModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/CodeGen/TableColumnConfigModel.cs index b5ec59d1..270fa3bf 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/CodeGen/TableColumnConfigModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/CodeGen/TableColumnConfigModel.cs @@ -250,12 +250,7 @@ public class TableColumnConfigModel public string LeagueTableNo { get; set; } /// - /// 需解析的控件类型 JnpfKeyConst @@ 需解析的字段集合(以,隔开). + /// 展示字段. /// - public List ParsJnpfKeyConstList { get; set; } - - /// - /// 需解析的控件类型 JnpfKeyConst @@ 需解析的字段集合(以,隔开)(行内编辑 特殊处理). - /// - public List ParsJnpfKeyConstListDetails { get; set; } + public string ShowField { get; set; } } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev.Engine/Model/ConfigModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/ConfigModel.cs index 935f3a71..556060e6 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/ConfigModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/ConfigModel.cs @@ -220,4 +220,10 @@ public class LinkageConfig /// 是否多选. /// public bool IsMultiple { get; set; } + + /// + /// 联动模板json. + /// + public List templateJson { get; set; } + } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev.Engine/Model/EntityFieldModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/EntityFieldModel.cs index 74b026ba..0bcc7749 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/EntityFieldModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/EntityFieldModel.cs @@ -5,7 +5,7 @@ namespace JNPF.VisualDev.Engine; /// /// 实体字段模型 /// 版 本:V3.0.0 -/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com) +/// 版 权:引迈信息技术有限公司(https://www.jnpfsoft.com) /// 作 者:JNPF开发平台组. /// [SuppressSniffer] diff --git a/visualdev/Tnb.VisualDev.Engine/Model/FieldsModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/FieldsModel.cs index 098297a5..856ff640 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/FieldsModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/FieldsModel.cs @@ -581,4 +581,9 @@ public class FieldsModel /// 上级__vModel__. /// public string superiorVModel { get; set; } + + /// + /// 后端自我创建字段、用于统一处理关联表单属性与弹窗选择属性. + /// + public string relational { get; set; } } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev.Engine/Security/BackEnd/CodeGenControlsAttributeHelper.cs b/visualdev/Tnb.VisualDev.Engine/Security/BackEnd/CodeGenControlsAttributeHelper.cs index b7e840ba..5b3c009e 100644 --- a/visualdev/Tnb.VisualDev.Engine/Security/BackEnd/CodeGenControlsAttributeHelper.cs +++ b/visualdev/Tnb.VisualDev.Engine/Security/BackEnd/CodeGenControlsAttributeHelper.cs @@ -92,7 +92,6 @@ public class CodeGenControlsAttributeHelper case JnpfKeyConst.DEPSELECT: case JnpfKeyConst.POSSELECT: case JnpfKeyConst.USERSELECT: - case JnpfKeyConst.POPUPTABLESELECT: case JnpfKeyConst.ROLESELECT: case JnpfKeyConst.GROUPSELECT: { @@ -106,7 +105,9 @@ public class CodeGenControlsAttributeHelper case JnpfKeyConst.CHECKBOX: case JnpfKeyConst.CASCADER: case JnpfKeyConst.COMSELECT: + case JnpfKeyConst.POPUPTABLESELECT: case JnpfKeyConst.ADDRESS: + case JnpfKeyConst.USERSSELECT: tag = true; break; } @@ -206,7 +207,6 @@ public class CodeGenControlsAttributeHelper case JnpfKeyConst.DEPSELECT: case JnpfKeyConst.POSSELECT: case JnpfKeyConst.USERSELECT: - case JnpfKeyConst.POPUPTABLESELECT: case JnpfKeyConst.ROLESELECT: case JnpfKeyConst.GROUPSELECT: { @@ -221,6 +221,7 @@ public class CodeGenControlsAttributeHelper case JnpfKeyConst.CASCADER: case JnpfKeyConst.COMSELECT: case JnpfKeyConst.ADDRESS: + case JnpfKeyConst.POPUPTABLESELECT: tag = true; break; } @@ -248,6 +249,7 @@ public class CodeGenControlsAttributeHelper case JnpfKeyConst.DEPSELECT: case JnpfKeyConst.POSSELECT: case JnpfKeyConst.USERSELECT: + case JnpfKeyConst.USERSSELECT: case JnpfKeyConst.POPUPTABLESELECT: case JnpfKeyConst.ROLESELECT: case JnpfKeyConst.GROUPSELECT: @@ -456,6 +458,14 @@ public class CodeGenControlsAttributeHelper if (!res.ContainsKey(JnpfKeyConst.USERSSELECT)) res.Add(JnpfKeyConst.USERSSELECT, new List()); res[JnpfKeyConst.USERSSELECT].Add(item.__vModel__); break; + case JnpfKeyConst.POPUPSELECT: // 弹窗选择 + if (!res.ContainsKey(JnpfKeyConst.POPUPSELECT)) res.Add(JnpfKeyConst.POPUPSELECT, new List()); + res[JnpfKeyConst.POPUPSELECT].Add(item.__vModel__); + break; + case JnpfKeyConst.RELATIONFORM: // 关联表单 + if (!res.ContainsKey(JnpfKeyConst.RELATIONFORM)) res.Add(JnpfKeyConst.RELATIONFORM, new List()); + res[JnpfKeyConst.RELATIONFORM].Add(item.__vModel__); + break; case JnpfKeyConst.TABLE: // 遍历 子表 控件 var ctRes = GetParsJnpfKeyConstList(item.__config__.children, isInlineEditor); if (ctRes != null && ctRes.Any()) @@ -463,7 +473,7 @@ public class CodeGenControlsAttributeHelper foreach (var ct in ctRes) { if (!res.ContainsKey(ct.FirstOrDefault())) res.Add(ct.FirstOrDefault(), new List()); - res[ct.FirstOrDefault()].AddRange(ct.LastOrDefault().Split(',')); + res[ct.FirstOrDefault()].Add(item.__vModel__ + "-" + ct.LastOrDefault()); } } break; @@ -506,10 +516,6 @@ public class CodeGenControlsAttributeHelper if (!res.ContainsKey(JnpfKeyConst.USERSSELECT)) res.Add(JnpfKeyConst.USERSSELECT, new List()); res[JnpfKeyConst.USERSSELECT].Add(item.__vModel__); break; - case JnpfKeyConst.POPUPTABLESELECT: // 下拉表格. - if (!res.ContainsKey(JnpfKeyConst.POPUPTABLESELECT)) res.Add(JnpfKeyConst.POPUPTABLESELECT, new List()); - res[JnpfKeyConst.POPUPTABLESELECT].Add(item.__vModel__); - break; case JnpfKeyConst.POPUPSELECT: // 弹窗选择. if (!res.ContainsKey(JnpfKeyConst.POPUPSELECT)) res.Add(JnpfKeyConst.POPUPSELECT, new List()); res[JnpfKeyConst.POPUPSELECT].Add(item.__vModel__); @@ -524,8 +530,8 @@ public class CodeGenControlsAttributeHelper { foreach (var ct in ctRes) { - if (!res.ContainsKey(item.__vModel__ + "-" + ct.FirstOrDefault())) res.Add(item.__vModel__ + "-" + ct.FirstOrDefault(), new List()); - res[item.__vModel__ + "-" + ct.FirstOrDefault()].AddRange(ct.LastOrDefault().Split(',')); + if (!res.ContainsKey(ct.FirstOrDefault())) res.Add(ct.FirstOrDefault(), new List()); + res[ct.FirstOrDefault()].Add(item.__vModel__ + "-" + ct.LastOrDefault()); } } diff --git a/visualdev/Tnb.VisualDev.Engine/Security/CodeGenUnifiedHandlerHelper.cs b/visualdev/Tnb.VisualDev.Engine/Security/CodeGenUnifiedHandlerHelper.cs index 18b73c32..339462fc 100644 --- a/visualdev/Tnb.VisualDev.Engine/Security/CodeGenUnifiedHandlerHelper.cs +++ b/visualdev/Tnb.VisualDev.Engine/Security/CodeGenUnifiedHandlerHelper.cs @@ -288,4 +288,41 @@ public class CodeGenUnifiedHandlerHelper } return NewFormDataModel; } + + /// + /// 统一处理控件关系. + /// + /// 控件列表. + /// + public static List UnifiedHandlerControlRelationship(List formDataModel, bool isMain = true) + { + formDataModel.ForEach(item => + { + switch (item.__config__.jnpfKey) + { + case JnpfKeyConst.RELATIONFORM: + { + var list = formDataModel.FindAll(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.RELATIONFORMATTR) && it.relationField.Equals(string.Format("{0}_jnpfTable_{1}{2}", item.__vModel__, item.__config__.tableName, isMain ? 1 : 0)) && it.__config__.isStorage.Equals(1)); + item.relational = string.Join(",", list.Select(it => it.showField).ToList()); + } + + break; + case JnpfKeyConst.TABLE: + { + item.__config__.children = UnifiedHandlerControlRelationship(item.__config__.children, false); + } + + break; + case JnpfKeyConst.POPUPSELECT: + { + var list = formDataModel.FindAll(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.POPUPATTR) && it.relationField.Equals(string.Format("{0}_jnpfTable_{1}{2}", item.__vModel__, item.__config__.tableName, isMain ? 1 : 0)) && it.__config__.isStorage.Equals(1)); + item.relational = string.Join(",", list.Select(it => it.showField).ToList()); + } + + break; + } + }); + + return formDataModel; + } } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev.Engine/Security/FrontEnd/CodeGenFormControlDesignHelper.cs b/visualdev/Tnb.VisualDev.Engine/Security/FrontEnd/CodeGenFormControlDesignHelper.cs index f9a1320c..063281e0 100644 --- a/visualdev/Tnb.VisualDev.Engine/Security/FrontEnd/CodeGenFormControlDesignHelper.cs +++ b/visualdev/Tnb.VisualDev.Engine/Security/FrontEnd/CodeGenFormControlDesignHelper.cs @@ -363,9 +363,11 @@ public class CodeGenFormControlDesignHelper { var relationField = Regex.Match(item.relationField, @"^(.+)_jnpfTable_").Groups[1].Value; var relationControl = realisticControls.Find(it => it.__vModel__ == relationField); + var columnDesign = columnDesignModel?.Find(it => it.__vModel__ == item.__vModel__); list.Add(new FormControlDesignModel() { vModel = item.__vModel__.IsNotEmptyOrNull() ? string.Format("v-model=\"dataForm.{0}\"", item.__vModel__) : string.Empty, + IsInlineEditor = columnDesignModel != null ? columnDesignModel.Any(it => it.__vModel__ == item.__vModel__) : false, Style = item.style != null && !item.style.ToString().Equals("{}") ? $":style='{item.style.ToJsonString()}' " : string.Empty, jnpfKey = config.jnpfKey, OriginalName = config.isStorage == 2 ? item.__vModel__ : relationField, @@ -377,7 +379,9 @@ public class CodeGenFormControlDesignHelper Label = config.label, Span = config.span, IsStorage = config.isStorage, + IndexWidth = columnDesign?.width, LabelWidth = config?.labelWidth ?? labelWidth, + IndexAlign = columnDesign?.align, }); } diff --git a/visualdev/Tnb.VisualDev/CodeGen/DataParsing/ControlParsing.cs b/visualdev/Tnb.VisualDev/CodeGen/DataParsing/ControlParsing.cs index 04e2377b..e1be8234 100644 --- a/visualdev/Tnb.VisualDev/CodeGen/DataParsing/ControlParsing.cs +++ b/visualdev/Tnb.VisualDev/CodeGen/DataParsing/ControlParsing.cs @@ -15,9 +15,6 @@ using JNPF.Systems.Interfaces.System; using JNPF.RemoteRequest.Extensions; using JNPF.Systems.Entitys.Model.DataInterFace; using JNPF.Common.Core.Manager; -using Microsoft.AspNetCore.Identity; -using Spire.Pdf.Lists; -using Senparc.NeuChar.Entities; namespace JNPF.Common.CodeGen.DataParsing; @@ -43,11 +40,6 @@ public class ControlParsing : ITransient /// private readonly IDataInterfaceService _dataInterfaceService; - /// - /// 解析控件的控件属性 (vModel , Attr). - /// - private Dictionary? ControlAttr; - /// /// 构造函数. /// @@ -74,9 +66,6 @@ public class ControlParsing : ITransient /// public async Task>> GetParsDataList(List> oldDatas, string vModelStr, string jnpfKeyConst, string tenantId, List? vModelAttr = null) { - ControlAttr = new Dictionary(); - if (vModelAttr != null) vModelAttr.ForEach(it => ControlAttr.Add(it.__vModel__, it)); - var vModels = new Dictionary(); var vModelList = vModelStr.Split(','); oldDatas.ForEach(items => @@ -91,45 +80,54 @@ public class ControlParsing : ITransient var ctOldDatas = item.Value.ToObject>>(); ctOldDatas.ForEach(ctItems => { - foreach (var ctItem in ctItems) if (vModelList.Contains(ctItem.Key) && !vModels.ContainsKey(ctItem.Key)) vModels.Add(ctItem.Key, jnpfKeyConst); + foreach (var ctItem in ctItems) + { + if (vModelList.Contains(item.Key + "-" + ctItem.Key) && !vModels.ContainsKey(item.Key + "-" + ctItem.Key)) + vModels.Add(item.Key + "-" + ctItem.Key, jnpfKeyConst); + } }); } } }); - return await GetParsDataByList(oldDatas, vModels, tenantId); + return await GetParsDataByList(vModelAttr, oldDatas, vModels, tenantId); } /// /// 获取解析数据. /// + /// 模板集合. /// 原数据集合. /// 需解析的字段 (字段名,JnpfKeyConst/子表dictionary). /// 租户Id. /// - private async Task>> GetParsDataByList(List> oldDatas, Dictionary vModels, string tenantId) + private async Task>> GetParsDataByList(List fields, List> oldDatas, Dictionary vModels, string tenantId) { var cacheData = await GetCaCheData(vModels, tenantId); var usersselectDatas = cacheData.Where(t => t.Key.Equals(CommonConst.CodeGenDynamic + "_usersSelect_" + tenantId)).FirstOrDefault().Value.ToObject>(); // 用户组件 - oldDatas.ForEach(async items => + foreach (var items in oldDatas) { - foreach (var item in items) + for(var i = 0; i < items.Count; i++) { - if (vModels.Any(x => x.Key.Equals(item.Key))) + var item = items.ToList()[i]; + + if (vModels.Any(x => x.Key.Equals(item.Key)) && items[item.Key] != null) { - FieldsModel model = ControlAttr.ContainsKey(item.Key) ? ControlAttr[item.Key] : new FieldsModel(); + FieldsModel model = fields.Any(x=>x.__vModel__.Equals(item.Key)) ? fields.Find(x=> x.__vModel__.Equals(item.Key)) : (fields.Any(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) ? fields.Find(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) : new FieldsModel()); model.separator = ","; var jnpfKey = vModels.FirstOrDefault(x => x.Key.Equals(item.Key)).Value; switch (jnpfKey) { case JnpfKeyConst.USERSSELECT: { - if (item.Value != null) + var itemValue = item.Value; + if (itemValue == null && items.ContainsKey(item.Key.Replace("_name", string.Empty))) itemValue = items[item.Key.Replace("_name", string.Empty)]; + if (itemValue != null) { var vList = new List(); - if (item.Value.ToString().Contains("[")) vList = item.Value.ToString().ToObject>(); - else vList.Add(item.Value.ToString()); + if (itemValue.ToString().Contains("[")) vList = itemValue.ToString().ToObject>(); + else vList.Add(itemValue.ToString()); var itemValues = new List(); vList.ForEach(it => { @@ -140,7 +138,6 @@ public class ControlParsing : ITransient } break; - case JnpfKeyConst.POPUPTABLESELECT: case JnpfKeyConst.POPUPSELECT: // 弹窗选择 { if (model.interfaceId.IsNullOrEmpty()) continue; @@ -193,62 +190,45 @@ public class ControlParsing : ITransient { case 1: // SQL数据 { - var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(items[item.Key].ToString())).FirstOrDefault(); + var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault(); if (specificData != null) { // 要用模板的 “显示字段 - relationField”来展示数据 items[item.Key + "_id"] = items[item.Key]; items[item.Key] = specificData[model.relationField]; - } - else - { - if (model.multiple) - { - var nameList = new List(); - items[item.Key].ToObject>().ForEach(strIt => - { - var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(strIt)).FirstOrDefault(); - if (specificData != null) - { - // 要用模板的 “显示字段 - relationField”来展示数据 - if (model.relationField.IsNotEmptyOrNull()) - nameList.Add(specificData[model.relationField]); - } - }); - if (nameList.Any()) - { - items[item.Key + "_id"] = items[item.Key]; - items[item.Key] = string.Join(model.separator, nameList); - } - } - else - { - items[item.Key] = items[item.Key].ToString().Contains("[") ? string.Join(model.separator, items[item.Key].ToObject>()) : items[item.Key]; - } + + // 弹窗选择属性 + if (model.relational.IsNotEmptyOrNull()) + foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = specificData[fItem]; } } break; case 2: // 静态数据 { - List dataList = items[item.Key].ToJsonString().ToObject>(); - List cascaderList = new List(); - foreach (var it in dataList) + var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault(); + if (vara != null) { - var vara = popupselectDataList.Where(a => a.ContainsValue(it)).FirstOrDefault(); - if (vara != null) cascaderList.Add(vara[model.props.props.label]); - } + items[item.Key + "_id"] = items[item.Key]; + items[item.Key] = vara[items[item.Key].ToString()]; - items[item.Key + "_id"] = items[item.Key]; - items[item.Key] = string.Join(model.separator, cascaderList); + // 弹窗选择属性 + if (model.relational.IsNotEmptyOrNull()) + foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem]; + } } break; case 3: // Api数据 { - List cascaderList = new List(); - if (popupselectDataList != null) popupselectDataList.ForEach(obj => { if (obj[model.propsValue] == items[item.Key].ToString()) cascaderList.Add(obj[model.relationField]); }); + var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault(); + if (vara != null) + { + items[item.Key + "_id"] = items[item.Key]; + items[item.Key] = vara[items[item.Key].ToString()]; - items[item.Key + "_id"] = items[item.Key]; - items[item.Key] = string.Join(model.separator, cascaderList); + // 弹窗选择属性 + if (model.relational.IsNotEmptyOrNull()) + foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem]; + } } break; } @@ -293,6 +273,10 @@ public class ControlParsing : ITransient { items[item.Key + "_id"] = relationFormRealData["id"]; items[item.Key] = relationFormRealData.ContainsKey(model.relationField) ? relationFormRealData[model.relationField] : string.Empty; + + // 关联表单属性 + if (model.relational.IsNotEmptyOrNull()) + foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = relationFormRealData[fItem]; } else { @@ -309,11 +293,15 @@ public class ControlParsing : ITransient { var ctList = item.Value.ToObject>>(); var ctVModels = new Dictionary(); - vModels.Where(x => x.Key.Contains(item.Key)).ToList().ForEach(ctItem => ctVModels.Add(ctItem.Key.Split("-").LastOrDefault(), ctItem.Value)); - if (ctList.Any()) items[item.Key] = await GetParsDataByList(ctList, ctVModels, tenantId); + foreach (var ctItem in vModels.Where(x => x.Key.Contains(item.Key)).ToList()) + { + ctVModels.Add(ctItem.Key.Split("-").LastOrDefault(), ctItem.Value); + var ctFields = fields.Find(x => x.__vModel__.Equals(ctItem.Key.Split("-").FirstOrDefault())).__config__.children; + if (ctList.Any()) items[item.Key] = await GetParsDataByList(ctFields, ctList, ctVModels, tenantId); + } } } - }); + } return oldDatas; } @@ -493,5 +481,4 @@ public class ControlParsing : ITransient } #endregion - } \ No newline at end of file diff --git a/visualdev/Tnb.VisualDev/CodeGen/ExportImport/ExportImportDataHelper.cs b/visualdev/Tnb.VisualDev/CodeGen/ExportImport/ExportImportDataHelper.cs index 2d8e4d1e..4a35792c 100644 --- a/visualdev/Tnb.VisualDev/CodeGen/ExportImport/ExportImportDataHelper.cs +++ b/visualdev/Tnb.VisualDev/CodeGen/ExportImport/ExportImportDataHelper.cs @@ -21,9 +21,9 @@ using JNPF.Systems.Entitys.Model.DataInterFace; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; using JNPF.VisualDev.Engine; using JNPF.VisualDev.Engine.Core; -using JNPF.VisualDev.Interfaces; using JNPF.WorkFlow.Interfaces.Service; using Mapster; using Newtonsoft.Json.Linq; @@ -50,7 +50,7 @@ public class ExportImportDataHelper : ITransient /// /// 在线开发运行服务. /// - private readonly IRunService _runService; + private readonly RunService _runService; /// /// 单据. @@ -93,7 +93,7 @@ public class ExportImportDataHelper : ITransient public ExportImportDataHelper( ISqlSugarRepository repositoryRepository, IUserManager userManager, - IRunService runService, + RunService runService, IBillRullService billRuleService, IDataInterfaceService dataInterfaceService, IDataBaseManager databaseService, @@ -369,6 +369,55 @@ public class ExportImportDataHelper : ITransient field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds; field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds; field.ableIds = (att as CodeGenUploadAttribute).ableIds; + field.relational = (att as CodeGenUploadAttribute).showField; + configModel = (att as CodeGenUploadAttribute).__config__.Adapt(); + configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__); + field.__config__ = configModel; + fieldList.Add(field); + } + } + } + return fieldList; + } + + /// + /// 获取数据转换模板解析. + /// + public static List GetDataConversionTemplateParsing(T entity) + { + List fieldList = new List(); + foreach (PropertyInfo prop in entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) + { + FieldsModel field = new FieldsModel(); + foreach (var att in prop.GetCustomAttributes(false)) + { + if (att is CodeGenUploadAttribute) + { + var configModel = new ConfigModel(); + field.__vModel__ = (att as CodeGenUploadAttribute).__vModel__ ?? (att as CodeGenUploadAttribute).__Model__; + field.level = (att as CodeGenUploadAttribute).level; + field.min = (att as CodeGenUploadAttribute).min == 0 ? null : (att as CodeGenUploadAttribute).min; + field.max = (att as CodeGenUploadAttribute).max == 0 ? null : (att as CodeGenUploadAttribute).max; + field.activeTxt = (att as CodeGenUploadAttribute).activeTxt; + field.inactiveTxt = (att as CodeGenUploadAttribute).inactiveTxt; + field.format = (att as CodeGenUploadAttribute).format; + field.multiple = (att as CodeGenUploadAttribute).multiple; + field.separator = (att as CodeGenUploadAttribute).separator; + field.__slot__ = (att as CodeGenUploadAttribute).__slot__.Adapt(); + field.props = (att as CodeGenUploadAttribute).props.Adapt(); + field.options = (att as CodeGenUploadAttribute).options; + field.propsValue = (att as CodeGenUploadAttribute).propsValue; + field.relationField = (att as CodeGenUploadAttribute).relationField; + field.modelId = (att as CodeGenUploadAttribute).modelId; + field.interfaceId = (att as CodeGenUploadAttribute).interfaceId; + field.selectType = (att as CodeGenUploadAttribute).selectType; + field.ableDepIds = (att as CodeGenUploadAttribute).ableDepIds; + field.ablePosIds = (att as CodeGenUploadAttribute).ablePosIds; + field.ableUserIds = (att as CodeGenUploadAttribute).ableUserIds; + field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds; + field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds; + field.ableIds = (att as CodeGenUploadAttribute).ableIds; + field.relational = (att as CodeGenUploadAttribute).showField; configModel = (att as CodeGenUploadAttribute).__config__.Adapt(); configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__); field.__config__ = configModel; @@ -416,6 +465,56 @@ public class ExportImportDataHelper : ITransient field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds; field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds; field.ableIds = (att as CodeGenUploadAttribute).ableIds; + field.relational = (att as CodeGenUploadAttribute).showField; + configModel = (att as CodeGenUploadAttribute).__config__.Adapt(); + configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__); + field.__config__ = configModel; + fieldList.Add(field); + } + } + } + + return fieldList; + } + + /// + /// 获取数据转换模板解析. + /// + public static List GetDataConversionTemplateParsing(T entity, string tableName) + { + List fieldList = new List(); + foreach (PropertyInfo prop in entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) + { + FieldsModel field = new FieldsModel(); + foreach (var att in prop.GetCustomAttributes(false)) + { + if (att is CodeGenUploadAttribute) + { + var configModel = new ConfigModel(); + field.__vModel__ = string.Format("jnpf_{0}_jnpf_{1}", tableName, (att as CodeGenUploadAttribute).__vModel__ ?? (att as CodeGenUploadAttribute).__Model__); + field.level = (att as CodeGenUploadAttribute).level; + field.min = (att as CodeGenUploadAttribute).min == 0 ? null : (att as CodeGenUploadAttribute).min; + field.max = (att as CodeGenUploadAttribute).max == 0 ? null : (att as CodeGenUploadAttribute).max; + field.activeTxt = (att as CodeGenUploadAttribute).activeTxt; + field.inactiveTxt = (att as CodeGenUploadAttribute).inactiveTxt; + field.format = (att as CodeGenUploadAttribute).format; + field.multiple = (att as CodeGenUploadAttribute).multiple; + field.separator = (att as CodeGenUploadAttribute).separator; + field.__slot__ = (att as CodeGenUploadAttribute).__slot__.Adapt(); + field.props = (att as CodeGenUploadAttribute).props.Adapt(); + field.options = (att as CodeGenUploadAttribute).options; + field.propsValue = (att as CodeGenUploadAttribute).propsValue; + field.relationField = (att as CodeGenUploadAttribute).relationField; + field.modelId = (att as CodeGenUploadAttribute).modelId; + field.interfaceId = (att as CodeGenUploadAttribute).interfaceId; + field.selectType = (att as CodeGenUploadAttribute).selectType; + field.ableDepIds = (att as CodeGenUploadAttribute).ableDepIds; + field.ablePosIds = (att as CodeGenUploadAttribute).ablePosIds; + field.ableUserIds = (att as CodeGenUploadAttribute).ableUserIds; + field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds; + field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds; + field.ableIds = (att as CodeGenUploadAttribute).ableIds; + field.relational = (att as CodeGenUploadAttribute).showField; configModel = (att as CodeGenUploadAttribute).__config__.Adapt(); configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__); field.__config__ = configModel; @@ -660,78 +759,78 @@ public class ExportImportDataHelper : ITransient return new { dataRow = resData, headerRow = headerRow }; } - ///// - ///// 导入数据. - ///// - ///// 模板信息. - ///// 数据集合. - ///// [成功列表,失败列表]. - //public async Task ImportMenuData(TemplateParsingBase tInfo, List> list) - //{ - // List> userInputList = ImportFirstVerify(tInfo, list); - // List fieldsModelList = tInfo.AllFieldsModel.Where(x => tInfo.selectKey.Contains(x.__vModel__)).ToList(); + /// + /// 导入数据. + /// + /// 模板信息. + /// 数据集合. + /// [成功列表,失败列表]. + public async Task ImportMenuData(TemplateParsingBase tInfo, List> list) + { + List> userInputList = ImportFirstVerify(tInfo, list); + List fieldsModelList = tInfo.AllFieldsModel.Where(x => tInfo.selectKey.Contains(x.__vModel__)).ToList(); - // var successList = new List>(); - // var errorsList = new List>(); + var successList = new List>(); + var errorsList = new List>(); - // // 捞取控件解析数据 - // var cData = await GetCDataList(tInfo.AllFieldsModel, new Dictionary>>()); - // var res = await ImportDataAssemble(fieldsModelList, userInputList, cData); - // res.Where(x => x.ContainsKey("errorsInfo")).ToList().ForEach(item => errorsList.Add(item)); - // res.Where(x => !x.ContainsKey("errorsInfo")).ToList().ForEach(item => successList.Add(item)); + // 捞取控件解析数据 + var cData = await GetCDataList(tInfo.AllFieldsModel, new Dictionary>>()); + var res = await ImportDataAssemble(fieldsModelList, userInputList, cData); + res.Where(x => x.ContainsKey("errorsInfo")).ToList().ForEach(item => errorsList.Add(item)); + res.Where(x => !x.ContainsKey("errorsInfo")).ToList().ForEach(item => successList.Add(item)); - // try - // { - // // 唯一验证已处理,入库前去掉. - // tInfo.AllFieldsModel.Where(x => x.__config__.jnpfKey.Equals(JnpfKeyConst.COMINPUT) && x.__config__.unique).ToList().ForEach(item => item.__config__.unique = false); - // _sqlSugarClient.BeginTran(); - // foreach (var item in successList) - // { - // if (item.ContainsKey("Update_MainTablePrimary_Id")) - // { - // string? mainId = item["Update_MainTablePrimary_Id"].ToString(); - // var haveTableSql = await _runService.GetUpdateSqlByTemplate(tInfo, new VisualDevModelDataUpInput() { data = item.ToJsonString() }, mainId); - // foreach (var it in haveTableSql) await _databaseService.ExecuteSql(tInfo.DbLink, it); // 修改功能数据 - // } - // else - // { - // if ((tInfo.visualDevEntity?.EnableFlow.Equals(1)).ParseToBool()) - // { - // var flowId = _repository.AsSugarClient().Queryable().First(x => x.Id.Equals(tInfo.visualDevEntity.Id)).FlowId; - // await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item.ToJsonString(), flowId = flowId, flowUrgent = 1 }); - // } - // else - // { - // string? mainId = YitIdHelper.NextId().ToString(); - // var haveTableSql = await _runService.GetCreateSqlByTemplate(tInfo, new VisualDevModelDataCrInput() { data = item.ToJsonString() }, mainId); + try + { + // 唯一验证已处理,入库前去掉. + tInfo.AllFieldsModel.Where(x => x.__config__.jnpfKey.Equals(JnpfKeyConst.COMINPUT) && x.__config__.unique).ToList().ForEach(item => item.__config__.unique = false); + _sqlSugarClient.BeginTran(); + foreach (var item in successList) + { + if (item.ContainsKey("Update_MainTablePrimary_Id")) + { + string? mainId = item["Update_MainTablePrimary_Id"].ToString(); + var haveTableSql = await _runService.GetUpdateSqlByTemplate(tInfo, new VisualDevModelDataUpInput() { data = item.ToJsonString() }, mainId); + foreach (var it in haveTableSql) await _databaseService.ExecuteSql(tInfo.DbLink, it); // 修改功能数据 + } + else + { + if ((tInfo.visualDevEntity?.EnableFlow.Equals(1)).ParseToBool()) + { + var flowId = _repository.AsSugarClient().Queryable().First(x => x.Id.Equals(tInfo.visualDevEntity.Id)).FlowId; + await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item, flowId = flowId, flowUrgent = 1, status = 1 }); + } + else + { + string? mainId = YitIdHelper.NextId().ToString(); + var haveTableSql = await _runService.GetCreateSqlByTemplate(tInfo, new VisualDevModelDataCrInput() { data = item.ToJsonString() }, mainId); - // // 主表自增长Id. - // if (haveTableSql.ContainsKey("MainTableReturnIdentity")) - // { - // mainId = haveTableSql["MainTableReturnIdentity"].First().First().Value.ToString(); - // haveTableSql.Remove("MainTableReturnIdentity"); - // } - // foreach (var it in haveTableSql) - // await _databaseService.ExecuteSql(tInfo.DbLink, it.Key, it.Value); // 新增功能数据 - // } - // } - // } + // 主表自增长Id. + if (haveTableSql.ContainsKey("MainTableReturnIdentity")) + { + mainId = haveTableSql["MainTableReturnIdentity"].First().First().Value.ToString(); + haveTableSql.Remove("MainTableReturnIdentity"); + } + foreach (var it in haveTableSql) + await _databaseService.ExecuteSql(tInfo.DbLink, it.Key, it.Value); // 新增功能数据 + } + } + } - // _sqlSugarClient.CommitTran(); - // } - // catch (Exception e) - // { - // _sqlSugarClient.RollbackTran(); - // throw; - // } + _sqlSugarClient.CommitTran(); + } + catch (Exception e) + { + _sqlSugarClient.RollbackTran(); + throw; + } - // errorsList.ForEach(item => - // { - // if (item.ContainsKey("errorsInfo") && item["errorsInfo"].IsNotEmptyOrNull()) item["errorsInfo"] = item["errorsInfo"].ToString().TrimStart(',').TrimEnd(','); - // }); + errorsList.ForEach(item => + { + if (item.ContainsKey("errorsInfo") && item["errorsInfo"].IsNotEmptyOrNull()) item["errorsInfo"] = item["errorsInfo"].ToString().TrimStart(',').TrimEnd(','); + }); - // return new object[] { successList, errorsList }; - //} + return new object[] { successList, errorsList }; + } /// /// Excel 转输出 Model. diff --git a/visualdev/Tnb.VisualDev/CodeGenService.cs b/visualdev/Tnb.VisualDev/CodeGenService.cs index 4260f320..d8e1e1ef 100644 --- a/visualdev/Tnb.VisualDev/CodeGenService.cs +++ b/visualdev/Tnb.VisualDev/CodeGenService.cs @@ -21,8 +21,6 @@ using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Entitys.Dto.CodeGen; using JNPF.VisualDev.Entitys.Enum; using Microsoft.AspNetCore.Mvc; -using Org.BouncyCastle.Asn1.Crmf; -using Spire.Presentation; using SqlSugar; using System.IO.Compression; using System.Text; @@ -300,6 +298,7 @@ public class CodeGenService : IDynamicApiController, ITransient // 统一处理下表单内控件 controls = CodeGenUnifiedHandlerHelper.UnifiedHandlerFormDataModel(controls, pcColumnDesignModel, appColumnDesignModel); + controls = CodeGenUnifiedHandlerHelper.UnifiedHandlerControlRelationship(controls); break; } diff --git a/visualdev/Tnb.VisualDev/VisualDevService.cs b/visualdev/Tnb.VisualDev/VisualDevService.cs index 1aa9e721..860f9ee6 100644 --- a/visualdev/Tnb.VisualDev/VisualDevService.cs +++ b/visualdev/Tnb.VisualDev/VisualDevService.cs @@ -1462,7 +1462,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans authList.Add(new ModuleDataAuthorizeEntity() { Id = SnowflakeIdHelper.NextId(), - ConditionSymbol = "Included", // 条件符号 + ConditionSymbol = "Equal", // 条件符号 Type = "varchar", // 字段类型 FullName = item.__config__.label, // 字段说明 ConditionText = "@userAraSubordinates", // 条件内容(当前用户及下属) @@ -1519,7 +1519,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans authList.Add(new ModuleDataAuthorizeEntity() { Id = SnowflakeIdHelper.NextId(), - ConditionSymbol = "Included", // 条件符号 + ConditionSymbol = "Equal", // 条件符号 Type = "varchar", // 字段类型 FullName = item.__config__.label, // 字段说明 ConditionText = "@organizationAndSuborganization", // 条件内容(当前组织及组织) @@ -1558,7 +1558,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans authList.Add(new ModuleDataAuthorizeEntity() { Id = SnowflakeIdHelper.NextId(), - ConditionSymbol = "Included", // 条件符号 + ConditionSymbol = "Equal", // 条件符号 Type = "varchar", // 字段类型 FullName = item.__config__.label, // 字段说明 ConditionText = "@branchManageOrganize", // 条件内容(当前分管组织) @@ -1576,7 +1576,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans authList.Add(new ModuleDataAuthorizeEntity() { Id = SnowflakeIdHelper.NextId(), - ConditionSymbol = "Included", // 条件符号 + ConditionSymbol = "Equal", // 条件符号 Type = "varchar", // 字段类型 FullName = item.__config__.label, // 字段说明 ConditionText = "@branchManageOrganizeAndSub", // 条件内容(当前分管组织及子组织) @@ -1623,11 +1623,11 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans || x.FullName == "当前用户及下属" || x.FullName == "当前组织及子组织" || x.FullName == "当前分管组织" || x.FullName == "当前分管组织及子组织") .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") - || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@userAraSubordinates\"") + || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userAraSubordinates\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") - || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@organizationAndSuborganization\"") - || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganize\"") - || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganizeAndSub\"")) + || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizationAndSuborganization\"") + || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganize\"") + || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganizeAndSub\"")) .ToListAsync(); List? authSchemeList = new List(); // 方案管理 @@ -1668,16 +1668,16 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans model = authList.FirstOrDefault(x => x.EnCode == item.__vModel__ && x.ConditionText.Equals("@userAraSubordinates")); condJson.groups.First().id = model.Id; - condJson.groups.First().op = "Included"; + condJson.groups.First().op = "Equal"; condJson.groups.First().value = "@userAraSubordinates"; - if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {包含} {@userAraSubordinates}】")) + if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {等于} {@userAraSubordinates}】")) { authSchemeList.Add(new ModuleDataAuthorizeSchemeEntity() { FullName = "当前用户及下属", EnCode = SnowflakeIdHelper.NextId(), SortCode = -9527, - ConditionText = "【{" + item.__config__.label + "} {包含} {@userAraSubordinates}】", + ConditionText = "【{" + item.__config__.label + "} {等于} {@userAraSubordinates}】", ConditionJson = new List() { condJson }.ToJsonString(), ModuleId = menuId }); @@ -1685,14 +1685,14 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans // 删除 //List? delData = oldDataAuthScheme.Where(x => x.EnCode != item.__vModel__ - //&& (x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@userAraSubordinates\""))).ToList(); + //&& (x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userAraSubordinates\""))).ToList(); //await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } else { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@userAraSubordinates\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userAraSubordinates\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } } @@ -1700,7 +1700,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@userAraSubordinates\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@userAraSubordinates\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } @@ -1735,16 +1735,16 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans model = authList.FirstOrDefault(x => x.EnCode == item.__vModel__ && x.ConditionText.Equals("@organizationAndSuborganization")); condJson.groups.First().id = model.Id; - condJson.groups.First().op = "Included"; + condJson.groups.First().op = "Equal"; condJson.groups.First().value = "@organizationAndSuborganization"; - if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {包含} {@organizationAndSuborganization}】")) + if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {等于} {@organizationAndSuborganization}】")) { authSchemeList.Add(new ModuleDataAuthorizeSchemeEntity() { FullName = "当前组织及子组织", EnCode = SnowflakeIdHelper.NextId(), SortCode = -9527, - ConditionText = "【{" + item.__config__.label + "} {包含} {@organizationAndSuborganization}】", + ConditionText = "【{" + item.__config__.label + "} {等于} {@organizationAndSuborganization}】", ConditionJson = new List() { condJson }.ToJsonString(), ModuleId = menuId }); @@ -1752,14 +1752,14 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans // 删除 //List? delData = oldDataAuthScheme.Where(x => x.EnCode != item.__vModel__ - //&& (x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@organizationAndSuborganization\""))).ToList(); + //&& (x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizationAndSuborganization\""))).ToList(); //await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } else { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@organizationAndSuborganization\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizationAndSuborganization\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } } @@ -1767,7 +1767,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@organizationAndSuborganization\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizeId\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@organizationAndSuborganization\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } @@ -1783,18 +1783,18 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans condJson.groups.First().bindTable = model.BindTable; condJson.groups.First().field = item.__vModel__; condJson.groups.First().fieldRule = model.FieldRule.ParseToInt(); - condJson.groups.First().op = "Included"; + condJson.groups.First().op = "Equal"; condJson.groups.First().value = "@branchManageOrganize"; // 新增 - if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {包含} {@branchManageOrganize}】")) + if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {等于} {@branchManageOrganize}】")) { authSchemeList.Add(new ModuleDataAuthorizeSchemeEntity() { FullName = "当前分管组织", EnCode = SnowflakeIdHelper.NextId(), SortCode = -9527, - ConditionText = "【{" + item.__config__.label + "} {包含} {@branchManageOrganize}】", + ConditionText = "【{" + item.__config__.label + "} {等于} {@branchManageOrganize}】", ConditionJson = new List() { condJson }.ToJsonString(), ModuleId = menuId }); @@ -1802,16 +1802,16 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans model = authList.FirstOrDefault(x => x.EnCode == item.__vModel__ && x.ConditionText.Equals("@branchManageOrganizeAndSub")); condJson.groups.First().id = model.Id; - condJson.groups.First().op = "Included"; + condJson.groups.First().op = "Equal"; condJson.groups.First().value = "@branchManageOrganizeAndSub"; - if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {包含} {@branchManageOrganizeAndSub}】")) + if (!oldDataAuthScheme.Any(x => x.ConditionText == "【{" + item.__config__.label + "} {等于} {@branchManageOrganizeAndSub}】")) { authSchemeList.Add(new ModuleDataAuthorizeSchemeEntity() { FullName = "当前分管组织及子组织", EnCode = SnowflakeIdHelper.NextId(), SortCode = -9527, - ConditionText = "【{" + item.__config__.label + "} {包含} {@branchManageOrganizeAndSub}】", + ConditionText = "【{" + item.__config__.label + "} {等于} {@branchManageOrganizeAndSub}】", ConditionJson = new List() { condJson }.ToJsonString(), ModuleId = menuId }); @@ -1819,14 +1819,14 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans // 删除 //List? delData = oldDataAuthScheme.Where(x => x.EnCode != item.__vModel__ - //&& (x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganizeAndSub\""))).ToList(); + //&& (x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganizeAndSub\""))).ToList(); //await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } else { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganizeAndSub\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganizeAndSub\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } } @@ -1834,7 +1834,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans { // 删除 List? delData = oldDataAuthScheme - .Where(x => x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Included\",\"value\":\"@branchManageOrganizeAndSub\"")).ToList(); + .Where(x => x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganize\"") || x.ConditionJson.Contains("\"op\":\"Equal\",\"value\":\"@branchManageOrganizeAndSub\"")).ToList(); await _visualDevRepository.AsSugarClient().Deleteable(delData).ExecuteCommandAsync(); } diff --git a/workflow/Tnb.WorkFlow/Repository/FlowTaskRepository.cs b/workflow/Tnb.WorkFlow/Repository/FlowTaskRepository.cs index 3541f44b..eaa5b4f4 100644 --- a/workflow/Tnb.WorkFlow/Repository/FlowTaskRepository.cs +++ b/workflow/Tnb.WorkFlow/Repository/FlowTaskRepository.cs @@ -220,7 +220,8 @@ public class FlowTaskRepository : IFlowTaskRepository, ITransient flowUrgent = a.FlowUrgent, startTime = a.CreatorTime, completion = a.Completion, - nodeName = b.NodeName + nodeName = b.NodeName, + templateId = a.TemplateId, }); // 委托审核 @@ -251,7 +252,8 @@ public class FlowTaskRepository : IFlowTaskRepository, ITransient flowUrgent = a.FlowUrgent, startTime = a.CreatorTime, completion = a.Completion, - nodeName = b.NodeName + nodeName = b.NodeName, + templateId = a.TemplateId, }); var output = await _repository.AsSugarClient().UnionAll(list1, list2).Where(whereLambda).MergeTable().OrderBy(x => x.creatorTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(output);