From e3ee1a42fb83c600eb340c2062d89f58dc05a9ca Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 1 Aug 2024 10:12:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9dicom=20=E8=8E=B7=E5=8F=96tag?= =?UTF-8?q?=E5=80=BC=20patientId=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRC.Core.SCP/Service/DicomArchiveService.cs | 2 +- IRC.Core.SCP/Service/OSSService.cs | 47 +++++--- IRC.Core.SCP/appsettings.Prod_IRC_SCP.json | 1 + IRC.Core.SCP/appsettings.Test_IRC_SCP.json | 1 + IRC.Core.SCP/appsettings.Uat_IRC_SCP.json | 1 + IRaCIS.Core.Application/Helper/OSSService.cs | 105 ++++++++++-------- .../IRaCIS.Core.Application.xml | 40 +++++++ 7 files changed, 132 insertions(+), 65 deletions(-) diff --git a/IRC.Core.SCP/Service/DicomArchiveService.cs b/IRC.Core.SCP/Service/DicomArchiveService.cs index 8632cd4e8..ee456af4a 100644 --- a/IRC.Core.SCP/Service/DicomArchiveService.cs +++ b/IRC.Core.SCP/Service/DicomArchiveService.cs @@ -57,7 +57,7 @@ namespace IRaCIS.Core.SCP.Service string seriesInstanceUid = dataset.GetString(DicomTag.SeriesInstanceUID); string sopInstanceUid = dataset.GetString(DicomTag.SOPInstanceUID); - string patientIdStr = dataset.GetString(DicomTag.PatientID); + string patientIdStr = dataset.GetSingleValueOrDefault(DicomTag.PatientID,string.Empty); //Guid patientId= IdentifierHelper.CreateGuid(patientIdStr); Guid studyId = IdentifierHelper.CreateGuid(studyInstanceUid,trialId.ToString()); diff --git a/IRC.Core.SCP/Service/OSSService.cs b/IRC.Core.SCP/Service/OSSService.cs index cfbe4b3f8..eb34ec64f 100644 --- a/IRC.Core.SCP/Service/OSSService.cs +++ b/IRC.Core.SCP/Service/OSSService.cs @@ -13,6 +13,7 @@ using System.Linq; using System.Security.AccessControl; using System.Text; using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace IRaCIS.Core.SCP { @@ -37,6 +38,9 @@ namespace IRaCIS.Core.SCP public string regionId { get; set; } public string accessKeyId { get; set; } public string accessKeySecret { get; set; } + + public string internalEndpoint { get; set; } + public string endPoint { get; set; } public string bucketName { get; set; } @@ -93,7 +97,7 @@ namespace IRaCIS.Core.SCP public interface IOSSService { - public Task UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName,bool isFileNameAddGuid=true); + public Task UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true); public Task UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true); public Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath); @@ -121,12 +125,12 @@ namespace IRaCIS.Core.SCP /// /// /// + /// /// public async Task UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true) { - - - var ossRelativePath = isFileNameAddGuid? $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}": $"{oosFolderPath}/{fileRealName}"; + var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}" : $"{oosFolderPath}/{fileRealName}"; + //var ossRelativePath = $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}"; //var ossRelativePath = oosFolderPath + "/" + fileRealName; try @@ -144,7 +148,7 @@ namespace IRaCIS.Core.SCP { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); @@ -195,7 +199,7 @@ namespace IRaCIS.Core.SCP catch (Exception ex) { - throw new BusinessValidationFailedException($"上传发生异常:{ex.Message}"); ; + throw new BusinessValidationFailedException($"上传发生异常:{ex.Message}"); } @@ -218,7 +222,8 @@ namespace IRaCIS.Core.SCP { var localFileName = Path.GetFileName(localFilePath); - var ossRelativePath = isFileNameAddGuid? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}"; + var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}"; + //var ossRelativePath = oosFolderPath + "/" + localFileName; @@ -227,7 +232,7 @@ namespace IRaCIS.Core.SCP { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 上传文件 var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, localFilePath); @@ -273,6 +278,7 @@ namespace IRaCIS.Core.SCP } + public async Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath) { @@ -285,7 +291,7 @@ namespace IRaCIS.Core.SCP { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 上传文件 var result = _ossClient.GetObject(aliConfig.bucketName, ossRelativePath); @@ -346,7 +352,7 @@ namespace IRaCIS.Core.SCP } - public async Task GetSignedUrl(string ossRelativePath) + public async Task GetSignedUrl(string ossRelativePath) { ossRelativePath = ossRelativePath.TrimStart('/'); try @@ -357,7 +363,7 @@ namespace IRaCIS.Core.SCP { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.endPoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 生成签名URL。 var req = new GeneratePresignedUriRequest(aliConfig.bucketName, ossRelativePath, SignHttpMethod.Get) @@ -378,10 +384,6 @@ namespace IRaCIS.Core.SCP .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) .Build(); - //var reqParams = new Dictionary(StringComparer.Ordinal) - // { - // { "response-content-type", "application/json" } - // }; var args = new PresignedGetObjectArgs() .WithBucket(minIOConfig.bucketName) @@ -407,7 +409,19 @@ namespace IRaCIS.Core.SCP .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) .Build(); - return string.Empty; + var args = new PresignedGetObjectArgs() + .WithBucket(minIOConfig.bucketName) + .WithObject(ossRelativePath) + .WithExpiry(3600); + + var presignedUrl = await minioClient.PresignedGetObjectAsync(args); + + Uri uri = new Uri(presignedUrl); + + string relativePath = uri.PathAndQuery; + + + return relativePath; } else { @@ -424,4 +438,5 @@ namespace IRaCIS.Core.SCP } + } diff --git a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json index 32ee00af6..6def61882 100644 --- a/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Prod_IRC_SCP.json @@ -10,6 +10,7 @@ "ObjectStoreUse": "AliyunOSS", "AliyunOSS": { "regionId": "cn-shanghai", + "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", "endpoint": "https://oss-cn-shanghai.aliyuncs.com", "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", diff --git a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json index aa6c2223b..4122b7ecf 100644 --- a/IRC.Core.SCP/appsettings.Test_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Test_IRC_SCP.json @@ -10,6 +10,7 @@ "ObjectStoreUse": "AliyunOSS", "AliyunOSS": { "regionId": "cn-shanghai", + "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", "endPoint": "https://oss-cn-shanghai.aliyuncs.com", "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", diff --git a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json index f50eedf66..9079082c4 100644 --- a/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json +++ b/IRC.Core.SCP/appsettings.Uat_IRC_SCP.json @@ -10,6 +10,7 @@ "ObjectStoreUse": "MinIO", "AliyunOSS": { "regionId": "cn-shanghai", + "internalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com", "endpoint": "https://oss-cn-shanghai.aliyuncs.com", "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 175367992..a50c92da3 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -1,11 +1,9 @@ using Aliyun.OSS; -using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Infrastructure; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Minio.DataModel.Args; using Minio; -using NPOI.HPSF; using SharpCompress.Common; using System; using System.Collections.Generic; @@ -15,6 +13,7 @@ using System.Linq; using System.Security.AccessControl; using System.Text; using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace IRaCIS.Core.Application.Helper { @@ -134,66 +133,76 @@ namespace IRaCIS.Core.Application.Helper //var ossRelativePath = $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}"; //var ossRelativePath = oosFolderPath + "/" + fileRealName; - using (var memoryStream = new MemoryStream()) + try { - fileStream.Seek(0, SeekOrigin.Begin); - - fileStream.CopyTo(memoryStream); - - memoryStream.Seek(0, SeekOrigin.Begin); - - - if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS") + using (var memoryStream = new MemoryStream()) { - var aliConfig = ObjectStoreServiceOptions.AliyunOSS; + fileStream.Seek(0, SeekOrigin.Begin); - var _ossClient = new OssClient(aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + fileStream.CopyTo(memoryStream); + + memoryStream.Seek(0, SeekOrigin.Begin); + + + if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS") + { + var aliConfig = ObjectStoreServiceOptions.AliyunOSS; + + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); - // 上传文件 - var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, memoryStream); + // 上传文件 + var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, memoryStream); - } - else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO") - { - var minIOConfig = ObjectStoreServiceOptions.MinIO; + } + else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO") + { + var minIOConfig = ObjectStoreServiceOptions.MinIO; - var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}") - .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) - .Build(); + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}") + .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) + .Build(); - var putObjectArgs = new PutObjectArgs() - .WithBucket(minIOConfig.bucketName) - .WithObject(ossRelativePath) - .WithStreamData(memoryStream) - .WithObjectSize(memoryStream.Length); + var putObjectArgs = new PutObjectArgs() + .WithBucket(minIOConfig.bucketName) + .WithObject(ossRelativePath) + .WithStreamData(memoryStream) + .WithObjectSize(memoryStream.Length); - await minioClient.PutObjectAsync(putObjectArgs); - } - else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS") - { - var minIOConfig = ObjectStoreServiceOptions.AWS; + await minioClient.PutObjectAsync(putObjectArgs); + } + else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS") + { + var minIOConfig = ObjectStoreServiceOptions.AWS; - var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}") - .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) - .Build(); + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}") + .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) + .Build(); - var putObjectArgs = new PutObjectArgs() - .WithBucket(minIOConfig.bucketName) - .WithObject(ossRelativePath) - .WithStreamData(memoryStream) - .WithObjectSize(memoryStream.Length); + var putObjectArgs = new PutObjectArgs() + .WithBucket(minIOConfig.bucketName) + .WithObject(ossRelativePath) + .WithStreamData(memoryStream) + .WithObjectSize(memoryStream.Length); - await minioClient.PutObjectAsync(putObjectArgs); - } - else - { - throw new BusinessValidationFailedException("未定义的存储介质类型"); + await minioClient.PutObjectAsync(putObjectArgs); + } + else + { + throw new BusinessValidationFailedException("未定义的存储介质类型"); + } } } + catch (Exception ex) + { + + throw new BusinessValidationFailedException($"上传发生异常:{ex.Message}"); + } + + return "/" + ossRelativePath; @@ -223,7 +232,7 @@ namespace IRaCIS.Core.Application.Helper { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)? aliConfig.endPoint: aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 上传文件 var result = _ossClient.PutObject(aliConfig.bucketName, ossRelativePath, localFilePath); @@ -282,7 +291,7 @@ namespace IRaCIS.Core.Application.Helper { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 上传文件 var result = _ossClient.GetObject(aliConfig.bucketName, ossRelativePath); @@ -354,7 +363,7 @@ namespace IRaCIS.Core.Application.Helper { var aliConfig = ObjectStoreServiceOptions.AliyunOSS; - var _ossClient = new OssClient(aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); + var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.endPoint : aliConfig.internalEndpoint, aliConfig.accessKeyId, aliConfig.accessKeySecret); // 生成签名URL。 var req = new GeneratePresignedUriRequest(aliConfig.bucketName, ossRelativePath, SignHttpMethod.Get) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index add5bef1a..fa33a1f82 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1293,6 +1293,18 @@ 获取登陆用户的系统通知列表 只是过滤了用户类型 和已经发布的 + + + UserFeedBackService + + + + + 批量更新状态 + + + + 验证CRC 是否已提交 已提交 就不允许进行任何操作,如果是IQC 那么还验证是否是当前任务领取人 @@ -10244,6 +10256,15 @@ SystemNoticeAddOrEdit 列表查询参数模型 + + UserFeedBackView 列表视图模型 + + + UserFeedBackQuery 列表查询参数模型 + + + UserFeedBackAddOrEdit 列表查询参数模型 + UserLogView 列表视图模型 @@ -11101,6 +11122,11 @@ ISystemNoticeService + + + IUserFeedBackService + + IUserLogService @@ -14075,6 +14101,13 @@ 影像阅片临床数据签名 + + + 一致性分析的临床数据 + + + + 获取下拉菜单 @@ -14096,6 +14129,13 @@ + + + 获取阅片临床数据列表 + + + + 获取单个阅片临床数据的所有文件