From c290515e22c6c73e79d08dfeac77a28f57bfbc2c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 8 Jan 2026 15:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9HIR=20=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/IRC.Core.SCP.csproj | 1 + IRC.Core.SCP/Program.cs | 3 + IRC.Core.SCP/Service/CStoreSCPService.cs | 1 - IRC.Core.SCP/Service/CacheHelper.cs | 101 ++++++++++++++++++++ IRC.Core.SCP/Service/DicomArchiveService.cs | 84 +++++++++++----- 5 files changed, 164 insertions(+), 26 deletions(-) create mode 100644 IRC.Core.SCP/Service/CacheHelper.cs diff --git a/IRC.Core.SCP/IRC.Core.SCP.csproj b/IRC.Core.SCP/IRC.Core.SCP.csproj index ae9eda876..548ed6ddf 100644 --- a/IRC.Core.SCP/IRC.Core.SCP.csproj +++ b/IRC.Core.SCP/IRC.Core.SCP.csproj @@ -48,6 +48,7 @@ + diff --git a/IRC.Core.SCP/Program.cs b/IRC.Core.SCP/Program.cs index 544d38a4d..4eea0413e 100644 --- a/IRC.Core.SCP/Program.cs +++ b/IRC.Core.SCP/Program.cs @@ -158,6 +158,9 @@ builder.Services.AddControllers(); //Swagger Api 文档 builder.Services.AddSwaggerSetup(); +// FusionCache +builder.Services.AddFusionCache(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index d9accd302..ccc491996 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -742,7 +742,6 @@ namespace IRaCIS.Core.SCP.Service var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, $"{seriesId.ToString()}_{instanceId.ToString()}.preview.jpg", false); - Console.WriteLine(seriesPath + " Id: " + seriesId); series.ImageResizePath = seriesPath; diff --git a/IRC.Core.SCP/Service/CacheHelper.cs b/IRC.Core.SCP/Service/CacheHelper.cs new file mode 100644 index 000000000..590cd6a20 --- /dev/null +++ b/IRC.Core.SCP/Service/CacheHelper.cs @@ -0,0 +1,101 @@ +using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Infra.EFCore; +using Microsoft.EntityFrameworkCore; + +namespace IRaCIS.Core.SCP.Service; + + +public static class CacheKeys +{ + //项目缓存 + public static string Trial(string trialIdStr) => $"TrialId:{trialIdStr}"; + + //检查编号递增锁 + public static string TrialStudyMaxCode(Guid trialId) => $"TrialStudyMaxCode:{trialId}"; + + public static string TrialStudyUidUploading(Guid trialId, string studyUid) => $"TrialStudyUid:{trialId}_{studyUid}"; + //CRC上传影像提交锁key + public static string TrialStudyUidDBLock(Guid trialId, string studyUid) => $"TrialStudyUidDBLock:{trialId}_{studyUid}"; + + public static string TrialTaskStudyUidUploading(Guid trialId, Guid visiTaskId, string studyUid) => $"TrialStudyUid:{trialId}_{visiTaskId}_{studyUid}"; + //影像后处理上传提交锁key + public static string TrialTaskStudyUidDBLock(Guid trialId, Guid visiTaskId, string studyUid) => $"TrialTaskStudyUidDBLock:{trialId}_{visiTaskId}_{studyUid}"; + //系统匿名化 + public static string SystemAnonymization => $"SystemAnonymization"; + //前端国际化 + public static string FrontInternational => $"FrontInternationalList"; + + //登录挤账号 + public static string UserToken(Guid userId) => $"UserToken:{userId}"; + + //超时没请求接口自动退出 + public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}"; + + + public static string UserDisable(Guid userId) => $"UserDisable:{userId}"; + + public static string UserRoleDisable(Guid userRoleId) => $"UserRoleDisable:{userRoleId}"; + + /// + /// 用户登录错误 限制登录 + /// + /// + /// + public static string UserLoginError(string userName) => $"login-failures:{userName}"; + + /// + /// 跳过阅片 + /// + /// + /// + public static string SkipReadingCacheKey(Guid userId) => $"{userId}SkipReadingCache"; + + + /// + /// 开始阅片时间 + /// + /// + /// + public static string StartReadingTimeKey(Guid userId) => $"{userId}StartReadingTime"; + + /// + /// 开始休息时间 + /// + /// + /// + public static string StartRestTime(Guid userId) => $"{userId}StartRestTime"; + + //每个用户 每个浏览器独立时间 + public static string UserMFAVerifyPass(Guid userId, string browserFingerprint) => $"UserMFAVerifyPass:{userId}:{browserFingerprint}"; + + public static string TrialSiteInfo(Guid trialSiteId) => $"{trialSiteId}TrialSiteInfo"; +} + +public static class CacheHelper +{ + public static async Task GetTrialStatusAsync(Guid trialId, IRepository _trialRepository) + { + var statusStr = await _trialRepository.Where(t => t.Id == trialId, ignoreQueryFilters: true).Select(t => t.TrialStatusStr).FirstOrDefaultAsync(); + + return statusStr; + } + + public class TrialSiteInfoDTO + { + public string TrialSiteCode { get; set; } + public string TrialCode { get; set; } + } + public static async Task GetTrialSiteInfo(Guid trialSiteId, IRepository _trialSiteRepository) + { + var obj = await _trialSiteRepository.Where(t => t.Id == trialSiteId, ignoreQueryFilters: true).Select(t => new TrialSiteInfoDTO { TrialCode= t.Trial.TrialCode, TrialSiteCode= t.TrialSiteCode }).FirstOrDefaultAsync(); + + return obj??new TrialSiteInfoDTO(); + } + + public static async Task> GetSystemAnonymizationListAsync(IRepository _systemAnonymizationRepository) + { + var list = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync(); + + return list; + } +} diff --git a/IRC.Core.SCP/Service/DicomArchiveService.cs b/IRC.Core.SCP/Service/DicomArchiveService.cs index c3321a4eb..109a11624 100644 --- a/IRC.Core.SCP/Service/DicomArchiveService.cs +++ b/IRC.Core.SCP/Service/DicomArchiveService.cs @@ -13,35 +13,21 @@ using IRaCIS.Core.Infra.EFCore; using MassTransit; using Serilog.Sinks.File; using IRaCIS.Core.Infrastructure.Extention; +using ZiggyCreatures.Caching.Fusion; namespace IRaCIS.Core.SCP.Service { - public class DicomArchiveService : BaseService, IDicomArchiveService + public class DicomArchiveService(IRepository _patientRepository, + IRepository _studyRepository, + IRepository _seriesRepository, + IRepository _instanceRepository, + IDistributedLockProvider _distributedLockProvider, + IRepository _systemAnonymizationRepository, + IRepository _trialSiteRepository, + IFusionCache _fusionCache + ) : BaseService, IDicomArchiveService { - private readonly IRepository _patientRepository; - private readonly IRepository _studyRepository; - private readonly IRepository _seriesRepository; - private readonly IRepository _instanceRepository; - private readonly IRepository _dictionaryRepository; - private readonly IDistributedLockProvider _distributedLockProvider; - - - private List _instanceIdList = new List(); - - public DicomArchiveService(IRepository patientRepository, IRepository studyRepository, - IRepository seriesRepository, - IRepository instanceRepository, - IRepository dictionaryRepository, - IDistributedLockProvider distributedLockProvider) - { - _distributedLockProvider = distributedLockProvider; - _studyRepository = studyRepository; - _patientRepository = patientRepository; - _seriesRepository = seriesRepository; - _instanceRepository = instanceRepository; - _dictionaryRepository = dictionaryRepository; - - } + @@ -56,6 +42,54 @@ namespace IRaCIS.Core.SCP.Service { var dataset = dicomFile.Dataset; + #region 匿名化 + + var anonymizeList = await _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_systemAnonymizationRepository), TimeSpan.FromDays(7)); + + + var fixedFiledList = anonymizeList.Where(t => t.IsFixed).ToList(); + + var ircFiledList = anonymizeList.Where(t => t.IsFixed == false).ToList(); + + foreach (var item in fixedFiledList) + { + + var dicomTag = new DicomTag(Convert.ToUInt16(item.Group, 16), Convert.ToUInt16(item.Element, 16)); + + dataset.AddOrUpdate(dicomTag, item.ReplaceValue); + } + + foreach (var item in ircFiledList) + { + + var dicomTag = new DicomTag(Convert.ToUInt16(item.Group, 16), Convert.ToUInt16(item.Element, 16)); + + if (dicomTag == DicomTag.ClinicalTrialProtocolID) + { + dataset.AddOrUpdate(dicomTag, ""); + + } + if (dicomTag == DicomTag.ClinicalTrialSiteID) + { + dataset.AddOrUpdate(dicomTag, ""); + } + + if (dicomTag == DicomTag.ClinicalTrialSubjectID) + { + dataset.AddOrUpdate(dicomTag, ""); + + } + if (dicomTag == DicomTag.ClinicalTrialTimePointID) + { + dataset.AddOrUpdate(dicomTag, ""); + + } + + + + } + #endregion + string studyInstanceUid = dataset.GetString(DicomTag.StudyInstanceUID); string seriesInstanceUid = dataset.GetString(DicomTag.SeriesInstanceUID);