Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
he 2025-10-09 15:38:32 +08:00
commit 7e39094b13
5 changed files with 81 additions and 7 deletions

View File

@ -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();

View File

@ -1517,6 +1517,14 @@
<param name="inCommand"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.AuditDocumentService.MoveSubtreeAsync(System.Guid,System.Nullable{System.Guid})">
<summary>
GPT 移动子树代码--适合一次提交事务
</summary>
<param name="subtreeRootId"></param>
<param name="newParentId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.AuditDocumentService.AddClosureRelationsAsync(System.Guid,System.Nullable{System.Guid})">
<summary>
插入闭包表关系

View File

@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace IRaCIS.Core.Application.MassTransit.Consumer;
//项目手动选择 周期性邮件
/// <summary>

View File

@ -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<AuditDocument> _auditDocumentRepos
#region 闭包修改
/// <summary>
/// GPT 移动子树代码--适合一次提交事务
/// </summary>
/// <param name="subtreeRootId"></param>
/// <param name="newParentId"></param>
/// <returns></returns>
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<AuditDocumentClosure>();
// 4. 生成新关系
var newClosures = new List<AuditDocumentClosure>();
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();
}
/// <summary>
/// 插入闭包表关系
/// </summary>
@ -600,8 +655,19 @@ public class AuditDocumentService(IRepository<AuditDocument> _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
// 不能移动到自己父类这个文件夹
if (await _auditDocumentRepository.AnyAsync(x => x.ParentId == inDto.ParentId && inDto.Ids.Contains(x.Id)))
{
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMoveToParent"]);

View File

@ -25,7 +25,7 @@ public static class DBContext_Ext
//记录要保存到数据库的事件
var eventStoreList = new List<EventStoreRecord>();
#region 中心调研邮件通知
#region 项目默认发送-- 中心调研邮件通知
foreach (var entry in changeTracker.Entries<TrialSiteSurvey>())
{
@ -64,7 +64,7 @@ public static class DBContext_Ext
#endregion
#region PD 入组发送邮件(不侵入之前的代码,有些判断过于复杂的,在代码里面有的,就手动 在跟踪的实体添加领域事件)
#region 项目手动选择发送--PD 入组发送邮件(不侵入之前的代码,有些判断过于复杂的,在代码里面有的,就手动 在跟踪的实体添加领域事件)
foreach (var entry in changeTracker.Entries<SubjectVisit>())
{
@ -385,7 +385,7 @@ public static class DBContext_Ext
#endregion
#region 直接申请流程重传
#region 项目默认发送--直接申请流程重传
foreach (var entry in changeTracker.Entries<SubjectVisitImageBackRecord>())
{
@ -424,7 +424,7 @@ public static class DBContext_Ext
#endregion
#region 阅片人筛选
#region 项目默认发送--阅片人筛选
var spmApproveEnrollIdList = new List<Guid>();
var pmApplyEnrollIdList = new List<Guid>();