From 4330afd6835598c099ff6cfe1e9ae308c7b1f734 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Dec 2024 15:16:06 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=BD=AF=E5=88=A0=E9=99=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9--pre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs | 3 -- .../Context/IRaCISDBContext.cs | 50 +++++++++++++++++-- .../VisitTaskConfigration.cs | 2 +- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs b/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs index 4baa2b531..740c60fa6 100644 --- a/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs +++ b/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs @@ -5,9 +5,6 @@ namespace IRaCIS.Core.Domain.Models; public partial class TrialStatusDetail : BaseAddAuditEntity { #region - [JsonIgnore] - public List IntoGroupDetails { get; set; } - [JsonIgnore] public Trial Trial { get; set; } #endregion diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 9778e7371..47c95e1da 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -3,6 +3,7 @@ using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infrastructure.Encryption; using IRaCIS.Core.Infrastructure.Extention; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Newtonsoft.Json; using System.ComponentModel; @@ -77,11 +78,11 @@ public class IRaCISDBContext : DbContext }); modelBuilder.Entity(entity => - { + { //项目术语配置 entity.OwnsMany(x => x.TrialObjectNameList, ownedNavigationBuilder => { - ownedNavigationBuilder.ToJson() ; + ownedNavigationBuilder.ToJson(); }); }); @@ -144,13 +145,54 @@ public class IRaCISDBContext : DbContext base.OnModelCreating(modelBuilder); + //软删除筛选器通常依赖于实体模型的完整定义(例如属性映射、继承关系等) + + + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) { // 软删除配置 if (typeof(ISoftDelete).IsAssignableFrom(entityType.ClrType)) { - entityType.AddSoftDeleteQueryFilter(); + //entityType.AddSoftDeleteQueryFilter(); + // 动态创建表达式:e => e.IsDeleted==false + var parameter = Expression.Parameter(entityType.ClrType, "e"); + var property = Expression.Property(parameter, nameof(ISoftDelete.IsDeleted)); + var filter = Expression.Lambda( + Expression.Equal(property, Expression.Constant(false)), + parameter); + + // 应用全局查询筛选器 + modelBuilder.Entity(entityType.ClrType).HasQueryFilter(filter); + + //Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name}"); + + } + foreach (var navigation in entityType.GetNavigations()) + { + + if (navigation.IsCollection) continue; + + // 配置基于导航属性的软删除查询筛选器 + if (typeof(ISoftDelete).IsAssignableFrom(navigation.TargetEntityType.ClrType)) + { + var clrType = entityType.ClrType; + var targetType = navigation.TargetEntityType.ClrType; + + //e => e.Subject.IsDeleted==false + var parameterNav = Expression.Parameter(clrType, "e"); + var navigationProperty = Expression.Property(parameterNav, navigation.Name); + var navigationFilter = Expression.Equal( + Expression.Property(navigationProperty, nameof(ISoftDelete.IsDeleted)), + Expression.Constant(false)); + + var filterNav = Expression.Lambda(navigationFilter, parameterNav); + + modelBuilder.Entity(clrType).HasQueryFilter(filterNav); + + //Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name} 导航属性{filterNav}"); + } } if (typeof(Entity).IsAssignableFrom(entityType.ClrType)) @@ -588,7 +630,7 @@ public class TestLength : Entity public string Name { get; set; } [StringLength(1000)] - public string[] StringList { get; set; }=new string[] { }; + public string[] StringList { get; set; } = new string[] { }; public List DateTimeList { get; set; } = new List(); diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs index c592a9fbb..c3d486497 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -21,7 +21,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration //对于全局修改的任务而言,会关联多个全局访视阅片结果(因为同一个访视结果,会被多个全局修改) //subject 删除了,但是任务没删除,导致的查询问题 - builder.HasQueryFilter(b => b.Subject.IsDeleted == false); + //builder.HasQueryFilter(b => b.Subject.IsDeleted == false); } } From 1f4aff279645642b65644c995c8ef0a55e229b08 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Dec 2024 19:26:31 +0800 Subject: [PATCH 2/6] xx --- IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs index a39763263..460dfc729 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs @@ -22,7 +22,7 @@ namespace IRaCIS.Core.Application.Services [HttpGet, Route("{studyId:guid}")] public async Task>> List(Guid studyId) { - + //断点 var seriesList = await _seriesRepository.Where(s => s.StudyId == studyId).OrderBy(s => s.SeriesNumber). ThenBy(s => s.SeriesTime).ThenBy(s => s.CreateTime) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); From 2a217c1a208a261e23ea38852ee1c16e784af436 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Dec 2024 19:44:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=9B=9E=E9=80=80=E6=92=A4=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs | 7 ++++++- .../EntityConfigration/VisitTaskConfigration.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 92a54bfcc..3f06bddc0 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -174,6 +174,7 @@ public class IRaCISDBContext : DbContext if (navigation.IsCollection) continue; + #region 有问题 // 配置基于导航属性的软删除查询筛选器 if (typeof(ISoftDelete).IsAssignableFrom(navigation.TargetEntityType.ClrType)) { @@ -191,8 +192,12 @@ public class IRaCISDBContext : DbContext modelBuilder.Entity(clrType).HasQueryFilter(filterNav); - //Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name} 导航属性{filterNav}"); + Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name} 导航属性{filterNav}"); } + + #endregion + + } if (typeof(Entity).IsAssignableFrom(entityType.ClrType)) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs index c3d486497..c592a9fbb 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -21,7 +21,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration //对于全局修改的任务而言,会关联多个全局访视阅片结果(因为同一个访视结果,会被多个全局修改) //subject 删除了,但是任务没删除,导致的查询问题 - //builder.HasQueryFilter(b => b.Subject.IsDeleted == false); + builder.HasQueryFilter(b => b.Subject.IsDeleted == false); } } From a74b264f3909a736d8d626153872b308d025e708 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Wed, 11 Dec 2024 22:46:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=BD=AF=E5=88=A0=E9=99=A4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Context/IRaCISDBContext.cs | 36 ++++++++++--------- .../EntityConfigration/ImageConfigration.cs | 4 +++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 3f06bddc0..a9402c07c 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -173,27 +173,29 @@ public class IRaCISDBContext : DbContext { if (navigation.IsCollection) continue; + + #region 有问题 + // 比如 e.SourceSubjectVisit.IsDeleted == False 还会导致 dicom 查询增加额外很多的连表 因为访视 项目 项目中心,dicom 都是软删除 + // + //// 配置基于导航属性的软删除查询筛选器 + //if (typeof(ISoftDelete).IsAssignableFrom(navigation.TargetEntityType.ClrType)) + //{ + // var clrType = entityType.ClrType; + // var targetType = navigation.TargetEntityType.ClrType; - #region 有问题 - // 配置基于导航属性的软删除查询筛选器 - if (typeof(ISoftDelete).IsAssignableFrom(navigation.TargetEntityType.ClrType)) - { - var clrType = entityType.ClrType; - var targetType = navigation.TargetEntityType.ClrType; + // //e => e.Subject.IsDeleted==false + // var parameterNav = Expression.Parameter(clrType, "e"); + // var navigationProperty = Expression.Property(parameterNav, navigation.Name); + // var navigationFilter = Expression.Equal( + // Expression.Property(navigationProperty, nameof(ISoftDelete.IsDeleted)), + // Expression.Constant(false)); - //e => e.Subject.IsDeleted==false - var parameterNav = Expression.Parameter(clrType, "e"); - var navigationProperty = Expression.Property(parameterNav, navigation.Name); - var navigationFilter = Expression.Equal( - Expression.Property(navigationProperty, nameof(ISoftDelete.IsDeleted)), - Expression.Constant(false)); + // var filterNav = Expression.Lambda(navigationFilter, parameterNav); - var filterNav = Expression.Lambda(navigationFilter, parameterNav); + // modelBuilder.Entity(clrType).HasQueryFilter(filterNav); - modelBuilder.Entity(clrType).HasQueryFilter(filterNav); - - Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name} 导航属性{filterNav}"); - } + // Console.WriteLine($"实体应用软删除:{entityType.ClrType.Name} 导航属性{filterNav}"); + //} #endregion diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs index 873e12540..a7bd145e0 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ImageConfigration.cs @@ -13,6 +13,8 @@ public class DicomStudyConfigration : IEntityTypeConfiguration { builder.HasKey(e => e.SeqId); + //builder.HasMany(s => s.InstanceList).WithOne(se => se.DicomStudy).HasForeignKey(se => se.StudyId).HasPrincipalKey(st => st.Id); + builder.HasMany(s => s.SeriesList).WithOne(se => se.DicomStudy).HasForeignKey(se => se.StudyId).HasPrincipalKey(st => st.Id); builder.HasMany(s => s.DicomStudyMonitorList).WithOne(sm => sm.DicomStudy).HasForeignKey(sm => sm.StudyId).HasPrincipalKey(se => se.Id); @@ -40,6 +42,8 @@ public class DicomInstanceConfigration : IEntityTypeConfiguration { builder.HasKey(e => e.SeqId); + builder.HasOne(e => e.DicomStudy).WithMany().HasForeignKey(t=>t.StudyId).HasPrincipalKey(st => st.Id); + builder.HasMany(s => s.ReadingTableAnswerRowInfoList).WithOne(di => di.Instance).HasForeignKey(t => t.InstanceId).HasPrincipalKey(se => se.Id); } From 4c672cd91c813857e981cf1e1e5285958cdb7a51 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Dec 2024 13:33:47 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/Service/CStoreSCPService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index 1f2dae205..25fa9adcf 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -275,7 +275,7 @@ namespace IRaCIS.Core.SCP.Service var _distributedLockProvider = _serviceProvider.GetService(); var storeRelativePath = string.Empty; - var ossFolderPath = $"{_trialId}/Image/PACS/{_trialSiteId}{studyInstanceUid}"; + var ossFolderPath = $"{_trialId}/Image/PACS/{_trialSiteId}/{studyInstanceUid}"; long fileSize = 0; From e5592338d0414dcfe34b0573e5c632411203765f Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Dec 2024 16:35:10 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=94=BE=E5=BC=80=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E8=B0=83=E7=A0=94=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialConfigService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 8f4384f13..274c10e2e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -10,6 +10,7 @@ using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infrastructure; using MassTransit; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Newtonsoft.Json; @@ -1349,6 +1350,7 @@ namespace IRaCIS.Core.Application /// /// /// + [AllowAnonymous] public async Task GetTrialExtralConfig(Guid trialId) { var extralObj = _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.TrialExtraConfigJsonStr, t.TrialObjectNameList }).FirstOrDefault();