diff --git a/IRC.Core.SCP/IRC.Core.SCP.csproj b/IRC.Core.SCP/IRC.Core.SCP.csproj index 768c65fef..311016000 100644 --- a/IRC.Core.SCP/IRC.Core.SCP.csproj +++ b/IRC.Core.SCP/IRC.Core.SCP.csproj @@ -14,9 +14,9 @@ - - - + + + diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 8ddb0f03d..2247700bf 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -69,6 +69,7 @@ + all @@ -79,8 +80,6 @@ - - diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs index c90e0a5f1..ae03f93a3 100644 --- a/IRaCIS.Core.API/Progranm.cs +++ b/IRaCIS.Core.API/Progranm.cs @@ -7,7 +7,6 @@ using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.Service.BusinessFilter; using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Infrastructure.Extention; -using LogDashboard; using MassTransit; using MassTransit.NewIdProviders; using Microsoft.AspNetCore.Builder; @@ -136,7 +135,7 @@ builder.Services.AddFusionCache(); builder.Services.AddhangfireSetup(_configuration); //Serilog 日志可视化 LogDashboard日志 -builder.Services.AddLogDashboardSetup(); +//builder.Services.AddLogDashboardSetup(); //Dicom影像渲染图片 跨平台 builder.Services.AddDicomSetup(); @@ -221,7 +220,7 @@ app.UseResponseCompression(); app.UseStaticFiles(); //LogDashboard -app.UseLogDashboard("/LogDashboard"); +//app.UseLogDashboard("/LogDashboard"); //hangfire app.UseHangfireConfig(env); diff --git a/IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs b/IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs index b644df0e3..f75dbf96a 100644 --- a/IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs +++ b/IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs @@ -1,15 +1,15 @@ -using LogDashboard; -using LogDashboard.Authorization; +//using LogDashboard; +//using LogDashboard.Authorization; -namespace IRaCIS.Core.API.Filter -{ +//namespace IRaCIS.Core.API.Filter +//{ - public class LogDashBoardAuthFilter : ILogDashboardAuthorizationFilter - { - //在此可以利用 本系统的UerTypeEnum 判断 - public bool Authorization(LogDashboardContext context) - { - return context.HttpContext.User.Identity.IsAuthenticated; - } - } -} \ No newline at end of file +// public class LogDashBoardAuthFilter : ILogDashboardAuthorizationFilter +// { +// //在此可以利用 本系统的UerTypeEnum 判断 +// public bool Authorization(LogDashboardContext context) +// { +// return context.HttpContext.User.Identity.IsAuthenticated; +// } +// } +//} \ No newline at end of file diff --git a/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs index 208d0672b..3a4912ea8 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs @@ -1,25 +1,25 @@  -using LogDashboard; -using Microsoft.Extensions.DependencyInjection; +//using LogDashboard; +//using Microsoft.Extensions.DependencyInjection; -namespace IRaCIS.Core.API -{ - public static class LogDashboardSetup - { - public static void AddLogDashboardSetup(this IServiceCollection services) - { - //IIS 配置虚拟路径部署,会出现IIS静态文件404 - services.AddLogDashboard(opt => - { - //opt.PathMatch = "/api/LogDashboard"; - opt.PathMatch = "/LogDashboard"; +//namespace IRaCIS.Core.API +//{ +// public static class LogDashboardSetup +// { +// public static void AddLogDashboardSetup(this IServiceCollection services) +// { +// //IIS 配置虚拟路径部署,会出现IIS静态文件404 +// services.AddLogDashboard(opt => +// { +// //opt.PathMatch = "/api/LogDashboard"; +// opt.PathMatch = "/LogDashboard"; - //opt.AddAuthorizationFilter(new LogDashboardBasicAuthFilter("admin", "zhizhun2018")); +// //opt.AddAuthorizationFilter(new LogDashboardBasicAuthFilter("admin", "zhizhun2018")); - //opt.AddAuthorizationFilter(new LogDashBoardAuthFilter()); +// //opt.AddAuthorizationFilter(new LogDashBoardAuthFilter()); - }); +// }); - } - } -} +// } +// } +//} diff --git a/IRaCIS.Core.API/appsettings.Event_IRC.json b/IRaCIS.Core.API/appsettings.Event_IRC.json index a5e5925ca..67ccf7b7b 100644 --- a/IRaCIS.Core.API/appsettings.Event_IRC.json +++ b/IRaCIS.Core.API/appsettings.Event_IRC.json @@ -7,8 +7,8 @@ } }, "ConnectionStrings": { - "RemoteNew": "Server=47.117.164.182,1434;Database=Event_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true", - "Hangfire": "Server=47.117.164.182,1434;Database=Event_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true" + "RemoteNew": "Server=101.132.253.119,1435;Database=irc_Prpd_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true", + "Hangfire": "Server=101.132.253.119,1435;Database=irc_Hangfire_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true" }, "ObjectStoreService": { "ObjectStoreUse": "AliyunOSS", diff --git a/IRaCIS.Core.Application/BusinessFilter/LegacyController/TrialGlobalLimitActionFilter.cs b/IRaCIS.Core.Application/BusinessFilter/LegacyController/TrialGlobalLimitActionFilter.cs index e845a10c4..8d24d2591 100644 --- a/IRaCIS.Core.Application/BusinessFilter/LegacyController/TrialGlobalLimitActionFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/LegacyController/TrialGlobalLimitActionFilter.cs @@ -62,9 +62,9 @@ public class TrialGlobalLimitActionFilter(IFusionCache _fusionCache, IUserInfo _ var index = context.HttpContext.Request.RouteValues.Keys.ToList().IndexOf("trialId"); trialIdStr = context.HttpContext.Request.RouteValues.Values.ToList()[index] as string; } - else if (context.HttpContext.Request.Headers["self-Referer"].ToString().Contains("trialId")) + else if (context.HttpContext.Request.Headers["Referer"].ToString().Contains("trialId")) { - var headerStr = context.HttpContext.Request.Headers["self-Referer"].ToString(); + var headerStr = context.HttpContext.Request.Headers["Referer"].ToString(); var trialIdIndex = headerStr.IndexOf("trialId"); diff --git a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/TrialGlobalLimitEndpointFilter.cs b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/TrialGlobalLimitEndpointFilter.cs index bb1974ff0..6648db25e 100644 --- a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/TrialGlobalLimitEndpointFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/TrialGlobalLimitEndpointFilter.cs @@ -71,9 +71,9 @@ public class TrialGlobalLimitEndpointFilter(IFusionCache _fusionCache, IUserInfo var index = context.HttpContext.Request.RouteValues.Keys.ToList().IndexOf("trialId"); trialIdStr = context.HttpContext.Request.RouteValues.Values.ToList()[index] as string; } - else if (context.HttpContext.Request.Headers["self-Referer"].ToString().Contains("trialId")) + else if (context.HttpContext.Request.Headers["Referer"].ToString().Contains("trialId")) { - var headerStr = context.HttpContext.Request.Headers["self-Referer"].ToString(); + var headerStr = context.HttpContext.Request.Headers["Referer"].ToString(); var trialIdIndex = headerStr.IndexOf("trialId"); diff --git a/IRaCIS.Core.Application/Helper/OtherTool/ImageHelper.cs b/IRaCIS.Core.Application/Helper/OtherTool/ImageHelper.cs index 293511f2d..83843f400 100644 --- a/IRaCIS.Core.Application/Helper/OtherTool/ImageHelper.cs +++ b/IRaCIS.Core.Application/Helper/OtherTool/ImageHelper.cs @@ -15,14 +15,20 @@ public static class ImageHelper fileStorePath = fileStorePath ?? filePath + ".preview.jpeg"; - using (var image = SixLabors.ImageSharp.Image.Load(filePath)) - { + // 读取 DICOM 文件 + var dicomImage = new DicomImage(filePath); + // 渲染 DICOM 图像到 ImageSharp 格式 + using (var image = dicomImage.RenderImage().AsSharpImage()) + { + // 生成缩略图(调整大小) image.Mutate(x => x.Resize(500, 500)); - image.Save(fileStorePath); - + // 保存缩略图为 JPEG + image.Save(fileStorePath, new JpegEncoder()); } + + } diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index cee4a0855..3ab94f632 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -37,16 +37,16 @@ - + - - - + + + @@ -54,14 +54,14 @@ - + true - + diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 13efcc8db..0917362b4 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -13888,6 +13888,22 @@ + + + IQC 回退到影像上传 + + + + + + + + + + 后端处理某个中心缩略图有问题 先下载,生成缩略图上传,然后更新数据库 + + + 非dicom 临床数据 diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 29327555a..6a53400fd 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -1,5 +1,6 @@ using Aliyun.OSS; using DocumentFormat.OpenXml.Spreadsheet; +using FellowOakDicom.Imaging; using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.BusinessFilter; using IRaCIS.Core.Application.Contracts; @@ -7,6 +8,7 @@ using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Service.BusinessFilter; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain; +using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Infrastructure; @@ -26,8 +28,13 @@ using Microsoft.Extensions.Options; using MiniExcelLibs; using NPOI.SS.Formula.Functions; using NPOI.XWPF.UserModel; +using SharpCompress.Common; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Processing; using System.Globalization; using System.Linq.Dynamic.Core; +using System.Reactive.Subjects; using System.Reflection.Metadata.Ecma335; using System.Runtime.InteropServices; using System.Text; @@ -53,6 +60,7 @@ namespace IRaCIS.Core.Application.Service IRepository _dicomSeriesRepository, IRepository _userRoleRepository, IRepository _trialBodyPartRepository, + IOSSService _IOSSService, IDistributedLockProvider _distributedLockProvider, ILogger _logger, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService { @@ -86,6 +94,144 @@ namespace IRaCIS.Core.Application.Service await _readingConsistentClinicalDataRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } + + + /// + /// IQC 回退到影像上传 + /// + /// + /// + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public async Task IQCBackToUpload(Guid[] subjectVisitIdList, + [FromServices] IRepository _subjectVisitRepository, + [FromServices] IRepository _trialQCQuestionAnswerRepository, + [FromServices] IRepository _readingClinicalDataReposiotry) + { + + foreach (var subjectVisitId in subjectVisitIdList) + { + var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException(); + + + //需要重新产生任务 + sv.IsVisitTaskGenerated = false; + sv.IsPMBackOrReReading = true; + + sv.AuditState = AuditStateEnum.None; + sv.SubmitState = SubmitStateEnum.ToSubmit; + sv.ReadingStatus = ReadingStatusEnum.ImageNotSubmit; + + //回退后,回退状态恢复 + sv.RequestBackState = RequestBackStateEnum.NotRequest; + sv.IsCheckBack = false; + sv.CheckBackTime = null; + sv.CheckState = CheckStateEnum.None; + sv.CheckChallengeState = CheckChanllengeTypeEnum.None; + + sv.SVENDTC = null; + sv.SVSTDTC = null; + + sv.PreliminaryAuditTime = null; + sv.SubmitTime = null; + sv.ReviewAuditTime = null; + sv.CurrentActionUserExpireTime = null; + + + sv.IsTake = false; + sv.CurrentActionUserId = null; + sv.PreliminaryAuditUserId = null; + sv.ReviewAuditUserId = null; + + + if (sv.IsBaseLine) + { + await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && (t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.Subject || t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit), c => new ReadingClinicalData() { IsSign = false, ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded }); + + } + else + { + await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit, c => new ReadingClinicalData() + { + IsSign = false, + ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded, + IsBlind = null, + IsComplete = null + }); + } + + + await _trialQCQuestionAnswerRepository.BatchDeleteNoTrackingAsync(t => t.SubjectVisitId == subjectVisitId); + } + + + + var success = await _subjectVisitRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + + } + + + + /// + /// 后端处理某个中心缩略图有问题 先下载,生成缩略图上传,然后更新数据库 + /// + /// + [AllowAnonymous] + public async Task BackImageResize(Guid trialSiteId ,Guid subjectId/* , [FromServices] IRepository<>*/) + { + ///${params.trialId}/ Image /${params.subjectId}/${params.subjectVisitId}/${ dicomInfo.studyUid}/${ v.seriesUid}.jpg + + var dealSeriesList = await _dicomSeriesRepository.Where(t => t.DicomStudy.Subject.TrialSiteId == trialSiteId && t.SubjectId== subjectId).Select(t => new { t.Id, t.SubjectId, t.TrialId, t.SubjectVisitId, t.StudyInstanceUid, t.SeriesInstanceUid, t.ImageResizePath, t.UpdateUserId, FirstInstancePath = t.DicomInstanceList.First().Path }).ToListAsync(); + + //下载到本地 + string tempFolderPath = Path.Combine(Directory.GetCurrentDirectory(), $"DownloadTemp_{NewId.NextGuid()}"); + Directory.CreateDirectory(tempFolderPath); + + foreach (var dealSeries in dealSeriesList) + { + var fileName = Path.GetFileNameWithoutExtension(dealSeries.FirstInstancePath); + + var localFilePath = Path.Combine(tempFolderPath, fileName); + + await _IOSSService.DownLoadFromOSSAsync(dealSeries.FirstInstancePath, localFilePath); + + + var resizePath = localFilePath + "_New.jpg"; + + //生成缩略图 + + // 读取 DICOM 文件 + var dicomImage = new DicomImage(localFilePath); + + + // 渲染 DICOM 图像到 ImageSharp 格式 + using (var image = dicomImage.RenderImage().AsSharpImage()) + { + // 生成缩略图(调整大小) + image.Mutate(x => x.Resize(500, 500)); + + // 保存缩略图为 JPEG + image.Save(resizePath, new JpegEncoder()); + } + + var ossFolder = $"{dealSeries.TrialId}/Image/{dealSeries.SubjectId}/{dealSeries.SubjectVisitId}/{dealSeries.StudyInstanceUid}"; + + var relativePath = await _IOSSService.UploadToOSSAsync(resizePath, ossFolder, false); + + await _dicomSeriesRepository.BatchUpdateNoTrackingAsync(t => t.Id == dealSeries.Id, u => new DicomSeries() { ImageResizePath = relativePath, UpdateUserId = dealSeries.UpdateUserId }); + + } + + return ResponseOutput.Ok(); + + } + + public async Task DeleteOSSDate(string rootFolder, [FromServices] IOSSService _oSSService, [FromServices] IWebHostEnvironment _hostEnvironment) { diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 383747676..9800d62b0 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -21,7 +21,7 @@ - + @@ -30,7 +30,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index cac011aba..4e4acb358 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -18,7 +18,7 @@ - + diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index ee616207e..de2af024c 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -49,11 +49,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive