下载压缩包 加入标准层级
parent
49554ae764
commit
7d81cb72ee
|
|
@ -1350,50 +1350,57 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
using var zip = new ZipArchive(responseStream, ZipArchiveMode.Create, leaveOpen: true);
|
using var zip = new ZipArchive(responseStream, ZipArchiveMode.Create, leaveOpen: true);
|
||||||
var existingEntryPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
var existingEntryPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
foreach (var item in data)
|
foreach (var criterion in data)
|
||||||
{
|
{
|
||||||
abortToken.ThrowIfCancellationRequested();
|
abortToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var folderName =
|
var criterionFolderName = SanitizePathSegment(criterion.CriterionName, "UnknownCriterion");
|
||||||
$"{SanitizePathSegment(item.SubjectCode, "UnknownSubject")}_{SanitizePathSegment(item.VisitName, "UnknownVisit")}";
|
|
||||||
|
|
||||||
foreach (var reportUrl in item.ReportUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
|
foreach (var item in criterion.ReadingReportAndImageList)
|
||||||
{
|
{
|
||||||
abortToken.ThrowIfCancellationRequested();
|
abortToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
try
|
var folderName =
|
||||||
{
|
$"{criterionFolderName}/{SanitizePathSegment(item.SubjectCode, "UnknownSubject")}_{SanitizePathSegment(item.VisitName, "UnknownVisit")}";
|
||||||
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();
|
foreach (var reportUrl in item.ReportUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
|
||||||
await using var source = await _oSSService.GetStreamFromOSSAsync(reportUrl);
|
{
|
||||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
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)))
|
foreach (var imageUrl in item.ImageUrlList.Where(x => !string.IsNullOrWhiteSpace(x)))
|
||||||
{
|
|
||||||
abortToken.ThrowIfCancellationRequested();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var fileName = GetEntryFileName(imageUrl, "Image", existingEntryPaths.Count + 1);
|
abortToken.ThrowIfCancellationRequested();
|
||||||
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
|
|
||||||
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
|
|
||||||
|
|
||||||
await using var entryStream = entry.Open();
|
try
|
||||||
await using var source = await _oSSService.GetStreamFromOSSAsync(imageUrl);
|
{
|
||||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
var fileName = GetEntryFileName(imageUrl, "Image", existingEntryPaths.Count + 1);
|
||||||
}
|
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
|
||||||
catch (Exception ex)
|
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
|
||||||
{
|
|
||||||
Log.Logger.Warning($"处理阅片图片文件{imageUrl}失败: {ex.Message}");
|
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}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
public List<Guid> VisitTaskIdList { get; set; } = new List<Guid>() { };
|
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
|
public class ReadingReportAndImage
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
public interface IReadingImageTaskService
|
public interface IReadingImageTaskService
|
||||||
{
|
{
|
||||||
Task<List<ReadingReportAndImage>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto);
|
Task<List<ReadingReportAndImageCriterion>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto);
|
||||||
Task<IResponseOutput> SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto);
|
Task<IResponseOutput> SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto);
|
||||||
|
|
||||||
Task<IResponseOutput> SubmitJudgeVisitTaskResult(SaveJudgeVisitTaskResult inDto);
|
Task<IResponseOutput> SubmitJudgeVisitTaskResult(SaveJudgeVisitTaskResult inDto);
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<List<ReadingReportAndImage>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto)
|
public async Task<List<ReadingReportAndImageCriterion>> GetReadingReportAndImage(GetReadingReportAndImageInDto inDto)
|
||||||
{
|
{
|
||||||
var taskList=new List<VisitTask> { };
|
var taskList=new List<VisitTask> { };
|
||||||
|
|
||||||
|
|
@ -88,7 +88,12 @@ namespace IRaCIS.Core.Application.Service
|
||||||
throw new BusinessValidationFailedException(_localizer["ReadingImage_ReportDataInvalid"]);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -96,68 +101,91 @@ namespace IRaCIS.Core.Application.Service
|
||||||
.Include(x => x.LesionList)
|
.Include(x => x.LesionList)
|
||||||
.Include(x => x.Subject)
|
.Include(x => x.Subject)
|
||||||
.Include(x => x.SourceSubjectVisit)
|
.Include(x => x.SourceSubjectVisit)
|
||||||
|
.Include(x=>x.TrialReadingCriterion)
|
||||||
.ToListAsync();
|
.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,
|
CriterionName = criterion.CriterionName,
|
||||||
VisitName = item.SourceSubjectVisit != null ? item.SourceSubjectVisit.VisitName : string.Empty,
|
ReadingReportAndImageList = new List<ReadingReportAndImage>() { }
|
||||||
ImageUrlList = item.LesionList != null ? item.LesionList.Where(x => x.PicturePath != string.Empty).Select(x => x.PicturePath).ToList() : new List<string>() { },
|
|
||||||
ReportUrlList = new List<string>()
|
|
||||||
{
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
ReadingReportAndImage data = new ReadingReportAndImage()
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
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.ReportExportUrl != string.Empty)
|
||||||
{
|
{
|
||||||
|
data.ReportUrlList.Add(item.ReportExportUrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
}
|
|
||||||
|
|
||||||
if (item.TumorEvaluationUrl != string.Empty)
|
|
||||||
{
|
|
||||||
data.ReportUrlList.Add(item.TumorEvaluationUrl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
data.ReportUrlList.Add(await _readingCalculateService.GetTumorEvaluationReportUrl(new CaGetVisitReadReportUrl()
|
try
|
||||||
{
|
{
|
||||||
VisitTaskId = item.Id,
|
data.ReportUrlList.Add(await _readingCalculateService.GetVisitReadReportUrl(new CaGetVisitReadReportUrl()
|
||||||
}));
|
{
|
||||||
|
VisitTaskId = item.Id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue