diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index afa48f485..636c02fd1 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -94,6 +94,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var errorPathList = new List(); + var batchId = Guid.NewGuid(); + foreach (var item in idPathList) { var path = item.Path; @@ -106,14 +108,18 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var prefix = path.Substring(1, path.LastIndexOf('/') - 1); - var maskPath = path.Contains(".MaskDicom") ? $"{Path.GetFileName(path)}" : $"{Path.GetFileName(path)}.MaskDicom"; + //每次都用一个新的名字 + var maskFileName = $"{Path.GetFileName(path)}.{batchId}_MaskDicom"; - //清理缓存的里面的遮盖图,多次遮盖同一张图时,清除缓存很重要 - await _oSSService.DeleteFromPrefix(maskPath, true); + if (path.Contains("_MaskDicom")) + { + //清理缓存的里面的遮盖图,多次遮盖同一张图时,清除缓存很重要 + await _oSSService.DeleteFromPrefix(path, true); //清理缓存的里面的遮盖图,多次遮盖同一张图时,清除缓存很重要 + } + + await _oSSService.UploadToOSSAsync(outPutStream, prefix, maskFileName, false); - await _oSSService.UploadToOSSAsync(outPutStream, prefix, maskPath, false); - - var newPath = path.Contains(".MaskDicom") ? path : path + ".MaskDicom"; + var newPath = $"/{prefix}/{maskFileName}"; await _dicomInstanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomInstance() { Path = newPath, IsMasked = true }); } @@ -160,11 +166,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc foreach (var item in idPathList) { - if (item.Path.EndsWith(".MaskDicom")) + if (item.Path.EndsWith("_MaskDicom")) { - var newPath = item.Path[..^10]; + await _oSSService.DeleteFromPrefix(item.Path, true); - //await _oSSService.DeleteFromPrefix(newPath, true); + var length = Guid.Empty.ToString().Length + "_MaskDicom".Length; + var newPath = item.Path[..^length]; await _dicomInstanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomInstance() { Path = newPath, IsMasked = false }); }