维护dir,方便下载
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
c7d4159302
commit
0ee3010e04
|
|
@ -1042,6 +1042,8 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
var dicomDirPath = $"{patient.PatientIdStr}/{studyTime}_{modalitysStr}/DICOMDIR";
|
var dicomDirPath = $"{patient.PatientIdStr}/{studyTime}_{modalitysStr}/DICOMDIR";
|
||||||
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
||||||
|
|
||||||
|
Log.Logger.Warning($"DIRPath: {study.StudyDIRPath}");
|
||||||
|
|
||||||
await using (var entryStream = dicomDirEntry.Open())
|
await using (var entryStream = dicomDirEntry.Open())
|
||||||
await using (var dirStream = await _oSSService.GetStreamFromOSSAsync(study.StudyDIRPath))
|
await using (var dirStream = await _oSSService.GetStreamFromOSSAsync(study.StudyDIRPath))
|
||||||
{
|
{
|
||||||
|
|
@ -1151,6 +1153,11 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
// ✅ HttpConnection.ContentLengthReadStream 已知问题
|
// ✅ HttpConnection.ContentLengthReadStream 已知问题
|
||||||
Log.Logger.Warning($"Stream aborted: {ex.Message}");
|
Log.Logger.Warning($"Stream aborted: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// ✅ HttpConnection.ContentLengthReadStream 已知问题
|
||||||
|
Log.Logger.Warning($"异常: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
return new EmptyResult();
|
return new EmptyResult();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using Aliyun.OSS;
|
using Aliyun.OSS;
|
||||||
|
using FellowOakDicom;
|
||||||
|
using FellowOakDicom.Imaging;
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.BusinessFilter;
|
using IRaCIS.Core.Application.BusinessFilter;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
|
|
@ -52,6 +54,70 @@ namespace IRaCIS.Core.Application.Service
|
||||||
ILogger<TestService> _logger, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
|
ILogger<TestService> _logger, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
|
||||||
{
|
{
|
||||||
public static int IntValue = 100;
|
public static int IntValue = 100;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 维护dir 需求新增的字段
|
||||||
|
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trialId"></param>
|
||||||
|
/// <param name="_instanceRepository"></param>
|
||||||
|
/// <param name="_studyRepository"></param>
|
||||||
|
/// <param name="_seriesRepository"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IResponseOutput> TrialImageAddExtralField(Guid trialId,
|
||||||
|
[FromServices] IRepository<DicomInstance> _instanceRepository,
|
||||||
|
[FromServices] IRepository<DicomStudy> _studyRepository,
|
||||||
|
[FromServices] IOSSService _oSSService,
|
||||||
|
[FromServices] IRepository<DicomSeries> _seriesRepository)
|
||||||
|
{
|
||||||
|
// UPDATE DicomStudy
|
||||||
|
//SET DicomStudyDate = CONVERT(char(8), StudyTime, 112), --yyyyMMdd
|
||||||
|
// DicomStudyTime = REPLACE(CONVERT(char(8), StudyTime, 108), ':', ''); --HHmmss
|
||||||
|
// where DicomStudyDate = ''
|
||||||
|
|
||||||
|
|
||||||
|
//instance 找到传输语法为空的,然后分组
|
||||||
|
var seriesList = _instanceRepository.Where(t => t.TrialId == trialId && t.TransferSyntaxUID == "")
|
||||||
|
//按照序列 和 NumberOfFrames 分组
|
||||||
|
.GroupBy(t => new { t.NumberOfFrames, t.SeriesId })
|
||||||
|
// 每个分组 取数据最小的一条
|
||||||
|
.Select(g => new { g.Key.SeriesId, g.Key.NumberOfFrames, g.OrderBy(t => t.FileSize).First().Path }).ToList();
|
||||||
|
|
||||||
|
foreach (var item in seriesList)
|
||||||
|
{
|
||||||
|
var stream = await _oSSService.GetStreamFromOSSAsync(item.Path);
|
||||||
|
|
||||||
|
var dicomFile = DicomFile.Open(stream);
|
||||||
|
|
||||||
|
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||||
|
|
||||||
|
//获取像素是否为封装形式
|
||||||
|
var syntax = dicomFile.Dataset.InternalTransferSyntax;
|
||||||
|
|
||||||
|
//读取需要维护的值
|
||||||
|
var transferSyntaxUID = dicomFile.FileMetaInfo.GetSingleValueOrDefault(DicomTag.TransferSyntaxUID, string.Empty);
|
||||||
|
var mediaStorageSOPClassUID = dicomFile.FileMetaInfo.GetSingleValueOrDefault(DicomTag.MediaStorageSOPClassUID, string.Empty);
|
||||||
|
var mediaStorageSOPInstanceUID = dicomFile.FileMetaInfo.GetSingleValueOrDefault(DicomTag.MediaStorageSOPInstanceUID, string.Empty);
|
||||||
|
var sOPClassUID = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.SOPClassUID, string.Empty);
|
||||||
|
|
||||||
|
//维护序列层级四个字段 后再用sql 维护study series 时间拆分 和 MediaStorageSOPInstanceUID
|
||||||
|
await _instanceRepository.BatchUpdateNoTrackingAsync(t => t.SeriesId == item.SeriesId, t => new DicomInstance()
|
||||||
|
{
|
||||||
|
IsEncapsulated = syntax.IsEncapsulated,
|
||||||
|
TransferSyntaxUID = transferSyntaxUID,
|
||||||
|
MediaStorageSOPClassUID = mediaStorageSOPClassUID,
|
||||||
|
SOPClassUID = sOPClassUID,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理一致性分析任务
|
/// 清理一致性分析任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue