From 2d0ef5be615a6f37f00b695e4d14b183df082752 Mon Sep 17 00:00:00 2001
From: wyw <571921741@qq.com>
Date: Thu, 23 Oct 2025 14:04:07 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AEO?=
=?UTF-8?q?RGID=E8=8E=B7=E5=8F=96Telnet?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
2、后端 处理 跨库数据查找 PF/PFApprove/FullGet
string tenant = OPTenantDBConnService.GetTenantByORGID(对应ORG_ID);
filter.IgnoreOrgRule = true;
filter.OrgId = null;
filter.IsSpecifyDb = true;
filter.SpecifyTenant = tenant;
ilter.IgnoreDataRule = true;
---
.../ApiModel/Platform/RedisCacheKey.cs | 5 ++
.../IServices/OP/IOPTenantDBConnService.cs | 8 +++
.../Services/OP/OPTenantDBConnService.cs | 51 +++++++++++++++++++
.../Controllers/Api/ApproveController.cs | 23 ++++-----
4 files changed, 75 insertions(+), 12 deletions(-)
diff --git a/APT.BaseData.Domain/ApiModel/Platform/RedisCacheKey.cs b/APT.BaseData.Domain/ApiModel/Platform/RedisCacheKey.cs
index 802a076..dfa712b 100644
--- a/APT.BaseData.Domain/ApiModel/Platform/RedisCacheKey.cs
+++ b/APT.BaseData.Domain/ApiModel/Platform/RedisCacheKey.cs
@@ -305,5 +305,10 @@
/// 所有数据库链接
///
public const string ConnAll = "OPConn";
+
+ ///
+ /// 所有Tenant
+ ///
+ public const string TenantAll = "OPTenant";
}
}
diff --git a/APT.BaseData.Domain/IServices/OP/IOPTenantDBConnService.cs b/APT.BaseData.Domain/IServices/OP/IOPTenantDBConnService.cs
index d493f25..c2aaaf6 100644
--- a/APT.BaseData.Domain/IServices/OP/IOPTenantDBConnService.cs
+++ b/APT.BaseData.Domain/IServices/OP/IOPTenantDBConnService.cs
@@ -22,5 +22,13 @@ namespace APT.BaseData.Domain.IServices.OP
/// 过滤值
///
string GetConnByORGID(Guid ORG_ID);
+
+
+ ///
+ /// 根据ORGID 获取 Tenant
+ ///
+ ///
+ ///
+ string GetTenantByORGID(Guid ORG_ID);
}
}
diff --git a/APT.BaseData.Services/Services/OP/OPTenantDBConnService.cs b/APT.BaseData.Services/Services/OP/OPTenantDBConnService.cs
index f4a9c4a..ee01ca6 100644
--- a/APT.BaseData.Services/Services/OP/OPTenantDBConnService.cs
+++ b/APT.BaseData.Services/Services/OP/OPTenantDBConnService.cs
@@ -164,5 +164,56 @@ namespace APT.BaseData.Services.Services.OP
}
return "";
}
+
+ ///
+ /// 根据ORGID 获取 Tenant
+ ///
+ ///
+ ///
+ public string GetTenantByORGID(Guid ORG_ID)
+ {
+
+ Dictionary dicORGCONN = new Dictionary();
+ //从Redis中获取所有数据库链接值
+
+ bool isRedisConfig = true;
+ var redisConfig = APT.Infrastructure.Api.ConfigurationManager.AppSettings["RedisFormConfig"];
+ if (!string.IsNullOrEmpty(redisConfig))
+ isRedisConfig = bool.Parse(redisConfig);
+ if (isRedisConfig)
+ {
+ if (CsRedisManager.KeyExists(RedisCacheKey.TenantAll))
+ dicORGCONN = CsRedisManager.StringGet>(RedisCacheKey.TenantAll);
+ }
+ #region Redis没找到 去数据库查找
+
+ if (dicORGCONN == null || dicORGCONN.Count < 1)
+ {
+ string conn = string.Empty;
+ IEnumerable listTent = null;
+ using (var context = new MigrationContext())
+ {
+ Expression> expression = e => e.DB_CONN_ID.HasValue;
+ listTent = context.GetEntities(expression, null, null);
+ if (listTent != null && listTent.Count() > 0)
+ {
+ foreach (var item in listTent)
+ {
+ if (!dicORGCONN.ContainsKey(item.ID))
+ {
+ dicORGCONN.Add(item.ID, item.CODE);
+ }
+ }
+ }
+ }
+ }
+ #endregion
+
+ if (dicORGCONN != null && dicORGCONN.Count > 0 && dicORGCONN.ContainsKey(ORG_ID))
+ {
+ return dicORGCONN[ORG_ID];
+ }
+ return "";
+ }
}
}
diff --git a/APT.MicroApi/APT.PF.WebApi/Controllers/Api/ApproveController.cs b/APT.MicroApi/APT.PF.WebApi/Controllers/Api/ApproveController.cs
index 07eef68..a0826a4 100644
--- a/APT.MicroApi/APT.PF.WebApi/Controllers/Api/ApproveController.cs
+++ b/APT.MicroApi/APT.PF.WebApi/Controllers/Api/ApproveController.cs
@@ -653,22 +653,21 @@
T_PF_APPROVE result = null;
if (!string.IsNullOrEmpty(filter.Parameter1) && filter.OrgId.HasValue && filter.Parameter1 != filter.OrgId.Value.ToString())
{
- //集团人员 通过 首页点击 获取对应的数据库链接 返回结果
- //这边怎么调用 原生的 GetEntity 方法
+ //集团人员 通过 首页点击 获取对应的数据库链接 返回结果
+ ////后端直接处理
+ //string tenant = OPTenantDBConnService.GetTenantByORGID(new Guid(filter.Parameter1));
+ //filter.IgnoreOrgRule = true;
+ //filter.OrgId = null;
+ //filter.IsSpecifyDb = true;
+ //filter.SpecifyTenant = tenant;
+ //filter.IgnoreDataRule = true;
+ //result = GetEntity(e => !e.IS_DELETED, filter, null);
- //string conn = OPTenantDBConnService.GetConnByORGID(new Guid(filter.Parameter1));
- //var service = APT.Infrastructure.Api.ServiceLocator.Instance.GetService();
+ //前端处理Tenant
filter.IgnoreOrgRule = true;
filter.OrgId = null;
- //filter.SpecifyDbConn = conn;
- filter.IsSpecifyDb = true;
- filter.SpecifyTenant = "0005";
- filter.IgnoreDataRule = true;
- //var ccc = service.GetEntities(e => !e.IS_DELETED, filter, null);
-
-
- var aaa = GetEntities(e => !e.IS_DELETED, filter, null);
+ result = GetEntity(e => !e.IS_DELETED, filter, null);
}
else
{