项目增加字段,维护最大的检查编号
parent
d60229fa99
commit
74844bf9ce
|
|
@ -163,13 +163,14 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
}
|
||||
|
||||
//默认会是0
|
||||
var code = await _noneDicomStudyRepository.Where(t => t.TrialId == addOrEditNoneDicomStudy.TrialId,ignoreQueryFilters:true).Select(x => x.Code).DefaultIfEmpty().MaxAsync();
|
||||
var code = await _trialRepository.Where(t => t.Id == addOrEditNoneDicomStudy.TrialId, ignoreQueryFilters: true).Select(x => x.MaxNoneDicomCode).DefaultIfEmpty().MaxAsync();
|
||||
|
||||
|
||||
optEntity = await _noneDicomStudyRepository.InsertFromDTOAsync(addOrEditNoneDicomStudy);
|
||||
|
||||
optEntity.Code = code + 1;
|
||||
|
||||
await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == addOrEditNoneDicomStudy.TrialId, u => new Trial() { MaxNoneDicomCode = optEntity.Code });
|
||||
|
||||
optEntity.StudyCode = AppSettings.GetCodeStr(optEntity.Code, nameof(NoneDicomStudy));
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
//查询数据库获取最大的Code 没有记录则为0
|
||||
var dbStudyCodeIntMax = _dicomStudyRepository.Where(s => s.TrialId == trialId, ignoreQueryFilters: true).Select(t => t.Code).DefaultIfEmpty().Max();
|
||||
var dbStudyCodeIntMax = _trialRepository.Where(s => s.Id == trialId, ignoreQueryFilters: true).Select(t => t.MaxDicomCode).DefaultIfEmpty().Max();
|
||||
|
||||
//获取缓存中的值 并发的时候,需要记录,已被占用的值 这样其他线程在此占用的最大的值上递增
|
||||
var cacheMaxCodeInt = await _fusionCache.GetOrDefaultAsync<int>(CacheKeys.TrialStudyMaxCode(trialId));
|
||||
|
|
@ -405,6 +405,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
addStudy.Code = currentNextCodeInt;
|
||||
|
||||
await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialId, u => new Trial() { MaxDicomCode = addStudy.Code });
|
||||
|
||||
addStudy.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy));
|
||||
|
||||
await _fusionCache.SetAsync<int>(CacheKeys.TrialStudyMaxCode(trialId), addStudy.Code, TimeSpan.FromMinutes(30));
|
||||
|
|
|
|||
|
|
@ -318,6 +318,12 @@ public partial class Trial : BaseFullDeleteAuditEntity
|
|||
|
||||
public TrialDataStore TrialDataStoreType { get; set; }
|
||||
|
||||
[Comment("最大的Dicom检查编号 整型")]
|
||||
public int MaxDicomCode { get; set; }
|
||||
|
||||
[Comment("最大的NoneDicom检查编号 整型")]
|
||||
public int MaxNoneDicomCode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public enum TrialDataStore
|
||||
|
|
|
|||
22153
IRaCIS.Core.Infra.EFCore/Migrations/20260506055909_AddTrialMaxCode.Designer.cs
generated
Normal file
22153
IRaCIS.Core.Infra.EFCore/Migrations/20260506055909_AddTrialMaxCode.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,54 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddTrialMaxCode : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MaxDicomCode",
|
||||
table: "Trial",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
comment: "最大的Dicom检查编号 整型");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MaxNoneDicomCode",
|
||||
table: "Trial",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
comment: "最大的NoneDicom检查编号 整型");
|
||||
|
||||
//migrationBuilder.AddForeignKey(
|
||||
// name: "FK_Segmentation_VisitTask_VisitTaskId",
|
||||
// table: "Segmentation",
|
||||
// column: "VisitTaskId",
|
||||
// principalTable: "VisitTask",
|
||||
// principalColumn: "Id",
|
||||
// onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Segmentation_VisitTask_VisitTaskId",
|
||||
table: "Segmentation");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MaxDicomCode",
|
||||
table: "Trial");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MaxNoneDicomCode",
|
||||
table: "Trial");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12644,6 +12644,14 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
.HasColumnType("nvarchar(400)")
|
||||
.HasComment("主研单位");
|
||||
|
||||
b.Property<int>("MaxDicomCode")
|
||||
.HasColumnType("int")
|
||||
.HasComment("最大的Dicom检查编号 整型");
|
||||
|
||||
b.Property<int>("MaxNoneDicomCode")
|
||||
.HasColumnType("int")
|
||||
.HasComment("最大的NoneDicom检查编号 整型");
|
||||
|
||||
b.Property<string>("MessageFromClient")
|
||||
.IsRequired()
|
||||
.HasMaxLength(400)
|
||||
|
|
@ -19245,7 +19253,15 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("IRaCIS.Core.Domain.Models.VisitTask", "VisitTask")
|
||||
.WithMany()
|
||||
.HasForeignKey("VisitTaskId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CreateUserRole");
|
||||
|
||||
b.Navigation("VisitTask");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Domain.Models.ShortcutKey", b =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue