下载压缩包 加入标准层级

Test_HIR_Net8
he 2026-05-28 15:41:04 +08:00
parent 49554ae764
commit 7d81cb72ee
4 changed files with 120 additions and 79 deletions

View File

@ -1350,50 +1350,57 @@ namespace IRaCIS.Core.API.Controllers
using var zip = new ZipArchive(responseStream, ZipArchiveMode.Create, leaveOpen: true);
var existingEntryPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var item in data)
foreach (var criterion in data)
{
abortToken.ThrowIfCancellationRequested();
var folderName =
$"{SanitizePathSegment(item.SubjectCode, "UnknownSubject")}_{SanitizePathSegment(item.VisitName, "UnknownVisit")}";
var criterionFolderName = SanitizePathSegment(criterion.CriterionName, "UnknownCriterion");
foreach (var reportUrl in item.ReportUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
foreach (var item in criterion.ReadingReportAndImageList)
{
abortToken.ThrowIfCancellationRequested();
try
{
var fileName = GetEntryFileName(reportUrl, "Report", existingEntryPaths.Count + 1);
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
var folderName =
$"{criterionFolderName}/{SanitizePathSegment(item.SubjectCode, "UnknownSubject")}_{SanitizePathSegment(item.VisitName, "UnknownVisit")}";
await using var entryStream = entry.Open();
await using var source = await _oSSService.GetStreamFromOSSAsync(reportUrl);
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
foreach (var reportUrl in item.ReportUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
{
abortToken.ThrowIfCancellationRequested();
try
{
var fileName = GetEntryFileName(reportUrl, "Report", existingEntryPaths.Count + 1);
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
await using var entryStream = entry.Open();
await using var source = await _oSSService.GetStreamFromOSSAsync(reportUrl);
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
catch (Exception ex)
{
Log.Logger.Warning($"处理阅片报告文件{reportUrl}失败: {ex.Message}");
}
}
catch (Exception ex)
{
Log.Logger.Warning($"处理阅片报告文件{reportUrl}失败: {ex.Message}");
}
}
foreach (var imageUrl in item.ImageUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
{
abortToken.ThrowIfCancellationRequested();
try
foreach (var imageUrl in item.ImageUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
{
var fileName = GetEntryFileName(imageUrl, "Image", existingEntryPaths.Count + 1);
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
abortToken.ThrowIfCancellationRequested();
await using var entryStream = entry.Open();
await using var source = await _oSSService.GetStreamFromOSSAsync(imageUrl);
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
catch (Exception ex)
{
Log.Logger.Warning($"处理阅片图片文件{imageUrl}失败: {ex.Message}");
try
{
var fileName = GetEntryFileName(imageUrl, "Image", existingEntryPaths.Count + 1);
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
await using var entryStream = entry.Open();
await using var source = await _oSSService.GetStreamFromOSSAsync(imageUrl);
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
catch (Exception ex)
{
Log.Logger.Warning($"处理阅片图片文件{imageUrl}失败: {ex.Message}");
}
}
}
}

View File

@ -298,6 +298,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public List<Guid> VisitTaskIdList { get; set; } = new List<Guid>() { };
}
public class ReadingReportAndImageCriterion
{
public string CriterionName { get; set; }
public List<ReadingReportAndImage> ReadingReportAndImageList { get; set; } = new List<ReadingReportAndImage>();
}
public class ReadingReportAndImage
{
/// <summary>

View File

@ -12,7 +12,7 @@ namespace IRaCIS.Core.Application.Contracts
{
public interface IReadingImageTaskService
{
Task<List<ReadingReportAndImage>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto);
Task<List<ReadingReportAndImageCriterion>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto);
Task<IResponseOutput> SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto);
Task<IResponseOutput> SubmitJudgeVisitTaskResult(SaveJudgeVisitTaskResult inDto);

View File

@ -77,7 +77,7 @@ namespace IRaCIS.Core.Application.Service
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<List<ReadingReportAndImage>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto)
public async Task<List<ReadingReportAndImageCriterion>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto)
{
var taskList=new List<VisitTask> { };
@ -88,7 +88,12 @@ namespace IRaCIS.Core.Application.Service
throw new BusinessValidationFailedException(_localizer["ReadingImage_ReportDataInvalid"]);
}
taskList=await _visitTaskRepository.Where(x => inDto.VisitTaskIdList.Contains(x.Id)&&x.ReadingCategory==ReadingCategory.Visit).Include(x=>x.LesionList).Include(x=>x.Subject).Include(x=>x.SourceSubjectVisit).ToListAsync();
taskList=await _visitTaskRepository.Where(x => inDto.VisitTaskIdList.Contains(x.Id)&&x.ReadingCategory==ReadingCategory.Visit)
.Include(x=>x.LesionList)
.Include(x=>x.Subject)
.Include(x=>x.SourceSubjectVisit)
.Include(x => x.TrialReadingCriterion)
.ToListAsync();
}
else
{
@ -96,68 +101,91 @@ namespace IRaCIS.Core.Application.Service
.Include(x => x.LesionList)
.Include(x => x.Subject)
.Include(x => x.SourceSubjectVisit)
.Include(x=>x.TrialReadingCriterion)
.ToListAsync();
}
List< ReadingReportAndImage > result = new List<ReadingReportAndImage>() { };
foreach (var item in taskList)
List<ReadingReportAndImageCriterion> imageCriteriaList = new List<ReadingReportAndImageCriterion>();
var trialReadingCriterionList = taskList.Select(x => x.TrialReadingCriterion).Distinct().ToList();
foreach (var criterion in trialReadingCriterionList)
{
ReadingReportAndImage data = new ReadingReportAndImage()
ReadingReportAndImageCriterion imageCriterion = new ReadingReportAndImageCriterion()
{
SubjectCode = item.Subject != null ? item.Subject.Code : string.Empty,
VisitName = item.SourceSubjectVisit != null ? item.SourceSubjectVisit.VisitName : string.Empty,
ImageUrlList = item.LesionList != null ? item.LesionList.Where(x => x.PicturePath != string.Empty).Select(x => x.PicturePath).ToList() : new List<string>() { },
ReportUrlList = new List<string>()
{
},
CriterionName = criterion.CriterionName,
ReadingReportAndImageList = new List<ReadingReportAndImage>() { }
};
if (item.ReportExportUrl != string.Empty)
var criterionTaskList = taskList.Where(x => x.TrialReadingCriterionId == criterion.Id).ToList();
foreach (var item in criterionTaskList)
{
data.ReportUrlList.Add(item.ReportExportUrl);
}
else
{
try
ReadingReportAndImage data = new ReadingReportAndImage()
{
data.ReportUrlList.Add(await _readingCalculateService.GetVisitReadReportUrl(new CaGetVisitReadReportUrl()
SubjectCode = item.Subject != null ? item.Subject.Code : string.Empty,
VisitName = item.SourceSubjectVisit != null ? item.SourceSubjectVisit.VisitName : string.Empty,
ImageUrlList = item.LesionList != null ? item.LesionList.Where(x => x.PicturePath != string.Empty).Select(x => x.PicturePath).ToList() : new List<string>() { },
ReportUrlList = new List<string>()
{
VisitTaskId = item.Id,
}));
}
catch (Exception)
{
},
};
}
}
if (item.TumorEvaluationUrl != string.Empty)
{
data.ReportUrlList.Add(item.TumorEvaluationUrl);
}
else
{
try
if (item.ReportExportUrl != string.Empty)
{
data.ReportUrlList.Add(await _readingCalculateService.GetTumorEvaluationReportUrl(new CaGetVisitReadReportUrl()
data.ReportUrlList.Add(item.ReportExportUrl);
}
else
{
try
{
data.ReportUrlList.Add(await _readingCalculateService.GetVisitReadReportUrl(new CaGetVisitReadReportUrl()
{
VisitTaskId = item.Id,
}));
}
catch (Exception)
{
VisitTaskId = item.Id,
}));
}
catch (Exception)
{
}
}
if (item.TumorEvaluationUrl != string.Empty)
{
data.ReportUrlList.Add(item.TumorEvaluationUrl);
}
else
{
try
{
data.ReportUrlList.Add(await _readingCalculateService.GetTumorEvaluationReportUrl(new CaGetVisitReadReportUrl()
{
VisitTaskId = item.Id,
}));
}
catch (Exception)
{
}
}
imageCriterion.ReadingReportAndImageList.Add(data);
}
result.Add(data);
imageCriteriaList.Add(imageCriterion);
}
return result;
return imageCriteriaList;
}
/// <summary>