[上传监控增加字段]
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
3dbe92a667
commit
ed01407382
|
@ -42,6 +42,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
//[JsonIgnore]
|
||||
//public int NoneDicomCode { get; set; }
|
||||
|
||||
public string RecordPath { get; set; } = string.Empty;
|
||||
public bool IsDicom { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
ArchiveFinishedTime = t.ArchiveFinishedTime,
|
||||
|
||||
|
||||
|
||||
RecordPath=t.RecordPath,
|
||||
|
||||
IsDicomReUpload = t.IsDicomReUpload,
|
||||
StudyId = t.Id,
|
||||
|
|
|
@ -371,80 +371,83 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 维护OSS 影像数据
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[AllowAnonymous]
|
||||
//[UnitOfWork]
|
||||
//public async Task<IResponseOutput> OldLocalImageResizeJpg([FromServices] IOSSService oSSService, [FromServices] IRepository _repository, [FromServices] IWebHostEnvironment _hostEnvironment)
|
||||
//{
|
||||
/// <summary>
|
||||
/// 维护OSS 影像数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> OldLocalImageResizeJpg([FromServices] IOSSService oSSService, [FromServices] IRepository _repository, [FromServices] IWebHostEnvironment _hostEnvironment)
|
||||
{
|
||||
|
||||
// var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
|
||||
var aliConfig = oSSService.ObjectStoreServiceOptions.AliyunOSS;
|
||||
var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret);
|
||||
|
||||
// var studyList = _repository.Where<DicomStudy>(t => t.SeriesList.Any(t => t.ImageResizePath.Length < 10)).Select(t => new { t.TrialId, t.SiteId, t.SubjectId, t.SubjectVisitId, t.Id }).ToList();
|
||||
var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
|
||||
|
||||
// foreach (var studyitem in studyList)
|
||||
// {
|
||||
var studyList = _repository.Where<DicomStudy>(t => t.SeriesList.Any(t => t.ImageResizePath.Length < 10)).Select(t => new { t.TrialId, t.SiteId, t.SubjectId, t.SubjectVisitId, t.Id }).ToList();
|
||||
|
||||
// var relativePath = $"{studyitem.TrialId}/{studyitem.SiteId}/{studyitem.SubjectId}/{studyitem.SubjectVisitId}/{StaticData.Folder.DicomFolder}/{studyitem.Id}/";
|
||||
foreach (var studyitem in studyList)
|
||||
{
|
||||
|
||||
// try
|
||||
// {
|
||||
// string nextMarker = null;
|
||||
// do
|
||||
// {
|
||||
// // 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
|
||||
// var objectListing = oSSService._ossClient.ListObjects(new ListObjectsRequest(oSSService._OSSConfig.bucketName)
|
||||
// {
|
||||
// Prefix = relativePath,
|
||||
// MaxKeys = 1000,
|
||||
// Marker = nextMarker
|
||||
// });
|
||||
var relativePath = $"{studyitem.TrialId}/{studyitem.SiteId}/{studyitem.SubjectId}/{studyitem.SubjectVisitId}/{StaticData.Folder.DicomFolder}/{studyitem.Id}/";
|
||||
|
||||
// var jpgInfoList = objectListing.ObjectSummaries
|
||||
// .Where(summary => summary.Key.EndsWith(".jpg"))
|
||||
// .Select(summary =>
|
||||
// {
|
||||
// string fileName = summary.Key.Split('/').Last(); // 提取文件夹名
|
||||
// return new
|
||||
// {
|
||||
try
|
||||
{
|
||||
string nextMarker = null;
|
||||
do
|
||||
{
|
||||
// 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
|
||||
var objectListing = _ossClient.ListObjects(new ListObjectsRequest(aliConfig.bucketName)
|
||||
{
|
||||
Prefix = relativePath,
|
||||
MaxKeys = 1000,
|
||||
Marker = nextMarker
|
||||
});
|
||||
|
||||
// Key = summary.Key,
|
||||
// InstanceId = Guid.TryParse(
|
||||
// fileName.Split('.')[0],
|
||||
// out Guid instanceId)
|
||||
// ? instanceId
|
||||
// : Guid.Empty
|
||||
// };
|
||||
// })
|
||||
// .Where(info => info.InstanceId != Guid.Empty)
|
||||
// .ToList();
|
||||
var jpgInfoList = objectListing.ObjectSummaries
|
||||
.Where(summary => summary.Key.EndsWith(".jpg"))
|
||||
.Select(summary =>
|
||||
{
|
||||
string fileName = summary.Key.Split('/').Last(); // 提取文件夹名
|
||||
return new
|
||||
{
|
||||
|
||||
// foreach (var jpg in jpgInfoList)
|
||||
// {
|
||||
// var seriesId = _repository.Where<DicomInstance>(t => t.Id == jpg.InstanceId).Select(t => t.SeriesId).FirstOrDefault();
|
||||
Key = summary.Key,
|
||||
InstanceId = Guid.TryParse(
|
||||
fileName.Split('.')[0],
|
||||
out Guid instanceId)
|
||||
? instanceId
|
||||
: Guid.Empty
|
||||
};
|
||||
})
|
||||
.Where(info => info.InstanceId != Guid.Empty)
|
||||
.ToList();
|
||||
|
||||
// await _repository.BatchUpdateAsync<DicomSeries>(t => t.Id == seriesId, t => new DicomSeries() { ImageResizePath = "/" + jpg.Key });
|
||||
// }
|
||||
foreach (var jpg in jpgInfoList)
|
||||
{
|
||||
var seriesId = _repository.Where<DicomInstance>(t => t.Id == jpg.InstanceId).Select(t => t.SeriesId).FirstOrDefault();
|
||||
|
||||
// // 设置 NextMarker 以获取下一页的数据
|
||||
// nextMarker = objectListing.NextMarker;
|
||||
await _repository.BatchUpdateAsync<DicomSeries>(t => t.Id == seriesId, t => new DicomSeries() { ImageResizePath = "/" + jpg.Key });
|
||||
}
|
||||
|
||||
// } while (!string.IsNullOrEmpty(nextMarker));
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"Error: {ex.Message}");
|
||||
// }
|
||||
// 设置 NextMarker 以获取下一页的数据
|
||||
nextMarker = objectListing.NextMarker;
|
||||
|
||||
// await _repository.SaveChangesAsync();
|
||||
// }
|
||||
} while (!string.IsNullOrEmpty(nextMarker));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error: {ex.Message}");
|
||||
}
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return ResponseOutput.Ok();
|
||||
//}
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in New Issue