From f55f498626bac774a3d891ffd42e0cb9c097006e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 30 Sep 2025 10:01:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0gpt=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Document/AuditDocumentService.cs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs index d45d8895b..f04b52e8a 100644 --- a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs @@ -23,6 +23,7 @@ using IRaCIS.Core.Application.Contracts; using Microsoft.EntityFrameworkCore; using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; using NPOI.SS.Formula.Functions; +using EFCore.BulkExtensions; namespace IRaCIS.Core.Application.Service; @@ -234,6 +235,60 @@ public class AuditDocumentService(IRepository _auditDocumentRepos #region 闭包修改 + /// + /// GPT 移动子树代码--适合一次提交事务 + /// + /// + /// + /// + private async Task MoveSubtreeAsync(Guid subtreeRootId, Guid? newParentId) + { + + // 1. 子树所有闭包关系(后代包含自身) + var subtreeClosures = await _auditDocumentClosureRepository + .Where(c => c.AncestorId == subtreeRootId) + .ToListAsync(); + + var descendantIdsQuery = _auditDocumentClosureRepository + .Where(c => c.AncestorId == subtreeRootId).Select(c => c.DescendantId); + + // 2. 删除原有祖先关系,保留自反关系和子树内部关系 + await _auditDocumentClosureRepository.BatchDeleteNoTrackingAsync(c => + descendantIdsQuery.Contains(c.DescendantId) && + c.AncestorId != c.DescendantId && // 保留自反关系 + !descendantIdsQuery.Contains(c.AncestorId) // 保留子树内部关系 + ); + + // 3. 查新父节点祖先 + var newParentClosures = newParentId.HasValue + ? await _auditDocumentClosureRepository + .Where(c => c.DescendantId == newParentId.Value) + .ToListAsync() + : new List(); + + // 4. 生成新关系 + var newClosures = new List(); + + foreach (var pc in newParentClosures) + { + foreach (var sc in subtreeClosures) + { + newClosures.Add(new AuditDocumentClosure + { + AncestorId = pc.AncestorId, + DescendantId = sc.DescendantId, + Depth = pc.Depth + sc.Depth + 1 //深度公式:新深度 = 父祖先深度 + 子树原深度 + 1 + }); + } + } + + // 5. 插入新关系 + await _auditDocumentClosureRepository.AddRangeAsync(newClosures); + await _auditDocumentClosureRepository.SaveChangesAsync(); + + } + + /// /// 插入闭包表关系 /// @@ -600,6 +655,17 @@ public class AuditDocumentService(IRepository _auditDocumentRepos throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]); } + #region 不考虑文件名重复 移动子树快速方法 + //foreach (var item in inDto.Ids) + //{ + // var subtreeRoot = await _auditDocumentRepository.FirstOrDefaultAsync(t => t.Id == item); + + // subtreeRoot.ParentId = inDto.ParentId; + + // await MoveSubtreeAsync(item, inDto.ParentId); + //} + #endregion + await CopyFileOrFolder(inDto); await DeleteAuditDocument(new DeleteAuditDocumentInDto() From bd92d482324b790ddde91eefa81a812a8b7c6269 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 9 Oct 2025 10:54:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/HostService/HangfireHostService.cs | 2 +- IRaCIS.Core.Application/IRaCIS.Core.Application.xml | 8 ++++++++ .../MassTransit/Recurring/QCRecurringEmailConsumer.cs | 2 +- .../Service/Document/AuditDocumentService.cs | 2 +- IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs | 8 ++++---- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.API/HostService/HangfireHostService.cs b/IRaCIS.Core.API/HostService/HangfireHostService.cs index 478d883b9..c522c2eb4 100644 --- a/IRaCIS.Core.API/HostService/HangfireHostService.cs +++ b/IRaCIS.Core.API/HostService/HangfireHostService.cs @@ -56,7 +56,7 @@ public class HangfireHostService(IRecurringMessageScheduler _recurringMessageSch } } - + // 项目手动选择,周期性邮件 var taskInfoList = await _trialEmailNoticeConfigRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing && t.EmailCron != string.Empty && t.IsAutoSend) .Select(t => new { t.Id, t.Code, TrialCode = t.Trial.TrialCode, t.EmailCron, t.BusinessScenarioEnum, t.TrialId }) .ToListAsync(); diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a52150858..b4b04a860 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1517,6 +1517,14 @@ + + + GPT 移动子树代码--适合一次提交事务 + + + + + 插入闭包表关系 diff --git a/IRaCIS.Core.Application/MassTransit/Recurring/QCRecurringEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Recurring/QCRecurringEmailConsumer.cs index 84ee27d3a..d2b39f2dc 100644 --- a/IRaCIS.Core.Application/MassTransit/Recurring/QCRecurringEmailConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Recurring/QCRecurringEmailConsumer.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Application.MassTransit.Consumer; - +//项目手动选择 周期性邮件 /// diff --git a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs index cf27ce4e0..852302cc4 100644 --- a/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/AuditDocumentService.cs @@ -667,7 +667,7 @@ public class AuditDocumentService(IRepository _auditDocumentRepos #endregion - // 不能自动到自己父类这个文件夹 + // 不能移动到自己父类这个文件夹 if (await _auditDocumentRepository.AnyAsync(x => x.ParentId == inDto.ParentId && inDto.Ids.Contains(x.Id))) { throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMoveToParent"]); diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs index 64fbc4f1a..f5e5b09f6 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs @@ -25,7 +25,7 @@ public static class DBContext_Ext //记录要保存到数据库的事件 var eventStoreList = new List(); - #region 中心调研邮件通知 + #region 项目默认发送-- 中心调研邮件通知 foreach (var entry in changeTracker.Entries()) { @@ -64,7 +64,7 @@ public static class DBContext_Ext #endregion - #region PD 入组发送邮件(不侵入之前的代码,有些判断过于复杂的,在代码里面有的,就手动 在跟踪的实体添加领域事件) + #region 项目手动选择发送--PD 入组发送邮件(不侵入之前的代码,有些判断过于复杂的,在代码里面有的,就手动 在跟踪的实体添加领域事件) foreach (var entry in changeTracker.Entries()) { @@ -385,7 +385,7 @@ public static class DBContext_Ext #endregion - #region 直接申请流程重传 + #region 项目默认发送--直接申请流程重传 foreach (var entry in changeTracker.Entries()) { @@ -424,7 +424,7 @@ public static class DBContext_Ext #endregion - #region 阅片人筛选 + #region 项目默认发送--阅片人筛选 var spmApproveEnrollIdList = new List(); var pmApplyEnrollIdList = new List();