上线1.2 数据维护测试

IRC_NewDev
hang 2023-12-11 13:24:41 +08:00
parent f4fc3dfab9
commit 3f714dd030
3 changed files with 113 additions and 11 deletions

View File

@ -93,7 +93,9 @@ namespace IRaCIS.Core.Application.Helper
public void DownLoadFromOSS(string ossRelativePath, string localFilePath); public void DownLoadFromOSS(string ossRelativePath, string localFilePath);
public AliyunOSSOptions _OSSConfig { get; set; }
public OssClient _ossClient { get; set; }
} }
public class OSSService : IOSSService public class OSSService : IOSSService
{ {

View File

@ -13896,6 +13896,12 @@
<param name="outEnrollTime"></param> <param name="outEnrollTime"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Application.Services.TestService.OldLocalImageResizeJpg(IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository,Microsoft.AspNetCore.Hosting.IWebHostEnvironment)">
<summary>
维护OSS 影像数据
</summary>
<returns></returns>
</member>
<member name="M:IRaCIS.Application.Services.TestService.ModifyClinicalDataTable"> <member name="M:IRaCIS.Application.Services.TestService.ModifyClinicalDataTable">
<summary> <summary>
维护临床数据 --一定要在同步表前同步数据才行 维护临床数据 --一定要在同步表前同步数据才行

View File

@ -1,5 +1,7 @@
using BeetleX; using Aliyun.OSS;
using BeetleX;
using BeetleX.BNR; using BeetleX.BNR;
using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
@ -15,7 +17,9 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MiniExcelLibs; using MiniExcelLibs;
using Minio; using Minio;
using NPOI.HPSF;
using NPOI.POIFS.Crypt; using NPOI.POIFS.Crypt;
using Spire.Doc;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -62,6 +66,96 @@ namespace IRaCIS.Application.Services
//_cache = cache; //_cache = cache;
} }
/// <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 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();
foreach (var studyitem in studyList)
{
var relativePath = $"{studyitem.TrialId}/{studyitem.SiteId}/{studyitem.SubjectId}/{studyitem.SubjectVisitId}/{StaticData.Folder.DicomFolder}/{studyitem.Id}/";
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 jpgInfoList = objectListing.ObjectSummaries
.Where(summary => summary.Key.EndsWith(".jpg"))
.Select(summary =>
{
string fileName = summary.Key.Split('/').Last(); // 提取文件夹名
return new
{
Key = summary.Key,
InstanceId = Guid.TryParse(
fileName.Split('.')[0],
out Guid instanceId)
? instanceId
: Guid.Empty
};
})
.Where(info => info.InstanceId != Guid.Empty)
.ToList();
foreach ( var jpg in jpgInfoList)
{
var seriesId= _repository.Where<DicomInstance>(t=>t.Id==jpg.InstanceId).Select(t=>t.SeriesId).FirstOrDefault();
await _repository.BatchUpdateAsync<DicomSeries>(t => t.Id == seriesId, t => new DicomSeries() { ImageResizePath ="/" +jpg.Key });
}
// 设置 NextMarker 以获取下一页的数据
nextMarker = objectListing.NextMarker;
} while (!string.IsNullOrEmpty(nextMarker));
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
await _repository.SaveChangesAsync();
}
return ResponseOutput.Ok();
}
public async Task<IResponseOutput> TestEFcore8()
{
await _dicRepository._dbContext.Subject.Where(t => t.Id == Guid.Empty).ExecuteUpdateAsync(t => t
.SetProperty(c => EF.Property<DateTime>(c, "UpdateTime"), u => DateTime.Now)
.SetProperty(c => c.FirstName, u => "NewUserName"));
await _repository.BatchUpdateAsync<Subject>(t => t.Id == Guid.Empty, u => new Subject() { FirstName = "fddd", LastName = "sss" });
return ResponseOutput.Ok();
}
// 设置 Ne
[AllowAnonymous] [AllowAnonymous]
public async Task<IResponseOutput> TestMinIO([FromServices] IOptionsMonitor<ObjectStoreServiceOptions> options) public async Task<IResponseOutput> TestMinIO([FromServices] IOptionsMonitor<ObjectStoreServiceOptions> options)
{ {