影像汇总修改
continuous-integration/drone/push Build is running Details

Test_IRC_Net8
hang 2025-08-07 15:37:21 +08:00
parent a13917bded
commit 2c3f35c26b
4 changed files with 76 additions and 15 deletions

View File

@ -389,14 +389,12 @@ public class OSSService : IOSSService
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken); var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
// 上传文件
var result = _ossClient.GetObject(aliConfig.BucketName, ossRelativePath); var result = _ossClient.GetObject(aliConfig.BucketName, ossRelativePath);
// 将下载的文件流保存到本地文件 // 将下载的文件流保存到本地文件
using (var fs = File.OpenWrite(localFilePath)) using (var fs = File.OpenWrite(localFilePath))
{ {
result.Content.CopyTo(fs); await result.Content.CopyToAsync(fs);
fs.Close();
} }
} }

View File

@ -180,21 +180,50 @@ namespace IRaCIS.Core.Application.Service
} }
#region 异步方式处理
const int batchSize = 15;
int totalCount = downloadJobs.Count; int totalCount = downloadJobs.Count;
int downloadedCount = 0; int downloadedCount = 0;
for (int i = 0; i < downloadJobs.Count; i += batchSize) foreach (var job in downloadJobs)
{ {
var batch = downloadJobs.Skip(i).Take(batchSize).Select(job => job()); try
{
await job();
}
catch (Exception ex)
{
Console.WriteLine($"下载失败: {ex.Message}");
}
await Task.WhenAll(batch); downloadedCount++;
downloadedCount += batch.Count(); // 每处理50个输出一次进度或最后一个时也输出
if (downloadedCount % 50 == 0 || downloadedCount == totalCount)
Console.WriteLine($"已下载 {downloadedCount} / {totalCount} 个文件,完成 {(downloadedCount * 100.0 / totalCount):F2}%"); {
Console.WriteLine($"已下载 {downloadedCount} / {totalCount} 个文件,完成 {(downloadedCount * 100.0 / totalCount):F2}%");
}
} }
#endregion
#region 多线程测试
//const int batchSize = 15;
//int totalCount = downloadJobs.Count;
//int downloadedCount = 0;
//for (int i = 0; i < downloadJobs.Count; i += batchSize)
//{
// var batch = downloadJobs.Skip(i).Take(batchSize).Select(job => job());
// await Task.WhenAll(batch);
// downloadedCount += batch.Count();
// Console.WriteLine($"已下载 {downloadedCount} / {totalCount} 个文件,完成 {(downloadedCount * 100.0 / totalCount):F2}%");
//}
#endregion
} }
return ResponseOutput.Ok(); return ResponseOutput.Ok();

View File

@ -612,6 +612,9 @@ namespace IRaCIS.Core.Application.Contracts
public bool IsKeyImage { get; set; } public bool IsKeyImage { get; set; }
// true 导出阅片null 就是所有影像
public bool? IsExportReading { get; set; }
} }
@ -655,10 +658,16 @@ namespace IRaCIS.Core.Application.Contracts
public long? TotalImageSize { get; set; } public long? TotalImageSize { get; set; }
public long? TotalReadingImageSize { get; set; }
public string TotalImageSizeStr => TotalImageSize.HasValue public string TotalImageSizeStr => TotalImageSize.HasValue
? $"{TotalImageSize.Value / 1024d / 1024d:F3} MB" ? $"{TotalImageSize.Value / 1024d / 1024d:F3} MB"
: "0.000 MB"; : "0.000 MB";
public string TotalReadingImageSizeStr => TotalReadingImageSize.HasValue
? $"{TotalReadingImageSize.Value / 1024d / 1024d:F3} MB"
: "0.000 MB";
public string ImageTypeStr => $"{(IsHaveDicom ? "DICOM" : "")}{(IsHaveNoneDicom&&IsHaveDicom?" , ":"")}{(IsHaveNoneDicom ? "Non-DICOM" : "")}"; public string ImageTypeStr => $"{(IsHaveDicom ? "DICOM" : "")}{(IsHaveNoneDicom&&IsHaveDicom?" , ":"")}{(IsHaveNoneDicom ? "Non-DICOM" : "")}";
public bool IsHaveDicom { get; set; } public bool IsHaveDicom { get; set; }
@ -710,6 +719,22 @@ namespace IRaCIS.Core.Application.Contracts
? $"{TotalImageSize.Value / SubjectVisitCount / 1024d / 1024d:F3} MB" ? $"{TotalImageSize.Value / SubjectVisitCount / 1024d / 1024d:F3} MB"
: "0.000 MB"; : "0.000 MB";
public long? TotalReadingImageSize { get; set; }
public string TotalReadingImageSizeStr => TotalReadingImageSize.HasValue
? $"{TotalReadingImageSize.Value / 1024d / 1024d:F3} MB"
: "0.000 MB";
public string SubjectReadingImageAVGSizeStr => TotalReadingImageSize.HasValue
? $"{TotalReadingImageSize.Value / SubjectCount / 1024d / 1024d:F3} MB"
: "0.000 MB";
public string SubjectVisitReadingImageAVGSizeStr => TotalReadingImageSize.HasValue
? $"{TotalReadingImageSize.Value / SubjectVisitCount / 1024d / 1024d:F3} MB"
: "0.000 MB";
} }
public class TrialImageDownloadView public class TrialImageDownloadView

View File

@ -1218,6 +1218,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
TotalImageSize = t.StudyList.SelectMany(t => t.InstanceList).Sum(t => t.FileSize) + t.NoneDicomStudyList.SelectMany(t => t.NoneDicomFileList).Sum(t => t.FileSize), TotalImageSize = t.StudyList.SelectMany(t => t.InstanceList).Sum(t => t.FileSize) + t.NoneDicomStudyList.SelectMany(t => t.NoneDicomFileList).Sum(t => t.FileSize),
TotalReadingImageSize = t.StudyList.SelectMany(t => t.InstanceList.Where(t => t.IsReading && t.DicomSerie.IsReading)).Sum(t => t.FileSize)
+ t.NoneDicomStudyList.Where(t => t.IsReading).SelectMany(t => t.NoneDicomFileList.Where(t => t.IsReading)).Sum(t => t.FileSize),
//DicomStudyCount = t.StudyList.Count(), //DicomStudyCount = t.StudyList.Count(),
//NoneDicomStudyCount = t.NoneDicomStudyList.Count(), //NoneDicomStudyCount = t.NoneDicomStudyList.Count(),
@ -1249,6 +1252,10 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
{ {
SubjectId = g.Key, SubjectId = g.Key,
VisitCount = g.Count(), VisitCount = g.Count(),
ReadingImageSize = g.SelectMany(t => t.NoneDicomStudyList.Where(t => t.IsReading)).SelectMany(t => t.NoneDicomFileList.Where(t => t.IsReading)).Sum(t => t.FileSize)
+ g.SelectMany(t => t.StudyList).SelectMany(t => t.InstanceList.Where(t => t.IsReading && t.DicomSerie.IsReading)).Sum(t => t.FileSize),
ImageSize = g.SelectMany(t => t.NoneDicomStudyList).SelectMany(t => t.NoneDicomFileList).Sum(t => t.FileSize) ImageSize = g.SelectMany(t => t.NoneDicomStudyList).SelectMany(t => t.NoneDicomFileList).Sum(t => t.FileSize)
+ g.SelectMany(t => t.StudyList).SelectMany(t => t.InstanceList).Sum(t => t.FileSize) + g.SelectMany(t => t.StudyList).SelectMany(t => t.InstanceList).Sum(t => t.FileSize)
@ -1261,7 +1268,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
var totalImageSize = subjectImageList.Sum(t => t.ImageSize); var totalImageSize = subjectImageList.Sum(t => t.ImageSize);
return ResponseOutput.Ok(new TrialImageStatInfo { SubjectCount = subjectCount, SubjectVisitCount = subjectVisitCount, TotalImageSize = totalImageSize }); return ResponseOutput.Ok(new TrialImageStatInfo { SubjectCount = subjectCount, SubjectVisitCount = subjectVisitCount, TotalImageSize = totalImageSize,Tot });
} }
@ -1275,6 +1282,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public async Task<IResponseOutput> GetExportSubjectVisitImageList(TrialExportImageCommand inCommand) public async Task<IResponseOutput> GetExportSubjectVisitImageList(TrialExportImageCommand inCommand)
{ {
var isExportReading = inCommand.IsExportReading == true;
if (inCommand.IsKeyImage) if (inCommand.IsKeyImage)
{ {
var downloadInfoList = _visitTaskRepository.Where(t => t.TrialId == inCommand.TrialId && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) var downloadInfoList = _visitTaskRepository.Where(t => t.TrialId == inCommand.TrialId && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global)
@ -1538,11 +1547,11 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
u.StudyTime, u.StudyTime,
u.StudyCode, u.StudyCode,
SeriesList = u.SeriesList.Select(z => new SeriesList = u.SeriesList.Where(t => isExportReading ? t.IsReading : true).Select(z => new
{ {
z.Modality, z.Modality,
InstancePathList = z.DicomInstanceList.Select(k => new InstancePathList = z.DicomInstanceList.Where(t => isExportReading ? t.IsReading : true).Select(k => new
{ {
k.Path k.Path
}) })
@ -1550,13 +1559,13 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}), }),
NoneDicomStudyList = sv.NoneDicomStudyList.Select(nd => new NoneDicomStudyList = sv.NoneDicomStudyList.Where(t => isExportReading ? t.IsReading : true).Select(nd => new
{ {
nd.Modality, nd.Modality,
nd.StudyCode, nd.StudyCode,
nd.ImageDate, nd.ImageDate,
FileList = nd.NoneDicomFileList.Select(file => new FileList = nd.NoneDicomFileList.Where(t => isExportReading ? t.IsReading : true).Select(file => new
{ {
file.FileName, file.FileName,
file.Path, file.Path,