增加测试接口
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
fb33acd827
commit
a0fd472e2e
|
|
@ -503,7 +503,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
|
||||
bot.Add(botOffset);
|
||||
|
||||
botOffset += (uint)data.Length; // 累加帧长度
|
||||
botOffset += (uint)data.Length +8 ; // 累加帧长度
|
||||
|
||||
while (offset < data.Length)
|
||||
{
|
||||
|
|
@ -540,24 +540,28 @@ namespace IRaCIS.Core.SCP.Service
|
|||
dicomFile.Save(ms);
|
||||
}
|
||||
//传递过来的就是拆分的,但是是没有偏移表的,我需要自己创建偏移表,不然生成缩略图失败
|
||||
else if (syntax.IsEncapsulated && fragmentCount > pixelData.NumberOfFrames && originOffsetTable.Count==0)
|
||||
else if (syntax.IsEncapsulated && fragmentCount > pixelData.NumberOfFrames && originOffsetTable.Count == 0)
|
||||
{
|
||||
|
||||
|
||||
uint offset = 0;
|
||||
|
||||
bot.Add(offset);
|
||||
|
||||
var fistSize = frag.Fragments.FirstOrDefault()?.Size??0;
|
||||
var fistSize = frag.Fragments.FirstOrDefault()?.Size ?? 0;
|
||||
|
||||
//和上一个大小不一样
|
||||
var isDiffrentBefore = false;
|
||||
|
||||
uint count = 0;
|
||||
|
||||
// 假设你知道每帧对应的 fragment 数量
|
||||
foreach (var frameFragments in frag.Fragments)
|
||||
{
|
||||
if(frameFragments.Size== fistSize)
|
||||
count++;
|
||||
|
||||
if (frameFragments.Size == fistSize)
|
||||
{
|
||||
isDiffrentBefore = false;
|
||||
isDiffrentBefore = false;
|
||||
// 累加这一帧所有 fragment 的大小
|
||||
offset += (uint)frameFragments.Size;
|
||||
continue;
|
||||
|
|
@ -571,7 +575,10 @@ namespace IRaCIS.Core.SCP.Service
|
|||
|
||||
if (isDiffrentBefore)
|
||||
{
|
||||
//每个Fragment 也占用字节
|
||||
offset += 8 * count;
|
||||
bot.Add(offset);
|
||||
count = 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -894,6 +894,51 @@ namespace IRaCIS.Core.API.Controllers
|
|||
#endregion
|
||||
|
||||
|
||||
[HttpGet("download/DownloadBigFileBatch")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> DownloadBigFileBatch(string fileName)
|
||||
{
|
||||
Response.ContentType = "application/zip";
|
||||
Response.Headers["Content-Disposition"] = "attachment; filename=big-file.zip";
|
||||
Response.Headers["Cache-Control"] = "no-store";
|
||||
|
||||
// ⚠️ 关键:直接用 Response.Body
|
||||
using var zip = new ZipArchive(Response.Body,ZipArchiveMode.Create,leaveOpen: true);
|
||||
|
||||
// 本地大文件路径
|
||||
var files = new[]
|
||||
{
|
||||
@$"{fileName}",
|
||||
};
|
||||
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var phyFilePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, filePath);
|
||||
|
||||
Console.WriteLine(phyFilePath);
|
||||
|
||||
var entryName = Path.GetFileName(phyFilePath);
|
||||
|
||||
var entry = zip.CreateEntry( entryName,
|
||||
CompressionLevel.Fastest); // 大文件建议 Fastest
|
||||
|
||||
await using var entryStream = entry.Open();
|
||||
await using var fileStream = new FileStream(
|
||||
filePath,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.Read,
|
||||
bufferSize: 1024 * 64, // 64KB buffer
|
||||
useAsync: true);
|
||||
|
||||
await fileStream.CopyToAsync(entryStream);
|
||||
}
|
||||
|
||||
return new EmptyResult(); // 必须
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost("download/PatientStudyBatchDownload")]
|
||||
public async Task<IActionResult> DownloadPatientStudyBatch([FromServices] IPatientService _patientService, [FromServices] IOSSService _oSSService,
|
||||
[FromServices] IHubContext<DownloadHub, IDownloadClient> _downLoadHub,
|
||||
|
|
@ -1032,6 +1077,10 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
// 获取 Pixel Data 标签
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
|
||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||
|
||||
var originOffsetTable = frag.OffsetTable;
|
||||
//获取像素是否为封装形式
|
||||
var syntax = dicomFile.Dataset.InternalTransferSyntax;
|
||||
|
||||
|
|
@ -1046,6 +1095,8 @@ namespace IRaCIS.Core.API.Controllers
|
|||
var frameData = pixelData.GetFrame(n);
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(frameData.Data));
|
||||
}
|
||||
|
||||
newFragments.OffsetTable.AddRange(originOffsetTable.ToArray());
|
||||
// 替换原有的片段序列
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue