From 21cb07446935289f73d088bfb0309f02733f5427 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 16:58:41 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Domain/Visit/SubjectVisit.cs | 2 - .../DictionaryConfigration.cs | 4 +- .../EntityConfigration/SubjectConfigration.cs | 6 +- .../SubjectVisitConfigration.cs | 16 -- .../CodeFirstTest/CodeFirst使用说明 | 9 +- .../DictionaryConfigration.cs | 24 ++ .../EntityConfigration/SubjectConfigration.cs | 33 +++ .../CodeFirstTest/MSSQL/IRCContext.cs | 14 +- ...910073024_oneToManyAndOneToOne.Designer.cs | 213 ++++++++++++++ .../20240910073024_oneToManyAndOneToOne.cs | 96 +++++++ ...75136_seftOneToManyAndOneToOne.Designer.cs | 269 ++++++++++++++++++ ...20240910075136_seftOneToManyAndOneToOne.cs | 60 ++++ .../Migrations/IRCContextModelSnapshot.cs | 154 +++++++++- .../CodeFirstTest/MSSQL/TrialImageDownload.cs | 62 +++- 14 files changed, 929 insertions(+), 33 deletions(-) delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs create mode 100644 IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs diff --git a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs index 44e477ee1..2e7a566fa 100644 --- a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs +++ b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs @@ -16,8 +16,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public TrialSite TrialSite { get; set; } - [JsonIgnore] - public VisitStage VisitStage { get; set; } [JsonIgnore] [ForeignKey("OutPlanPreviousVisitId")] public SubjectVisit OutPlanPreviousVisit { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs index 1326060fc..9d77cb761 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs @@ -16,8 +16,8 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - - builder.HasMany(t => t.ChildList).WithOne(t => t.Parent); + //自身同时存在一对多 和一对一的关系,配置一对多的就可以,一对一 不用配置,有点奇怪 + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index 239c349da..87893ad17 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -13,9 +13,9 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { //不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置 - builder.HasOne(s => s.LatestSubjectVisit); - builder.HasOne(s => s.FinalSubjectVisit); - builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject); + builder.HasOne(s => s.LatestSubjectVisit).WithMany().HasForeignKey(t => t.LatestSubjectVisitId); + builder.HasOne(s => s.FinalSubjectVisit).WithMany().HasForeignKey(t => t.FinalSubjectVisitId); + builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject).HasForeignKey(t => t.SubjectId); } } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs deleted file mode 100644 index d916b4ee1..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectVisitConfigration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class SubjectVisitConfigration : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - - builder.HasOne(s => s.Subject).WithMany(sv => sv.SubjectVisitList); - } - } -} diff --git a/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 index 33b575bf1..5a329af9d 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 +++ b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 @@ -2,13 +2,14 @@ #οѧϰĵ https://www.cnblogs.com/cqpanda/p/16815263.html -# ָĿƣҪĿĿ¼ һpwershellĿĿ¼ҪָĿ - cd .\IRaCIS.Core.Test - - # Ŀ¼жģҪֶָ # dotnet ef migrations add ǩ -p Ŀ -c -o ǨļĿ¼ + 1Ǩļ dotnet ef migrations add Initial -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations + 2ղɵǨļ + dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext + + 3Ǩļµݿ dotnet ef database update -p IRaCIS.Core.Test -c IRCContext \ No newline at end of file diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs new file mode 100644 index 000000000..07ea337df --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/DictionaryConfigration.cs @@ -0,0 +1,24 @@ +using IRaCIS.Core.Domain.Models; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL +{ + public class DictionaryConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); + + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs new file mode 100644 index 000000000..888935f60 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL +{ + public class SubjectConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + //不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置 + builder.HasOne(s => s.LatestSubjectVisit); + builder.HasOne(s => s.FinalSubjectVisit); + builder.HasMany(s => s.SubejectVisitList).WithOne(sv => sv.Subject); + } + } + + public class TestOneConfigration : IEntityTypeConfiguration + { + + + public void Configure(EntityTypeBuilder builder) + { + + builder.HasOne(s => s.LatestTestMany).WithMany().HasForeignKey(t=>t.LatestTestManyId); + builder.HasOne(s => s.FinalTestMany).WithMany().HasForeignKey(t => t.FinalTestManyId); + builder.HasMany(s => s.TestManyList).WithOne(sv => sv.TestOne).HasForeignKey(t => t.TestOneId); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs index 4f6220861..01eb69f95 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Reflection; using IRaCIS.Core.Test.CodeFirstTest.MSSQL; using Microsoft.EntityFrameworkCore; @@ -24,13 +26,23 @@ public partial class IRCContext : DbContext public virtual DbSet SubejectVisit { get; set; } + public virtual DbSet Dictionary { get; set; } + public virtual DbSet TestOne { get; set; } + public virtual DbSet TestMany { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true"); protected override void OnModelCreating(ModelBuilder modelBuilder) { + //遍历实体模型手动配置 + var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null); + foreach (var type in typesToRegister) + { + dynamic configurationInstance = Activator.CreateInstance(type); + modelBuilder.ApplyConfiguration(configurationInstance); + } - OnModelCreatingPartial(modelBuilder); } diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs new file mode 100644 index 000000000..20cdc133f --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs @@ -0,0 +1,213 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910073024_oneToManyAndOneToOne")] + partial class oneToManyAndOneToOne + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs new file mode 100644 index 000000000..3627f081b --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.cs @@ -0,0 +1,96 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class oneToManyAndOneToOne : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SubejectVisit", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SubjectId = table.Column(type: "uniqueidentifier", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubejectVisit", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Subject", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + LatestSubjectVisitId = table.Column(type: "uniqueidentifier", nullable: true), + FinalSubjectVisitId = table.Column(type: "uniqueidentifier", nullable: true), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subject", x => x.Id); + table.ForeignKey( + name: "FK_Subject_SubejectVisit_FinalSubjectVisitId", + column: x => x.FinalSubjectVisitId, + principalTable: "SubejectVisit", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Subject_SubejectVisit_LatestSubjectVisitId", + column: x => x.LatestSubjectVisitId, + principalTable: "SubejectVisit", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_SubejectVisit_SubjectId", + table: "SubejectVisit", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Subject_FinalSubjectVisitId", + table: "Subject", + column: "FinalSubjectVisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Subject_LatestSubjectVisitId", + table: "Subject", + column: "LatestSubjectVisitId"); + + migrationBuilder.AddForeignKey( + name: "FK_SubejectVisit_Subject_SubjectId", + table: "SubejectVisit", + column: "SubjectId", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_SubejectVisit_Subject_SubjectId", + table: "SubejectVisit"); + + migrationBuilder.DropTable( + name: "Subject"); + + migrationBuilder.DropTable( + name: "SubejectVisit"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs new file mode 100644 index 000000000..69d7b8786 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs @@ -0,0 +1,269 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240910075136_seftOneToManyAndOneToOne")] + partial class seftOneToManyAndOneToOne + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs new file mode 100644 index 000000000..32920762b --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class seftOneToManyAndOneToOne : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Dictionary", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + ConfigTypeId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(max)", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Dictionary", x => x.Id); + table.ForeignKey( + name: "FK_Dictionary_Dictionary_ConfigTypeId", + column: x => x.ConfigTypeId, + principalTable: "Dictionary", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Dictionary_Dictionary_ParentId", + column: x => x.ParentId, + principalTable: "Dictionary", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Dictionary_ConfigTypeId", + table: "Dictionary", + column: "ConfigTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Dictionary_ParentId", + table: "Dictionary", + column: "ParentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Dictionary"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs index f87ae145d..ffb12bafa 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs @@ -22,6 +22,105 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject", (string)null); + }); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => { b.Property("Id") @@ -51,7 +150,7 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasIndex("TrialImageDownloadId"); - b.ToTable("TestNew"); + b.ToTable("TestNew", (string)null); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => @@ -94,7 +193,48 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasKey("Id"); - b.ToTable("TrialImageDownload"); + b.ToTable("TrialImageDownload", (string)null); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => @@ -106,6 +246,16 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations .IsRequired(); }); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => { b.Navigation("TestNewList"); diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs index 06119c778..56a90d864 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs @@ -1,4 +1,5 @@ using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Domain.Share; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -48,7 +49,7 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL } - public class Subject: BaseFullAuditEntity + public class Subject : BaseFullAuditEntity { public string Name { get; set; } @@ -59,8 +60,10 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL #region 同时配置一对多,一对一 导航属性 + [ForeignKey("FinalSubjectVisitId")] public SubejectVisit FinalSubjectVisit { get; set; } + [ForeignKey("LatestSubjectVisitId")] public SubejectVisit LatestSubjectVisit { get; set; } public List SubejectVisitList { get; set; } @@ -68,11 +71,64 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL } - public class SubejectVisit: BaseFullAuditEntity + public class SubejectVisit : BaseFullAuditEntity { public Subject Subject { get; set; } - + public Guid SubjectId { get; set; } } + + + public class Dictionary : BaseFullAuditEntity + { + #region 导航属性 + [ForeignKey("ConfigTypeId")] + public Dictionary ConfigType { get; set; } + + [ForeignKey("ParentId")] + public Dictionary Parent { get; set; } + + public List ChildList { get; set; } = new List(); + + #endregion + + + public Guid? ParentId { get; set; } + + + public Guid? ConfigTypeId { get; set; } + + public string Code { get; set; } + } + + + public class TestOne : BaseFullAuditEntity + { + public string Code { get; set; } + + [ForeignKey(nameof(TestOne.FinalTestMany))] + public Guid? LatestTestManyId { get; set; } + + [ForeignKey(nameof(TestOne.LatestTestMany))] + public Guid? FinalTestManyId { get; set; } + + #region 同时配置一对多,一对一 导航属性 + + + public TestMany FinalTestMany { get; set; } + + public TestMany LatestTestMany { get; set; } + + public List TestManyList { get; set; } + + #endregion + } + + public class TestMany : BaseFullAuditEntity + { + public TestOne TestOne { get; set; } + + public Guid TestOneId { get; set; } + } } From 2aa63a6132e2b61e4ca03c427c1730339a357e25 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 17:11:43 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=B1=E5=83=8F?= =?UTF-8?q?=E5=90=8E=E5=A4=84=E7=90=86nonedicom=20=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Visit/DTO/VisitPointViewModel.cs | 3 +++ .../Service/Visit/SubjectVisitService.cs | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs b/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs index 31e34b7b0..af0413301 100644 --- a/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs +++ b/IRaCIS.Core.Application/Service/Visit/DTO/VisitPointViewModel.cs @@ -186,8 +186,11 @@ namespace IRaCIS.Core.Application.Contracts public class GetReadingVisitStudyListIndto { + [NotDefault] public Guid TrialId { get; set; } + [NotDefault] public Guid SujectVisitId { get; set; } + [NotDefault] public Guid VisitTaskId { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 1a0b415f2..d393bdbf7 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application.Services IRepository _trialReadingCriterionRepository ) : BaseService, ISubjectVisitService { - + [HttpPost] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] @@ -541,7 +541,7 @@ namespace IRaCIS.Core.Application.Services SeriesId = x.SeriesId, StudyId = x.StudyId, InstanceId = x.InstanceId, - NumberOfFrames=x.NumberOfFrames, + NumberOfFrames = x.NumberOfFrames, }).ToListAsync(); @@ -594,20 +594,20 @@ namespace IRaCIS.Core.Application.Services HtmlPath = k.HtmlPath, Path = k.Path, InstanceNumber = k.InstanceNumber, - StudyId= k.StudyId, - SeriesId= k.SeriesId, + StudyId = k.StudyId, + SeriesId = k.SeriesId, }).ToListAsync(); item.InstanceInfoList.ForEach(x => { - var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id&&y.NumberOfFrames!=0).Select(y => y.NumberOfFrames).Distinct().ToList(); + var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id && y.NumberOfFrames != 0).Select(y => y.NumberOfFrames).Distinct().ToList(); if (keyFramesList.Count() > 0) { x.KeyFramesList = keyFramesList; } - + var item = rowInfoList.FirstOrDefault(y => y.InstanceId == x.Id); if (item != null) { @@ -632,7 +632,7 @@ namespace IRaCIS.Core.Application.Services - studyList.Insert(0,thisVisitTaskStudy); + studyList.Insert(0, thisVisitTaskStudy); } @@ -658,7 +658,7 @@ namespace IRaCIS.Core.Application.Services #region 非Dicom 检查查询 var noDicomList = await _noneDicomStudyRepository.Where(x => x.TrialId == indto.TrialId && x.SubjectVisitId == indto.SujectVisitId && x.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip))) - .WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality) ).ToListAsync(); + .WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality)).ToListAsync(); List noDicomStudyList = noDicomList.Select(x => new VisitStudyDTO() @@ -672,11 +672,14 @@ namespace IRaCIS.Core.Application.Services }).ToList(); + var isExistTaskNoneDicomFile = _noneDicomStudyFileRepository.Any(t => t.OriginNoneDicomStudyId == indto.VisitTaskId); + foreach (var item in noDicomStudyList) { var nodicom = noDicomList.Where(x => x.Id == item.StudyId).First(); - var instanceCount = await _noneDicomStudyFileRepository.Where(x => x.NoneDicomStudyId == item.StudyId).CountAsync(); + var instanceCount = await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId) + .WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId).CountAsync(); if (instanceCount == 0) { @@ -697,7 +700,9 @@ namespace IRaCIS.Core.Application.Services SubjectVisitId=nodicom.SubjectVisitId, SubjectId=nodicom.SubjectId, SeriesNumber=1, - NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.Where(x=>x.NoneDicomStudyId==item.StudyId && !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(), + NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId) + .WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId) + .Where(x=> !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(), } }; From e012384dfa0d833b0629f410d109c5c42c71255a Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 17:27:25 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index d393bdbf7..ee4383ff0 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -672,7 +672,7 @@ namespace IRaCIS.Core.Application.Services }).ToList(); - var isExistTaskNoneDicomFile = _noneDicomStudyFileRepository.Any(t => t.OriginNoneDicomStudyId == indto.VisitTaskId); + var isExistTaskNoneDicomFile = _noneDicomStudyFileRepository.Any(t => t.VisitTaskId == indto.VisitTaskId); foreach (var item in noDicomStudyList) { From 6b7542b11f90a126b96d7b525602462bc09e3b8d Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 17:44:36 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=98=85=E7=89=87?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=9D=9Edicom=20=E6=A3=80=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=90=8E=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingNoDicomTaskService.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs index 4f3a7c39d..0276b80f9 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingNoDicomTaskService.cs @@ -6,6 +6,7 @@ using Panda.DynamicWebApi.Attributes; using IRaCIS.Core.Application.Contracts; using MassTransit; using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Domain.Models; namespace IRaCIS.Application.Services { @@ -66,7 +67,7 @@ namespace IRaCIS.Application.Services /// /// [HttpPost] - public async Task> > GetReadingImageFile(GetReadingImgInDto inDto) + public async Task>> GetReadingImageFile(GetReadingImgInDto inDto) { var task = await GetNextTask(new GetNextTaskInDto() { @@ -84,10 +85,26 @@ namespace IRaCIS.Application.Services // 阅片期取前面所有的图像 visitIds.AddRange(await _subjectVisitRepository.Where(x => x.VisitNum <= task.VisitNum && x.SubjectId == task.SubjectId).Select(x => x.Id).ToListAsync()); } - List result = await _noneDicomStudyRepository.Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t=>!t.FileType.Contains(StaticData.FileType.Zip))) - .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true }).ToListAsync(); - var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).FirstNotNullAsync(); + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).Select(t => new { t.BlindSubjectCode, t.TrialReadingCriterionId, t.TrialReadingCriterion.IsImageFilter, t.TrialReadingCriterion.CriterionModalitys }).FirstNotNullAsync(); + + + IQueryable noneDicomStudyQueryable = default; + if (inDto.VisistTaskId == null) + { + noneDicomStudyQueryable = _noneDicomStudyRepository + .Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip))) + .WhereIf(taskinfo.IsImageFilter == true, t => taskinfo.CriterionModalitys.Contains(t.Modality)) + .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true }); + } + else + { + noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == inDto.VisistTaskId)) + .Where(t => visitIds.Contains(t.SubjectVisitId)) + .ProjectTo(_mapper.ConfigurationProvider, new { isFilterZip = true, visiTaskId = inDto.VisistTaskId }); + } + List result = await noneDicomStudyQueryable.ToListAsync(); + var trialInfo = await _trialRepository.Where(x => x.Id == inDto.TrialId).Select(x => new { @@ -121,7 +138,7 @@ namespace IRaCIS.Application.Services var taskInfo = await _visitTaskRepository.Where(x => x.Id == task.VisitTaskId).FirstNotNullAsync(); - return ResponseOutput.Ok (result, new + return ResponseOutput.Ok(result, new { VisitTaskId = task.VisitTaskId, SubjectId = task.SubjectId, From 60330fbd93b933759d21d8aebae45b85b9e4387c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 17:54:20 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=8D=E9=A6=88bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Management/_MapConfig.cs | 3 ++- IRaCIS.Core.Domain/Management/UserFeedBack.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index d9ec78199..afc1653ac 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -136,7 +136,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.FeedBackUserName, c => c.MapFrom(t => t.CreateUser.UserName)) .ForMember(d => d.FeedBackFullName, c => c.MapFrom(t => t.CreateUser.FullName)) .ForMember(d => d.UserTypeEnum, c => c.MapFrom(t => t.CreateUser.UserTypeEnum)); - CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); } } diff --git a/IRaCIS.Core.Domain/Management/UserFeedBack.cs b/IRaCIS.Core.Domain/Management/UserFeedBack.cs index f83a4e91b..d02c8c12e 100644 --- a/IRaCIS.Core.Domain/Management/UserFeedBack.cs +++ b/IRaCIS.Core.Domain/Management/UserFeedBack.cs @@ -33,7 +33,7 @@ namespace IRaCIS.Core.Domain.Models public VisitTask VisitTask { get; set; } [NotMapped] - public List ScreenshotList => JsonConvert.DeserializeObject>(ScreenshotListStr); + public List FeedBackScreenshotList => JsonConvert.DeserializeObject>(ScreenshotListStr); #endregion From f7dd5117a01da78b989cc731db1d731d48a19ec1 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 18:08:23 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=BB=E5=AD=A6?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs | 2 ++ .../Service/ImageAndDoc/DownloadAndUploadService.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index 088c77ef3..8a3f8d0a1 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -527,6 +527,8 @@ namespace IRaCIS.Core.Application.Contracts [NotDefault] public string SubjectCode { get; set; } + + public Guid? VisitTaskId { get; set; } } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index 69534ade5..edd727cbc 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -738,9 +738,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [HttpPost] public async Task> GetSubjectImageDownloadSelectList(IRReadingDownloadQuery inQuery) { + var doctorUserId = _userInfo.Id; + + //医学审核查看下载按钮,这个时候需要知道医生 + if (inQuery.VisitTaskId != null && inQuery.VisitTaskId!=Guid.Empty) + { + doctorUserId = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => (Guid)t.DoctorUserId).FirstNotNullAsync(); + } var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId - && t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect) + && t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect) .ProjectTo(_mapper.ConfigurationProvider); From 405454f71f0e88bb11562a3845eac508e97abf23 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 10 Sep 2024 18:46:00 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E5=88=86=E6=9E=90=20=E4=B8=8B=E8=BD=BD=E5=BD=B1?= =?UTF-8?q?=E5=83=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageAndDoc/DTO/UnionStudyViewDodel.cs | 2 +- .../ImageAndDoc/DownloadAndUploadService.cs | 8 ++++- .../EntityConfigration/DoctorConfigration.cs | 33 ------------------- .../ReadModuleConfigration.cs | 2 +- 4 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index 8a3f8d0a1..7d82d7ec2 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -556,6 +556,6 @@ namespace IRaCIS.Core.Application.Contracts { public Guid SubjectVisitId { get; set; } - public Guid VisitTaskId { get; set; } + public Guid TaskId { get; set; } } } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index edd727cbc..e9ad732f9 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -823,10 +823,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var isQueryDicom = inQuery.DicomStudyIdList.Count > 0; var isQueryNoneDicom = inQuery.NoneDicomStudyIdList.Count > 0; + var taskIdList = inQuery.SubjectVisitTaskList.Select(t => t.TaskId).ToList(); + var subjectVisitIdList = inQuery.SubjectVisitTaskList.Select(t => t.SubjectVisitId).ToList(); + //var a = _visitTaskRepository.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id); + var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))) - join visitTask in _visitTaskRepository.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) + //一致性分析,导致查询出来两条数据 + join visitTask in _visitTaskRepository.Where(t=> taskIdList.Contains(t.Id)) /*.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)*/ + on sv.Id equals visitTask.SourceSubjectVisitId select new { diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs deleted file mode 100644 index a9011126a..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs +++ /dev/null @@ -1,33 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using System.Reflection.Emit; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class DoctorConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder - .HasOne(dd => dd.Doctor) - .WithMany(p => p.DoctorDicRelationList) - .HasForeignKey(dd => dd.DoctorId); - - builder - .HasOne(dd => dd.Dictionary) - .WithMany(d => d.DoctorDicRelationList) - .HasForeignKey(dd => dd.DictionaryId); - } - - - } - - - - -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs index 5d7c8d501..6159328a5 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs @@ -12,7 +12,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList); + builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t=>t.SubjectVisitId); } } } From d3f13e844d654239d68db6efb9ad21476d1c20f1 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 20:28:51 +0800 Subject: [PATCH 08/14] =?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.Application/Helper/CacheHelper.cs | 3 +-- IRaCIS.Core.Application/Helper/OSSService.cs | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/CacheHelper.cs b/IRaCIS.Core.Application/Helper/CacheHelper.cs index f3cf0cf51..5fb158ed1 100644 --- a/IRaCIS.Core.Application/Helper/CacheHelper.cs +++ b/IRaCIS.Core.Application/Helper/CacheHelper.cs @@ -10,6 +10,7 @@ namespace IRaCIS.Core.Application.Helper public static class CacheKeys { + //项目缓存 public static string Trial(string trialIdStr) => $"TrialId:{trialIdStr}"; //检查编号递增锁 @@ -33,8 +34,6 @@ namespace IRaCIS.Core.Application.Helper //超时没请求接口自动退出 public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}"; - // 你可以为其他实体和模块定义更多的键 - /// /// 跳过阅片 /// diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 9c7e96872..50d346ab3 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -109,17 +109,13 @@ namespace IRaCIS.Core.Application.Helper public string AccessKeyId { get; set; } public string AccessKeySecret { get; set; } - public string EndPoint { get; set; } public string BucketName { get; set; } - public string Region { get; set; } public string ViewEndpoint { get; set; } - - public string SecurityToken { get; set; } public DateTime Expiration { get; set; } From b32225b8bb884dd21f3d2408f1628154b0c61395 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 21:05:59 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=98=85=E7=89=87?= =?UTF-8?q?=E5=99=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingPeriod/ReadModuleService.cs | 2 +- .../DictionaryConfigration.cs | 24 --------------- .../NoneDicomStudyConfigration.cs | 20 ------------- .../ReadModuleConfigration.cs | 18 ------------ .../ReadingQuestionTrialConfigration.cs | 25 ---------------- .../EntityConfigration/StudyConfigration.cs | 6 ++-- .../EntityConfigration/SubjectConfigration.cs | 24 +++++++++++++-- .../TrialSiteConfigration.cs | 25 ---------------- .../TrialUserConfigration.cs | 15 ++++++---- .../VisitTaskConfigration.cs | 29 +++++++++---------- IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 4 --- 11 files changed, 49 insertions(+), 143 deletions(-) delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs delete mode 100644 IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs index ddcc65d0b..a37441d60 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs @@ -654,7 +654,7 @@ namespace IRaCIS.Application.Services var query = subjectVisitQuery.Union(readMouduleQuery) - .WhereIf(inQuery.SubjectId != null, x => x.Id == inQuery.SubjectId) + .WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.TrialSiteCode), x => x.TrialSiteCode.Contains(inQuery.TrialSiteCode)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectCode), x => x.SubjectCode.Contains(inQuery.SubjectCode)) .WhereIf(isFilterModuleType, t => t.ModuleType == inQuery.ModuleType) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs deleted file mode 100644 index 9d77cb761..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DictionaryConfigration.cs +++ /dev/null @@ -1,24 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class DictionaryConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - //自身同时存在一对多 和一对一的关系,配置一对多的就可以,一对一 不用配置,有点奇怪 - builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); - - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs deleted file mode 100644 index a2a0f9ce9..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/NoneDicomStudyConfigration.cs +++ /dev/null @@ -1,20 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using System.Reflection.Emit; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class NoneDicomStudyConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - builder.HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId); - builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId); - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs deleted file mode 100644 index 6159328a5..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadModuleConfigration.cs +++ /dev/null @@ -1,18 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class ReadModuleConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t=>t.SubjectVisitId); - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs deleted file mode 100644 index 85d875028..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/ReadingQuestionTrialConfigration.cs +++ /dev/null @@ -1,25 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - - public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - - - builder.HasQueryFilter(p => p.IsAdditional == false); - - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs index c1b0133e8..490d1980f 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs @@ -8,11 +8,13 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public class StudyConfigration : IEntityTypeConfiguration { - + /// + /// 一个外键,关联多个表 + /// + /// public void Configure(EntityTypeBuilder builder) { - builder .HasMany(s => s.ReadingClinicalDataList) .WithOne(c => c.DicomStudy) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index 87893ad17..b22f05c95 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -6,9 +6,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { public class SubjectConfigration : IEntityTypeConfiguration - { - - + { public void Configure(EntityTypeBuilder builder) { @@ -18,4 +16,24 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject).HasForeignKey(t => t.SubjectId); } } + public class DictionaryConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + + //自身同时存在一对多 和一对一的关系,配置一对多的就可以,一对一 不用配置,有点奇怪 + builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId); + + } + } + + public class NoneDicomStudyConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + //同样一个实体 有两个相同的类型的导航属性,需要手动配置 + builder.HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId); + builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId); + } + } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs deleted file mode 100644 index a9173db0a..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs +++ /dev/null @@ -1,25 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - - public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder - .HasMany(s => s.SubjectCriteriaEvaluationVisitFilterList) - .WithOne(c => c.SubjectCriteriaEvaluation) - .HasForeignKey(s => new { s.SubjectId, s.TrialReadingCriterionId }) - .HasPrincipalKey(c => new { c.SubjectId, c.TrialReadingCriterionId }); - - } - } - - -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs index ffc7a2ba8..c0fefeb07 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs @@ -8,8 +8,6 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public class TrialUserConfigration : IEntityTypeConfiguration { - - public void Configure(EntityTypeBuilder builder) { builder @@ -21,14 +19,19 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } - public class UserConfigration : IEntityTypeConfiguration + public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration { - - public void Configure(EntityTypeBuilder builder) + public void Configure(EntityTypeBuilder builder) { - builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); + builder + .HasMany(s => s.SubjectCriteriaEvaluationVisitFilterList) + .WithOne(c => c.SubjectCriteriaEvaluation) + .HasForeignKey(s => new { s.SubjectId, s.TrialReadingCriterionId }) + .HasPrincipalKey(c => new { c.SubjectId, c.TrialReadingCriterionId }); } } + + } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs index 6cf3de657..0c48832b7 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -15,31 +15,24 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask); - builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); builder.HasMany(t => t.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId); - builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId); - - builder.HasQueryFilter(b => b.Subject.IsDeleted == false); + } + } + public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { - //modelBuilder.Entity().HasMany(t => t.DoctorTrialVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); - - //modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId }); - - //会导致级联删除 - //modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }) - // ./*IsRequired(false)*/OnDelete(DeleteBehavior.NoAction); - - // builder.HasOne(t => t.SujectArm).WithMany(s => s.SubjectArmVisitTaskList).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum }); - + builder.HasQueryFilter(p => p.IsAdditional == false); } } @@ -51,7 +44,13 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); } } - + public class UserConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); + } + } } diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index 77dd99306..9d1a28e03 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -1,8 +1,4 @@  - - utf-8 - utf-8 - enable From 3f38cf25c5ef1e1a5f8d070068a01fc489fc6f80 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 21:08:40 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=A4=8D=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EntityConfigration/StudyConfigration.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs index 490d1980f..4114c225a 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs @@ -30,4 +30,14 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } + + public class ReadModuleConfigration : IEntityTypeConfiguration + { + + public void Configure(EntityTypeBuilder builder) + { + + builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t => t.SubjectVisitId); + } + } } From 5e1ec1ffb2826365fbd3ffc6129dab06cfb46807 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 23:30:51 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=EF=BC=8C=E9=87=8D=E5=91=BD=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/DTO/VisitTaskViewModel.cs | 6 +- .../Allocation/VisitTaskHelpeService.cs | 4 +- .../Service/Allocation/VisitTaskService.cs | 14 ++--- IRaCIS.Core.Domain/Allocation/SubjectUser.cs | 11 ++-- .../Allocation/TaskInfluence.cs | 1 + .../ClinicalData/ReadingClinicalData.cs | 3 +- .../ReadingConsistentClinicalData.cs | 4 +- .../EntityConfigration/StudyConfigration.cs | 61 +++++++++---------- .../VisitTaskConfigration.cs | 30 ++++----- .../CodeFirstTest/CodeFirst使用说明 | 10 ++- .../EntityConfigration/SubjectConfigration.cs | 11 ---- .../CodeFirstTest/MSSQL/IRCContext.cs | 4 +- .../CodeFirstTest/MSSQL/TrialImageDownload.cs | 29 ++++----- 13 files changed, 92 insertions(+), 96 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index d680022ac..2f0b41192 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -602,9 +602,9 @@ namespace IRaCIS.Core.Application.ViewModel [JsonIgnore] public List DoctorUserList { get; set; } - public List PreviousDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId != null).ToList(); + public List PreviousDoctorUserList => DoctorUserList.Where(t => t.ReplacedSubjectUserId != null).ToList(); - public List NowDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId == null).ToList(); + public List NowDoctorUserList => DoctorUserList.Where(t => t.ReplacedSubjectUserId == null).ToList(); @@ -622,7 +622,7 @@ namespace IRaCIS.Core.Application.ViewModel public bool IsConfirmed { get; set; } //该属性有值 说明该医生被替换了 分配的时候 要过滤掉 - public Guid? OrignalSubjectUserId { get; set; } + public Guid? ReplacedSubjectUserId { get; set; } public UserSimpleInfo DoctorUser { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 8a7108bb9..7d83da129 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -144,7 +144,7 @@ namespace IRaCIS.Core.Application.Service foreach (var subjectGroup in needGenerateVisit.GroupBy(t => t.SubjectId).Select(g => new { SubjectId = g.Key, SubjectVisitList = g.ToList() })) { - var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectGroup.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); + var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectGroup.SubjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); @@ -632,7 +632,7 @@ namespace IRaCIS.Core.Application.Service { - var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); + var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); var isNeedClinicalDataSign = IsNeedClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList); var isClinicalDataSign = IsClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList, subjectVisit.Id, trialId); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 83d1bb3cf..e480900e2 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -171,7 +171,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { foreach (var doctorArm in command.DoctorArmList) { - if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.OrignalSubjectUserId == null)) + if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.ReplacedSubjectUserId == null)) { await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = command.TrialId, TrialReadingCriterionId = command.TrialReadingCriterionId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now }); @@ -246,7 +246,7 @@ namespace IRaCIS.Core.Application.Service.Allocation /// public async Task<(List, object)> GetSubjectAssignedDoctorList(Guid subjectId, Guid trialReadingCriterionId) { - var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsGlobalReading, x.IsOncologyReading, x.IsArbitrationReading }).FirstOrDefaultAsync()).IfNullThrowException(); @@ -479,13 +479,13 @@ namespace IRaCIS.Core.Application.Service.Allocation var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum; - if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.OrignalSubjectUserId == null)) + if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.ReplacedSubjectUserId == null)) { //---有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生 throw new BusinessValidationFailedException(_localizer["VisitTask_InconsistentSubjectStatus"]); } - if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.OrignalSubjectUserId == null)) + if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.ReplacedSubjectUserId == null)) { //---有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期 throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]); @@ -568,11 +568,11 @@ namespace IRaCIS.Core.Application.Service.Allocation //将关系确认 if (assignConfirmCommand.SubjectDoctorUserList.Count == 0) { - await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.OrignalSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true }); + await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true }); } else { - await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.OrignalSubjectUserId == null + await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null && subjectIdList.Contains(t.SubjectId), u => new SubjectUser() { IsConfirmed = true }); } @@ -597,7 +597,7 @@ namespace IRaCIS.Core.Application.Service.Allocation if (assignConfirmCommand.SubjectDoctorUserList.Count == 0) { - subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList(); + subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList(); } else { diff --git a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs b/IRaCIS.Core.Domain/Allocation/SubjectUser.cs index 88680dc39..f4adcfcde 100644 --- a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs +++ b/IRaCIS.Core.Domain/Allocation/SubjectUser.cs @@ -24,8 +24,8 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] //Parent - [ForeignKey("OrignalSubjectUserId")] - public SubjectUser OrignalSubjectUser { get; set; } + [ForeignKey("ReplacedSubjectUserId")] + public SubjectUser ReplacedSubjectUser { get; set; } //ChildList [JsonIgnore] @@ -34,6 +34,9 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public User DoctorUser { get; set; } + + [JsonIgnore] + public Subject Subject { get; set; } #endregion public Guid TrialId { get; set; } @@ -44,8 +47,6 @@ namespace IRaCIS.Core.Domain.Models public Guid SubjectId { get; set; } - public Subject Subject { get; set; } - public Guid DoctorUserId { get; set; } @@ -55,7 +56,7 @@ namespace IRaCIS.Core.Domain.Models public bool IsConfirmed { get; set; } = true; //该属性有值 说明该医生被替换了 分配的时候 要过滤掉 - public Guid? OrignalSubjectUserId { get; set; } + public Guid? ReplacedSubjectUserId { get; set; } diff --git a/IRaCIS.Core.Domain/Allocation/TaskInfluence.cs b/IRaCIS.Core.Domain/Allocation/TaskInfluence.cs index c372cbb50..9f0ce8173 100644 --- a/IRaCIS.Core.Domain/Allocation/TaskInfluence.cs +++ b/IRaCIS.Core.Domain/Allocation/TaskInfluence.cs @@ -19,6 +19,7 @@ namespace IRaCIS.Core.Domain.Models #region 导航属性 [JsonIgnore] public VisitTask OriginalTask { get; set; } + [JsonIgnore] public VisitTask InfluenceTask { get; set; } #endregion diff --git a/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingClinicalData.cs b/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingClinicalData.cs index a4188779c..989a66465 100644 --- a/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingClinicalData.cs +++ b/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingClinicalData.cs @@ -22,7 +22,8 @@ namespace IRaCIS.Core.Domain.Models public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; } [JsonIgnore] - public DicomStudy? DicomStudy { get; set; } + [ForeignKey("StudyId")] + public DicomStudy DicomStudy { get; set; } [JsonIgnore] [ForeignKey("TrialId")] diff --git a/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingConsistentClinicalData.cs b/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingConsistentClinicalData.cs index 37510150f..6c0d126ad 100644 --- a/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingConsistentClinicalData.cs +++ b/IRaCIS.Core.Domain/Reading/ClinicalData/ReadingConsistentClinicalData.cs @@ -21,8 +21,8 @@ namespace IRaCIS.Core.Domain.Models public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; } [JsonIgnore] - - public DicomStudy? DicomStudy { get; set; } + [ForeignKey("StudyId")] + public DicomStudy DicomStudy { get; set; } [JsonIgnore] [ForeignKey("TrialId")] diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs index 4114c225a..5fa1e61c3 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs @@ -5,39 +5,38 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { - public class StudyConfigration : IEntityTypeConfiguration - { - - /// - /// 一个外键,关联多个表 - /// - /// - public void Configure(EntityTypeBuilder builder) - { - - builder - .HasMany(s => s.ReadingClinicalDataList) - .WithOne(c => c.DicomStudy) - .HasForeignKey(s => new { s.StudyId }) - .HasPrincipalKey(c => new { c.Id }); + //public class StudyConfigration : IEntityTypeConfiguration + //{ + + // /// + // /// 一个外键,关联多个表 ReadingId + // /// + // /// + // public void Configure(EntityTypeBuilder builder) + // { + + // builder + // .HasMany(s => s.ReadingClinicalDataList) + // .WithOne(c => c.DicomStudy) + // .HasForeignKey(s => new { s.StudyId }) + // .HasPrincipalKey(c => new { c.Id }); - builder - .HasMany(s => s.ReadingConsistentClinicalDataList) - .WithOne(c => c.DicomStudy) - .HasForeignKey(s => new { s.StudyId }) - .HasPrincipalKey(c => new { c.Id }); + // builder + // .HasMany(s => s.ReadingConsistentClinicalDataList) + // .WithOne(c => c.DicomStudy) + // .HasForeignKey(s => new { s.StudyId }) + // .HasPrincipalKey(c => new { c.Id }); - } - } + // } + //} - public class ReadModuleConfigration : IEntityTypeConfiguration - { - - public void Configure(EntityTypeBuilder builder) - { - - builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t => t.SubjectVisitId); - } - } + //public class UserConfigration : IEntityTypeConfiguration + //{ + // public void Configure(EntityTypeBuilder builder) + // { + // //对于阅片人来讲,会有很多任务 + // builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); + // } + //} } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs index 0c48832b7..61f1d1111 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -12,26 +12,31 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { + //对于裁判任务而言,一个裁判任务,关联了两个产生裁判的任务 + builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask).HasForeignKey(t => t.JudgeVisitTaskId); - builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask); - - builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); - - builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); - + //对于退回或者重阅的任务而已,会关联多个影响的任务 builder.HasMany(t => t.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId); + //对于全局任务而言,会关联多个全局访视阅片结果(因为同一全局会对多个访视的结果进行修改) builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId); + //对于全局修改的任务而言,会关联多个全局访视阅片结果(因为同一个访视结果,会被多个全局修改) + //subject 删除了,但是任务没删除,导致的查询问题 builder.HasQueryFilter(b => b.Subject.IsDeleted == false); + + //builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); + //builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); + + } } public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - + //不影响之前的逻辑,附加评估 builder.HasQueryFilter(p => p.IsAdditional == false); } @@ -41,16 +46,11 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { public void Configure(EntityTypeBuilder builder) { - builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); - } - } - public class UserConfigration : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false); + //对于替换后的医生而言,关联多个之前的医生 + builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.ReplacedSubjectUser); } } + } diff --git a/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 index 5a329af9d..78ded9bf4 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 +++ b/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明 @@ -12,4 +12,12 @@ https://www.cnblogs.com/cqpanda/p/16815263.html dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext 3Ǩļµݿ - dotnet ef database update -p IRaCIS.Core.Test -c IRCContext \ No newline at end of file + dotnet ef database update -p IRaCIS.Core.Test -c IRCContext + + 4鿴Ǩ + dotnet ef migrations list -p IRaCIS.Core.Test -c IRCContext + + 5ijθµݿǨ + dotnet ef database update ijǨƵǰһǨ -p IRaCIS.Core.Test -c IRCContext + + diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs index 888935f60..ff0800238 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/EntityConfigration/SubjectConfigration.cs @@ -18,16 +18,5 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL } } - public class TestOneConfigration : IEntityTypeConfiguration - { - - public void Configure(EntityTypeBuilder builder) - { - - builder.HasOne(s => s.LatestTestMany).WithMany().HasForeignKey(t=>t.LatestTestManyId); - builder.HasOne(s => s.FinalTestMany).WithMany().HasForeignKey(t => t.FinalTestManyId); - builder.HasMany(s => s.TestManyList).WithOne(sv => sv.TestOne).HasForeignKey(t => t.TestOneId); - } - } } diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs index 01eb69f95..099056b6f 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs @@ -27,8 +27,8 @@ public partial class IRCContext : DbContext public virtual DbSet SubejectVisit { get; set; } public virtual DbSet Dictionary { get; set; } - public virtual DbSet TestOne { get; set; } - public virtual DbSet TestMany { get; set; } + public virtual DbSet ReadingClinicalData { get; set; } + public virtual DbSet ReadModule { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true"); diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs index 56a90d864..02eee8fe9 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs @@ -102,33 +102,30 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL public string Code { get; set; } } - - public class TestOne : BaseFullAuditEntity + #region 一个外键 关联两个实体 + public class ReadingClinicalData : BaseFullAuditEntity { public string Code { get; set; } - [ForeignKey(nameof(TestOne.FinalTestMany))] - public Guid? LatestTestManyId { get; set; } - [ForeignKey(nameof(TestOne.LatestTestMany))] - public Guid? FinalTestManyId { get; set; } - - #region 同时配置一对多,一对一 导航属性 + public Guid ReadingId { get; set; } - public TestMany FinalTestMany { get; set; } + [ForeignKey("ReadingId")] - public TestMany LatestTestMany { get; set; } + public SubejectVisit SubjectVisit { get; set; } - public List TestManyList { get; set; } + [ForeignKey("ReadingId")] - #endregion + public ReadModule ReadModule { get; set; } } - public class TestMany : BaseFullAuditEntity + public class ReadModule : BaseFullAuditEntity { - public TestOne TestOne { get; set; } - - public Guid TestOneId { get; set; } + public string Name { get; set; } } + #endregion + + + } From 510a35e2b49cd3ad674ca1584451b84278c7ea15 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 23:38:39 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E7=B3=BB=E5=88=B0=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=96=87=E4=BB=B6=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E7=90=86=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EntityConfigration/SubjectConfigration.cs | 10 ++++++++++ .../EntityConfigration/VisitTaskConfigration.cs | 14 -------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index b22f05c95..1fb1584fd 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -36,4 +36,14 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId); } } + + public class SubjectUserConfigration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + //自身存在一对多的关系 + //对于替换后的医生而言,关联多个之前的医生 + builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.ReplacedSubjectUser).HasForeignKey(t => t.ReplacedSubjectUserId); + } + } } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs index 61f1d1111..0e15a0649 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/VisitTaskConfigration.cs @@ -25,11 +25,8 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration //subject 删除了,但是任务没删除,导致的查询问题 builder.HasQueryFilter(b => b.Subject.IsDeleted == false); - //builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId); //builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); - - } } public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration @@ -42,15 +39,4 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } - public class SubjectUserConfigration : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - //对于替换后的医生而言,关联多个之前的医生 - builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.ReplacedSubjectUser); - } - } - - - } From 8678c3602fec2169b4951248d5c8193b66e17a3d Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Tue, 10 Sep 2024 23:59:18 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialMaintenanceService.cs | 2 +- .../Service/TrialSiteUser/_MapConfig.cs | 2 +- IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs | 3 +-- IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs | 3 --- .../EntityConfigration/TrialUserConfigration.cs | 12 ------------ 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 0198b9589..57f4ad08c 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -67,7 +67,7 @@ namespace IRaCIS.Application.Services .WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => (t.User.FullName).Contains(inQuery.UserRealName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.User.OrganizationName.Contains(inQuery.OrganizationName)) - .ProjectTo(_mapper.ConfigurationProvider, new { trialSiteId = inQuery.TrialSiteId }); + .ProjectTo(_mapper.ConfigurationProvider); return await query.ToPagedListAsync(inQuery); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index 543e702de..ed572a3c3 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -98,7 +98,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.UserRealName, u => u.MapFrom(s => s.User.FullName)) .ForMember(d => d.TrialSiteId, u => u.MapFrom(t => trialSiteId)) .ForMember(d => d.UserType, u => u.MapFrom(t => t.User.UserTypeRole.UserTypeShortName)) - .ForMember(d => d.IsSelect, u => u.MapFrom(t => t.SiteList.Any(k => k.TrialSiteId == trialSiteId))); + .ForMember(d => d.IsSelect, u => u.MapFrom(t => t.Trial.TrialSiteUserList.Any(k => k.UserId == t.UserId))); CreateMap(); var trialId = Guid.Empty; diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs index 4cdda8998..ad366265a 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs @@ -27,8 +27,7 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public TrialSite TrialSite { get; set; } - [JsonIgnore] - public TrialUser TrialUser { get; set; } + #endregion public Guid TrialSiteId { get; set; } diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs index 5ac7e53d8..1e5c15a93 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs @@ -17,9 +17,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] [ForeignKey("UserId")] public User User { get; set; } - - [JsonIgnore] - public List SiteList { get; set; } #endregion public Guid UserId { get; set; } public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs index c0fefeb07..c4f782f0c 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialUserConfigration.cs @@ -6,18 +6,6 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration { - public class TrialUserConfigration : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder - .HasMany(s => s.SiteList) - .WithOne(c => c.TrialUser) - .HasForeignKey(s => new { s.TrialId, s.UserId }) - .HasPrincipalKey(c => new { c.TrialId, c.UserId }); - - } - } public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration { From b9b095a19c4773257549433127cbf51dac5eeaf0 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Sep 2024 08:58:52 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E5=88=86?= =?UTF-8?q?=E6=9E=90=E4=BB=BB=E5=8A=A1=EF=BC=8C=E4=B8=8B=E8=BD=BD=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageAndDoc/DownloadAndUploadService.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index e9ad732f9..41d195d93 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -606,7 +606,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var query = from u in _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect) - join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter,t=> ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|")) + join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter, t => ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|")) on u.SourceSubjectVisitId equals ns.SubjectVisitId select new TaskNoneDicomStudyDTO() @@ -740,14 +740,19 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var doctorUserId = _userInfo.Id; + var isAnalysisCreate = false; + //医学审核查看下载按钮,这个时候需要知道医生 - if (inQuery.VisitTaskId != null && inQuery.VisitTaskId!=Guid.Empty) + if (inQuery.VisitTaskId != null && inQuery.VisitTaskId != Guid.Empty) { - doctorUserId = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => (Guid)t.DoctorUserId).FirstNotNullAsync(); + var info = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => new { t.DoctorUserId, t.IsAnalysisCreate }).FirstNotNullAsync(); + + doctorUserId = (Guid)info.DoctorUserId!; + isAnalysisCreate = info.IsAnalysisCreate; } var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId - && t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect) + && t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == isAnalysisCreate) .ProjectTo(_mapper.ConfigurationProvider); @@ -827,11 +832,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var subjectVisitIdList = inQuery.SubjectVisitTaskList.Select(t => t.SubjectVisitId).ToList(); - //var a = _visitTaskRepository.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id); - var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))) - //一致性分析,导致查询出来两条数据 - join visitTask in _visitTaskRepository.Where(t=> taskIdList.Contains(t.Id)) /*.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)*/ + //一致性分析,导致查询出来两条数据 + join visitTask in _visitTaskRepository.Where(t => taskIdList.Contains(t.Id)) on sv.Id equals visitTask.SourceSubjectVisitId select new