From d2e3e4de8655c24418d9e1d9a806a7d482ce6c9c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 17 Dec 2025 15:11:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=86=99=E5=85=A5=E6=B5=81?= =?UTF-8?q?=E7=9A=84=E8=BF=9B=E5=BA=A6=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UploadDownLoadController.cs | 50 ++++++++++++++++++- IRaCIS.Core.API/SignalRHub/UploadHub.cs | 2 +- .../Service/Visit/DTO/PatientViewModel.cs | 3 ++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index a47b30c69..c4f742047 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -1,5 +1,8 @@ using AutoMapper; using ExcelDataReader; +using FellowOakDicom; +using FellowOakDicom.Imaging; +using FellowOakDicom.IO.Buffer; using IRaCIS.Application.Contracts; using IRaCIS.Application.Interfaces; using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson; @@ -901,7 +904,12 @@ namespace IRaCIS.Core.API.Controllers var downloadInfo = (SubejctVisitDownload)rusult.OtherData; + long receivedsize = 0; + long receivedCount = 0; + long totalSize = downloadInfo.ImageSize; + long toTalCount = downloadInfo.ImageCount; + var abortToken = HttpContext.RequestAborted; var lastNotify = DateTime.UtcNow; @@ -939,6 +947,10 @@ namespace IRaCIS.Core.API.Controllers { foreach (var instance in series.InstanceList) { + //当前完成大小 + receivedsize = receivedsize + instance.FileSize ?? 0; + receivedCount++; + abortToken.ThrowIfCancellationRequested(); var entryPath = @@ -949,10 +961,44 @@ namespace IRaCIS.Core.API.Controllers await using var entryStream = entry.Open(); await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path); - await source.CopyToAsync(entryStream, 32 * 1024, abortToken); + #region 将多帧合并为一帧 + + // 如果你是从 stream 打开 + var dicomFile = await DicomFile.OpenAsync(source); + + // 获取 Pixel Data 标签 + var pixelData = DicomPixelData.Create(dicomFile.Dataset); + //获取像素是否为封装形式 + var syntax = dicomFile.Dataset.InternalTransferSyntax; + + //对于封装像素的文件做转换 + if (syntax.IsEncapsulated) + { + // 创建一个新的片段序列 + var newFragments = new DicomOtherByteFragment(DicomTag.PixelData); + // 获取每帧数据并封装为单独的片段 + for (int n = 0; n < pixelData.NumberOfFrames; n++) + { + var frameData = pixelData.GetFrame(n); + newFragments.Fragments.Add(new MemoryByteBuffer(frameData.Data)); + } + // 替换原有的片段序列 + dicomFile.Dataset.AddOrUpdate(newFragments); + } + + #endregion + + await dicomFile.SaveAsync(entryStream); + //await source.CopyToAsync(entryStream, 32 * 1024, abortToken); - //await _downLoadHub.Clients.User(_userInfo.IdentityUserId.ToString()).ReceivProgressAsync(archiveStudyCommand.StudyInstanceUid, receivedCount); + await _downLoadHub.Clients.User(_userInfo.IdentityUserId.ToString()).ReceivProgressAsync(inCommand.CurrentNoticeId, + (new + { + CountPercent = downloadInfo.ImageCount > 0 ? Math.Round(receivedCount * 100m / downloadInfo.ImageCount, 2) : 0m, + SizePercent = totalSize > 0 ? Math.Round(receivedsize * 100m / totalSize, 2) : 0m + } + )); } } } diff --git a/IRaCIS.Core.API/SignalRHub/UploadHub.cs b/IRaCIS.Core.API/SignalRHub/UploadHub.cs index f102f1460..ba1fc6d35 100644 --- a/IRaCIS.Core.API/SignalRHub/UploadHub.cs +++ b/IRaCIS.Core.API/SignalRHub/UploadHub.cs @@ -61,7 +61,7 @@ namespace IRaCIS.Core.API public interface IDownloadClient { - Task ReceivProgressAsync(Guid downloadId, string percent); + Task ReceivProgressAsync(string downloadId, object percent); } diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs b/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs index 6ac63a26d..f6eca470d 100644 --- a/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs +++ b/IRaCIS.Core.Application/Service/Visit/DTO/PatientViewModel.cs @@ -970,6 +970,9 @@ namespace IRaCIS.Application.Contracts public List PatientIdList { get; set; } public List SCPStudyIdList { get; set; } + + [NotDefault] + public string CurrentNoticeId { get; set; } } public class VisitImageDownloadQuery : PageInput