Compare commits
253 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ee85bfa3c | |||
| 434cdf8529 | |||
| f42ebcac61 | |||
| d594c6e52a | |||
| 9bb32c8779 | |||
| 13f983bc21 | |||
| 1fa81d1e4f | |||
| 9bd090da66 | |||
| e40a9fe9cb | |||
| 3200c71996 | |||
| 88dca637c2 | |||
| c65860796b | |||
| 8ea8572947 | |||
| 82ec00e9e9 | |||
| 0af8e2f017 | |||
| f56dcb0cce | |||
| 7957a33fc4 | |||
| e150fbb807 | |||
| 32a06be96d | |||
| f6c9490124 | |||
| e84c96f4ee | |||
| c330fdc145 | |||
| d38ce06f90 | |||
| fe34788cff | |||
| 8983cb59b4 | |||
| 3179fca112 | |||
| 9ad1bbdd7d | |||
| 74844bf9ce | |||
| 6296c54e2a | |||
| 4b8d9bf7bf | |||
| 7bfb6d2c5f | |||
| 9e2cede844 | |||
| d60229fa99 | |||
| 5c29eb5860 | |||
| 9a6220bda1 | |||
| 55b75d7c32 | |||
| 0b9115f6a6 | |||
| ce49d9ed45 | |||
| 13397b0bc8 | |||
| 303bf195d2 | |||
| af1d4b3cd1 | |||
| 0fa16e2962 | |||
| 855f66566f | |||
| 913663068c | |||
| 6f05a9e456 | |||
| 5c86778902 | |||
| cfe9023ddd | |||
| 04815b9217 | |||
| 3a918f1aa5 | |||
| e3ee2cbe2f | |||
| 962f88f94d | |||
| 34f5978aea | |||
| 50576c4ba9 | |||
| b56bfcbfcf | |||
| 80cc578be9 | |||
| bb9c7066c7 | |||
| f3d70c0d12 | |||
| 372c6d5e0d | |||
| eca91b139b | |||
| 0d8626509c | |||
| e7548c08a6 | |||
| cfadc07b52 | |||
| 2f2f49c6c7 | |||
| 9a23c31313 | |||
| 27bdc95f6e | |||
| d74e3a9f60 | |||
| 10f8039b1b | |||
| f2adb16189 | |||
| d807fe0126 | |||
| fa464e6ed8 | |||
| 3c62d16ff8 | |||
| 2008a1f104 | |||
| 3716ad2f62 | |||
| 6c929043c1 | |||
| 3888b6f5d2 | |||
| b59415e461 | |||
| af160e3c96 | |||
| b5e6a81a52 | |||
| 58eb59bd61 | |||
| 104d44d757 | |||
| b29ed4d6a2 | |||
| 34008ef6db | |||
| a1dc17c582 | |||
| 01f339cb41 | |||
| 6315f1dc55 | |||
| 5df7c5c37d | |||
| dee2cae126 | |||
| 4d7ad9255a | |||
| ae5e9a75d6 | |||
| 53134ee4d2 | |||
| ea781dcd38 | |||
| 633a0bb777 | |||
| 3d83f18c71 | |||
| 89f6cd4244 | |||
| 1c154de18b | |||
| 6bb3be17ee | |||
| 8259e2fea3 | |||
| 152c5200cb | |||
| 99a1690481 | |||
| fa4564d491 | |||
| be5c25ba5f | |||
| 65e57aab7f | |||
| 5e04634837 | |||
| c9a8d7ad4c | |||
| 7c2ca13951 | |||
| ebf6c225f3 | |||
| 7083cc4493 | |||
| 711e2a53a5 | |||
| 5fd2f782c2 | |||
| 6147415cea | |||
| 6c34489aee | |||
| 1618f0454c | |||
| 1771e9731c | |||
| 1e509c0ec7 | |||
| 0d412c245f | |||
| 736266d8e8 | |||
| 05b2ab75a3 | |||
| e197a889d4 | |||
| 334e8f6267 | |||
| e430c40b99 | |||
| 1d6cb765cc | |||
| d7926a309a | |||
| cca587fb17 | |||
| 742b36ed4a | |||
| 50da5376b5 | |||
| d262057a73 | |||
| 797b076705 | |||
| 6633e26175 | |||
| 6c1c46601c | |||
| 411168be9c | |||
| efda03a0c9 | |||
| d4d632adce | |||
| 040ca6eb77 | |||
| 9bdfb355f1 | |||
| e392c436de | |||
| 294f59c4f3 | |||
| e6bdb51b5b | |||
| 5a7796939f | |||
| cad9eaf966 | |||
| 651af672f6 | |||
| 49375ec5a9 | |||
| 50f2a6a8b0 | |||
| 81280a3fed | |||
| 626de2e44a | |||
| 195d0d406c | |||
| 30ec92c805 | |||
| 9a276e3d3c | |||
| 75cceee734 | |||
| 00dcf84abe | |||
| 529033c5e4 | |||
| fecbc276c8 | |||
| f778451356 | |||
| 6b9f108fe1 | |||
| b848fbdd20 | |||
| beca7bbfc6 | |||
| a8af33a30a | |||
| 9a40cf66cc | |||
| 25f62a35ee | |||
| 24261a3dcb | |||
| 42e34b5e5c | |||
| 52f49994ab | |||
| 3f9e506d09 | |||
| 4c27e66870 | |||
| 0e909906be | |||
| 94bf9895af | |||
| b7f53f4036 | |||
| 49ffbad759 | |||
| a8f405ddc0 | |||
| 3396d73077 | |||
| 5ed24c209f | |||
| 14499009b6 | |||
| 77b2d7bed4 | |||
| 2d52102014 | |||
| 4e20a86155 | |||
| de0cb6788e | |||
| 3d8fc0776c | |||
| 38d1c2f92a | |||
| ada55aefd4 | |||
| 3bb1a9b46d | |||
| 751121e878 | |||
| 61c4d79fa1 | |||
| 22730f063c | |||
| 396244f044 | |||
| dccbe6be77 | |||
| f4fc51b66d | |||
| 7a8ec6221f | |||
| c84fed8af1 | |||
| 67216d1c92 | |||
| 24b30b1c4b | |||
| 62d065fccb | |||
| a5d1ad92c5 | |||
| bfe2478628 | |||
| dedab4e6ba | |||
| 52d1575890 | |||
| 3beac6177f | |||
| 3813b93dc5 | |||
| e0bf859cb2 | |||
| 8ac515acbd | |||
| aafc679e45 | |||
| f172a15e6e | |||
| c279733413 | |||
| 1b808595b8 | |||
| c833c88fe3 | |||
| 89fb8eac00 | |||
| 5c15967985 | |||
| 5ad84eebbf | |||
| e149a45981 | |||
| 4969e0f812 | |||
| bb7f6f3a1c | |||
| 991f1554ec | |||
| 02a1ffe8b7 | |||
| 56cbe08f39 | |||
| b048437b37 | |||
| 1353fed0ee | |||
| 8ec535be53 | |||
| 121ca01be3 | |||
| 229a83720f | |||
| 3bca306702 | |||
| 3c2701fe9d | |||
| 01058d42d3 | |||
| 59be897fd8 | |||
| 1a39d03c7e | |||
| 49eeee35bb | |||
| c1743c2934 | |||
| c906284f07 | |||
| 6427d1f5fb | |||
| 4b569e8fdb | |||
| 6b453648ee | |||
| 9cd09470d4 | |||
| 216d194d77 | |||
| 29600e9ac2 | |||
| 67fd739b0e | |||
| 083c68b528 | |||
| 121d3a3e64 | |||
| cfa38f2318 | |||
| 20f87c953c | |||
| 4f62f2f2d0 | |||
| ace5afca66 | |||
| 3dfffa557a | |||
| 2c878a90f8 | |||
| 03b5a01400 | |||
| d7e4a810f6 | |||
| 338ef9d988 | |||
| 65c67835f2 | |||
| d8d9e25191 | |||
| 3dd7859752 | |||
| 358699dbd3 | |||
| 2754973c8d | |||
| 8865db72d1 | |||
| 31158fed0e | |||
| ae624730aa | |||
| 3fd299bb49 | |||
| 9acfc4c544 |
@@ -12,8 +12,9 @@
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.5" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.416.8" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.401.81" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.21" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.5.19" />
|
||||
|
||||
<PackageReference Include="DistributedLock.Core" Version="1.0.8" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.6" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.1" />
|
||||
|
||||
@@ -118,7 +118,7 @@ public class AWSTempToken
|
||||
public string SecretAccessKey { get; set; }
|
||||
public string BucketName { get; set; }
|
||||
public string ViewEndpoint { get; set; }
|
||||
public DateTime Expiration { get; set; }
|
||||
public DateTime? Expiration { get; set; }
|
||||
}
|
||||
|
||||
public enum ObjectStoreUse
|
||||
@@ -231,8 +231,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -320,8 +320,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -397,8 +397,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -493,8 +493,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -625,8 +625,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.SCP;
|
||||
|
||||
|
||||
public class SyncFileRecoveryService(IServiceScopeFactory _scopeFactory, FileSyncQueue _fileSyncQueue) : BackgroundService
|
||||
{
|
||||
|
||||
private readonly int _pageSize = 500;
|
||||
|
||||
/// <summary>
|
||||
/// 多个程序,如果恢复同一份数据,造成重复同步,SCP服务不恢复任务
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken"></param>
|
||||
/// <returns></returns>
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
//在本地调试的时候,不干涉部署同步任务
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
||||
//using var scope = _scopeFactory.CreateScope();
|
||||
//var fileUploadRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<FileUploadRecord>>();
|
||||
|
||||
//// 延迟启动,保证主机快速启动
|
||||
//await Task.Delay(5000, stoppingToken);
|
||||
|
||||
//int page = 0;
|
||||
|
||||
|
||||
//while (!stoppingToken.IsCancellationRequested)
|
||||
//{
|
||||
// // 分页获取未入队任务
|
||||
// var pending = await fileUploadRecordRepository
|
||||
// .Where(x => x.IsNeedSync == true && (x.IsSync == false || x.IsSync == null))
|
||||
// .OrderByDescending(x => x.Priority)
|
||||
// .Select(t => new { t.Id, t.Priority })
|
||||
// .Skip(page * _pageSize)
|
||||
// .Take(_pageSize)
|
||||
// .ToListAsync(stoppingToken);
|
||||
|
||||
// if (!pending.Any())
|
||||
// break; // 扫描完毕,退出循环
|
||||
|
||||
// foreach (var file in pending)
|
||||
// {
|
||||
// //file.IsQueued = true; // 避免重复入队
|
||||
// _fileSyncQueue.Enqueue(file.Id, file.Priority ?? 0); // 放入队列
|
||||
// }
|
||||
|
||||
// page++; // 下一页
|
||||
// await Task.Delay(200, stoppingToken); // 缓解数据库压力
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class FileSyncWorker(IServiceScopeFactory _scopeFactory, ILogger<FileSyncWorker> _logger, FileSyncQueue _fileSyncQueue) : BackgroundService
|
||||
{
|
||||
|
||||
// ⭐ 自动根据服务器CPU
|
||||
private readonly int _workerCount = Math.Max(1, Environment.ProcessorCount - 1);
|
||||
|
||||
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
for (int i = 0; i < _workerCount; i++)
|
||||
Task.Run(() => WorkerLoop(stoppingToken));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
private async Task WorkerLoop(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
var id = await _fileSyncQueue.DequeueAsync(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var _fileUploadRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<FileUploadRecord>>();
|
||||
var _uploadFileSyncRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<UploadFileSyncRecord>>();
|
||||
|
||||
var syncConfig = (scope.ServiceProvider.GetRequiredService<IOptionsMonitor<ObjectStoreServiceOptions>>()).CurrentValue;
|
||||
|
||||
var oss = scope.ServiceProvider.GetRequiredService<IOSSService>();
|
||||
|
||||
var file = await _fileUploadRecordRepository.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// ✅ 不要 return
|
||||
if (file == null || file.IsNeedSync != true || syncConfig.IsOpenStoreSync == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (syncConfig.SyncConfigList.Any(t => t.UploadRegion == file.UploadRegion && t.IsOpenSync == false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//如果发现系统配置某一边同步进行了关闭,那么就直接返回,不执行任务
|
||||
if (syncConfig.SyncConfigList.Any(t => t.UploadRegion == file.UploadRegion && t.IsOpenSync == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var log = new UploadFileSyncRecord
|
||||
{
|
||||
FileUploadRecordId = id,
|
||||
StartTime = DateTime.Now,
|
||||
JobState = jobState.RUNNING
|
||||
};
|
||||
|
||||
await _uploadFileSyncRecordRepository.AddAsync(log);
|
||||
await _uploadFileSyncRecordRepository.SaveChangesAsync(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
await oss.SyncFileAsync(file.Path.TrimStart('/'), file.UploadRegion == "CN" ? ObjectStoreUse.AliyunOSS : ObjectStoreUse.AWS, file.UploadRegion == "CN" ? ObjectStoreUse.AWS : ObjectStoreUse.AliyunOSS);
|
||||
|
||||
file.IsSync = true;
|
||||
file.SyncFinishedTime = DateTime.Now;
|
||||
|
||||
log.JobState = jobState.SUCCESS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.JobState = jobState.FAILED;
|
||||
|
||||
log.Msg = ex.Message.Length > 300 ? ex.Message.Substring(0, 300) : ex.Message;
|
||||
}
|
||||
|
||||
log.EndTime = DateTime.Now;
|
||||
|
||||
await _uploadFileSyncRecordRepository.SaveChangesAsync(stoppingToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Sync failed {Id}", id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// ⭐⭐⭐ 永远执行
|
||||
_fileSyncQueue.Complete(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,28 +7,28 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.5" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.2.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="11.0.0" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.416.8" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.401.81" />
|
||||
<PackageReference Include="DistributedLock.Core" Version="1.0.8" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.6" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.4" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.4" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.4" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.21" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.5.19" />
|
||||
<PackageReference Include="DistributedLock.Core" Version="1.0.9" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.7" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.6" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.7" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Minio" Version="6.0.3" />
|
||||
<PackageReference Include="AutoMapper" Version="16.1.1" />
|
||||
<PackageReference Include="Minio" Version="7.0.0" />
|
||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.3.0">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.2" />
|
||||
<PackageReference Include="Serilog.Enrichers.ClientInfo" Version="2.1.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.ClientInfo" Version="2.9.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -63,6 +63,10 @@ builder.Host
|
||||
#region 配置服务
|
||||
var _configuration = builder.Configuration;
|
||||
|
||||
builder.Services.AddSingleton<FileSyncQueue>();
|
||||
builder.Services.AddHostedService<SyncFileRecoveryService>();
|
||||
builder.Services.AddHostedService<FileSyncWorker>();
|
||||
|
||||
//健康检查
|
||||
builder.Services.AddHealthChecks();
|
||||
|
||||
|
||||
@@ -540,12 +540,12 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
//保留原始偏移表
|
||||
|
||||
if (originOffsetTable.Count == pixelData.NumberOfFrames)
|
||||
{
|
||||
newFragments.OffsetTable.AddRange(originOffsetTable.ToArray());
|
||||
//if (originOffsetTable.Count == pixelData.NumberOfFrames)
|
||||
//{
|
||||
// newFragments.OffsetTable.AddRange(originOffsetTable.ToArray());
|
||||
|
||||
}
|
||||
else
|
||||
//}
|
||||
//else
|
||||
{
|
||||
newFragments.OffsetTable.AddRange(bot.ToArray());
|
||||
|
||||
@@ -644,7 +644,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
ms.Position = 0;
|
||||
|
||||
//irc 从路径最后一截取Guid
|
||||
storeRelativePath = await ossService.UploadToOSSAsync(ms, ossFolderPath, instanceId.ToString(), false);
|
||||
storeRelativePath = await ossService.UploadToOSSAsync(ms, ossFolderPath, instanceId.ToString(), false, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = _trialId, BatchDataType = BatchDataType.PACSReceive });
|
||||
|
||||
fileSize = ms.Length;
|
||||
|
||||
@@ -674,7 +674,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
// 上传缩略图到 OSS
|
||||
|
||||
var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, $"{seriesId.ToString()}_{instanceId.ToString()}.preview.jpg", false);
|
||||
var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, $"{seriesId.ToString()}_{instanceId.ToString()}.preview.jpg", false, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = _trialId, BatchDataType = BatchDataType.PACSReceive });
|
||||
|
||||
|
||||
series.ImageResizePath = seriesPath;
|
||||
|
||||
@@ -69,6 +69,8 @@ public static class CacheKeys
|
||||
public static string UserMFAVerifyPass(Guid userId, string browserFingerprint) => $"UserMFAVerifyPass:{userId}:{browserFingerprint}";
|
||||
|
||||
public static string TrialSiteInfo(Guid trialSiteId) => $"{trialSiteId}TrialSiteInfo";
|
||||
|
||||
public static string TrialDataStoreType(Guid trialId) => $"TrialDataStoreType:{trialId}";
|
||||
}
|
||||
|
||||
public static class CacheHelper
|
||||
|
||||
@@ -204,6 +204,12 @@ namespace IRaCIS.Core.SCP.Service
|
||||
AcquisitionNumber = dataset.GetSingleValueOrDefault(DicomTag.AcquisitionNumber, string.Empty),
|
||||
TriggerTime = dataset.GetSingleValueOrDefault(DicomTag.TriggerTime, string.Empty),
|
||||
|
||||
RadionuclideTotalDose= dataset.GetSingleValueOrDefault(DicomTag.RadionuclideTotalDose, string.Empty),
|
||||
|
||||
RadionuclideHalfLife= dataset.GetSingleValueOrDefault(DicomTag.RadionuclideHalfLife, string.Empty),
|
||||
RadiopharmaceuticalStartTime = dataset.GetSingleValueOrDefault(DicomTag.RadiopharmaceuticalStartTime, string.Empty),
|
||||
|
||||
|
||||
Manufacturer = dataset.GetSingleValueOrDefault(DicomTag.Manufacturer, string.Empty),
|
||||
ManufacturerModelName = dataset.GetSingleValueOrDefault(DicomTag.ManufacturerModelName, string.Empty),
|
||||
DeviceSerialNumber = dataset.GetSingleValueOrDefault(DicomTag.DeviceSerialNumber, string.Empty),
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:15:17Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using AutoMapper;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using IRaCIS.Core.SCP;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Drawing;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service;
|
||||
|
||||
public class FileUploadRecordAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
public string FileType { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
|
||||
public string UploadBatchId { get; set; }
|
||||
public BatchDataType BatchDataType { get; set; }
|
||||
|
||||
public string StudyCode { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
public Guid? SubjectVisitId { get; set; }
|
||||
|
||||
public Guid? DicomStudyId { get; set; }
|
||||
|
||||
public Guid? NoneDicomStudyId { get; set; }
|
||||
|
||||
|
||||
|
||||
public string FileMarkId { get; set; }
|
||||
|
||||
public int? Priority { get; set; }
|
||||
public string IP { get; set; }
|
||||
public bool? IsNeedSync { get; set; }
|
||||
public string UploadRegion { get; set; }
|
||||
public string TargetRegion { get; set; }
|
||||
}
|
||||
public interface IFileUploadRecordService
|
||||
{
|
||||
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateFileUploadRecord(FileUploadRecordAddOrEdit addOrEditFileUploadRecord);
|
||||
|
||||
}
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class FileUploadRecordService(IRepository<FileUploadRecord> _fileUploadRecordRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IOptionsMonitor<ObjectStoreServiceOptions> options,
|
||||
IFusionCache _fusionCache, IRepository<Trial> _trialRepository, FileSyncQueue _fileSyncQueue) : BaseService, IFileUploadRecordService
|
||||
{
|
||||
|
||||
ObjectStoreServiceOptions ObjectStoreServiceConfig = options.CurrentValue;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateFileUploadRecord(FileUploadRecordAddOrEdit addOrEditFileUploadRecord)
|
||||
{
|
||||
|
||||
addOrEditFileUploadRecord.IP = _userInfo.IP;
|
||||
|
||||
if (ObjectStoreServiceConfig.IsOpenStoreSync && _userInfo.Domain.IsNotNullOrEmpty())
|
||||
{
|
||||
var find = ObjectStoreServiceConfig.SyncConfigList.FirstOrDefault(t => t.Domain == _userInfo.Domain);
|
||||
if (find != null)
|
||||
{
|
||||
addOrEditFileUploadRecord.UploadRegion = find.UploadRegion;
|
||||
addOrEditFileUploadRecord.TargetRegion = find.TargetRegion;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//前后端调试的时候,上传的时候域名不对应,自动按照后端配置设置上传区域和同步区域
|
||||
var apiDefalut = ObjectStoreServiceConfig.SyncConfigList.FirstOrDefault(t => t.UploadRegion == ObjectStoreServiceConfig.ApiDeployRegion);
|
||||
|
||||
if (apiDefalut != null)
|
||||
{
|
||||
addOrEditFileUploadRecord.UploadRegion = apiDefalut.UploadRegion;
|
||||
addOrEditFileUploadRecord.TargetRegion = apiDefalut.TargetRegion;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addOrEditFileUploadRecord.TrialId != null)
|
||||
{
|
||||
|
||||
var trialDataStore = await _fusionCache.GetOrSetAsync(CacheKeys.TrialDataStoreType(addOrEditFileUploadRecord.TrialId.Value), async _ =>
|
||||
{
|
||||
return await _trialRepository.Where(t => t.Id == addOrEditFileUploadRecord.TrialId).Select(t => t.TrialDataStoreType)
|
||||
.FirstOrDefaultAsync();
|
||||
},
|
||||
TimeSpan.FromDays(7)
|
||||
);
|
||||
|
||||
//项目配置了,那么就设置需要同步
|
||||
if (trialDataStore == TrialDataStore.MUtiCenter)
|
||||
{
|
||||
addOrEditFileUploadRecord.IsNeedSync = true;
|
||||
|
||||
addOrEditFileUploadRecord.Priority = 0;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
addOrEditFileUploadRecord.IsNeedSync = false;
|
||||
|
||||
//addOrEditFileUploadRecord.TargetRegion = "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//系统文件,默认同步
|
||||
addOrEditFileUploadRecord.IsNeedSync = true;
|
||||
|
||||
addOrEditFileUploadRecord.Priority = 0;
|
||||
}
|
||||
|
||||
var entity = await _fileUploadRecordRepository.InsertOrUpdateAsync(addOrEditFileUploadRecord, true);
|
||||
|
||||
if (addOrEditFileUploadRecord.IsNeedSync == true)
|
||||
{
|
||||
_fileSyncQueue.Enqueue(entity.Id, addOrEditFileUploadRecord.Priority ?? 0);
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public sealed class FileSyncQueue
|
||||
{
|
||||
/// <summary>
|
||||
/// 优先级队列(仅负责排序)
|
||||
/// </summary>
|
||||
private readonly PriorityQueue<Guid, int> _queue = new();
|
||||
|
||||
/// <summary>
|
||||
/// 当前等待中的任务(唯一真实数据)
|
||||
/// key = Guid
|
||||
/// value = 最新 priority
|
||||
/// </summary>
|
||||
private readonly Dictionary<Guid, int> _waiting = new();
|
||||
|
||||
/// <summary>
|
||||
/// 正在执行的任务(防止重复执行)
|
||||
/// </summary>
|
||||
private readonly HashSet<Guid> _running = new();
|
||||
|
||||
/// <summary>
|
||||
/// worker 等待信号
|
||||
/// </summary>
|
||||
private readonly SemaphoreSlim _signal = new(0);
|
||||
|
||||
|
||||
private readonly object _lock = new();
|
||||
|
||||
// ============================================================
|
||||
// Enqueue
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 入队(同 Guid 会覆盖优先级)
|
||||
/// </summary>
|
||||
public void Enqueue(Guid id, int priority)
|
||||
{
|
||||
bool needSignal = false;
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
// 如果正在执行,忽略(防止重复)
|
||||
if (_running.Contains(id))
|
||||
return;
|
||||
|
||||
// 是否新任务(用于减少 signal 风暴)
|
||||
if (!_waiting.ContainsKey(id))
|
||||
needSignal = true;
|
||||
|
||||
// 更新为最新优先级(最后一次为准)
|
||||
_waiting[id] = priority; //等价于添加或者更新
|
||||
|
||||
// PriorityQueue 无法更新节点
|
||||
// 允许旧节点存在,Dequeue 时过滤
|
||||
_queue.Enqueue(id, -priority);
|
||||
}
|
||||
|
||||
// 只有新增任务才唤醒 worker
|
||||
if (needSignal)
|
||||
_signal.Release();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Dequeue
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个待执行任务(无任务时自动等待)
|
||||
/// </summary>
|
||||
public async Task<Guid> DequeueAsync(CancellationToken ct)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
await _signal.WaitAsync(ct);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
while (_queue.Count > 0)
|
||||
{
|
||||
var id = _queue.Dequeue();
|
||||
|
||||
// 已被覆盖或取消
|
||||
if (!_waiting.TryGetValue(id, out _))
|
||||
continue;
|
||||
|
||||
// 标记为运行中
|
||||
_waiting.Remove(id);
|
||||
_running.Add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Complete
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 任务执行完成(必须调用)
|
||||
/// </summary>
|
||||
public void Complete(Guid id)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_running.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Snapshot
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 当前等待中的任务快照
|
||||
/// </summary>
|
||||
public Guid[] Snapshot()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _waiting.Keys.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 状态信息(调试用)
|
||||
// ============================================================
|
||||
|
||||
public int WaitingCount
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _waiting.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int RunningCount
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _running.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1369
-105
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
"AliyunOSS": {
|
||||
"RegionId": "cn-shanghai",
|
||||
"InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
|
||||
"EndPoint": "https://oss-cn-shanghai.aliyuncs.com",
|
||||
"AccessKeyId": "LTAI5tFUCCmz5TwghZHsj45Y",
|
||||
"AccessKeySecret": "8evrBy1fVfzJG25i67Jm0xqn9Xcw2T",
|
||||
"RoleArn": "acs:ram::1078130221702011:role/uat-oss-access",
|
||||
"BucketName": "tl-med-irc-event-store",
|
||||
"ViewEndpoint": "https://tl-med-irc-event-store.oss-cn-shanghai.aliyuncs.com",
|
||||
"Region": "oss-cn-shanghai",
|
||||
"DurationSeconds": 7200
|
||||
}
|
||||
},
|
||||
|
||||
"ConnectionStrings": {
|
||||
"RemoteNew": "Server=101.132.253.119,1435;Database=irc_Prpd_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=101.132.253.119,1435;Database=irc_Hangfire_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
|
||||
},
|
||||
|
||||
"DicomSCPServiceConfig": {
|
||||
"CalledAEList": [
|
||||
"STORESCP"
|
||||
],
|
||||
"ServerPort": 11112
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ using Microsoft.Extensions.Options;
|
||||
using Org.BouncyCastle.Tls;
|
||||
using RestSharp;
|
||||
using RestSharp.Authenticators;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -137,9 +138,14 @@ namespace IRaCIS.Api.Controllers
|
||||
public async Task<IResponseOutput> GetObjectStoreTokenAsync([FromServices] IOptionsMonitor<ObjectStoreServiceOptions> options, [FromServices] IOSSService _oSSService)
|
||||
{
|
||||
|
||||
var result = _oSSService.GetObjectStoreTempToken();
|
||||
var domain = HttpContext.Request.Host.Host;
|
||||
|
||||
//result.AWS = await GetAWSTemToken(options.CurrentValue);
|
||||
|
||||
var result = _oSSService.GetObjectStoreTempToken(domain);
|
||||
|
||||
|
||||
|
||||
Log.Logger.Information($"使用域名:{domain}请求token.返回{result.ToJsonStr()}");
|
||||
|
||||
return ResponseOutput.Ok(result);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
ITrialDocumentService _trialDocumentService,
|
||||
IReadingImageTaskService _iReadingImageTaskService,
|
||||
ITrialConfigService _trialConfigService,
|
||||
IStudyService _studyService,
|
||||
IClinicalAnswerService _clinicalAnswerService,
|
||||
IReadingClinicalDataService _readingClinicalDataService,
|
||||
IQCOperationService _qCOperationService,
|
||||
@@ -146,6 +147,26 @@ namespace IRaCIS.Core.API.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修正患者基本信息
|
||||
/// </summary>
|
||||
/// <param name="opt"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Inspection/Study/AmendmentPatientInfo")]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> AmendmentPatientInfo(DataInspectionDto<EditPatientInfoCommand> opt)
|
||||
{
|
||||
|
||||
var singid = await _inspectionService.RecordSing(opt.SignInfo);
|
||||
var result = await _studyService.AmendmentPatientInfo(opt.Data);
|
||||
await _inspectionService.CompletedSign(singid, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 医学审核完成
|
||||
/// </summary>
|
||||
@@ -155,10 +176,19 @@ namespace IRaCIS.Core.API.Controllers
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> FinishMedicalReview(DataInspectionDto<FinishMedicalReviewInDto> opt)
|
||||
public async Task<IResponseOutput> FinishMedicalReview(DataInspectionDto<CloseAndFinishMedicalReview> opt)
|
||||
{
|
||||
var singid = await _inspectionService.RecordSing(opt.SignInfo);
|
||||
var result = await _readingMedicalReviewService.FinishMedicalReview(opt.Data);
|
||||
|
||||
await _readingMedicalReviewService.ClosedMedicalReviewDialog(new ClosedMedicalReviewDialogInDto() {
|
||||
DialogCloseReason=opt.Data.DialogCloseReason,
|
||||
IsClosedDialog=opt.Data.IsClosedDialog,
|
||||
MedicalDialogCloseEnum=opt.Data.MedicalDialogCloseEnum,
|
||||
TaskMedicalReviewId=opt.Data.TaskMedicalReviewId
|
||||
});
|
||||
var result = await _readingMedicalReviewService.FinishMedicalReview(new FinishMedicalReviewInDto() {
|
||||
TaskMedicalReviewId=opt.Data.TaskMedicalReviewId
|
||||
});
|
||||
await _inspectionService.CompletedSign(singid, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
@@ -598,7 +599,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
templateFileStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", realFileName);
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", realFileName, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId, BatchDataType = BatchDataType.DataReconciliation });
|
||||
|
||||
var addEntity = await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }, true);
|
||||
|
||||
@@ -856,7 +857,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
throw new BusinessValidationFailedException(_localizer["UploadDownLoad_TemplateUploadData"]);
|
||||
}
|
||||
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/SiteSurvey", realFileName);
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/SiteSurvey", realFileName, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId ,BatchDataType=BatchDataType.SiteUserSurvey});
|
||||
|
||||
await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }, true);
|
||||
|
||||
@@ -1008,7 +1009,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
Other = 6,
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.API.HostService;
|
||||
|
||||
|
||||
public class SyncFileRecoveryService(IServiceScopeFactory _scopeFactory, FileSyncQueue _fileSyncQueue) : BackgroundService
|
||||
{
|
||||
|
||||
private readonly int _pageSize = 500;
|
||||
|
||||
/// <summary>
|
||||
/// 多个程序,如果恢复同一份数据,造成重复同步,SCP服务不恢复任务
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken"></param>
|
||||
/// <returns></returns>
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
//在本地调试的时候,不干涉部署同步任务
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var fileUploadRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<FileUploadRecord>>();
|
||||
|
||||
// 延迟启动,保证主机快速启动
|
||||
await Task.Delay(5000, stoppingToken);
|
||||
|
||||
int page = 0;
|
||||
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
// 分页获取未入队任务
|
||||
var pending = await fileUploadRecordRepository
|
||||
.Where(x => x.IsNeedSync == true && (x.IsSync == false || x.IsSync == null))
|
||||
.OrderByDescending(x => x.Priority)
|
||||
.Select(t => new { t.Id, t.Priority })
|
||||
.Skip(page * _pageSize)
|
||||
.Take(_pageSize)
|
||||
.ToListAsync(stoppingToken);
|
||||
|
||||
if (!pending.Any())
|
||||
break; // 扫描完毕,退出循环
|
||||
|
||||
foreach (var file in pending)
|
||||
{
|
||||
//file.IsQueued = true; // 避免重复入队
|
||||
_fileSyncQueue.Enqueue(file.Id, file.Priority ?? 0); // 放入队列
|
||||
}
|
||||
|
||||
page++; // 下一页
|
||||
await Task.Delay(200, stoppingToken); // 缓解数据库压力
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FileSyncWorker(IServiceScopeFactory _scopeFactory, ILogger<FileSyncWorker> _logger, FileSyncQueue _fileSyncQueue) : BackgroundService
|
||||
{
|
||||
|
||||
// ⭐ 自动根据服务器CPU
|
||||
private readonly int _workerCount = Math.Max(1, Environment.ProcessorCount - 1);
|
||||
|
||||
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
for (int i = 0; i < _workerCount; i++)
|
||||
Task.Run(() => WorkerLoop(stoppingToken));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task WorkerLoop(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
var id = await _fileSyncQueue.DequeueAsync(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var _fileUploadRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<FileUploadRecord>>();
|
||||
var _uploadFileSyncRecordRepository = scope.ServiceProvider.GetRequiredService<IRepository<UploadFileSyncRecord>>();
|
||||
|
||||
var syncConfig = (scope.ServiceProvider.GetRequiredService<IOptionsMonitor<ObjectStoreServiceOptions>>()).CurrentValue;
|
||||
|
||||
var oss = scope.ServiceProvider.GetRequiredService<IOSSService>();
|
||||
|
||||
var file = await _fileUploadRecordRepository.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// ✅ 不要 return
|
||||
if (file == null || file.IsNeedSync != true || syncConfig.IsOpenStoreSync == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (syncConfig.SyncConfigList.Any(t => t.UploadRegion == file.UploadRegion && t.IsOpenSync == false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//如果发现系统配置某一边同步进行了关闭,那么就直接返回,不执行任务
|
||||
if (syncConfig.SyncConfigList.Any(t => t.UploadRegion == file.UploadRegion && t.IsOpenSync == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var log = new UploadFileSyncRecord
|
||||
{
|
||||
FileUploadRecordId = id,
|
||||
StartTime = DateTime.Now,
|
||||
JobState = jobState.RUNNING
|
||||
};
|
||||
|
||||
await _uploadFileSyncRecordRepository.AddAsync(log);
|
||||
await _uploadFileSyncRecordRepository.SaveChangesAsync(stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
await oss.SyncFileAsync(file.Path.TrimStart('/'), file.UploadRegion == "CN" ? ObjectStoreUse.AliyunOSS : ObjectStoreUse.AWS, file.UploadRegion == "CN" ? ObjectStoreUse.AWS : ObjectStoreUse.AliyunOSS);
|
||||
|
||||
file.IsSync = true;
|
||||
file.SyncFinishedTime = DateTime.Now;
|
||||
|
||||
log.JobState = jobState.SUCCESS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.JobState = jobState.FAILED;
|
||||
|
||||
log.Msg = ex.Message.Length > 300 ? ex.Message.Substring(0, 300) : ex.Message;
|
||||
}
|
||||
|
||||
log.EndTime = DateTime.Now;
|
||||
|
||||
await _uploadFileSyncRecordRepository.SaveChangesAsync(stoppingToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Sync failed {Id}", id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// ⭐⭐⭐ 永远执行
|
||||
_fileSyncQueue.Complete(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,14 @@
|
||||
<param name="opt"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.InspectionController.FinishMedicalReview(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionDto{IRaCIS.Core.Application.Service.Reading.Dto.FinishMedicalReviewInDto})">
|
||||
<member name="M:IRaCIS.Core.API.Controllers.InspectionController.AmendmentPatientInfo(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionDto{IRaCIS.Core.Application.Contracts.EditPatientInfoCommand})">
|
||||
<summary>
|
||||
修正患者基本信息
|
||||
</summary>
|
||||
<param name="opt"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.InspectionController.FinishMedicalReview(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionDto{IRaCIS.Core.Application.Service.Reading.Dto.CloseAndFinishMedicalReview})">
|
||||
<summary>
|
||||
医学审核完成
|
||||
</summary>
|
||||
@@ -344,6 +351,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.HostService.SyncFileRecoveryService.ExecuteAsync(System.Threading.CancellationToken)">
|
||||
<summary>
|
||||
多个程序,如果恢复同一份数据,造成重复同步,SCP服务不恢复任务
|
||||
</summary>
|
||||
<param name="stoppingToken"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.API.IpPolicyRateLimitSetup">
|
||||
<summary>
|
||||
IPLimit限流 启动服务
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using IRaCIS.Core.API;
|
||||
using FellowOakDicom;
|
||||
using IRaCIS.Core.API;
|
||||
using IRaCIS.Core.API.HostService;
|
||||
using IRaCIS.Core.Application.BusinessFilter;
|
||||
using IRaCIS.Core.Application.BusinessFilter.LegacyController.Database.Api;
|
||||
@@ -14,6 +15,7 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -88,6 +90,10 @@ builder.Services.ConfigureServices(_configuration);
|
||||
|
||||
builder.Services.AddHostedService<HangfireHostService>();
|
||||
|
||||
builder.Services.AddSingleton<FileSyncQueue>();
|
||||
builder.Services.AddHostedService<SyncFileRecoveryService>();
|
||||
builder.Services.AddHostedService<FileSyncWorker>();
|
||||
|
||||
//minimal api 异常处理
|
||||
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
|
||||
//builder.Services.AddProblemDetails();
|
||||
@@ -173,6 +179,7 @@ var env = app.Environment;
|
||||
|
||||
#region 配置中间件
|
||||
|
||||
DicomSetupBuilder.UseServiceProvider(app.Services);
|
||||
|
||||
app.UseMiddleware<EncryptionRequestMiddleware>();
|
||||
|
||||
|
||||
@@ -8,13 +8,21 @@ namespace IRaCIS.Core.API
|
||||
{
|
||||
public static void AddDicomSetup(this IServiceCollection services)
|
||||
{
|
||||
|
||||
// ⭐ 先做全局 DICOM 配置
|
||||
new DicomSetupBuilder()
|
||||
.RegisterServices(s => s.AddFellowOakDicom()
|
||||
.AddTranscoderManager<FellowOakDicom.Imaging.NativeCodec.NativeTranscoderManager>()
|
||||
.AddImageManager<ImageSharpImageManager>()
|
||||
)
|
||||
.SkipValidation()
|
||||
.Build();
|
||||
.SkipValidation() // 👈 在这里设置
|
||||
.Build();
|
||||
|
||||
services.AddFellowOakDicom().AddTranscoderManager<FellowOakDicom.Imaging.NativeCodec.NativeTranscoderManager>().AddImageManager<ImageSharpImageManager>();
|
||||
|
||||
// new DicomSetupBuilder()
|
||||
// .RegisterServices(s => s.AddFellowOakDicom()
|
||||
//.AddTranscoderManager<FellowOakDicom.Imaging.NativeCodec.NativeTranscoderManager>()
|
||||
// .AddImageManager<ImageSharpImageManager>()
|
||||
// )
|
||||
// .SkipValidation()
|
||||
// .Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ namespace IRaCIS.Core.API
|
||||
var dbType = configuration.GetSection("ConnectionStrings:Db_Type").Value;
|
||||
if (!string.IsNullOrWhiteSpace(dbType) && dbType == "pgsql")
|
||||
{
|
||||
options.UseNpgsql(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure());
|
||||
options.UseNpgsql(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure().CommandTimeout(90));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure()/*.CommandTimeout(60)*/);
|
||||
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure().CommandTimeout(90));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -116,6 +116,9 @@ public static class SwaggerSetup
|
||||
//DocExpansion设置为none可折叠所有方法
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
|
||||
// 开启Swagger UI的搜索/过滤功能
|
||||
options.EnableFilter();
|
||||
|
||||
//DefaultModelsExpandDepth设置为 - 1 可不显示models
|
||||
options.DefaultModelsExpandDepth(-1);
|
||||
});
|
||||
|
||||
+53
-15
@@ -10,8 +10,16 @@
|
||||
"RemoteNew": "Server=101.132.253.119,1435;Database=irc_Prpd_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=101.132.253.119,1435;Database=irc_Hangfire_bak;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
|
||||
},
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
|
||||
"AliyunOSS": {
|
||||
"RegionId": "cn-shanghai",
|
||||
"InternalEndpoint": "https://oss-cn-shanghai-internal.aliyuncs.com",
|
||||
@@ -24,13 +32,30 @@
|
||||
"Region": "oss-cn-shanghai",
|
||||
"DurationSeconds": 7200
|
||||
},
|
||||
|
||||
"MinIO": {
|
||||
"endpoint": "http://192.168.3.68",
|
||||
"port": "8001",
|
||||
"endPoint": "hir-oss.uat.extimaging.com",
|
||||
"port": "80",
|
||||
"useSSL": false,
|
||||
"accessKey": "IDFkwEpWej0b4DtiuThL",
|
||||
"secretKey": "Lhuu83yMhVwu7c1SnjvGY6lq74jzpYqifK6Qtj4h",
|
||||
"bucketName": "test"
|
||||
"viewEndpoint": "http://hir-oss.uat.extimaging.com/irc-uat",
|
||||
//"port": "443",
|
||||
//"useSSL": true,
|
||||
//"viewEndpoint": "https://hir-oss.uat.extimaging.com/irc-uat",
|
||||
"accessKey": "b9Ul0e98xPzt6PwRXA1Q",
|
||||
"secretKey": "DzMaU2L4OXl90uytwOmDXF2encN0Jf4Nxu2XkYqQ",
|
||||
"bucketName": "irc-uat"
|
||||
|
||||
},
|
||||
"AWS": {
|
||||
"Region": "us-east-1",
|
||||
"EndPoint": "s3.us-east-1.amazonaws.com",
|
||||
"UseSSL": true,
|
||||
"RoleArn": "arn:aws:iam::471112624751:role/sts_s3_upload",
|
||||
"AccessKeyId": "AKIAW3MEAFJXWRCGSX5Z",
|
||||
"SecretAccessKey": "miais4jQGSd37A+TfBEP11AQM5u/CvotSmznJd8k",
|
||||
"BucketName": "ei-med-s3-lili-uat-store",
|
||||
"ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
|
||||
"DurationSeconds": 7200
|
||||
}
|
||||
},
|
||||
|
||||
@@ -38,27 +63,26 @@
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
"OpenLoginLimit": true,
|
||||
"LoginMaxFailCount": 5,
|
||||
|
||||
"LoginFailLockMinutes": 30,
|
||||
"AutoLoginOutMinutes": 60,
|
||||
"AutoLoginOutMinutes": 120,
|
||||
|
||||
"OpenLoginMFA": false,
|
||||
|
||||
"ContinuousReadingTimeMin": 120,
|
||||
|
||||
"ReadingRestTimeMin": 10,
|
||||
|
||||
"IsNeedChangePassWord": true,
|
||||
|
||||
"ChangePassWordDays": 90,
|
||||
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 2,
|
||||
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
|
||||
},
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 465,
|
||||
@@ -66,14 +90,29 @@
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "uat@extimaging.com",
|
||||
"FromName": "UAT_IRC",
|
||||
"FromName": "Uat IRC Imaging System",
|
||||
"AuthorizationCode": "SHzyyl2021",
|
||||
"SiteUrl": "http://irc.event.extimaging.com/login",
|
||||
"SiteUrl": "http://irc.uat.extimaging.com/login",
|
||||
|
||||
"PlatformName": "EICS",
|
||||
"PlatformNameCN": "展影云平台",
|
||||
"SystemShortName": "IRC",
|
||||
"OrganizationName": "ExtImaging",
|
||||
"OrganizationNameCN": "ExtImaging",
|
||||
"CompanyName": "Extensive Imaging",
|
||||
"CompanyNameCN": "上海展影医疗科技有限公司",
|
||||
"CompanyShortName": "Extensive Imaging",
|
||||
"CompanyShortNameCN": "展影医疗",
|
||||
"IsEnv_US": false
|
||||
"IsEnv_US": false,
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "zh-CN",
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11116",
|
||||
"IP": "101.132.253.119"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
@@ -82,5 +121,4 @@
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"RemoteNew": "Server=101.132.193.237,1434;Database=Prod_IRC;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=101.132.193.237,1434;Database=Prod_IRC_Hangfire;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true"
|
||||
"RemoteNew": "Server=10.10.10.49,1434;Database=Prod_IRC;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=10.10.10.49,1434;Database=Prod_IRC_Hangfire;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true"
|
||||
//"RemoteNew": "Server=prod_mssql_standard,1433;Database=Prod_IRC;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true",
|
||||
//"Hangfire": "Server=prod_mssql_standard,1433;Database=Prod_IRC_Hangfire;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true"
|
||||
},
|
||||
@@ -16,7 +16,7 @@
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
|
||||
@@ -22,12 +22,32 @@
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
// 对象存储服务配置
|
||||
"ObjectStoreService": {
|
||||
// 使用的对象存储服务类型
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
"IsOpenStoreSync": true,
|
||||
"ApiDeployRegion": "CN",
|
||||
"SyncConfigList": [
|
||||
{
|
||||
"Domain": "irc.test.extimaging.com",
|
||||
"Primary": "AliyunOSS",
|
||||
"Target": "AWS",
|
||||
"UploadRegion": "CN",
|
||||
"TargetRegion": "US",
|
||||
"IsOpenSync": true
|
||||
},
|
||||
{
|
||||
"Domain": "lili.test.extimaging.com",
|
||||
"Primary": "AWS",
|
||||
"Target": "AliyunOSS",
|
||||
"UploadRegion": "US",
|
||||
"TargetRegion": "CN",
|
||||
"IsOpenSync": true
|
||||
}
|
||||
],
|
||||
// 阿里云对象存储服务的配置
|
||||
"AliyunOSS": {
|
||||
// 阿里云 OSS 的 Region ID
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
"ObjectStoreUse": "AWS",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
|
||||
"ObjectStoreService": {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621b97b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -112,8 +112,23 @@
|
||||
}, info: function () {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
fn: {
|
||||
opsFilter: function (taggedOps, phrase) {
|
||||
var normalPhrase = phrase.toLowerCase();
|
||||
return taggedOps.map(function (tagObj, tag) {
|
||||
var operations = tagObj.get("operations").filter(function (op) {
|
||||
var summary = op.getIn(["operation", "summary"]) || "";
|
||||
var path = op.get("path") || "";
|
||||
var tagMatch = tag.toLowerCase().indexOf(normalPhrase) !== -1;
|
||||
return tagMatch || summary.toLowerCase().indexOf(normalPhrase) !== -1 || path.toLowerCase().indexOf(normalPhrase) !== -1;
|
||||
});
|
||||
return tagObj.set("operations", operations);
|
||||
}).filter(function (tagObj) {
|
||||
return tagObj.get("operations").size > 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
+5
-5
@@ -29,11 +29,11 @@ public class TrialGlobalLimitActionFilter(IFusionCache _fusionCache, IUserInfo _
|
||||
var requestHost = context.HttpContext.Request.Host;
|
||||
|
||||
// 检查请求是否来自 localhost:6100
|
||||
//if (requestHost.Host == "localhost" && (requestHost.Port == 6100 || requestHost.Port == 3305))
|
||||
//{
|
||||
// await next();
|
||||
// return;
|
||||
//}
|
||||
if (requestHost.Host == "localhost" && (requestHost.Port == 6100 || requestHost.Port == 3305))
|
||||
{
|
||||
await next();
|
||||
return;
|
||||
}
|
||||
|
||||
#region 特殊用户类型拦截
|
||||
// 用户类型检查
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace IRaCIS.Core.Application.Helper;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper;
|
||||
|
||||
|
||||
public static class CacheKeys
|
||||
@@ -66,6 +68,10 @@ public static class CacheKeys
|
||||
|
||||
public static string UserMFATag(Guid userId) => $"UserMFAVerifyPass:{userId}";
|
||||
|
||||
public static string TrialDataStoreType(Guid trialId) => $"TrialDataStoreType:{trialId}";
|
||||
|
||||
|
||||
public static string UserQCSkipTask(Guid userId) => $"UserSKipQCTask:{userId}";
|
||||
}
|
||||
|
||||
public static class CacheHelper
|
||||
@@ -77,6 +83,9 @@ public static class CacheHelper
|
||||
return statusStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static async Task<List<SystemAnonymization>> GetSystemAnonymizationListAsync(IRepository<SystemAnonymization> _systemAnonymizationRepository)
|
||||
{
|
||||
var list = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using DocumentFormat.OpenXml.Office.CustomUI;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Media;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -58,7 +60,11 @@ namespace IRaCIS.Core.Application.Helper
|
||||
var mappings = new List<string>();
|
||||
int index = 1;
|
||||
|
||||
var studyUid=list.FirstOrDefault()?.StudyInstanceUid;
|
||||
var trialId = Guid.Empty;
|
||||
|
||||
Guid.TryParse(ossFolder.Split('/', StringSplitOptions.RemoveEmptyEntries)[0], out trialId);
|
||||
|
||||
var studyUid = list.FirstOrDefault()?.StudyInstanceUid;
|
||||
|
||||
var dicomDir = new DicomDirectory();
|
||||
|
||||
@@ -130,9 +136,9 @@ namespace IRaCIS.Core.Application.Helper
|
||||
// 重置流位置
|
||||
memoryStream.Position = 0;
|
||||
|
||||
var relativePath= await _oSSService.UploadToOSSAsync(memoryStream, ossFolder, "DICOMDIR", true);
|
||||
var relativePath = await _oSSService.UploadToOSSAsync(memoryStream, ossFolder, "DICOMDIR", true, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId, BatchDataType = BatchDataType.DICOMDIR });
|
||||
|
||||
dic.Add($"{studyUid}_DICOMDIR" , relativePath.Split('/').Last());
|
||||
dic.Add($"{studyUid}_DICOMDIR", relativePath.Split('/').Last());
|
||||
}
|
||||
|
||||
//清理临时文件
|
||||
@@ -146,7 +152,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||
var mappingText = string.Join(Environment.NewLine, mappings);
|
||||
await using var mappingStream = new MemoryStream(Encoding.UTF8.GetBytes(mappingText));
|
||||
|
||||
await _oSSService.UploadToOSSAsync(mappingStream, ossFolder, $"Download_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", false);
|
||||
await _oSSService.UploadToOSSAsync(mappingStream, ossFolder, $"Download_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}", false, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId, BatchDataType = BatchDataType.DICOMDIR });
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ using Amazon.S3;
|
||||
using Amazon.S3.Model;
|
||||
using Amazon.SecurityToken;
|
||||
using Amazon.SecurityToken.Model;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
|
||||
using MassTransit;
|
||||
@@ -16,6 +20,8 @@ using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using Serilog.Parsing;
|
||||
using SkiaSharp;
|
||||
using System.IO;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -80,6 +86,28 @@ public class ObjectStoreServiceOptions
|
||||
|
||||
public AWSOptions AWS { get; set; }
|
||||
|
||||
public bool IsOpenStoreSync { get; set; }
|
||||
|
||||
public string ApiDeployRegion { get; set; }
|
||||
|
||||
public List<SyncStoreConfig> SyncConfigList { get; set; } = new List<SyncStoreConfig>();
|
||||
|
||||
}
|
||||
|
||||
public class SyncStoreConfig
|
||||
{
|
||||
public string Domain { get; set; }
|
||||
|
||||
public string UploadRegion { get; set; }
|
||||
|
||||
public string TargetRegion { get; set; }
|
||||
|
||||
public string Primary { get; set; }
|
||||
|
||||
public string Target { get; set; }
|
||||
|
||||
public bool IsOpenSync { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ObjectStoreDTO
|
||||
@@ -93,6 +121,10 @@ public class ObjectStoreDTO
|
||||
|
||||
public AWSTempToken AWS { get; set; }
|
||||
|
||||
public bool IsOpenStoreSync { get; set; }
|
||||
|
||||
public List<SyncStoreConfig> SyncConfigList { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[LowerCamelCaseJson]
|
||||
@@ -137,6 +169,7 @@ public enum ObjectStoreUse
|
||||
AWS = 2,
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
// aws 参考链接 https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/S3/S3_Basics
|
||||
@@ -147,8 +180,8 @@ public interface IOSSService
|
||||
public Task RestoreFilesByPrefixAsync(string prefix, int restoreDays = 3, int batchSize = 100);
|
||||
|
||||
|
||||
public Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true);
|
||||
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false);
|
||||
public Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true, FileUploadRecordAddOrEdit? uploadInfo = null);
|
||||
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false, FileUploadRecordAddOrEdit? uploadInfo = null);
|
||||
|
||||
public Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath);
|
||||
|
||||
@@ -164,28 +197,30 @@ public interface IOSSService
|
||||
|
||||
List<string> GetRootFolderNames();
|
||||
|
||||
public ObjectStoreDTO GetObjectStoreTempToken();
|
||||
public ObjectStoreDTO GetObjectStoreTempToken(string? domain = null, bool? isGetAllTempToken = null, string? objectUse = null);
|
||||
|
||||
public Task MoveObject(string sourcePath, string destPath, bool overwrite = true);
|
||||
|
||||
public Task<long> GetObjectSizeAsync(string sourcePath);
|
||||
|
||||
public Task SyncFileAsync(string objectKey, ObjectStoreUse source, ObjectStoreUse destination, CancellationToken ct = default);
|
||||
|
||||
public void ConvertPrefixToStandard(string prefix);
|
||||
}
|
||||
|
||||
|
||||
public class OSSService : IOSSService
|
||||
public class OSSService(IOptionsMonitor<ObjectStoreServiceOptions> options,
|
||||
IFileUploadRecordService _fileUploadRecordService) : IOSSService
|
||||
{
|
||||
public ObjectStoreServiceOptions ObjectStoreServiceOptions { get; set; }
|
||||
public ObjectStoreServiceOptions ObjectStoreServiceOptions { get; set; } = options.CurrentValue;
|
||||
|
||||
private AliyunOSSTempToken AliyunOSSTempToken { get; set; }
|
||||
|
||||
private AWSTempToken AWSTempToken { get; set; }
|
||||
public object result { get; private set; }
|
||||
|
||||
|
||||
public OSSService(IOptionsMonitor<ObjectStoreServiceOptions> options)
|
||||
{
|
||||
ObjectStoreServiceOptions = options.CurrentValue;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将指定前缀下的所有现有文件立即转为目标存储类型
|
||||
@@ -506,8 +541,8 @@ public class OSSService : IOSSService
|
||||
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region),
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
using var client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -620,6 +655,90 @@ public class OSSService : IOSSService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将某个路径下的归档的文件 转为标准存储
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
public void ConvertPrefixToStandard(string prefix)
|
||||
{
|
||||
|
||||
BackBatchGetToken();
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
{
|
||||
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
var _ossClient = new OssClient(
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint,
|
||||
AliyunOSSTempToken.AccessKeyId,
|
||||
AliyunOSSTempToken.AccessKeySecret,
|
||||
AliyunOSSTempToken.SecurityToken
|
||||
);
|
||||
var bucketName = aliConfig.BucketName;
|
||||
|
||||
try
|
||||
{
|
||||
ObjectListing objectListing = null;
|
||||
string nextMarker = null;
|
||||
do
|
||||
{
|
||||
// 使用 prefix 模拟目录结构,设置 MaxKeys 和 NextMarker
|
||||
objectListing = _ossClient.ListObjects(new Aliyun.OSS.ListObjectsRequest(bucketName)
|
||||
{
|
||||
Prefix = prefix,
|
||||
MaxKeys = 1000,
|
||||
Marker = nextMarker
|
||||
});
|
||||
|
||||
|
||||
foreach (var obj in objectListing.ObjectSummaries)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 👇 跳过已经是标准存储的(优化)
|
||||
if (obj.StorageClass == StorageClass.Standard.ToString())
|
||||
continue;
|
||||
|
||||
var metadata = new ObjectMetadata();
|
||||
|
||||
// 👇 关键:手动加 Header
|
||||
metadata.AddHeader("x-oss-storage-class", "Standard");
|
||||
|
||||
var copyRequest = new Aliyun.OSS.CopyObjectRequest(bucketName, obj.Key, bucketName, obj.Key) { NewObjectMetadata = metadata };
|
||||
|
||||
|
||||
_ossClient.CopyObject(copyRequest);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"❌ 失败: {obj.Key}, 错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 设置 NextMarker 以获取下一页的数据
|
||||
nextMarker = objectListing.NextMarker;
|
||||
|
||||
} while (objectListing.IsTruncated);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"Error: {ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 坑方法,会清空之前的规则
|
||||
/// </summary>
|
||||
@@ -686,8 +805,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -700,6 +819,9 @@ public class OSSService : IOSSService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
|
||||
/// </summary>
|
||||
@@ -707,8 +829,9 @@ public class OSSService : IOSSService
|
||||
/// <param name="oosFolderPath"></param>
|
||||
/// <param name="fileRealName"></param>
|
||||
/// <param name="isFileNameAddGuid"></param>
|
||||
/// <param name="uploadInfo"> 只用赋值业务参数Id 和批次信息即可,其他信息不用传递</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true)
|
||||
public async Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true, FileUploadRecordAddOrEdit? uploadInfo = null)
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
@@ -716,74 +839,68 @@ public class OSSService : IOSSService
|
||||
|
||||
try
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
if (fileStream.CanSeek)
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
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, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
|
||||
// 上传文件
|
||||
var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, fileStream);
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
{
|
||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||
|
||||
|
||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
||||
.Build();
|
||||
|
||||
var putObjectArgs = new PutObjectArgs()
|
||||
.WithBucket(minIOConfig.BucketName)
|
||||
.WithObject(ossRelativePath)
|
||||
.WithStreamData(fileStream)
|
||||
.WithObjectSize(fileStream.Length);
|
||||
|
||||
await minioClient.PutObjectAsync(putObjectArgs);
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||
|
||||
|
||||
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
|
||||
|
||||
// 上传文件
|
||||
var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, memoryStream);
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
var putObjectRequest = new Amazon.S3.Model.PutObjectRequest()
|
||||
{
|
||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||
BucketName = awsConfig.BucketName,
|
||||
InputStream = fileStream,
|
||||
Key = ossRelativePath,
|
||||
};
|
||||
|
||||
|
||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
||||
.Build();
|
||||
|
||||
var putObjectArgs = new PutObjectArgs()
|
||||
.WithBucket(minIOConfig.BucketName)
|
||||
.WithObject(ossRelativePath)
|
||||
.WithStreamData(memoryStream)
|
||||
.WithObjectSize(memoryStream.Length);
|
||||
|
||||
await minioClient.PutObjectAsync(putObjectArgs);
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||
|
||||
|
||||
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
var putObjectRequest = new Amazon.S3.Model.PutObjectRequest()
|
||||
{
|
||||
BucketName = awsConfig.BucketName,
|
||||
InputStream = memoryStream,
|
||||
Key = ossRelativePath,
|
||||
};
|
||||
|
||||
await amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
await amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -793,13 +910,27 @@ public class OSSService : IOSSService
|
||||
}
|
||||
|
||||
|
||||
var returnPath = "/" + ossRelativePath;
|
||||
|
||||
|
||||
return "/" + ossRelativePath;
|
||||
if (ObjectStoreServiceOptions.IsOpenStoreSync && uploadInfo != null)
|
||||
{
|
||||
uploadInfo.FileSize = fileStream.CanSeek ? fileStream.Length : 0;
|
||||
uploadInfo.Path = returnPath;
|
||||
uploadInfo.FileName = fileRealName;
|
||||
uploadInfo.FileType = Path.GetExtension(returnPath).TrimStart('.');
|
||||
|
||||
|
||||
await _fileUploadRecordService.AddOrUpdateFileUploadRecord(uploadInfo);
|
||||
}
|
||||
|
||||
|
||||
return returnPath;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//后端批量上传 或者下载,不每个文件获取临时token
|
||||
private void BackBatchGetToken()
|
||||
{
|
||||
@@ -841,10 +972,12 @@ public class OSSService : IOSSService
|
||||
/// <param name="randomFileName">随机文件名</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false)
|
||||
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false, FileUploadRecordAddOrEdit? uploadInfo = null)
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
long fileSize = 0;
|
||||
|
||||
var localFileName = Path.GetFileName(localFilePath);
|
||||
|
||||
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
|
||||
@@ -864,6 +997,8 @@ public class OSSService : IOSSService
|
||||
// 上传文件
|
||||
var result = _ossClient.PutObject(aliConfig.BucketName, ossRelativePath, localFilePath);
|
||||
|
||||
fileSize = result.ContentLength;
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
{
|
||||
@@ -879,7 +1014,9 @@ public class OSSService : IOSSService
|
||||
.WithObject(ossRelativePath)
|
||||
.WithFileName(localFilePath);
|
||||
|
||||
await minioClient.PutObjectAsync(putObjectArgs);
|
||||
var result = await minioClient.PutObjectAsync(putObjectArgs);
|
||||
|
||||
fileSize = result.Size;
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
@@ -904,14 +1041,30 @@ public class OSSService : IOSSService
|
||||
Key = ossRelativePath,
|
||||
};
|
||||
|
||||
await amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
|
||||
var result = await amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
fileSize = result.ContentLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
return "/" + ossRelativePath;
|
||||
|
||||
var returnPath = "/" + ossRelativePath;
|
||||
|
||||
|
||||
if (ObjectStoreServiceOptions.IsOpenStoreSync && uploadInfo != null)
|
||||
{
|
||||
uploadInfo.FileSize = fileSize;
|
||||
uploadInfo.Path = returnPath;
|
||||
uploadInfo.FileName = Path.GetFileName(localFilePath);
|
||||
uploadInfo.FileType = Path.GetExtension(returnPath).TrimStart(".");
|
||||
|
||||
|
||||
await _fileUploadRecordService.AddOrUpdateFileUploadRecord(uploadInfo);
|
||||
}
|
||||
|
||||
|
||||
return returnPath;
|
||||
|
||||
}
|
||||
|
||||
@@ -920,6 +1073,13 @@ public class OSSService : IOSSService
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
// 确保目标目录存在
|
||||
string directory = Path.GetDirectoryName(localFilePath);
|
||||
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
ossRelativePath = ossRelativePath.TrimStart('/');
|
||||
try
|
||||
{
|
||||
@@ -1023,11 +1183,6 @@ public class OSSService : IOSSService
|
||||
// 直接返回流
|
||||
return result.Content;
|
||||
|
||||
//// 将OSS返回的流复制到内存流中并返回
|
||||
//var memoryStream = new MemoryStream();
|
||||
//await result.Content.CopyToAsync(memoryStream);
|
||||
//memoryStream.Position = 0; // 重置位置以便读取
|
||||
//return memoryStream;
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
{
|
||||
@@ -1076,8 +1231,8 @@ public class OSSService : IOSSService
|
||||
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -1093,10 +1248,6 @@ public class OSSService : IOSSService
|
||||
// ⭐ 直接返回流
|
||||
return response.ResponseStream;
|
||||
|
||||
//var memoryStream = new MemoryStream();
|
||||
//await response.ResponseStream.CopyToAsync(memoryStream);
|
||||
//memoryStream.Position = 0;
|
||||
//return memoryStream;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1337,8 +1488,8 @@ public class OSSService : IOSSService
|
||||
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -1440,9 +1591,36 @@ public class OSSService : IOSSService
|
||||
/// <returns></returns>
|
||||
public async Task DeleteFromPrefix(string prefix, bool isCache = false)
|
||||
{
|
||||
GetObjectStoreTempToken();
|
||||
if (prefix.StartsWith("/"))
|
||||
{
|
||||
prefix = prefix.TrimStart("/");
|
||||
}
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
//打开了同步的,删除的时候,一起删除
|
||||
if (ObjectStoreServiceOptions.IsOpenStoreSync && ObjectStoreServiceOptions.SyncConfigList.Any(t => t.IsOpenSync))
|
||||
{
|
||||
foreach (var config in ObjectStoreServiceOptions.SyncConfigList.Where(t => t.IsOpenSync))
|
||||
{
|
||||
|
||||
|
||||
GetObjectStoreTempToken(objectUse: config.Primary);
|
||||
|
||||
await DeleteFromPrefixInternal(config.Primary, prefix, isCache);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetObjectStoreTempToken();
|
||||
|
||||
await DeleteFromPrefixInternal(ObjectStoreServiceOptions.ObjectStoreUse, prefix, isCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task DeleteFromPrefixInternal(string objectUse, string prefix, bool isCache = false)
|
||||
{
|
||||
if (objectUse == "AliyunOSS")
|
||||
{
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
@@ -1498,7 +1676,7 @@ public class OSSService : IOSSService
|
||||
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
else if (objectUse == "MinIO")
|
||||
{
|
||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||
|
||||
@@ -1535,7 +1713,7 @@ public class OSSService : IOSSService
|
||||
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
else if (objectUse == "AWS")
|
||||
{
|
||||
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
@@ -1591,8 +1769,31 @@ public class OSSService : IOSSService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task DeleteObjects(List<string> objectKeys, bool isCache = false)
|
||||
{
|
||||
//打开了同步的,删除的时候,一起删除
|
||||
if (ObjectStoreServiceOptions.IsOpenStoreSync && ObjectStoreServiceOptions.SyncConfigList.Any(t => t.IsOpenSync))
|
||||
{
|
||||
foreach (var config in ObjectStoreServiceOptions.SyncConfigList.Where(t => t.IsOpenSync))
|
||||
{
|
||||
|
||||
GetObjectStoreTempToken(objectUse: config.Primary);
|
||||
|
||||
await DeleteObjectsInternal(objectKeys, isCache);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetObjectStoreTempToken();
|
||||
|
||||
await DeleteObjectsInternal(objectKeys, isCache);
|
||||
}
|
||||
}
|
||||
public async Task DeleteObjectsInternal(List<string> objectKeys, bool isCache = false)
|
||||
{
|
||||
|
||||
|
||||
GetObjectStoreTempToken();
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
@@ -1755,13 +1956,42 @@ public class OSSService : IOSSService
|
||||
|
||||
|
||||
|
||||
public ObjectStoreDTO GetObjectStoreTempToken()
|
||||
public ObjectStoreDTO GetObjectStoreTempToken(string? domain = null, bool? isGetAllTempToken = null, string? objectUse = null)
|
||||
{
|
||||
|
||||
var ossOptions = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
string objectStoreUse = string.Empty;
|
||||
//使用指定配置
|
||||
if (objectUse != null)
|
||||
{
|
||||
objectStoreUse = objectUse?.Trim() ?? string.Empty;
|
||||
}
|
||||
//根据域名动态判断
|
||||
else
|
||||
{
|
||||
//如果传递了域名,并且打开了存储同步,根据域名使用的具体存储覆盖之前的配置,否则就用固定的配置
|
||||
if (ObjectStoreServiceOptions.IsOpenStoreSync && domain.IsNotNullOrEmpty() && ObjectStoreServiceOptions.SyncConfigList.Any(t => t.Domain == domain))
|
||||
{
|
||||
|
||||
var find = ObjectStoreServiceOptions.SyncConfigList.FirstOrDefault(t => t.Domain == domain);
|
||||
if (find != null)
|
||||
{
|
||||
objectStoreUse = find.Primary;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//兜底,如果是本地测试环境,那就使用部署默认配置
|
||||
objectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var objectStoreDTO = new ObjectStoreDTO() { ObjectStoreUse = objectStoreUse, IsOpenStoreSync = ObjectStoreServiceOptions.IsOpenStoreSync, SyncConfigList = ObjectStoreServiceOptions.SyncConfigList };
|
||||
|
||||
if (objectStoreUse == "AliyunOSS" || isGetAllTempToken == true)
|
||||
{
|
||||
var ossOptions = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
var client = new Client(new AlibabaCloud.OpenApiClient.Models.Config()
|
||||
{
|
||||
AccessKeyId = ossOptions.AccessKeyId,
|
||||
@@ -1803,13 +2033,14 @@ public class OSSService : IOSSService
|
||||
|
||||
AliyunOSSTempToken = tempToken;
|
||||
|
||||
return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, AliyunOSS = tempToken };
|
||||
objectStoreDTO.AliyunOSS = tempToken;
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
if (objectStoreUse == "MinIO")
|
||||
{
|
||||
return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, MinIO = ObjectStoreServiceOptions.MinIO };
|
||||
objectStoreDTO.MinIO = ObjectStoreServiceOptions.MinIO;
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
if (objectStoreUse == "AWS" || isGetAllTempToken == true)
|
||||
{
|
||||
var awsOptions = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
@@ -1851,12 +2082,111 @@ public class OSSService : IOSSService
|
||||
};
|
||||
|
||||
AWSTempToken = tempToken;
|
||||
return new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, AWS = tempToken };
|
||||
|
||||
objectStoreDTO.AWS = tempToken;
|
||||
}
|
||||
else
|
||||
|
||||
if (objectStoreUse.IsNullOrEmpty())
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
|
||||
return objectStoreDTO;
|
||||
}
|
||||
|
||||
|
||||
public async Task SyncFileAsync(string objectKey, ObjectStoreUse source, ObjectStoreUse destination, CancellationToken ct = default)
|
||||
{
|
||||
var tempConfig = GetObjectStoreTempToken(isGetAllTempToken: true);
|
||||
|
||||
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
// ⭐ 关键变量
|
||||
IDisposable? owner = null;
|
||||
Stream sourceStream;
|
||||
long contentLength;
|
||||
|
||||
// ========= 获取流 + 长度 =========
|
||||
switch (source)
|
||||
{
|
||||
case ObjectStoreUse.AliyunOSS:
|
||||
{
|
||||
|
||||
var obj = _ossClient.GetObject(
|
||||
aliConfig.BucketName,
|
||||
objectKey);
|
||||
|
||||
owner = obj;
|
||||
sourceStream = obj.Content;
|
||||
contentLength = obj.ContentLength;
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectStoreUse.AWS:
|
||||
{
|
||||
var response = await amazonS3Client.GetObjectAsync(
|
||||
awsConfig.BucketName,
|
||||
objectKey,
|
||||
ct);
|
||||
|
||||
owner = response;
|
||||
sourceStream = response.ResponseStream;
|
||||
contentLength = response.Headers.ContentLength;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new BusinessValidationFailedException("未定义的同步类型");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// ========= 上传 =========
|
||||
if (destination == ObjectStoreUse.AWS)
|
||||
{
|
||||
var putRequest = new Amazon.S3.Model.PutObjectRequest
|
||||
{
|
||||
BucketName = awsConfig.BucketName,
|
||||
Key = objectKey,
|
||||
InputStream = sourceStream,
|
||||
Headers = { ContentLength = contentLength }
|
||||
};
|
||||
|
||||
await amazonS3Client.PutObjectAsync(putRequest, ct);
|
||||
}
|
||||
else if (destination == ObjectStoreUse.AliyunOSS)
|
||||
{
|
||||
_ossClient.PutObject(
|
||||
aliConfig.BucketName,
|
||||
objectKey,
|
||||
sourceStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的同步类型");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// ⭐⭐⭐ 真正释放 HTTP 连接
|
||||
owner?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using IdentityModel;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using IdentityModel;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper.OtherTool;
|
||||
|
||||
@@ -31,6 +32,13 @@ public static class WeComNotifier
|
||||
|
||||
public static async Task SendAlertAsync(string webhook, WeComAlert alert)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var client = new RestClient();
|
||||
|
||||
@@ -33,36 +33,36 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IdentityModel.OidcClient" Version="6.0.0" />
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.6" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.1.3" />
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.2.0" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.4.1" />
|
||||
<PackageReference Include="DocX" Version="4.0.25105.5786" />
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.21" />
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.5.19" />
|
||||
<PackageReference Include="DocX" Version="5.0.0" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.7.0" />
|
||||
<PackageReference Include="ExcelDataReader.DataSet" Version="3.7.0" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.1.0" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.6" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.2" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.2" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.4" />
|
||||
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
|
||||
<PackageReference Include="MailKit" Version="4.11.0" />
|
||||
<PackageReference Include="Masa.Contrib.Service.MinimalAPIs" Version="1.0.0" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="5.3.0" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.8.0" />
|
||||
<PackageReference Include="ExcelDataReader.DataSet" Version="3.8.0" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.1.1" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.7" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.6" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.6" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.7" />
|
||||
<PackageReference Include="IP2Region.Net" Version="3.0.2" />
|
||||
<PackageReference Include="MailKit" Version="4.15.1" />
|
||||
<PackageReference Include="Masa.Contrib.Service.MinimalAPIs" Version="1.1.0" />
|
||||
<PackageReference Include="MaxMind.GeoIP2" Version="5.4.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
|
||||
<PackageReference Include="MimeKit" Version="4.11.0" />
|
||||
<PackageReference Include="MimeKit" Version="4.15.1" />
|
||||
<PackageReference Include="MiniExcel" Version="1.41.2" />
|
||||
<PackageReference Include="Minio" Version="6.0.3" />
|
||||
<PackageReference Include="MiniWord" Version="0.9.2" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.3.0">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NPOI" Version="2.7.4" />
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.2" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
<PackageReference Include="RestSharp" Version="114.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts.DTO;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MassTransit;
|
||||
@@ -320,7 +321,7 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
join study in _studyRepository.AsQueryable() on sv.Id equals study.SubjectVisitId
|
||||
select new CheckDBModel()
|
||||
{
|
||||
SubjectStatus = sv.Subject.Status,
|
||||
SubjectStatus = sv.Subject.Status,
|
||||
SubjectVisitId = sv.Id,
|
||||
SiteCode = sv.TrialSite.TrialSiteCode,
|
||||
StudyDate = study.StudyTime == null ? string.Empty : ((DateTime)study.StudyTime).ToString("yyyy-MM-dd"),
|
||||
@@ -403,7 +404,7 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
{
|
||||
SubjectStatus = dbCurrentVisitFirst.SubjectStatus,
|
||||
CheckTime = DateTime.Now,
|
||||
CheckState=CheckStateEnum.CVPassed,
|
||||
CheckState = CheckStateEnum.CVPassed,
|
||||
SiteCode = dbCurrentVisitFirst.SiteCode,
|
||||
SubjectCode = dbCurrentVisitFirst.SubjectCode,
|
||||
VisitName = dbCurrentVisitFirst.VisitName,
|
||||
@@ -448,7 +449,7 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
|
||||
var fileStreamResult = (FileStreamResult)await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialConsistentFUllCheckList_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(FullCheckResult));
|
||||
|
||||
var ossRelativePath = await _oSSService.UploadToOSSAsync(fileStreamResult.FileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", "DataReconciliation");
|
||||
var ossRelativePath = await _oSSService.UploadToOSSAsync(fileStreamResult.FileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", "DataReconciliation", uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId, BatchDataType = BatchDataType.DataReconciliation });
|
||||
|
||||
|
||||
//var add = await _inspectionFileRepository.FindAsync(inspectionFileId);
|
||||
|
||||
@@ -703,6 +703,10 @@ public class QCClaimTaskEventConsumer(
|
||||
|
||||
|
||||
var userinfo = subjectVisit.CurrentActionUser;
|
||||
if (userinfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
|
||||
@@ -43,6 +43,9 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _trialReadingCriterionRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository,
|
||||
IRepository<Segment> _segmentRepository,
|
||||
IRepository<Segmentation> _segmentationRepository,
|
||||
IRepository<SegmentBinding> _segmentBindingRepository,
|
||||
IRepository<DicomInstance> _dicomInstanceRepository,
|
||||
IRepository<DicomSeries> _dicomSeriesRepository,
|
||||
IRepository<SubjectCanceDoctor> _subjectCanceDoctorRepository,
|
||||
@@ -2220,7 +2223,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyForms(VisitTask newTask, VisitTask origenalTask)
|
||||
private async Task CopyForms(VisitTask newTask, VisitTask origenalTask)
|
||||
{
|
||||
newTask.IsCopyLesionAnswer = true;
|
||||
//自定义
|
||||
@@ -2236,6 +2239,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
//_ = _readingCustomTagRepository.AddRangeAsync(readingCustomTagList).Result;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var readingTaskQuestionAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
|
||||
@@ -2294,6 +2298,64 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 分割
|
||||
Dictionary<Guid, Guid> segmentationRelationship = new Dictionary<Guid, Guid>() { };
|
||||
var segmentationList = _segmentationRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
|
||||
|
||||
foreach (var item in segmentationList)
|
||||
{
|
||||
|
||||
var newSegmentationId = NewId.NextSequentialGuid();
|
||||
segmentationRelationship.Add(item.Id, newSegmentationId);
|
||||
item.Id = newSegmentationId;
|
||||
item.VisitTaskId = newTask.Id;
|
||||
}
|
||||
|
||||
|
||||
Dictionary<Guid, Guid> segmentRelationship = new Dictionary<Guid, Guid>() { };
|
||||
var segmentList = _segmentRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
|
||||
foreach (var item in segmentList)
|
||||
{
|
||||
var newSegmentationId = NewId.NextSequentialGuid();
|
||||
segmentRelationship.Add(item.Id, newSegmentationId);
|
||||
if (segmentationRelationship.ContainsKey(item.SegmentationId))
|
||||
{
|
||||
item.SegmentationId = segmentationRelationship[item.SegmentationId];
|
||||
}
|
||||
item.Id = newSegmentationId;
|
||||
item.VisitTaskId = newTask.Id;
|
||||
}
|
||||
|
||||
var segmentBindingList = _segmentBindingRepository.Where(x => x.VisitTaskId == origenalTask.Id).ToList();
|
||||
|
||||
foreach (var item in segmentBindingList)
|
||||
{
|
||||
if (segmentationRelationship.ContainsKey(item.SegmentationId))
|
||||
{
|
||||
item.SegmentationId = segmentationRelationship[item.SegmentationId];
|
||||
}
|
||||
if (segmentRelationship.ContainsKey(item.SegmentId))
|
||||
{
|
||||
item.SegmentId = segmentRelationship[item.SegmentId];
|
||||
}
|
||||
|
||||
if (item.RowId != null && lesionRelationship.ContainsKey(item.RowId.Value))
|
||||
{
|
||||
item.RowId = lesionRelationship[item.RowId.Value];
|
||||
}
|
||||
item.Id = NewId.NextSequentialGuid();
|
||||
item.VisitTaskId = newTask.Id;
|
||||
}
|
||||
|
||||
|
||||
_ = _segmentationRepository.AddRangeAsync(segmentationList).Result;
|
||||
_ = _segmentRepository.AddRangeAsync(segmentList).Result;
|
||||
_ = _segmentBindingRepository.AddRangeAsync(segmentBindingList).Result;
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
foreach (var item in readingTableAnswerRowInfoList)
|
||||
{
|
||||
if (item.SplitRowId != null && lesionRelationship.ContainsKey(item.SplitRowId.Value))
|
||||
@@ -2654,6 +2716,19 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
sv.ReviewAuditUserId = null;
|
||||
sv.SecondReviewState = SecondReviewState.None;
|
||||
|
||||
|
||||
// 处理阅片期的临床数据
|
||||
var readModuleIdList =await _readModuleRepository.Where(x => x.SubjectVisitId == sv.Id).Select(x => x.Id).ToListAsync();
|
||||
|
||||
|
||||
await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => readModuleIdList.Contains(t.ReadingId), c => new ReadingClinicalData()
|
||||
{
|
||||
IsSign = false,
|
||||
ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded,
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (sv.IsBaseLine)
|
||||
{
|
||||
await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && (t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.Subject || t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit), c => new ReadingClinicalData() { IsSign = false, ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded });
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:15:31Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
public class SubjectFileUploadRecordView
|
||||
{
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
public string StudyCode { get; set; }
|
||||
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
public Guid? SubjectVisitId { get; set; }
|
||||
|
||||
public int FileCount { get; set; }
|
||||
|
||||
|
||||
public string? UploadRegion { get; set; }
|
||||
public string? TargetRegion { get; set; }
|
||||
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
public DateTime? SyncFinishedTime { get; set; }
|
||||
|
||||
public bool IsSync { get; set; }
|
||||
}
|
||||
|
||||
public class FileUploadRecordView : FileUploadRecordAddOrEdit
|
||||
{
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||
|
||||
[Comment("同步结束时间-最后一个任务的时间")]
|
||||
public DateTime? SyncFinishedTime { get; set; }
|
||||
|
||||
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class FileUploadRecordAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
public string FileType { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
|
||||
public string UploadBatchId { get; set; }
|
||||
public BatchDataType BatchDataType { get; set; }
|
||||
|
||||
public string StudyCode { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
public Guid? SubjectVisitId { get; set; }
|
||||
|
||||
public Guid? DicomStudyId { get; set; }
|
||||
|
||||
public Guid? NoneDicomStudyId { get; set; }
|
||||
|
||||
|
||||
|
||||
public string FileMarkId { get; set; }
|
||||
|
||||
public int? Priority { get; set; }
|
||||
public string IP { get; set; }
|
||||
public bool? IsNeedSync { get; set; }
|
||||
public string UploadRegion { get; set; }
|
||||
public string TargetRegion { get; set; }
|
||||
|
||||
public bool? IsSync { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SubjectFileUploadRecordQuery : PageInput
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
public string? StudyCode { get; set; }
|
||||
|
||||
public string? UploadRegion { get; set; }
|
||||
public string? TargetRegion { get; set; }
|
||||
|
||||
public bool? IsSync { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class FileUploadRecordQuery : PageInput
|
||||
{
|
||||
|
||||
public BatchDataType? BatchDataType { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
public int? DataFileType { get; set; }
|
||||
|
||||
public string StudyCode { get; set; }
|
||||
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
public Guid? SubjectVisitId { get; set; }
|
||||
|
||||
|
||||
|
||||
public string? FileMarkId { get; set; }
|
||||
|
||||
public string? FileName { get; set; }
|
||||
|
||||
|
||||
public string? FileType { get; set; }
|
||||
|
||||
public string? IP { get; set; }
|
||||
|
||||
public bool? IsNeedSync { get; set; }
|
||||
|
||||
public bool? IsSync { get; set; }
|
||||
|
||||
|
||||
public string? Path { get; set; }
|
||||
|
||||
public int? Priority { get; set; }
|
||||
|
||||
public string? TargetRegion { get; set; }
|
||||
|
||||
|
||||
public string? UploadBatchId { get; set; }
|
||||
|
||||
public string? UploadRegion { get; set; }
|
||||
|
||||
|
||||
public DateTime? SyncFinishedStartTime { get; set; }
|
||||
|
||||
public DateTime? SyncFinishedEndTime { get; set; }
|
||||
|
||||
public DateTime? UploadStartTime { get; set; }
|
||||
|
||||
public DateTime? UploadEndTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class UploadFileSyncRecordView
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public jobState JobState { get; set; }
|
||||
|
||||
|
||||
public string Msg { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||
public Guid? FileUploadRecordId { get; set; }
|
||||
public string? FileName { get; set; }
|
||||
|
||||
public string? FileType { get; set; }
|
||||
|
||||
public string? Path { get; set; }
|
||||
|
||||
|
||||
public string StudyCode { get; set; }
|
||||
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class UploadFileSyncRecordQuery : PageInput
|
||||
{
|
||||
|
||||
public Guid? FileUploadRecordId { get; set; }
|
||||
|
||||
|
||||
public jobState? JobState { get; set; }
|
||||
|
||||
public string? SubjectCode { get; set; }
|
||||
|
||||
public string? VisitName { get; set; }
|
||||
|
||||
public string? StudyCode { get; set; }
|
||||
}
|
||||
|
||||
public class BatchAddSyncFileCommand
|
||||
{
|
||||
public List<Guid> FileUploadRecordIdList { get; set; }
|
||||
|
||||
public int? Priority { get; set; }
|
||||
}
|
||||
@@ -155,7 +155,8 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||
fileStream: decodeStream,
|
||||
oosFolderPath: $"EmailAttachment/{emailInfo.Id}", // OSS 虚拟目录
|
||||
fileRealName: emaliAttachmentInfo.AttachmentName,
|
||||
isFileNameAddGuid: true); // 让方法自己在文件名前加 Guid
|
||||
isFileNameAddGuid: true,
|
||||
uploadInfo: new FileUploadRecordAddOrEdit() {TrialId= inDto.TrialId, BatchDataType = BatchDataType.EmailAttach }); // 让方法自己在文件名前加 Guid
|
||||
|
||||
attachmentInfos.Add(emaliAttachmentInfo);
|
||||
}
|
||||
|
||||
@@ -984,7 +984,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId)
|
||||
.Where(t => t.Subject.IsSubjectQuit == false || t.SubmitState >= SubmitStateEnum.ToSubmit)
|
||||
|
||||
.WhereIf(inQuery.SubjectStatus != null, t => t.Subject.Status == inQuery.SubjectStatus)
|
||||
.Where(t => t.Subject.FinalSubjectVisitId != null ? t.VisitNum <= t.Subject.FinalSubjectVisit.VisitNum : true)
|
||||
.WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
|
||||
.WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId)
|
||||
@@ -1034,7 +1034,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId)
|
||||
|
||||
.Where(t => t.Subject.IsSubjectQuit == false || t.AuditState > AuditStateEnum.ToAudit)
|
||||
|
||||
.WhereIf(inQuery.SubjectStatus != null, t => t.Subject.Status == inQuery.SubjectStatus)
|
||||
.WhereIf(inQuery.VisitId != null, t => t.Id == inQuery.VisitId)
|
||||
.WhereIf(inQuery.CurrentActionUserId != null, t => t.CurrentActionUserId == inQuery.CurrentActionUserId)
|
||||
.WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState)
|
||||
@@ -2774,7 +2774,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.IVUS_CDISC_Export, ExportCatogory = ExportResult.IVUS_CDISC_Export });
|
||||
}
|
||||
if (criterion.CriterionGroup != CriterionGroup.Tumor && criterion.CriterionType != CriterionType.OCT && criterion.CriterionType != CriterionType.IVUS)
|
||||
if (criterion.CriterionGroup != CriterionGroup.Tumor /*&& criterion.CriterionType != CriterionType.OCT && criterion.CriterionType != CriterionType.IVUS*/)
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.CDISC_Reading_Export, ExportCatogory = ExportResult.NoneTumorCDISC });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,589 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:15:17Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Spire.Doc.Interface;
|
||||
using System.Drawing;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class FileUploadRecordService(IRepository<FileUploadRecord> _fileUploadRecordRepository, IRepository<UploadFileSyncRecord> _uploadFileSyncRecordRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IOptionsMonitor<ObjectStoreServiceOptions> options,
|
||||
IFusionCache _fusionCache, IRepository<Trial> _trialRepository, FileSyncQueue _fileSyncQueue) : BaseService, IFileUploadRecordService
|
||||
{
|
||||
|
||||
ObjectStoreServiceOptions ObjectStoreServiceConfig = options.CurrentValue;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按照 subject visit studyCode 三个维度进行分组的查询列表 (subject相关)
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SubjectFileUploadRecordView>> GetSubjectUploadRecordList(SubjectFileUploadRecordQuery inQuery)
|
||||
{
|
||||
|
||||
var query = _fileUploadRecordRepository.Where(t => t.TrialId == inQuery.TrialId && t.SubjectId != null)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.VisitName), t => t.SubjectVisit.VisitName.Contains(inQuery.VisitName))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Subject.Code.Contains(inQuery.SubjectCode))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UploadRegion), t => t.UploadRegion == inQuery.UploadRegion)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.TargetRegion), t => t.TargetRegion == inQuery.TargetRegion)
|
||||
.WhereIf(inQuery.IsSync != null, t => t.IsSync == inQuery.IsSync)
|
||||
.GroupBy(t => new { t.StudyCode, SubjectCode = t.Subject.Code, t.SubjectVisit.VisitName, t.SubjectId, t.SubjectVisitId })
|
||||
.Select(g => new SubjectFileUploadRecordView()
|
||||
{
|
||||
SubjectCode = g.Key.SubjectCode,
|
||||
VisitName = g.Key.VisitName,
|
||||
StudyCode = g.Key.StudyCode,
|
||||
SubjectId = g.Key.SubjectId,
|
||||
SubjectVisitId = g.Key.SubjectVisitId,
|
||||
|
||||
FileCount = g.Count(),
|
||||
|
||||
CreateTime = g.Max(t => t.CreateTime),
|
||||
|
||||
SyncFinishedTime = g.Max(t => t.SyncFinishedTime),
|
||||
|
||||
UploadRegion = g.First().UploadRegion,
|
||||
|
||||
TargetRegion = g.First().TargetRegion,
|
||||
|
||||
IsSync = !g.Any(t => t.IsSync == false || t.IsSync == null)
|
||||
|
||||
});
|
||||
|
||||
|
||||
var pageList = await query.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上传记录表--里面包含待同步任务 DataFileType= 0 :代表系统文件 1:Subject相关 2:项目相关,但是和subject 没关系
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<FileUploadRecordView>> GetFileUploadRecordList(FileUploadRecordQuery inQuery)
|
||||
{
|
||||
|
||||
var fileUploadRecordQueryable = _fileUploadRecordRepository
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.FileName), t => t.FileName.Contains(inQuery.FileName))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.FileType), t => t.FileType.Contains(inQuery.FileType))
|
||||
.WhereIf(inQuery.TrialId != null, t => t.TrialId == inQuery.TrialId)
|
||||
|
||||
.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
|
||||
.WhereIf(inQuery.SubjectVisitId != null, t => t.SubjectVisitId == inQuery.SubjectVisitId)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.VisitName), t => t.SubjectVisit.VisitName.Contains(inQuery.VisitName))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Subject.Code.Contains(inQuery.SubjectCode))
|
||||
|
||||
.WhereIf(inQuery.DataFileType == 1 && inQuery.SubjectId != null && inQuery.SubjectVisitId == null, t => t.SubjectVisitId == null)
|
||||
.WhereIf(inQuery.DataFileType == 1 && inQuery.SubjectVisitId != null && inQuery.StudyCode == "", t => t.StudyCode == "")
|
||||
.WhereIf(inQuery.DataFileType == 1 && inQuery.SubjectCode.IsNotNullOrEmpty() && inQuery.VisitName.IsNullOrEmpty(), t => t.SubjectVisitId == null)
|
||||
.WhereIf(inQuery.DataFileType == 1 && inQuery.VisitName.IsNotNullOrEmpty() && inQuery.StudyCode == "", t => t.StudyCode == "")
|
||||
|
||||
.WhereIf(inQuery.DataFileType == 0, t => t.TrialId == null)
|
||||
.WhereIf(inQuery.DataFileType == 1, t => t.SubjectId != null)
|
||||
.WhereIf(inQuery.DataFileType == 2, t => t.SubjectId == null)
|
||||
|
||||
.WhereIf(inQuery.IsNeedSync != null, t => t.IsNeedSync == inQuery.IsNeedSync)
|
||||
|
||||
.WhereIf(inQuery.IsSync != null, t => t.IsSync == inQuery.IsSync)
|
||||
.WhereIf(inQuery.Priority != null, t => t.Priority == inQuery.Priority)
|
||||
.WhereIf(inQuery.BatchDataType != null, t => t.BatchDataType == inQuery.BatchDataType)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UploadRegion), t => t.UploadRegion == inQuery.UploadRegion)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.TargetRegion), t => t.TargetRegion == inQuery.TargetRegion)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UploadBatchId), t => t.UploadBatchId.Contains(inQuery.UploadBatchId))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Path), t => t.Path.Contains(inQuery.Path))
|
||||
.WhereIf(inQuery.UploadStartTime != null, t => t.CreateTime >= inQuery.UploadStartTime)
|
||||
.WhereIf(inQuery.UploadEndTime != null, t => t.CreateTime <= inQuery.UploadEndTime)
|
||||
.WhereIf(inQuery.SyncFinishedStartTime != null, t => t.SyncFinishedTime >= inQuery.SyncFinishedStartTime)
|
||||
.WhereIf(inQuery.SyncFinishedEndTime != null, t => t.SyncFinishedTime <= inQuery.SyncFinishedEndTime)
|
||||
|
||||
.ProjectTo<FileUploadRecordView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await fileUploadRecordQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 任务具体执行记录表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<UploadFileSyncRecordView>> GetUploadFileSyncRecordList(UploadFileSyncRecordQuery inQuery)
|
||||
{
|
||||
|
||||
var fileUploadRecordQueryable = _uploadFileSyncRecordRepository
|
||||
.WhereIf(inQuery.JobState != null, t => t.JobState == inQuery.JobState)
|
||||
.WhereIf(inQuery.FileUploadRecordId != null, t => t.FileUploadRecordId == inQuery.FileUploadRecordId)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.FileUploadRecord.StudyCode.Contains(inQuery.StudyCode))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.VisitName), t => t.FileUploadRecord.SubjectVisit.VisitName.Contains(inQuery.VisitName))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.FileUploadRecord.Subject.Code.Contains(inQuery.SubjectCode))
|
||||
|
||||
.ProjectTo<UploadFileSyncRecordView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await fileUploadRecordQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量设置为需要同步,并且设置优先级
|
||||
/// </summary>
|
||||
/// <param name="inComand"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> BatchAddSyncFileTask(BatchAddSyncFileCommand inComand)
|
||||
{
|
||||
|
||||
|
||||
await _fileUploadRecordRepository.BatchUpdateNoTrackingAsync(t => inComand.FileUploadRecordIdList.Contains(t.Id), u => new FileUploadRecord() { IsNeedSync = true, Priority = inComand.Priority ?? 0 });
|
||||
|
||||
foreach (var item in inComand.FileUploadRecordIdList)
|
||||
{
|
||||
_fileSyncQueue.Enqueue(item, inComand.Priority ?? 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
await _fileUploadRecordRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateFileUploadRecord(FileUploadRecordAddOrEdit addOrEditFileUploadRecord)
|
||||
{
|
||||
|
||||
addOrEditFileUploadRecord.IP = _userInfo.IP;
|
||||
|
||||
if (ObjectStoreServiceConfig.IsOpenStoreSync && _userInfo.Domain.IsNotNullOrEmpty())
|
||||
{
|
||||
var find = ObjectStoreServiceConfig.SyncConfigList.FirstOrDefault(t => t.Domain == _userInfo.Domain);
|
||||
if (find != null)
|
||||
{
|
||||
addOrEditFileUploadRecord.UploadRegion = find.UploadRegion;
|
||||
addOrEditFileUploadRecord.TargetRegion = find.TargetRegion;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//前后端调试的时候,上传的时候域名不对应,自动按照后端配置设置上传区域和同步区域
|
||||
var apiDefalut = ObjectStoreServiceConfig.SyncConfigList.FirstOrDefault(t => t.UploadRegion == ObjectStoreServiceConfig.ApiDeployRegion);
|
||||
|
||||
if (apiDefalut != null)
|
||||
{
|
||||
addOrEditFileUploadRecord.UploadRegion = apiDefalut.UploadRegion;
|
||||
addOrEditFileUploadRecord.TargetRegion = apiDefalut.TargetRegion;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addOrEditFileUploadRecord.TrialId != null)
|
||||
{
|
||||
|
||||
var trialDataStore = await _fusionCache.GetOrSetAsync(CacheKeys.TrialDataStoreType(addOrEditFileUploadRecord.TrialId.Value), async _ =>
|
||||
{
|
||||
return await _trialRepository.Where(t => t.Id == addOrEditFileUploadRecord.TrialId).Select(t => t.TrialDataStoreType)
|
||||
.FirstOrDefaultAsync();
|
||||
},
|
||||
TimeSpan.FromDays(7)
|
||||
);
|
||||
|
||||
//项目配置了,那么就设置需要同步
|
||||
if (trialDataStore == TrialDataStore.MUtiCenter)
|
||||
{
|
||||
addOrEditFileUploadRecord.IsNeedSync = true;
|
||||
|
||||
addOrEditFileUploadRecord.Priority = addOrEditFileUploadRecord.Priority?? 0;
|
||||
|
||||
addOrEditFileUploadRecord.IsSync = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
addOrEditFileUploadRecord.IsNeedSync = false;
|
||||
|
||||
//addOrEditFileUploadRecord.TargetRegion = "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//系统文件,默认同步
|
||||
addOrEditFileUploadRecord.IsNeedSync = true;
|
||||
|
||||
addOrEditFileUploadRecord.IsSync = false;
|
||||
|
||||
addOrEditFileUploadRecord.Priority = addOrEditFileUploadRecord.Priority ?? 0;
|
||||
}
|
||||
|
||||
var entity = await _fileUploadRecordRepository.InsertOrUpdateAsync(addOrEditFileUploadRecord, true);
|
||||
|
||||
if (addOrEditFileUploadRecord.IsNeedSync == true)
|
||||
{
|
||||
_fileSyncQueue.Enqueue(entity.Id, addOrEditFileUploadRecord.Priority ?? 0);
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpDelete("{fileUploadRecordId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteFileUploadRecord(Guid fileUploadRecordId)
|
||||
{
|
||||
var success = await _fileUploadRecordRepository.BatchDeleteNoTrackingAsync(t => t.Id == fileUploadRecordId);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region 同步队列
|
||||
|
||||
|
||||
public sealed class FileSyncQueue
|
||||
{
|
||||
/// <summary>
|
||||
/// 优先级队列(仅负责排序)
|
||||
/// </summary>
|
||||
private readonly PriorityQueue<Guid, int> _queue = new();
|
||||
|
||||
/// <summary>
|
||||
/// 当前等待中的任务(唯一真实数据)
|
||||
/// key = Guid
|
||||
/// value = 最新 priority
|
||||
/// </summary>
|
||||
private readonly Dictionary<Guid, int> _waiting = new();
|
||||
|
||||
/// <summary>
|
||||
/// 正在执行的任务(防止重复执行)
|
||||
/// </summary>
|
||||
private readonly HashSet<Guid> _running = new();
|
||||
|
||||
/// <summary>
|
||||
/// worker 等待信号
|
||||
/// </summary>
|
||||
private readonly SemaphoreSlim _signal = new(0);
|
||||
|
||||
|
||||
private readonly object _lock = new();
|
||||
|
||||
// ============================================================
|
||||
// Enqueue
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 入队(同 Guid 会覆盖优先级)
|
||||
/// </summary>
|
||||
public void Enqueue(Guid id, int priority)
|
||||
{
|
||||
bool needSignal = false;
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
// 如果正在执行,忽略(防止重复)
|
||||
if (_running.Contains(id))
|
||||
return;
|
||||
|
||||
// 是否新任务(用于减少 signal 风暴)
|
||||
if (!_waiting.ContainsKey(id))
|
||||
needSignal = true;
|
||||
|
||||
// 更新为最新优先级(最后一次为准)
|
||||
_waiting[id] = priority; //等价于添加或者更新
|
||||
|
||||
// PriorityQueue 无法更新节点
|
||||
// 允许旧节点存在,Dequeue 时过滤
|
||||
_queue.Enqueue(id, -priority);
|
||||
}
|
||||
|
||||
// 只有新增任务才唤醒 worker
|
||||
if (needSignal)
|
||||
_signal.Release();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Dequeue
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个待执行任务(无任务时自动等待)
|
||||
/// </summary>
|
||||
public async Task<Guid> DequeueAsync(CancellationToken ct)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
await _signal.WaitAsync(ct);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
while (_queue.Count > 0)
|
||||
{
|
||||
var id = _queue.Dequeue();
|
||||
|
||||
// 已被覆盖或取消 如果这个任务已经不是“当前最新版任务”,那它只是 PriorityQueue 里的垃圾数据,直接跳过。
|
||||
if (!_waiting.TryGetValue(id, out _)) //能从等待任务中取到,那么就是有效的,不能取到那么就是覆盖的
|
||||
continue;
|
||||
|
||||
// 标记为运行中
|
||||
_waiting.Remove(id);
|
||||
_running.Add(id);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Complete
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 任务执行完成(必须调用)
|
||||
/// </summary>
|
||||
public void Complete(Guid id)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_running.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Snapshot
|
||||
// ============================================================
|
||||
|
||||
/// <summary>
|
||||
/// 当前等待中的任务快照
|
||||
/// </summary>
|
||||
public Guid[] Snapshot()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _waiting.Keys.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 状态信息(调试用)
|
||||
// ============================================================
|
||||
|
||||
public int WaitingCount
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _waiting.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int RunningCount
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _running.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 同步队列 信号量
|
||||
///// </summary>
|
||||
//public class FileSyncQueue
|
||||
//{
|
||||
// private readonly PriorityQueue<Guid, int> _queue = new();
|
||||
// private readonly SemaphoreSlim _signal = new(0);
|
||||
// private readonly object _lock = new();
|
||||
|
||||
// public void Enqueue(Guid id, int priority)
|
||||
// {
|
||||
// lock (_lock)
|
||||
// {
|
||||
// // priority 越大越优先
|
||||
// _queue.Enqueue(id, -priority);
|
||||
// }
|
||||
|
||||
// //类似于计数器,不会产生通知风暴,可消费资源 +1
|
||||
// //if (有等待线程) 唤醒一个 else 仅增加计数
|
||||
// _signal.Release(); // 唤醒一个 worker
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 如果没有任务 → 挂起等待 有任务 → 被唤醒并返回
|
||||
// /// </summary>
|
||||
// /// <param name="ct"></param>
|
||||
// /// <returns></returns>
|
||||
// public async Task<Guid> DequeueAsync(CancellationToken ct)
|
||||
// {
|
||||
// await _signal.WaitAsync(ct);
|
||||
|
||||
// lock (_lock)
|
||||
// {
|
||||
// return _queue.Dequeue();
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 获取队列任务Id
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// public Guid[] Snapshot()
|
||||
// {
|
||||
// lock (_lock)
|
||||
// {
|
||||
// return _queue.UnorderedItems
|
||||
// .Select(x => x.Element)
|
||||
// .ToArray();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
#region 这里不用 SyncQueueUseChannel 和调度器 SyncScheduler
|
||||
public class SyncQueueUseChannel
|
||||
{
|
||||
// 优先级队列(priority 越大越先执行)
|
||||
private readonly PriorityQueue<Guid, int> _queue = new();
|
||||
|
||||
// Worker 唤醒信号
|
||||
private readonly Channel<bool> _signal =
|
||||
Channel.CreateUnbounded<bool>(new UnboundedChannelOptions
|
||||
{
|
||||
SingleReader = false,
|
||||
SingleWriter = false
|
||||
});
|
||||
|
||||
// 队列任务数量(不是CPU数量!)
|
||||
private int _count = 0;
|
||||
|
||||
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// 入队任务
|
||||
/// </summary>
|
||||
public void Enqueue(Guid id, int priority)
|
||||
{
|
||||
bool needSignal = false;
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
// priority 越大越优先 → 转负数
|
||||
_queue.Enqueue(id, -priority);
|
||||
|
||||
// 只有从 0 → 1 才需要唤醒 worker
|
||||
if (_count == 0)
|
||||
needSignal = true;
|
||||
|
||||
_count++;
|
||||
}
|
||||
|
||||
// 避免 signal 风暴
|
||||
if (needSignal)
|
||||
_signal.Writer.TryWrite(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Worker 等待并获取任务
|
||||
/// </summary>
|
||||
public async Task<Guid> DequeueAsync(CancellationToken ct)
|
||||
{
|
||||
|
||||
// 没任务时挂起(不会占CPU)
|
||||
await _signal.Reader.ReadAsync(ct);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
var id = _queue.Dequeue();
|
||||
|
||||
_count--;
|
||||
|
||||
// 如果还有任务,继续唤醒下一个 worker
|
||||
if (_count > 0)
|
||||
_signal.Writer.TryWrite(true);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前排队数量(调试用)
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步调度器
|
||||
/// </summary>
|
||||
public class FileSyncScheduler
|
||||
{
|
||||
private readonly FileSyncQueue _queue;
|
||||
|
||||
public FileSyncScheduler(FileSyncQueue queue)
|
||||
{
|
||||
_queue = queue;
|
||||
}
|
||||
|
||||
public void Enqueue(FileUploadRecord file)
|
||||
{
|
||||
if (file.IsNeedSync != true)
|
||||
return;
|
||||
|
||||
_queue.Enqueue(file.Id, file.Priority ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果没有任务 → 挂起等待 有任务 → 被唤醒并返回
|
||||
/// </summary>
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
public Task<Guid> WaitAsync(CancellationToken ct)
|
||||
=> _queue.DequeueAsync(ct);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:15:31Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Interfaces;
|
||||
|
||||
public interface IFileUploadRecordService
|
||||
{
|
||||
|
||||
Task<PageOutput<FileUploadRecordView>> GetFileUploadRecordList(FileUploadRecordQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateFileUploadRecord(FileUploadRecordAddOrEdit addOrEditFileUploadRecord);
|
||||
|
||||
Task<IResponseOutput> DeleteFileUploadRecord(Guid fileUploadRecordId);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.Util;
|
||||
using SharpCompress.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -49,7 +50,51 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
private static async Task<bool> TryWriteMergedDicomAsync(Func<Task<Stream>> sourceFactory, Stream output)
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var source = await sourceFactory();
|
||||
// 如果你是从 stream 打开
|
||||
var dicomFile = await DicomFile.OpenAsync(source);
|
||||
|
||||
//获取像素是否为封装形式
|
||||
var syntax = dicomFile.Dataset.InternalTransferSyntax;
|
||||
|
||||
//对于封装像素的文件做转换
|
||||
if (syntax.IsEncapsulated)
|
||||
{
|
||||
// 获取 Pixel Data 标签
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
|
||||
// 创建一个新的片段序列
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
// 获取每帧数据并封装为单独的片段
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n);
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(frameData.Data));
|
||||
}
|
||||
|
||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||
|
||||
var originOffsetTable = frag?.OffsetTable;
|
||||
|
||||
newFragments.OffsetTable.AddRange(originOffsetTable?.ToArray());
|
||||
// 替换原有的片段序列
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
}
|
||||
|
||||
await dicomFile.SaveAsync(output);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 只记录,不传播
|
||||
Log.Logger.Warning($"TryWriteMergedDicomAsync failed: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -61,6 +106,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> DownloadTrialImage(Guid trialId)
|
||||
{
|
||||
//找到项目里面未阅片的影像
|
||||
|
||||
|
||||
//var subjectCodeList = new List<string>() { "05002", "07006", "07026" };
|
||||
var downloadInfo = _trialRepository.Where(t => t.Id == trialId).Select(t => new
|
||||
{
|
||||
@@ -85,7 +133,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
InstancePathList = z.DicomInstanceList.Where(t => t.IsReading).Select(k => new
|
||||
{
|
||||
k.Path
|
||||
k.Path,
|
||||
k.IsEncapsulated,
|
||||
k.NumberOfFrames,
|
||||
}).ToList()
|
||||
})
|
||||
|
||||
@@ -118,9 +168,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
var downloadJobs = new List<Func<Task>>();
|
||||
|
||||
var rootFolder = @"E:\DownloadImage";
|
||||
//var rootFolder = @"E:\DownloadImage";
|
||||
|
||||
//var rootFolder = FileStoreHelper.GetDonwnloadImageFolder(_hostEnvironment);
|
||||
var rootFolder = FileStoreHelper.GetDonwnloadImageFolder(_hostEnvironment);
|
||||
|
||||
// 获取无效字符(系统定义的)
|
||||
string invalidChars = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
||||
@@ -168,9 +218,18 @@ namespace IRaCIS.Core.Application.Service
|
||||
// 复制文件到相应的文件夹
|
||||
string destinationPath = Path.Combine(studyDicomFolderPath, Path.GetFileName(instanceInfo.Path));
|
||||
|
||||
|
||||
//加入到下载任务里
|
||||
downloadJobs.Add(() => _oSSService.DownLoadFromOSSAsync(instanceInfo.Path, destinationPath));
|
||||
await using var output = File.Create(destinationPath);
|
||||
if (instanceInfo.IsEncapsulated)
|
||||
{
|
||||
//加入到下载任务里
|
||||
downloadJobs.Add(() => TryWriteMergedDicomAsync(() => _oSSService.GetStreamFromOSSAsync(instanceInfo.Path), output));
|
||||
}
|
||||
else
|
||||
{
|
||||
//加入到下载任务里
|
||||
downloadJobs.Add(() => _oSSService.DownLoadFromOSSAsync(instanceInfo.Path, destinationPath));
|
||||
}
|
||||
|
||||
|
||||
//下载到当前目录
|
||||
//await _oSSService.DownLoadFromOSSAsync(instanceInfo.Path, destinationPath);
|
||||
@@ -213,7 +272,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"下载失败: {ex.Message}");
|
||||
Log.Logger.Error($"下载失败: {ex.Message}");
|
||||
}
|
||||
|
||||
downloadedCount++;
|
||||
@@ -221,7 +280,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
// 每处理50个,输出一次进度(或最后一个时也输出)
|
||||
if (downloadedCount % 50 == 0 || downloadedCount == totalCount)
|
||||
{
|
||||
Console.WriteLine($"已下载 {downloadedCount} / {totalCount} 个文件,完成 {(downloadedCount * 100.0 / totalCount):F2}%");
|
||||
|
||||
Log.Logger.Error($"已下载 {downloadedCount} / {totalCount} 个文件,完成 {(downloadedCount * 100.0 / totalCount):F2}%");
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CreateMap<EmailLog, GetEmailInfoOutDto>()
|
||||
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList))
|
||||
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
|
||||
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
|
||||
|
||||
CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
.ForMember(t => t.EmailNoticeUserList, u => u.MapFrom(c => c.EmailNoticeUserTypeList));
|
||||
|
||||
CreateMap<EmailNoticeConfig, EmailNoticeConfigExportDto>();
|
||||
|
||||
|
||||
|
||||
CreateMap<Dictionary, DicView>()
|
||||
.ForMember(t => t.ParentCode, u => u.MapFrom(c => c.Parent.Code));
|
||||
@@ -89,14 +89,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
CreateMap<Internationalization, InternationalizationAddOrEdit>().ReverseMap();
|
||||
|
||||
CreateMap<InternationalizationAddOrEdit, IRCGlobalInfoDTO>();
|
||||
|
||||
|
||||
|
||||
CreateMap<Internationalization, BatchInternationalizationDto>().ReverseMap();
|
||||
|
||||
CreateMap<Internationalization, IRCGlobalInfoDTO>();
|
||||
|
||||
CreateMap<EventStoreRecord, EventStoreRecordView>();
|
||||
|
||||
|
||||
CreateMap<BatchAddInternationalizationDto, InternationalizationAddOrEdit>();
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
.ForMember(d => d.TrialSiteCode, u => u.MapFrom(s => s.Subject.TrialSite.TrialSiteCode));
|
||||
|
||||
|
||||
CreateMap<TumorExportBaseModel , TU_Export>();
|
||||
CreateMap<TumorExportBaseModel, TU_Export>();
|
||||
CreateMap<TumorExportBaseModel, TR_Export>();
|
||||
CreateMap<TumorExportBaseModel, RS_Export>();
|
||||
CreateMap<TumorExportBaseModel, CO_Export>();
|
||||
@@ -124,6 +124,21 @@ namespace IRaCIS.Core.Application.Service
|
||||
CreateMap<IVUS_OCTBaseDto, IvusExportDto>();
|
||||
CreateMap<IVUS_OCTBaseDto, OctExportDto>();
|
||||
|
||||
|
||||
CreateMap<FileUploadRecord, FileUploadRecordView>()
|
||||
.ForMember(d => d.SubjectCode, u => u.MapFrom(s => s.Subject.Code))
|
||||
.ForMember(d => d.VisitName, u => u.MapFrom(s => s.SubjectVisit.VisitName));
|
||||
CreateMap<FileUploadRecord, FileUploadRecordAddOrEdit>().ReverseMap();
|
||||
|
||||
|
||||
CreateMap<UploadFileSyncRecord, UploadFileSyncRecordView>()
|
||||
.ForMember(d => d.FileName, u => u.MapFrom(s => s.FileUploadRecord.FileName))
|
||||
.ForMember(d => d.FileType, u => u.MapFrom(s => s.FileUploadRecord.FileType))
|
||||
.ForMember(d => d.Path, u => u.MapFrom(s => s.FileUploadRecord.Path))
|
||||
.ForMember(d => d.StudyCode, u => u.MapFrom(s => s.FileUploadRecord.StudyCode))
|
||||
.ForMember(d => d.SubjectCode, u => u.MapFrom(s => s.FileUploadRecord.Subject.Code))
|
||||
.ForMember(d => d.VisitName, u => u.MapFrom(s => s.FileUploadRecord.SubjectVisit.VisitName));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
//重新插入新的 Title记录
|
||||
updateModel.TitleIds.ForEach(titleId => adddata.Add(new DoctorDictionary() { DoctorId = updateModel.Id.Value, KeyName = StaticData.Title, DictionaryId = titleId }));
|
||||
|
||||
indto.ReviewerCode = doctor.ReviewerCode;
|
||||
await _doctorDictionaryRepository.AddRangeAsync(adddata);
|
||||
|
||||
_mapper.Map(indto, doctor);
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
|
||||
public string SliceThickness { get; set; } = String.Empty;
|
||||
|
||||
public string ImagePositionPatient { get; set; }
|
||||
public string ImageOrientationPatient { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
|
||||
|
||||
public bool IsBeMark { get; set; } = false;
|
||||
|
||||
public bool IsBeSegment { get; set; } = false;
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid StudyId { get; set; }
|
||||
public string StudyInstanceUid { get; set; } = String.Empty;
|
||||
@@ -100,6 +102,10 @@ namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
|
||||
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public bool? IsMasked { get; set; }
|
||||
|
||||
public string? PhotometricInterpretation { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int ShowOrder { get; set; }
|
||||
[JsonIgnore]
|
||||
@@ -108,6 +114,10 @@ namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
|
||||
public string WindowCenter { get; set; }
|
||||
[JsonIgnore]
|
||||
public string WindowWidth { get; set; }
|
||||
[JsonIgnore]
|
||||
public string ImagePositionPatient { get; set; }
|
||||
[JsonIgnore]
|
||||
public string ImageOrientationPatient { get; set; }
|
||||
|
||||
public DateTime? RowDate { get; set; }
|
||||
}
|
||||
|
||||
@@ -47,6 +47,50 @@
|
||||
public DateTime UpdateTime { get; set; }
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
#region 核验
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
public string PatientWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 成像 / 采集时间
|
||||
/// </summary>
|
||||
public string AcquisitionTime { get; set; } = null!;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在空字符串字段(PatientSex、PatientWeight、RadionuclideTotalDose、RadionuclideHalfLife、RadiopharmaceuticalStartTime、AcquisitionTime 任意一个为空/空字符串)
|
||||
/// </summary>
|
||||
public bool IsHasEmptyPatientInfo =>
|
||||
string.IsNullOrWhiteSpace(PatientSex) ||
|
||||
string.IsNullOrWhiteSpace(PatientWeight) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideTotalDose) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideHalfLife) ||
|
||||
string.IsNullOrWhiteSpace(RadiopharmaceuticalStartTime) ||
|
||||
string.IsNullOrWhiteSpace(AcquisitionTime);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class RelationVisitDTO
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FellowOakDicom;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Newtonsoft.Json;
|
||||
@@ -193,6 +194,86 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
}
|
||||
|
||||
public class EditPatientInfoCommand
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public string PatientSex { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
public string PatientWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 成像 / 采集时间
|
||||
/// </summary>
|
||||
public string AcquisitionTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 修改原因
|
||||
/// </summary>
|
||||
public string Reason { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class GetPatientInfoInDto
|
||||
{
|
||||
public Guid StudyId { get; set; }
|
||||
}
|
||||
|
||||
public class PatientInfoDto
|
||||
{
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public string PatientSex { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
public string PatientWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 成像 / 采集时间
|
||||
/// </summary>
|
||||
public string AcquisitionTime { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class PreArchiveDicomStudyCommand
|
||||
{
|
||||
|
||||
@@ -265,6 +346,11 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
[NotDefault]
|
||||
public Guid StudyMonitorId { get; set; }
|
||||
|
||||
[NotDefault]
|
||||
public string UploadBatchId { get; set; }
|
||||
|
||||
|
||||
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public string RecordPath { get; set; } = string.Empty;
|
||||
@@ -289,6 +375,10 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
[NotDefault]
|
||||
public Guid StudyMonitorId { get; set; }
|
||||
|
||||
[NotDefault]
|
||||
public string UploadBatchId { get; set; }
|
||||
|
||||
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public string RecordPath { get; set; } = string.Empty;
|
||||
@@ -352,6 +442,24 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
#endregion
|
||||
|
||||
#region 核验
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; }
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class AddOrUpdateSeriesDto
|
||||
@@ -633,6 +741,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class DownloadDicomInstanceDto
|
||||
{
|
||||
public int NumberOfFrames { get; set; }
|
||||
public bool IsEncapsulated { get; set; }
|
||||
public Guid InstanceId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
@@ -954,7 +1063,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
}
|
||||
|
||||
|
||||
public class SubjectVisitMarkQuery:PageInput
|
||||
public class SubjectVisitMarkQuery : PageInput
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
@@ -1038,4 +1147,31 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public List<StudyBasicInfo> UploadStudyList { get; set; }
|
||||
}
|
||||
|
||||
public class StudyMaskImageCommand
|
||||
{
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public List<Guid>? InstanceIdList { get; set; }
|
||||
|
||||
public List<MaskRegion> MaskRegionList { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class StudyUndoMaskImageCommand
|
||||
{
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public List<Guid>? InstanceIdList { get; set; }
|
||||
}
|
||||
|
||||
public class InstanceIdPath
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<SubjectVisit> _subjectVisitRepository,
|
||||
IOSSService _oSSService,
|
||||
IRepository<FileUploadRecord> _fileUploadRecordRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<StudyMonitor> _studyMonitorRepository,
|
||||
@@ -803,6 +804,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
await _taskStudyRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await _fileUploadRecordRepository.BatchUpdateNoTrackingAsync(t => t.UploadBatchId == incommand.UploadBatchId, u => new FileUploadRecord() { StudyCode = findStudy.StudyCode });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -938,8 +941,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
//存在ivus 和oct 这两种的项目
|
||||
if (_readingQuestionCriterionTrialRepository.Where(t => t.TrialId == info.TrialId &&
|
||||
(t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT)).Distinct().Count() == 2
|
||||
&& !_noneDicomStudyReposiotry.Any(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS"))
|
||||
((t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT) && t.IsConfirm)).Distinct().Count() == 2
|
||||
&& _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS").Count() != _dicomStudyRepository.Where(t => t.SubjectId == inQuery.SubjectId).Select(t => t.SubjectVisitId).Distinct().Count()
|
||||
)
|
||||
{
|
||||
#region ivus 自动创建非dicom检查
|
||||
|
||||
@@ -957,6 +961,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var noneDicomStudyVisitIdList = _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS").Select(t => t.SubjectVisitId).ToList();
|
||||
|
||||
var @lock = _distributedLockProvider.CreateLock($"NoneDicomCode");
|
||||
|
||||
@@ -967,10 +972,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
//默认会是0
|
||||
var code = await _noneDicomStudyReposiotry.Where(t => t.TrialId == trialId).Select(x => x.Code).DefaultIfEmpty().MaxAsync();
|
||||
|
||||
foreach (var g in addList.GroupBy(t => t.SubjectVisitId))
|
||||
foreach (var g in addList.Where(t => !noneDicomStudyVisitIdList.Contains(t.SubjectVisitId)).GroupBy(t => t.SubjectVisitId))
|
||||
{
|
||||
var addOrEditNoneDicomStudy = g.First();
|
||||
|
||||
|
||||
|
||||
var optEntity = await _noneDicomStudyReposiotry.InsertFromDTOAsync(addOrEditNoneDicomStudy);
|
||||
|
||||
optEntity.Code = code + 1;
|
||||
@@ -1653,7 +1660,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
#endregion
|
||||
|
||||
var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id) && t.CheckState == CheckStateEnum.CVPassed))
|
||||
//一致性分析,导致查询出来两条数据
|
||||
//一致性分析,导致查询出来两条数据
|
||||
join visitTask in _visitTaskRepository.Where(t => taskIdList.Contains(t.Id)) on sv.Id equals visitTask.SourceSubjectVisitId into cc
|
||||
from leftVisitTask in cc.DefaultIfEmpty()
|
||||
select new ImageDownloadDto()
|
||||
@@ -1998,6 +2005,21 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取未阅片完成的访视,方便前端调用下载
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Guid?>> GetTrialUnreadVisitList(Guid trialId)
|
||||
{
|
||||
|
||||
var subjectVisitList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.SourceSubjectVisitId!=null).Select(t => t.SourceSubjectVisitId)
|
||||
.Distinct().ToListAsync();
|
||||
|
||||
return subjectVisitList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量勾选访视 进行下载
|
||||
/// </summary>
|
||||
|
||||
@@ -29,6 +29,14 @@ namespace IRaCIS.Core.Application.Services
|
||||
.OrderBy(s => s.InstanceNumber).ThenBy(s => s.InstanceTime).ThenBy(s => s.CreateTime)
|
||||
.ProjectTo<DicomInstanceDTO>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
// ⭐ DICOM 空间排序(带兜底)
|
||||
var sorted = DicomSortHelper.SortSlices(
|
||||
list,
|
||||
x => x.ImagePositionPatient,
|
||||
x => x.ImageOrientationPatient,
|
||||
x => x.InstanceNumber
|
||||
);
|
||||
|
||||
var seriesInfo = await _instanceRepository.Where(s => s.SeriesId == seriesId).Select(t => new
|
||||
{
|
||||
t.DicomSerie.ImageResizePath,
|
||||
@@ -38,7 +46,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
t.DicomSerie.SubjectVisit.VisitName
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
return ResponseOutput.Ok(list, seriesInfo);
|
||||
return ResponseOutput.Ok(sorted, seriesInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
DicomTrialSiteSubjectInfo GetSaveToDicomInfo(Guid subjectVisitId);
|
||||
IResponseOutput<DicomStudyDTO> Item(Guid studyId,bool? isPacs);
|
||||
Task<FileContentResult> Preview(Guid studyId);
|
||||
|
||||
Task<IResponseOutput> AmendmentPatientInfo(EditPatientInfoCommand command);
|
||||
//IResponseOutput<List<VerifyStudyUploadResult>> VerifyStudyAllowUpload(VerifyUploadOrReupload verifyInfo);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
@@ -77,7 +78,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
//ivus-在访视的时候visitTaskId==null 需要过滤掉空检查 ,但是在靶段标注的查看访视级别的时候不能过滤
|
||||
if (_subjectVisitRepository.Where(t => t.Id == subjectVisitId).SelectMany(t => t.Trial.TrialReadingCriterionList)
|
||||
.Where(t => t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT).Distinct().Count() == 2
|
||||
.Where(t => (t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT) && t.IsConfirm).Distinct().Count() == 2
|
||||
&& visitTaskId == null)
|
||||
{
|
||||
isFilterIVUSNoneDicom = true;
|
||||
@@ -114,7 +115,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
var list = await noneDicomStudyQueryable.Where(t => isFilterIVUSNoneDicom ? t.Modality != "IVUS" : true)
|
||||
.OrderBy(x => x.ImageDate).ThenBy(x => x.CreateTime).ToListAsync();
|
||||
|
||||
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState, CriterionType=criterionType }).FirstOrDefaultAsync();
|
||||
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState, CriterionType = criterionType }).FirstOrDefaultAsync();
|
||||
return ResponseOutput.Ok(list, config);
|
||||
}
|
||||
|
||||
@@ -154,14 +155,22 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
if (addOrEditNoneDicomStudy.Id == Guid.Empty || addOrEditNoneDicomStudy.Id == null)
|
||||
{
|
||||
|
||||
if (_subjectVisitRepository.Where(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId).SelectMany(t => t.Trial.TrialReadingCriterionList)
|
||||
.Where(t => (t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT) && t.IsConfirm).Distinct().Count() == 2 && addOrEditNoneDicomStudy.Modality != "OCT")
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["NoneDicomStudy_OnlyNeedOCT"]);
|
||||
}
|
||||
|
||||
//默认会是0
|
||||
var code = await _noneDicomStudyRepository.Where(t => t.TrialId == addOrEditNoneDicomStudy.TrialId).Select(x => x.Code).DefaultIfEmpty().MaxAsync();
|
||||
var code = await _trialRepository.Where(t => t.Id == addOrEditNoneDicomStudy.TrialId, ignoreQueryFilters: true).Select(x => x.MaxNoneDicomCode).DefaultIfEmpty().MaxAsync();
|
||||
|
||||
|
||||
optEntity = await _noneDicomStudyRepository.InsertFromDTOAsync(addOrEditNoneDicomStudy);
|
||||
|
||||
optEntity.Code = code + 1;
|
||||
|
||||
await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == addOrEditNoneDicomStudy.TrialId, u => new Trial() { MaxNoneDicomCode = optEntity.Code });
|
||||
|
||||
optEntity.StudyCode = AppSettings.GetCodeStr(optEntity.Code, nameof(NoneDicomStudy));
|
||||
|
||||
|
||||
@@ -46,13 +46,23 @@ namespace IRaCIS.Core.Application.Services
|
||||
var instanceList = await _scpInstanceRepository.Where(s => s.StudyId == studyId).IgnoreQueryFilters()
|
||||
.OrderBy(t => t.SeriesId).ThenBy(t => t.InstanceNumber)
|
||||
.ThenBy(s => s.InstanceTime).ThenBy(s => s.CreateTime)
|
||||
.Select(t => new { t.SeriesId, t.Id, t.Path, t.NumberOfFrames, t.InstanceNumber, t.FileSize }).ToListAsync();//.GroupBy(u => u.SeriesId);
|
||||
.Select(t => new { t.SeriesId, t.Id, t.Path, t.NumberOfFrames, t.InstanceNumber, t.FileSize, t.ImagePositionPatient, t.ImageOrientationPatient }).ToListAsync();//.GroupBy(u => u.SeriesId);
|
||||
|
||||
|
||||
foreach (var series in seriesList)
|
||||
{
|
||||
|
||||
series.InstanceInfoList = instanceList.Where(t => t.SeriesId == series.Id).OrderBy(t => t.InstanceNumber).Select(k =>
|
||||
var instances = instanceList.Where(x => x.SeriesId == series.Id);
|
||||
|
||||
// ⭐ DICOM 空间排序(带兜底)
|
||||
var sorted = DicomSortHelper.SortSlices(
|
||||
instances,
|
||||
x => x.ImagePositionPatient,
|
||||
x => x.ImageOrientationPatient,
|
||||
x => x.InstanceNumber
|
||||
);
|
||||
|
||||
series.InstanceInfoList = sorted.Select(k =>
|
||||
new InstanceBasicInfo()
|
||||
{
|
||||
Id = k.Id,
|
||||
@@ -62,7 +72,8 @@ namespace IRaCIS.Core.Application.Services
|
||||
InstanceNumber = k.InstanceNumber,
|
||||
IsReading = true,
|
||||
IsDeleted = false,
|
||||
FileSize = k.FileSize
|
||||
FileSize = k.FileSize,
|
||||
|
||||
|
||||
}).ToList();
|
||||
|
||||
@@ -93,7 +104,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
.WhereIf(isReading == true, t => t.IsReading == true)
|
||||
.OrderBy(t => t.SeriesId).ThenBy(t => t.InstanceNumber)
|
||||
.ThenBy(s => s.InstanceTime).ThenBy(s => s.CreateTime)
|
||||
.Select(t => new { t.SeriesId, t.Id, t.Path, t.NumberOfFrames, t.InstanceNumber, t.HtmlPath, t.IsReading, t.IsDeleted, t.FileSize }).ToListAsync();//.GroupBy(u => u.SeriesId);
|
||||
.Select(t => new { t.SeriesId, t.Id, t.Path, t.NumberOfFrames, t.InstanceNumber, t.HtmlPath, t.IsReading, t.IsDeleted, t.FileSize ,t.IsMasked}).ToListAsync();//.GroupBy(u => u.SeriesId);
|
||||
|
||||
|
||||
foreach (var series in seriesList)
|
||||
@@ -109,7 +120,8 @@ namespace IRaCIS.Core.Application.Services
|
||||
InstanceNumber = k.InstanceNumber,
|
||||
IsReading = k.IsReading,
|
||||
IsDeleted = k.IsDeleted,
|
||||
FileSize = k.FileSize
|
||||
FileSize = k.FileSize,
|
||||
IsMasked = k.IsMasked
|
||||
|
||||
}).ToList();
|
||||
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging;
|
||||
using FellowOakDicom.IO.Buffer;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using MathNet.Numerics;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NetTopologySuite.Algorithm;
|
||||
using SharpCompress.Common;
|
||||
using SkiaSharp;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
@@ -20,12 +32,13 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<SCPStudy> _scpStudyRepository,
|
||||
IRepository<FileUploadRecord> _fileUploadRecordRepository,
|
||||
IRepository<Subject> _subjectRepository,
|
||||
IRepository<StudyMonitor> _studyMonitorRepository,
|
||||
IRepository<SystemAnonymization> _systemAnonymizationRepository,
|
||||
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
||||
IDistributedLockProvider _distributedLockProvider,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IStudyService
|
||||
IDistributedLockProvider _distributedLockProvider, IOSSService _oSSService,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache, IWebHostEnvironment _hostEnvironment) : BaseService, IStudyService
|
||||
{
|
||||
|
||||
|
||||
@@ -65,6 +78,471 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
}
|
||||
|
||||
|
||||
private static async Task<bool> TryWriteMergedDicomAsync(Func<Task<Stream>> sourceFactory, Stream output)
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var source = await sourceFactory();
|
||||
// 如果你是从 stream 打开
|
||||
var dicomFile = await DicomFile.OpenAsync(source);
|
||||
|
||||
//获取像素是否为封装形式
|
||||
var syntax = dicomFile.Dataset.InternalTransferSyntax;
|
||||
|
||||
//对于封装像素的文件做转换
|
||||
if (syntax.IsEncapsulated)
|
||||
{
|
||||
// 获取 Pixel Data 标签
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
|
||||
// 创建一个新的片段序列
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
// 获取每帧数据并封装为单独的片段
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n);
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(frameData.Data));
|
||||
}
|
||||
|
||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||
|
||||
var originOffsetTable = frag?.OffsetTable;
|
||||
|
||||
newFragments.OffsetTable.AddRange(originOffsetTable?.ToArray());
|
||||
// 替换原有的片段序列
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
}
|
||||
|
||||
await dicomFile.SaveAsync(output);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 只记录,不传播
|
||||
Log.Logger.Warning($"TryWriteMergedDicomAsync failed: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<DicomFile> TryWriteSplitDicomAsync(Stream input)
|
||||
{
|
||||
var dicomFile = await DicomFile.OpenAsync(input);
|
||||
|
||||
var numberOfFrames = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1);
|
||||
|
||||
//多帧处理逻辑
|
||||
if (numberOfFrames > 1)
|
||||
{
|
||||
//一定要有像素数据才处理
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
|
||||
if (pixelData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
var syntax = pixelData.Syntax;
|
||||
|
||||
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
||||
int fragmentSize = 20 * 1024;
|
||||
|
||||
|
||||
|
||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||
|
||||
int fragmentCount = frag?.Fragments?.Count() ?? 0;
|
||||
|
||||
var originOffsetTable = frag?.OffsetTable; //有可能没有表,需要自己重建
|
||||
|
||||
var bot = new List<uint>();
|
||||
|
||||
uint botOffset = 0;
|
||||
|
||||
//需要拆成固定片段的
|
||||
if (syntax.IsEncapsulated && fragmentCount == pixelData.NumberOfFrames && numberOfFrames > 1)
|
||||
{
|
||||
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
|
||||
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n);
|
||||
var data = frameData.Data;
|
||||
|
||||
// 当前 frame 起始 offset
|
||||
bot.Add(botOffset);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
while (offset < data.Length)
|
||||
{
|
||||
int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
|
||||
var buffer = new byte[size];
|
||||
Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
|
||||
// 一个 fragment:
|
||||
// 8-byte item header
|
||||
// + fragment payload
|
||||
botOffset += (uint)(8 + size);
|
||||
|
||||
offset += size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 最终使用
|
||||
|
||||
//for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
//{
|
||||
// var frameData = pixelData.GetFrame(n); // 获取完整一帧
|
||||
// var data = frameData.Data;
|
||||
// int offset = 0;
|
||||
|
||||
// bot.Add(botOffset);
|
||||
|
||||
// botOffset += (uint)data.Length;
|
||||
|
||||
|
||||
// while (offset < data.Length)
|
||||
// {
|
||||
// botOffset += 8;
|
||||
|
||||
|
||||
// int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
// var buffer = new byte[size];
|
||||
// Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
// newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
|
||||
// offset += size;
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
//保留原始偏移表
|
||||
|
||||
//if (originOffsetTable.Count == pixelData.NumberOfFrames)
|
||||
//{
|
||||
// newFragments.OffsetTable.AddRange(originOffsetTable.ToArray());
|
||||
|
||||
//}
|
||||
//else
|
||||
{
|
||||
newFragments.OffsetTable.AddRange(bot.ToArray());
|
||||
|
||||
Log.Logger.Warning(bot.ToArray().ToJsonStr());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
|
||||
|
||||
}
|
||||
//传递过来的就是拆分的,但是是没有偏移表的,我需要自己创建偏移表,不然生成缩略图失败
|
||||
else if (syntax.IsEncapsulated && fragmentCount > pixelData.NumberOfFrames && originOffsetTable.Count == 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint offset = 0;
|
||||
|
||||
bot.Add(offset);
|
||||
|
||||
var fistSize = frag.Fragments.FirstOrDefault()?.Size ?? 0;
|
||||
|
||||
//和上一个大小不一样
|
||||
var isDiffrentBefore = false;
|
||||
|
||||
uint count = 0;
|
||||
|
||||
// 假设你知道每帧对应的 fragment 数量
|
||||
foreach (var frameFragments in frag.Fragments)
|
||||
{
|
||||
count++;
|
||||
|
||||
if (frameFragments.Size == fistSize)
|
||||
{
|
||||
isDiffrentBefore = false;
|
||||
// 累加这一帧所有 fragment 的大小
|
||||
offset += (uint)frameFragments.Size;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += (uint)frameFragments.Size;
|
||||
isDiffrentBefore = true;
|
||||
|
||||
}
|
||||
|
||||
if (isDiffrentBefore)
|
||||
{
|
||||
//每个Fragment 也占用字节
|
||||
offset += 8 * count;
|
||||
bot.Add(offset);
|
||||
count = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bot.RemoveAt(bot.Count - 1);
|
||||
// 设置到新的 PixelData
|
||||
frag.OffsetTable.AddRange(bot.ToArray());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 只记录,不传播
|
||||
Log.Logger.Warning($"拆分 failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dicomFile;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标注遮盖影像 路径后面加了.MaskImage 就是遮盖的新路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> StudyMaskImage(StudyMaskImageCommand inCommand)
|
||||
{
|
||||
if (inCommand.SeriesId == null && inCommand.InstanceIdList == null)
|
||||
{
|
||||
return ResponseOutput.NotOk("SeriesId and InstanceIdList can not both be null");
|
||||
}
|
||||
|
||||
|
||||
var idPathList = new List<DownloadDicomInstanceDto>();
|
||||
|
||||
if (inCommand.SeriesId == null && inCommand.InstanceIdList != null)
|
||||
{
|
||||
idPathList = await _dicomInstanceRepository.Where(t => inCommand.InstanceIdList.Contains(t.Id)).ProjectTo<DownloadDicomInstanceDto>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
idPathList = await _dicomInstanceRepository.Where(t => t.SeriesId == inCommand.SeriesId).ProjectTo<DownloadDicomInstanceDto>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
}
|
||||
|
||||
var errorList = new List<InstanceIdPath>();
|
||||
|
||||
var okList = new List<InstanceIdPath>();
|
||||
|
||||
var batchId = Guid.NewGuid();
|
||||
|
||||
foreach (var item in idPathList)
|
||||
{
|
||||
var path = item.Path;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
await using var inputStream = new MemoryStream();
|
||||
|
||||
if (item.IsEncapsulated)
|
||||
{
|
||||
|
||||
var ok = await TryWriteMergedDicomAsync(() => _oSSService.GetStreamFromOSSAsync(path), inputStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
await (await _oSSService.GetStreamFromOSSAsync(path)).CopyToAsync(inputStream);
|
||||
}
|
||||
|
||||
|
||||
var outPutStream = await DicomPixelMasker.MaskAsync(inputStream, inCommand.MaskRegionList);
|
||||
|
||||
var needUploadDicomFile = await TryWriteSplitDicomAsync(outPutStream);
|
||||
|
||||
var prefix = path.Substring(1, path.LastIndexOf('/') - 1);
|
||||
|
||||
//每次都用一个新的名字
|
||||
var maskFileName = string.Empty;
|
||||
|
||||
if (path.Contains(".MaskDicom_"))
|
||||
{
|
||||
//清理缓存的里面的遮盖图,多次遮盖同一张图时,清除缓存很重要
|
||||
await _oSSService.DeleteFromPrefix(path, true); //清理缓存的里面的遮盖图,多次遮盖同一张图时,清除缓存很重要
|
||||
|
||||
//本身就是遮盖的图,那么就要要替换guid
|
||||
var length = Guid.Empty.ToString().Length + ".MaskDicom_".Length;
|
||||
|
||||
var restorePath = item.Path[..^length];
|
||||
|
||||
maskFileName = $"{Path.GetFileName(restorePath)}.MaskDicom_{batchId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
//没有遮盖的,直接加上.批次_MaskDicom
|
||||
maskFileName = $"{Path.GetFileName(path)}.MaskDicom_{batchId}";
|
||||
}
|
||||
|
||||
|
||||
// 直接写入内存
|
||||
await using var uploadStream = new MemoryStream();
|
||||
await needUploadDicomFile.SaveAsync(uploadStream);
|
||||
uploadStream.Position = 0;
|
||||
|
||||
await _oSSService.UploadToOSSAsync(uploadStream, prefix, maskFileName, false);
|
||||
|
||||
var newPath = $"/{prefix}/{maskFileName}";
|
||||
|
||||
okList.Add(new InstanceIdPath() { Id = item.InstanceId, Path = newPath });
|
||||
|
||||
await _dicomInstanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.InstanceId, u => new DicomInstance() { Path = newPath, IsMasked = true });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
errorList.Add(new InstanceIdPath() { Id = item.InstanceId, Path = path });
|
||||
|
||||
Log.Logger.Error(ex, $"StudyMaskImage Error for InstanceIdList Path:{path} {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await _dicomInstanceRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(new { OkList = okList, ErrorList = errorList });
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 撤销遮盖的影像,可以单张,也可以整个序列
|
||||
/// </summary>
|
||||
/// <param name="inCommand"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> StudyUndoMaskImage(StudyUndoMaskImageCommand inCommand)
|
||||
{
|
||||
if (inCommand.SeriesId == null && inCommand.InstanceIdList == null)
|
||||
{
|
||||
return ResponseOutput.NotOk("SeriesId and InstanceIdList can not both be null");
|
||||
}
|
||||
|
||||
|
||||
var idPathList = new List<InstanceIdPath>();
|
||||
|
||||
if (inCommand.SeriesId == null && inCommand.InstanceIdList != null)
|
||||
{
|
||||
idPathList = await _dicomInstanceRepository.Where(t => inCommand.InstanceIdList.Contains(t.Id)).Select(t => new InstanceIdPath { Id = t.Id, Path = t.Path }).ToListAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
idPathList = await _dicomInstanceRepository.Where(t => t.SeriesId == inCommand.SeriesId).Select(t => new InstanceIdPath { Id = t.Id, Path = t.Path }).ToListAsync();
|
||||
}
|
||||
|
||||
var okList = new List<InstanceIdPath>();
|
||||
|
||||
foreach (var item in idPathList)
|
||||
{
|
||||
if (item.Path.Contains(".MaskDicom_"))
|
||||
{
|
||||
await _oSSService.DeleteFromPrefix(item.Path, true);
|
||||
|
||||
var length = Guid.Empty.ToString().Length + ".MaskDicom_".Length;
|
||||
var newPath = item.Path[..^length];
|
||||
|
||||
okList.Add(new InstanceIdPath() { Id = item.Id, Path = newPath });
|
||||
|
||||
await _dicomInstanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomInstance() { Path = newPath, IsMasked = false });
|
||||
}
|
||||
|
||||
//if (item.Path.EndsWith("."))
|
||||
//{
|
||||
// await _oSSService.DeleteFromPrefix(item.Path, true);
|
||||
|
||||
// var newPath = item.Path[..^1];
|
||||
|
||||
// okList.Add(new InstanceIdPath() { Id = item.Id, Path = newPath });
|
||||
|
||||
// await _dicomInstanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomInstance() { Path = newPath, IsMasked = false });
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
await _dicomInstanceRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok(new { OkList = okList });
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取患者基本信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PatientInfoDto> GetPatientInfo(GetPatientInfoInDto inDto)
|
||||
{
|
||||
var study = await _dicomStudyRepository.Where(s => s.Id == inDto.StudyId).ProjectTo<PatientInfoDto>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
|
||||
return study;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑患者基本信息
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> EditPatientInfo(EditPatientInfoCommand command)
|
||||
{
|
||||
await _dicomStudyRepository.UpdatePartialFromQueryAsync(command.Id, x => new DicomStudy
|
||||
{
|
||||
PatientSex = command.PatientSex,
|
||||
PatientWeight = command.PatientWeight,
|
||||
RadionuclideTotalDose = command.RadionuclideTotalDose,
|
||||
RadionuclideHalfLife = command.RadionuclideHalfLife,
|
||||
RadiopharmaceuticalStartTime = command.RadiopharmaceuticalStartTime,
|
||||
AcquisitionTime = command.AcquisitionTime,
|
||||
});
|
||||
await _dicomStudyRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修正患者基本信息
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AmendmentPatientInfo(EditPatientInfoCommand command)
|
||||
{
|
||||
await _dicomStudyRepository.UpdatePartialFromQueryAsync(command.Id, x => new DicomStudy
|
||||
{
|
||||
PatientSex = command.PatientSex,
|
||||
PatientWeight = command.PatientWeight,
|
||||
RadionuclideTotalDose = command.RadionuclideTotalDose,
|
||||
RadionuclideHalfLife = command.RadionuclideHalfLife,
|
||||
RadiopharmaceuticalStartTime = command.RadiopharmaceuticalStartTime,
|
||||
AcquisitionTime = command.AcquisitionTime,
|
||||
Reason = command.Reason,
|
||||
});
|
||||
await _dicomStudyRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
|
||||
public async Task<IResponseOutput> PreArchiveDicomStudy(PreArchiveDicomStudyCommand preArchiveStudyCommand)
|
||||
@@ -183,7 +661,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
//查询数据库获取最大的Code 没有记录则为0
|
||||
var dbStudyCodeIntMax = _dicomStudyRepository.Where(s => s.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max();
|
||||
var dbStudyCodeIntMax = _trialRepository.Where(s => s.Id == trialId, ignoreQueryFilters: true).Select(t => t.MaxDicomCode).DefaultIfEmpty().Max();
|
||||
|
||||
//获取缓存中的值 并发的时候,需要记录,已被占用的值 这样其他线程在此占用的最大的值上递增
|
||||
var cacheMaxCodeInt = await _fusionCache.GetOrDefaultAsync<int>(CacheKeys.TrialStudyMaxCode(trialId));
|
||||
@@ -192,6 +670,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
addStudy.Code = currentNextCodeInt;
|
||||
|
||||
await _trialRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialId, u => new Trial() { MaxDicomCode = addStudy.Code });
|
||||
|
||||
addStudy.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy));
|
||||
|
||||
await _fusionCache.SetAsync<int>(CacheKeys.TrialStudyMaxCode(trialId), addStudy.Code, TimeSpan.FromMinutes(30));
|
||||
@@ -318,12 +798,29 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
// 不管是新的序列 还是 该序列 掉了Instance 重传的时候 检查的instance 数量都会增加
|
||||
findStudy.InstanceCount += seriesItem.InstanceList.Count;
|
||||
|
||||
|
||||
if (incommand.Study.RadionuclideTotalDose != string.Empty
|
||||
|| incommand.Study.RadionuclideHalfLife != string.Empty
|
||||
|| incommand.Study.RadiopharmaceuticalStartTime != string.Empty
|
||||
|
||||
)
|
||||
{
|
||||
await _dicomStudyRepository.UpdatePartialFromQueryAsync(t => t.Id == findStudy.Id, u => new DicomStudy()
|
||||
{
|
||||
RadionuclideTotalDose = incommand.Study.RadionuclideTotalDose.IsNotNullOrEmpty() ? incommand.Study.RadionuclideTotalDose : findStudy.RadionuclideTotalDose,
|
||||
RadionuclideHalfLife = incommand.Study.RadionuclideHalfLife.IsNotNullOrEmpty() ? incommand.Study.RadionuclideHalfLife : findStudy.RadionuclideHalfLife,
|
||||
RadiopharmaceuticalStartTime = incommand.Study.RadiopharmaceuticalStartTime.IsNotNullOrEmpty() ? incommand.Study.RadiopharmaceuticalStartTime : findStudy.RadiopharmaceuticalStartTime
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit");
|
||||
@@ -332,6 +829,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
await _dicomInstanceRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await _fileUploadRecordRepository.BatchUpdateNoTrackingAsync(t => t.UploadBatchId == incommand.UploadBatchId, u => new FileUploadRecord() { StudyCode = findStudy.StudyCode });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -434,7 +933,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
Id = t.Id,
|
||||
|
||||
Bodypart = t.BodyPart,
|
||||
BodyPartForEditOther=t.BodyPartForEditOther,
|
||||
BodyPartForEditOther = t.BodyPartForEditOther,
|
||||
|
||||
Modalities = t.Modality,
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CreateMap<AddInstanceDto, TaskInstance>();
|
||||
|
||||
CreateMap<DicomStudy, PatientInfoDto>();
|
||||
|
||||
|
||||
CreateMap<DicomSeries, DicomSeriesWithLabelDTO>();
|
||||
|
||||
@@ -183,7 +185,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CreateMap<ImageMarkNoneDicomStudyBasicInfo, NoneDicomStudyBasicInfo>();
|
||||
|
||||
|
||||
CreateMap<DicomInstance, DownloadDicomInstanceDto>()
|
||||
.ForMember(d => d.InstanceId, u => u.MapFrom(s => s.Id));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,6 +260,11 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO
|
||||
public bool obtaionOrCancel { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateReadModuleClinicalDataInDto
|
||||
{
|
||||
public Guid ReadingClinicalDataId { get; set; }
|
||||
}
|
||||
|
||||
public class ReadingClinicalDataSignIndto
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -32,6 +32,18 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
public UserTypeEnum UserTypeEnum { get; set; }
|
||||
}
|
||||
|
||||
public class SetUserFeedBackStateInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public int State { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 原因
|
||||
/// </summary>
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
public class GetUserFeedBackQuery
|
||||
{
|
||||
@@ -86,6 +98,11 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原因
|
||||
/// </summary>
|
||||
public string Reason { get; set; } = string.Empty;
|
||||
|
||||
public List<string> ScreenshotList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
||||
@@ -53,12 +53,27 @@ namespace IRaCIS.Core.Application.Service
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户反馈状态 并且可以提供理由
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetUserFeedBackState(SetUserFeedBackStateInDto inDto)
|
||||
{
|
||||
|
||||
await _userFeedBackRepository.UpdatePartialFromQueryAsync(inDto.Id, u => new UserFeedBack() { State = inDto.State, Reason = inDto.Reason });
|
||||
await _userFeedBackRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> GetUserFeedBackInfo(GetUserFeedBackQuery inQuery)
|
||||
{
|
||||
if (inQuery.Id == null && inQuery.VisitTaskId == null)
|
||||
{
|
||||
throw new BusinessValidationFailedException("Id 或者VisitTaskId 必传一个");
|
||||
throw new BusinessValidationFailedException("The interface parameter Id or VisitTaskId cannot be passed at the same time");
|
||||
}
|
||||
|
||||
var result = await _userFeedBackRepository
|
||||
|
||||
@@ -359,6 +359,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await _mailVerificationService.AnolymousSendEmailForResetAccount(email, verificationCode);
|
||||
|
||||
await _fusionCache.RemoveAsync(CacheKeys.UserLoginError(existUser.UserName));
|
||||
|
||||
await _fusionCache.RemoveByTagAsync(CacheKeys.UserMFATag(existUser.Id));
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
@@ -415,6 +415,52 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
||||
|
||||
public string BodyPartForEditOther { get; set; }
|
||||
|
||||
#region 核验
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public string PatientSex { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
public string PatientWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 成像 / 采集时间
|
||||
/// </summary>
|
||||
public string AcquisitionTime { get; set; } = null!;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在空字符串字段(PatientSex、PatientWeight、RadionuclideTotalDose、RadionuclideHalfLife、RadiopharmaceuticalStartTime、AcquisitionTime 任意一个为空/空字符串)
|
||||
/// </summary>
|
||||
public bool IsHasEmptyPatientInfo =>
|
||||
string.IsNullOrWhiteSpace(PatientSex) ||
|
||||
string.IsNullOrWhiteSpace(PatientWeight) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideTotalDose) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideHalfLife) ||
|
||||
string.IsNullOrWhiteSpace(RadiopharmaceuticalStartTime) ||
|
||||
string.IsNullOrWhiteSpace(AcquisitionTime);
|
||||
}
|
||||
|
||||
public class QASeriesInfoDto
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string[]? VisitPlanArray { get; set; }
|
||||
public bool? IsSubjectQuit { get; set; }
|
||||
|
||||
public SubjectStatus? SubjectStatus { get; set; }
|
||||
}
|
||||
|
||||
public class GetNextQCInfoInDto
|
||||
@@ -98,6 +100,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public DateTime? EndAuditTime { get; set; }
|
||||
|
||||
public SubjectStatus? SubjectStatus { get; set; }
|
||||
|
||||
public bool? IsSubjectQuit { get; set; }
|
||||
}
|
||||
|
||||
@@ -109,6 +113,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
public Guid SubjectId { get; set; }
|
||||
[NotDefault]
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
|
||||
public bool IsSkipCurrentVisit { get; set; }
|
||||
}
|
||||
|
||||
public class GetNextIQCQualityOutDto
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray);
|
||||
|
||||
var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId)
|
||||
.WhereIf(inQuery.SubjectStatus != null, t => t.Subject.Status == inQuery.SubjectStatus)
|
||||
.Where(t => !(t.Subject.Status == SubjectStatus.EndOfVisit && t.SubmitState == SubmitStateEnum.None && !t.Subject.SubjectVisitList.Any(c => c.VisitNum > t.VisitNum && c.SubmitState > SubmitStateEnum.None)))
|
||||
.Where(t => t.Subject.FinalSubjectVisitId != null ? t.VisitNum <= t.Subject.FinalSubjectVisit.VisitNum : true)
|
||||
.WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
|
||||
@@ -280,6 +281,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
.WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState)
|
||||
.WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId)
|
||||
.WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId)
|
||||
.WhereIf(inQuery.SubjectStatus != null, t => t.Subject.Status == inQuery.SubjectStatus)
|
||||
.WhereIf(inQuery.IsSubjectQuit != null, t => t.Subject.IsSubjectQuit == inQuery.IsSubjectQuit)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => /*t.Subject.FirstName.Contains(subjectInfo) || t.Subject.LastName.Contains(subjectInfo) ||*/ t.Subject.Code.Contains(inQuery.SubjectInfo))
|
||||
.WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts.DTO;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
@@ -8,6 +9,7 @@ using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
@@ -1107,6 +1109,23 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
{
|
||||
await VerifyIsCanQCAsync(null, subjectVisitId);
|
||||
|
||||
var visit = await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId);
|
||||
|
||||
var isExistStudyClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(t => t.TrialId == visit.TrialId && t.ClinicalDataLevel == ClinicalLevel.Study&&t.IsConfirm&&t.IsApply);
|
||||
if(isExistStudyClinicalData)
|
||||
{
|
||||
List<string> modalitieTypes = new List<string>() { "PT、CT", "CT、PT", "PET-CT" };
|
||||
|
||||
var studyList=await _dicomStudyRepository.Where(t => t.SubjectVisitId == subjectVisitId&& modalitieTypes.Contains(t.Modalities)).ProjectTo<QAStudyInfoDTO>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
if (studyList.Any(x => x.IsHasEmptyPatientInfo))
|
||||
{
|
||||
return ResponseOutput.NotOk(_localizer["QCOperation_IsHasEmptyPatientInfo"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (await _qcChallengeRepository.AnyAsync(t => t.SubjectVisitId == subjectVisitId && t.IsClosed == false))
|
||||
{
|
||||
//---当前访视有质疑未关闭,不允许该操作
|
||||
@@ -1208,6 +1227,12 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
{
|
||||
await VerifyIsCanQCAsync(null, subjectVisitId);
|
||||
|
||||
|
||||
string cacheKey = CacheKeys.UserQCSkipTask(_userInfo.UserRoleId);
|
||||
|
||||
|
||||
await _fusionCache.SetAsync(cacheKey, new List<Guid>(), TimeSpan.FromMinutes(60));
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
@@ -1297,6 +1322,21 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
|
||||
var isDistinguishType = trialConfig.IsIQCAutoNextTask && trialConfig.IsIQCAutoTaskDistinguishType;
|
||||
|
||||
if (inDto.IsSkipCurrentVisit)
|
||||
{
|
||||
string cacheKey = CacheKeys.UserQCSkipTask(_userInfo.UserRoleId);
|
||||
|
||||
// 获取当前缓存中的访视Id集合(如果没有则创建空集合)
|
||||
var skippedVisits = await _fusionCache.GetOrDefaultAsync<List<Guid>>(cacheKey, new List<Guid>());
|
||||
|
||||
// 如果当前访视Id不在集合中,则添加
|
||||
if (!skippedVisits.Contains(inDto.SubjectVisitId))
|
||||
{
|
||||
skippedVisits.Add(inDto.SubjectVisitId);
|
||||
await _fusionCache.SetAsync(cacheKey, skippedVisits, TimeSpan.FromMinutes(60));
|
||||
}
|
||||
}
|
||||
|
||||
if (isDistinguishType == false)
|
||||
{
|
||||
//不区分任务类型,也要按照当前任务类型给,没找到,按照默认规则给任务 无质疑 普通质控任务
|
||||
@@ -1348,17 +1388,27 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
.Where(t => t.Subject.Status != SubjectStatus.EndOfVisit)
|
||||
.WhereIf(isDistinguishType, t => isSecondReview == true ? t.SecondReviewState == SecondReviewState.WaitAudit : t.SecondReviewState == SecondReviewState.None)
|
||||
.WhereIf(isDistinguishType, t => ishaveQCChallenge == true ? t.QCChallengeList.Any() : !t.QCChallengeList.Any())
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, SubjectVisitId = t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.OrderBy(t => t.IshaveQCChallenge).ThenBy(t => t.SecondReviewState).ThenBy(x => x.IsUrgent).ThenBy(x => x.SubjectCode).ThenBy(x => x.VisitNum).ToListAsync();
|
||||
|
||||
|
||||
// 获取当前缓存中的访视Id集合(如果没有则创建空集合)
|
||||
var skippedVisits = await _fusionCache.GetOrDefaultAsync<List<Guid>>(CacheKeys.UserQCSkipTask(_userInfo.UserRoleId), new List<Guid>() { });
|
||||
//跳过当前访视
|
||||
if (inDto.IsSkipCurrentVisit)
|
||||
{
|
||||
skippedVisits.Add(inDto.SubjectVisitId);
|
||||
|
||||
currentActionList = currentActionList.Where(t => !skippedVisits.Contains(t.SubjectVisitId)).ToList();
|
||||
}
|
||||
|
||||
if (currentActionList.Count() > 0)
|
||||
{
|
||||
return new GetNextIQCQualityOutDto()
|
||||
{
|
||||
IsReceived = true,
|
||||
SubjectId = currentActionList[0].SubjectId,
|
||||
VisitId = currentActionList[0].Id,
|
||||
VisitId = currentActionList[0].SubjectVisitId,
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1392,19 +1442,16 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
.Where(x => x.SubmitState == SubmitStateEnum.Submitted && x.TrialId == inDto.TrialId && x.CurrentActionUserId == null)
|
||||
//.WhereIf(isSecondReview, t => t.PreliminaryAuditUserId != null)
|
||||
//.Where(x => x.QCChallengeList.Count() == 0 || x.QCChallengeList.Where(y => !y.IsClosed).OrderByDescending(x => x.CreateTime).FirstOrDefault().CreateUserId != _userInfo.UserRoleId)
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, SubjectVisitId = t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.OrderBy(t => t.IshaveQCChallenge).ThenBy(t => t.SecondReviewState).ThenBy(x => x.IsUrgent).ThenBy(x => x.SubjectCode).ThenBy(x => x.VisitNum).ToListAsync();
|
||||
|
||||
//var subjectVisit = visitList.Where(x => x.SubjectId == inDto.SubjectId).OrderBy(x => x.VisitNum).FirstOrDefault();
|
||||
|
||||
//if (subjectVisit != null)
|
||||
//{
|
||||
// return new GetNextIQCQualityOutDto()
|
||||
// {
|
||||
// SubjectId = subjectVisit.SubjectId,
|
||||
// VisitId = subjectVisit.Id
|
||||
// };
|
||||
//}
|
||||
|
||||
//跳过当前访视
|
||||
if (inDto.IsSkipCurrentVisit)
|
||||
{
|
||||
visitList = visitList.Where(t => !skippedVisits.Contains(t.SubjectVisitId)).ToList();
|
||||
}
|
||||
|
||||
var subjectVisit = visitList.FirstOrDefault();
|
||||
if (subjectVisit != null)
|
||||
@@ -1412,7 +1459,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
return new GetNextIQCQualityOutDto()
|
||||
{
|
||||
SubjectId = subjectVisit.SubjectId,
|
||||
VisitId = subjectVisit.Id
|
||||
VisitId = subjectVisit.SubjectVisitId
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -1438,19 +1485,16 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
|
||||
|
||||
//.Where(x => x.QCChallengeList.Count() == 0 || x.QCChallengeList.Where(y => !y.IsClosed).OrderByDescending(x => x.CreateTime).FirstOrDefault().CreateUserId != _userInfo.UserRoleId)
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.Select(t => new { t.IsUrgent, SubjectCode = t.Subject.Code, t.SubjectId, SubjectVisitId = t.Id, t.VisitNum, IshaveQCChallenge = t.QCChallengeList.Any(), t.SecondReviewState })
|
||||
.OrderBy(t => t.IshaveQCChallenge).ThenBy(t => t.SecondReviewState).ThenBy(x => x.IsUrgent).ThenBy(x => x.SubjectCode).ThenBy(x => x.VisitNum).ToListAsync();
|
||||
|
||||
//subjectVisit = visitList.Where(x => x.SubjectId == inDto.SubjectId).OrderBy(x => x.VisitNum).FirstOrDefault();
|
||||
|
||||
//if (subjectVisit != null)
|
||||
//{
|
||||
// return new GetNextIQCQualityOutDto()
|
||||
// {
|
||||
// SubjectId = subjectVisit.SubjectId,
|
||||
// VisitId = subjectVisit.Id
|
||||
// };
|
||||
//}
|
||||
|
||||
//跳过当前访视
|
||||
if (inDto.IsSkipCurrentVisit)
|
||||
{
|
||||
visitList = visitList.Where(t => !skippedVisits.Contains(t.SubjectVisitId)).ToList();
|
||||
}
|
||||
|
||||
subjectVisit = visitList.FirstOrDefault();
|
||||
if (subjectVisit != null)
|
||||
@@ -1458,7 +1502,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
return new GetNextIQCQualityOutDto()
|
||||
{
|
||||
SubjectId = subjectVisit.SubjectId,
|
||||
VisitId = subjectVisit.Id
|
||||
VisitId = subjectVisit.SubjectVisitId
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -1975,7 +2019,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
SubjectVisitId = dbSubjectVisit.Id,
|
||||
ModuleName = $"G-{dbSubjectVisit.VisitName}",
|
||||
ModuleType = ModuleTypeEnum.Global,
|
||||
ReadModuleAddTypeEnum= dbSubjectVisit.PDState == PDStateEnum.PDProgress? ReadModuleAddType.PDConfirmation : ReadModuleAddType.FinalVisit,
|
||||
ReadModuleAddTypeEnum = dbSubjectVisit.PDState == PDStateEnum.PDProgress ? ReadModuleAddType.PDConfirmation : ReadModuleAddType.FinalVisit,
|
||||
IsUrgent = dbSubjectVisit.IsUrgent,
|
||||
TrialId = dbSubjectVisit.TrialId,
|
||||
SubjectId = dbSubjectVisit.SubjectId
|
||||
@@ -1984,7 +2028,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
|
||||
if (await _readingQuestionCriterionTrialRepository.AnyAsync(x => x.Id == trialReadingCriterionId && x.IsOncologyReading))
|
||||
{
|
||||
await _readModuleRepository.AddAsync(new ReadModule()
|
||||
await _readModuleRepository.AddAsync(new ReadModule()
|
||||
{
|
||||
TrialReadingCriterionId = trialReadingCriterionId,
|
||||
ReadingSetType = ReadingSetType.TumorReading,
|
||||
|
||||
@@ -372,6 +372,34 @@ namespace IRaCIS.Core.Application.Service
|
||||
return ResponseOutput.Result(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改临床数据后 将签名状态变更为未签名
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> UpdateReadModuleClinicalData(UpdateReadModuleClinicalDataInDto inDto)
|
||||
{
|
||||
var data = await _readingClinicalDataRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == inDto.ReadingClinicalDataId);
|
||||
|
||||
await _readingClinicalDataRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.ReadingClinicalDataId, x => new ReadingClinicalData()
|
||||
{
|
||||
IsSign = false,
|
||||
ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded
|
||||
});
|
||||
|
||||
var result = await _readModuleRepository.Where(x=>x.Id== data.ReadingId).Include(x=>x.SubjectVisit).FirstNotNullAsync();
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(x => x.TrialReadingCriterionId == result.TrialReadingCriterionId && x.VisitTaskNum > result.SubjectVisit.VisitNum, x => new VisitTask()
|
||||
{
|
||||
IsFrontTaskNeedSignButNotSign = false,
|
||||
});
|
||||
await _visitTaskRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Result(true);
|
||||
|
||||
|
||||
}
|
||||
///// <summary>
|
||||
///// 一致性分析的临床数据
|
||||
///// </summary>
|
||||
|
||||
@@ -208,25 +208,30 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public class IVUSMeasuredValue
|
||||
{
|
||||
///// <summary>
|
||||
///// 斑块编号
|
||||
///// </summary>
|
||||
//public int PlaqueNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 斑块编号
|
||||
/// 帧数
|
||||
/// </summary>
|
||||
public int PlaqueNum { get; set; }
|
||||
public string FrameNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外弹力膜面积Emm
|
||||
/// </summary>
|
||||
public decimal Emm { get; set; }
|
||||
public decimal? Emm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管腔面积Lumen
|
||||
/// </summary>
|
||||
public decimal Lumen { get; set; }
|
||||
public decimal? Lumen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外弹力膜面积- 管腔面积
|
||||
/// </summary>
|
||||
public decimal EmmSubtractionLumen
|
||||
public decimal? EmmSubtractionLumen
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -245,24 +250,24 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
public class OCTFCTUploadData
|
||||
{
|
||||
/// <summary>
|
||||
/// 斑块编号
|
||||
/// 帧数
|
||||
/// </summary>
|
||||
public int PlaqueNum { get; set; }
|
||||
public string FrameNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第一次
|
||||
/// </summary>
|
||||
public decimal FirstData { get; set; }
|
||||
public decimal? FirstData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第二次
|
||||
/// </summary>
|
||||
public decimal SecondData { get; set; }
|
||||
public decimal? SecondData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 第三次
|
||||
/// </summary>
|
||||
public decimal ThirdData { get; set; }
|
||||
public decimal? ThirdData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 巨噬细胞浸润测量
|
||||
@@ -290,13 +295,27 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public decimal? LumenAreaMeasurement { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 脂质角度
|
||||
/// </summary>
|
||||
public decimal? LipidAngle { get; set; }
|
||||
|
||||
|
||||
public decimal? Avg
|
||||
{
|
||||
get
|
||||
{
|
||||
var values = new[] { FirstData, SecondData, ThirdData };
|
||||
|
||||
public decimal Avg { get {
|
||||
|
||||
return ( FirstData + SecondData + ThirdData) / 3;
|
||||
} }
|
||||
var count = values.Count(x => x.HasValue);
|
||||
if (count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var avg = values.Where(x => x.HasValue).Select(x => x.Value).Average();
|
||||
return avg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -480,6 +480,22 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public ValueUnit? Unit { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
public ValueOfType? ValueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义单位
|
||||
/// </summary>
|
||||
public string? CustomUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public string? Type { get; set; }
|
||||
|
||||
public List<ReportChartData> ChartDataList { get; set; }
|
||||
|
||||
|
||||
@@ -536,6 +552,21 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
public ReportChartType? ChartType { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public ValueUnit? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
public ValueOfType? ValueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义单位
|
||||
/// </summary>
|
||||
public string? CustomUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public string? Type { get; set; }
|
||||
public List<string> VisitTaskNameList { get; set; } = new List<string>();
|
||||
public List<DateTime?> LatestScanDateList { get; set; } = new List<DateTime?>();
|
||||
public List<ReportChartData> ChartDataList { get; set; } = new List<ReportChartData>();
|
||||
@@ -2087,6 +2118,16 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
|
||||
public bool IsHaveKeyFile { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 定圆工具默认半径
|
||||
/// </summary>
|
||||
public decimal? CircleRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认SegmentName
|
||||
/// </summary>
|
||||
public DefaultSegmentNameDto DefaultSegmentName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class GetReadingImgInDto
|
||||
@@ -2207,6 +2248,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public ValueUnit? Unit { get; set; }
|
||||
|
||||
public string CustomUnit { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 答案组合
|
||||
/// </summary>
|
||||
|
||||
@@ -203,6 +203,27 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
public Guid TaskMedicalReviewId { get; set; }
|
||||
}
|
||||
|
||||
public class CloseAndFinishMedicalReview
|
||||
{
|
||||
public Guid TaskMedicalReviewId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否关闭
|
||||
/// </summary>
|
||||
public bool IsClosedDialog { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 医学审核对话关闭原因
|
||||
/// </summary>
|
||||
public MedicalDialogClose MedicalDialogCloseEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对话关闭原因
|
||||
/// </summary>
|
||||
public string DialogCloseReason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class JointMedicalReviewI18n
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -324,6 +324,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public ImageMark? ImageMarkEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 影像标记类型
|
||||
/// </summary>
|
||||
public ImageMarkType? ImageMarkTypeEnum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否预设
|
||||
@@ -983,6 +988,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public ImageMark? ImageMarkEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 影像标记类型
|
||||
/// </summary>
|
||||
public ImageMarkType? ImageMarkTypeEnum { get; set; }
|
||||
|
||||
public string QuestionGroupName { get; set; }
|
||||
|
||||
public string QuestionGroupEnName { get; set; }
|
||||
@@ -2463,6 +2473,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
/// </summary>
|
||||
public ImageMark? ImageMarkEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 影像标记类型
|
||||
/// </summary>
|
||||
public ImageMarkType? ImageMarkTypeEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 影像工具
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-19 07:13:41Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
public class SegmentBindingView : SegmentBindingAddOrEdit
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否锁定
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; } = false;
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分割分组名称
|
||||
/// </summary>
|
||||
public string SegmentationName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// SegmentName
|
||||
/// </summary>
|
||||
public string SegmentName { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
|
||||
public class SaveSegmentBindingAndAnswerInDto
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
public List<SaveSegmentBindingDto> BindingList { get; set; }
|
||||
}
|
||||
|
||||
public class SaveSegmentBindingDto
|
||||
{
|
||||
public string Answer { get; set; }
|
||||
|
||||
public Guid? QuestionId { get; set; }
|
||||
|
||||
public Guid? RowId { get; set; }
|
||||
|
||||
public Guid? SegmentId { get; set; }
|
||||
|
||||
public Guid? SegmentationId { get; set; }
|
||||
|
||||
public Guid? TableQuestionId { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
public class SegmentBindingAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public Guid? QuestionId { get; set; }
|
||||
|
||||
public Guid? RowId { get; set; }
|
||||
|
||||
public Guid SegmentId { get; set; }
|
||||
|
||||
public Guid SegmentationId { get; set; }
|
||||
|
||||
public Guid? TableQuestionId { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class LockOrUnLockSegmentInDto
|
||||
{
|
||||
public Guid SegmentId { get; set; }
|
||||
|
||||
public bool IsLock { get; set; }
|
||||
}
|
||||
public class SegmentBindingQuery:PageInput
|
||||
{
|
||||
public Guid? QuestionId { get; set; }
|
||||
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
|
||||
public Guid? RowId { get; set; }
|
||||
|
||||
public Guid? SegmentId { get; set; }
|
||||
|
||||
public Guid? SegmentationId { get; set; }
|
||||
|
||||
public Guid? TableQuestionId { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 05:44:27Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
public class SegmentView : SegmentAddOrEdit
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否锁定
|
||||
/// </summary>
|
||||
public bool IsLock { get; set; } = false;
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class SegmentAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public decimal? AvgValue { get; set; }
|
||||
|
||||
public string ColorRgb { get; set; }
|
||||
|
||||
public decimal? MTV { get; set; }
|
||||
|
||||
public decimal? MajorAxis { get; set; }
|
||||
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
public decimal? Median { get; set; }
|
||||
|
||||
public decimal? MinValue { get; set; }
|
||||
|
||||
public decimal? Peak { get; set; }
|
||||
|
||||
public int SegmentNumber { get; set; }
|
||||
|
||||
public string SegmentName { get; set; }
|
||||
|
||||
public Guid SegmentationId { get; set; }
|
||||
|
||||
public decimal? ShortAxis { get; set; }
|
||||
|
||||
public decimal? TLG { get; set; }
|
||||
|
||||
public decimal? Variance { get; set; }
|
||||
|
||||
public decimal? Volume { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分割的Json
|
||||
/// </summary>
|
||||
public string SegmentJson { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SegmentQuery:PageInput
|
||||
{
|
||||
public decimal? AvgValue { get; set; }
|
||||
|
||||
public string? ColorRgb { get; set; }
|
||||
|
||||
public decimal? MTV { get; set; }
|
||||
|
||||
public decimal? MajorAxis { get; set; }
|
||||
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
public decimal? Median { get; set; }
|
||||
|
||||
public decimal? MinValue { get; set; }
|
||||
|
||||
public decimal? Peak { get; set; }
|
||||
|
||||
public int? SegmentNumber { get; set; }
|
||||
|
||||
public string? SegmentName { get; set; }
|
||||
|
||||
public Guid? SegmentationId { get; set; }
|
||||
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
public decimal? ShortAxis { get; set; }
|
||||
|
||||
public decimal? TLG { get; set; }
|
||||
|
||||
public decimal? Variance { get; set; }
|
||||
|
||||
public decimal? Volume { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:17:31Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
public class SegmentationView : SegmentationAddOrEdit
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否保存
|
||||
/// </summary>
|
||||
public bool IsSaved { get; set; } = false;
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class ChangeSegmentationSavedStatusInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否保存
|
||||
/// </summary>
|
||||
public bool IsSaved { get; set; } = false;
|
||||
}
|
||||
|
||||
public class SegmentationAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public string SEGUrl { get; set; }
|
||||
|
||||
public string SegmentationJson { get; set; }
|
||||
|
||||
public string SegmentationName { get; set; }
|
||||
|
||||
public Guid SeriesId { get; set; }
|
||||
|
||||
public Guid StudyId { get; set; }
|
||||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小,单位字节
|
||||
/// </summary>
|
||||
public long FileSize { get; set; } = 0;
|
||||
|
||||
}
|
||||
|
||||
public class SegmentationQuery:PageInput
|
||||
{
|
||||
public string? SEGUrl { get; set; }
|
||||
|
||||
public string? SegmentationJson { get; set; }
|
||||
|
||||
public string? SegmentationName { get; set; }
|
||||
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public Guid? StudyId { get; set; }
|
||||
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
public Guid? SubjectVisitId { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
public class SegmentationVersionView
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SegmentationId { get; set; }
|
||||
public int Version { get; set; }
|
||||
public string SegmentationJson { get; set; }
|
||||
public string SEGUrl { get; set; }
|
||||
public long FileSize { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public string CreateUserName { get; set; }
|
||||
}
|
||||
|
||||
public class SaveSegmentationVersionAsyncInDto
|
||||
{
|
||||
public Guid SegmentationId { get; set; }
|
||||
}
|
||||
|
||||
public class SegmentationVersionQuery : PageInput
|
||||
{
|
||||
public Guid SegmentationId { get; set; }
|
||||
}
|
||||
|
||||
public class RestoreSegmentationVersionInDto
|
||||
{
|
||||
public Guid SegmentationId { get; set; }
|
||||
public Guid VersionId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,8 +27,16 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class GetAutoCutNextTaskInDto
|
||||
{
|
||||
public int ImageToolType { get; set; }
|
||||
}
|
||||
|
||||
public class SetAutoCutNextTaskInDto
|
||||
{
|
||||
public int ImageToolType { get; set; }
|
||||
|
||||
public bool AutoCutNextTask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,5 +9,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
Task<IResponseOutput> FinishMedicalReview(FinishMedicalReviewInDto inDto);
|
||||
|
||||
Task<IResponseOutput> ClosedMedicalReviewDialog(ClosedMedicalReviewDialogInDto inDto);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:17:31Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Interfaces;
|
||||
|
||||
public interface ISegmentationService
|
||||
{
|
||||
|
||||
Task<PageOutput<SegmentationView>> GetSegmentationList(SegmentationQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation);
|
||||
|
||||
Task<IResponseOutput> DeleteSegmentation(Guid segmentationId);
|
||||
|
||||
|
||||
Task<PageOutput<SegmentView>> GetSegmentList(SegmentQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateSegment(SegmentAddOrEdit addOrEditSegment);
|
||||
|
||||
Task<IResponseOutput> DeleteSegment(Guid segmentId);
|
||||
|
||||
Task<PageOutput<SegmentBindingView>> GetSegmentBindingList(SegmentBindingQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateSegmentBinding(SegmentBindingAddOrEdit addOrEditSegmentBinding);
|
||||
|
||||
Task<IResponseOutput> DeleteSegmentBinding(Guid segmentBindingId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
@@ -787,7 +787,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
.Select(x => new GetTrialGroupNameOutDto
|
||||
{
|
||||
GroupId = x.Id,
|
||||
GroupName = x.GroupName,
|
||||
GroupName =_userInfo.IsEn_Us?x.GroupEnName: x.GroupName,
|
||||
}).ToListAsync();
|
||||
|
||||
return result;
|
||||
@@ -1485,7 +1485,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
toolList = toolList.Distinct().ToList();
|
||||
|
||||
if (tabletoolList.Except(trialCriterion.ReadingToolList).Count() > 0)
|
||||
var alltool = trialCriterion.ReadingToolList.Union(trialCriterion.SegmentToolList).ToList();
|
||||
|
||||
if (tabletoolList.Except(alltool).Count() > 0)
|
||||
{
|
||||
//---问题的阅片工具不在标准配置的阅片工具列表中
|
||||
throw new BusinessValidationFailedException(_localizer["TrialConfig_TableToolNotInStdTool"]);
|
||||
@@ -1780,5 +1782,28 @@ namespace IRaCIS.Core.Application.Service
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目问题id获取项目问题信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ReadingQuestionTrialView> GetReadingQuestionTrialById(Guid id)
|
||||
{
|
||||
var result = await _readingQuestionTrialRepository.Where(x => x.Id == id).ProjectTo<ReadingQuestionTrialView>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目表格问题id获取项目表格问题信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ReadingTableQuestionTrialView> GetReadingTableQuestionTrialById(Guid id)
|
||||
{
|
||||
var result = await _readingTableQuestionTrialRepository.Where(x => x.Id == id).ProjectTo<ReadingTableQuestionTrialView>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
IRepository<UserLog> _userLogRepository,
|
||||
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||
IRepository<ReadingOncologyTaskInfo> _readingOncologyTaskInfoRepository,
|
||||
IRepository<Segmentation> _segmentationRepository,
|
||||
IRepository<SegmentBinding> _segmentBindingRepository,
|
||||
IVisitTaskHelpeService _visitTaskHelpeService,
|
||||
IVisitTaskService _visitTaskService,
|
||||
IReadingClinicalDataService _readingClinicalDataService,
|
||||
@@ -3371,6 +3373,12 @@ namespace IRaCIS.Core.Application.Service
|
||||
return ResponseOutput.NotOk(_localizer["ReadingImage_BackImageNotExist"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (await _segmentationRepository.AnyAsync(x => !x.IsSaved && x.VisitTaskId == inDto.VisitTaskId))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["ReadingImage_SegmentationNeedSave"]);
|
||||
}
|
||||
|
||||
await VerifyTaskIsSign(inDto.VisitTaskId);
|
||||
await VerifyDefaultQuestionBeAnswer(inDto);
|
||||
|
||||
@@ -3407,6 +3415,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
throw new BusinessValidationFailedException(_localizer["ReadingImage_RequiredQuestion", string.Join(',', readingQuestionList.Select(x => x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us)))]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 各个标准不同
|
||||
await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
|
||||
|
||||
@@ -3782,6 +3792,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
x.IseCRFShowInDicomReading,
|
||||
x.IsReadingTaskViewInOrder,
|
||||
x.ReadingToolList,
|
||||
x.CircleRadius,
|
||||
x.DefaultSegmentName,
|
||||
}).FirstNotNullAsync();
|
||||
|
||||
task.IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults;
|
||||
@@ -3825,6 +3837,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
var trialInfo = await _trialRepository.Where(x => x.Id == visitTaskInfo.TrialId).FirstNotNullAsync();
|
||||
|
||||
// 如果已经签名 就不需要再读了
|
||||
task.CircleRadius = criterionInfo.CircleRadius;
|
||||
task.DefaultSegmentName = criterionInfo.DefaultSegmentName;
|
||||
task.IsNeedReadClinicalData = visitTaskInfo.ReadingTaskState == ReadingTaskState.HaveSigned ? false : task.IsNeedReadClinicalData;
|
||||
task.DigitPlaces = criterionInfo.DigitPlaces;
|
||||
task.CriterionType = criterionInfo.CriterionType;
|
||||
@@ -3875,6 +3889,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
|
||||
await _readingNoneDicomMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
|
||||
await _readingNoneDicomMarkBindingRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
|
||||
await _segmentBindingRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
|
||||
|
||||
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.WaitReading
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
Type = x.Type,
|
||||
ShowOrder= x.ShowOrder,
|
||||
Unit = x.Unit,
|
||||
CustomUnit= x.CustomUnit,
|
||||
ReadingQuestionTrialId = x.Id,
|
||||
JudgeDifferenceValue = x.JudgeDifferenceValue,
|
||||
JudgeDifferenceType = x.JudgeDifferenceType,
|
||||
|
||||
@@ -0,0 +1,523 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2026-03-10 06:17:28Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
/// <summary>
|
||||
/// 分割
|
||||
/// </summary>
|
||||
/// <param name="_segmentationRepository"></param>
|
||||
/// <param name="_mapper"></param>
|
||||
/// <param name="_userInfo"></param>
|
||||
/// <param name="_localizer"></param>
|
||||
[ ApiExplorerSettings(GroupName = "Reading")]
|
||||
public class SegmentationService(IRepository<Segmentation> _segmentationRepository,
|
||||
IRepository<SegmentBinding> _segmentBindingRepository,
|
||||
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||
IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||
IRepository<Segment> _segmentRepository,
|
||||
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||
IRepository<SegmentationVersion> _segmentationVersionRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, ISegmentationService
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取分割组
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SegmentationView>> GetSegmentationList(SegmentationQuery inQuery)
|
||||
{
|
||||
|
||||
var segmentationQueryable =_segmentationRepository
|
||||
.WhereIf(inQuery.SegmentationName.IsNotNullOrEmpty(),x=>x.SegmentationName.Contains(inQuery.SegmentationName))
|
||||
.WhereIf(inQuery.Id != null, x => x.Id == inQuery.Id)
|
||||
.WhereIf(inQuery.TrialId != null, x => x.TrialId == inQuery.TrialId)
|
||||
.WhereIf(inQuery.SeriesId != null, x => x.SeriesId == inQuery.SeriesId)
|
||||
.WhereIf(inQuery.StudyId != null, x => x.StudyId == inQuery.StudyId)
|
||||
.WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
|
||||
.WhereIf(inQuery.SubjectVisitId != null, x => x.SubjectVisitId == inQuery.SubjectVisitId)
|
||||
.WhereIf(inQuery.VisitTaskId != null, x => x.VisitTaskId == inQuery.VisitTaskId)
|
||||
.ProjectTo<SegmentationView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList= await segmentationQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改分割组
|
||||
/// </summary>
|
||||
/// <param name="addOrEditSegmentation"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateSegmentation(SegmentationAddOrEdit addOrEditSegmentation)
|
||||
{
|
||||
|
||||
if (addOrEditSegmentation.Id != null)
|
||||
{
|
||||
|
||||
await SaveSegmentationVersionAsync(new SaveSegmentationVersionAsyncInDto() { SegmentationId = addOrEditSegmentation.Id.Value });
|
||||
}
|
||||
var entity = await _segmentationRepository.InsertOrUpdateAsync(addOrEditSegmentation, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加新版本
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
private async Task SaveSegmentationVersionAsync(SaveSegmentationVersionAsyncInDto inDto)
|
||||
{
|
||||
var data = await _segmentationRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == inDto.SegmentationId);
|
||||
var segmentList = await _segmentRepository.Where(x => x.SegmentationId == inDto.SegmentationId).OrderBy(x=>x.SegmentNumber).ProjectTo<SegmentVersionData>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
if (data.SEGUrl != string.Empty)
|
||||
{
|
||||
// 如果是新增或修改,记录一条版本信息
|
||||
var maxVersion = await _segmentationVersionRepository
|
||||
.Where(x => x.SegmentationId == data.Id)
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Select(x => x.Version)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
var newVersion = maxVersion + 1;
|
||||
|
||||
var versionEntity = new SegmentationVersion
|
||||
{
|
||||
SegmentationId = data.Id,
|
||||
Version = newVersion,
|
||||
SegmentationJson = data.SegmentationJson,
|
||||
SEGUrl = data.SEGUrl,
|
||||
FileSize = data.FileSize,
|
||||
SegmentList= segmentList,
|
||||
};
|
||||
|
||||
await _segmentationVersionRepository.AddAsync(versionEntity);
|
||||
|
||||
await _segmentationRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取分割组历史版本
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SegmentationVersionView>> GetSegmentationVersionList(SegmentationVersionQuery inQuery)
|
||||
{
|
||||
var versionQueryable = _segmentationVersionRepository
|
||||
.Where(x => x.SegmentationId == inQuery.SegmentationId)
|
||||
.ProjectTo<SegmentationVersionView>(_mapper.ConfigurationProvider);
|
||||
var defalutSortArray = new string[] { nameof(SegmentationVersion.Version) + " desc" };
|
||||
var pageList = await versionQueryable.ToPagedListAsync(inQuery, defalutSortArray);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复分割组历史版本
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> RestoreSegmentationVersion(RestoreSegmentationVersionInDto inDto)
|
||||
{
|
||||
var version = await _segmentationVersionRepository.Where(x => x.Id == inDto.VersionId && x.SegmentationId == inDto.SegmentationId).FirstNotNullAsync();
|
||||
var segmentation = await _segmentationRepository.Where(x => x.Id == inDto.SegmentationId).FirstNotNullAsync();
|
||||
|
||||
await SaveSegmentationVersionAsync(new SaveSegmentationVersionAsyncInDto() { SegmentationId=inDto.SegmentationId});
|
||||
await _segmentationRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.SegmentationId, t => new Segmentation
|
||||
{
|
||||
SegmentationJson = version.SegmentationJson,
|
||||
SEGUrl = version.SEGUrl,
|
||||
FileSize = version.FileSize,
|
||||
});
|
||||
|
||||
var segmentList = _mapper.Map<List<Segment>>(version.SegmentList);
|
||||
|
||||
await _segmentRepository.BatchDeleteNoTrackingAsync(x => x.SegmentationId == inDto.SegmentationId);
|
||||
await _segmentRepository.AddRangeAsync(segmentList);
|
||||
|
||||
await _segmentationRepository.SaveChangesAsync();
|
||||
|
||||
await DeleteBindingsAndAnswersAsync(inDto.SegmentationId, null);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除分割组
|
||||
/// </summary>
|
||||
/// <param name="segmentationId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{segmentationId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteSegmentation(Guid segmentationId)
|
||||
{
|
||||
await DeleteBindingsAndAnswersAsync(segmentationId, null);
|
||||
var success = await _segmentationRepository.DeleteFromQueryAsync(t => t.Id == segmentationId,true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改分割组的保存状态
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ChangeSegmentationSavedStatus(ChangeSegmentationSavedStatusInDto inDto)
|
||||
{
|
||||
await _segmentationRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.Id, t => new Segmentation
|
||||
{
|
||||
IsSaved = inDto.IsSaved
|
||||
});
|
||||
await _segmentationRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取分割
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SegmentView>> GetSegmentList(SegmentQuery inQuery)
|
||||
{
|
||||
|
||||
var segmentQueryable = _segmentRepository
|
||||
|
||||
.WhereIf(inQuery.SegmentationId != null, x => x.SegmentationId == inQuery.SegmentationId)
|
||||
.WhereIf(inQuery.SegmentName.IsNotNullOrEmpty(), x => x.SegmentName.Contains(inQuery.SegmentName))
|
||||
.WhereIf(inQuery.VisitTaskId != null, x => x.VisitTaskId == inQuery.VisitTaskId)
|
||||
.WhereIf(inQuery.Id != null, x => x.Id == inQuery.Id)
|
||||
.ProjectTo<SegmentView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await segmentQueryable.ToPagedListAsync(inQuery,nameof(SegmentView.SegmentNumber));
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改分割
|
||||
/// </summary>
|
||||
/// <param name="addOrEditSegment"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateSegment(SegmentAddOrEdit addOrEditSegment)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var entity = await _segmentRepository.InsertOrUpdateAsync(addOrEditSegment, true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除分割
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{segmentId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteSegment(Guid segmentId)
|
||||
{
|
||||
await DeleteBindingsAndAnswersAsync(null, segmentId);
|
||||
var success = await _segmentRepository.DeleteFromQueryAsync(t => t.Id == segmentId, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 锁定解锁分割
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> LockOrUnLockSegment(LockOrUnLockSegmentInDto inDto)
|
||||
{
|
||||
await _segmentRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.SegmentId, t => new Segment
|
||||
{
|
||||
IsLock = inDto.IsLock
|
||||
});
|
||||
await _segmentRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取分割绑定
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<SegmentBindingView>> GetSegmentBindingList(SegmentBindingQuery inQuery)
|
||||
{
|
||||
|
||||
var segmentBindingQueryable = _segmentBindingRepository
|
||||
.WhereIf(inQuery.Id != null, x => x.Id == inQuery.Id)
|
||||
.WhereIf(inQuery.QuestionId != null, x => x.QuestionId == inQuery.QuestionId)
|
||||
.WhereIf(inQuery.RowId != null, x => x.RowId == inQuery.RowId)
|
||||
.WhereIf(inQuery.SegmentId != null, x => x.SegmentId == inQuery.SegmentId)
|
||||
.WhereIf(inQuery.SegmentationId != null, x => x.SegmentationId == inQuery.SegmentationId)
|
||||
.WhereIf(inQuery.TableQuestionId != null, x => x.TableQuestionId == inQuery.TableQuestionId)
|
||||
.WhereIf(inQuery.VisitTaskId != null, x => x.VisitTaskId == inQuery.VisitTaskId)
|
||||
.ProjectTo<SegmentBindingView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await segmentBindingQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改分割绑定
|
||||
/// </summary>
|
||||
/// <param name="addOrEditSegmentBinding"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> AddOrUpdateSegmentBinding(SegmentBindingAddOrEdit addOrEditSegmentBinding)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var entity = await _segmentBindingRepository.InsertOrUpdateAsync(addOrEditSegmentBinding, true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除分割
|
||||
/// </summary>
|
||||
/// <param name="segmentBindingId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{segmentBindingId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteSegmentBinding(Guid segmentBindingId)
|
||||
{
|
||||
var success = await _segmentBindingRepository.DeleteFromQueryAsync(t => t.Id == segmentBindingId, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存分割绑定和答案
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> SaveSegmentBindingAndAnswer(SaveSegmentBindingAndAnswerInDto inDto)
|
||||
{
|
||||
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId)
|
||||
.FirstNotNullAsync();
|
||||
foreach (var item in inDto.BindingList)
|
||||
{
|
||||
// 处理绑定关系
|
||||
var binding = await _segmentBindingRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == item.QuestionId && x.RowId == item.RowId && x.TableQuestionId == item.TableQuestionId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (binding == null)
|
||||
{
|
||||
if (item.SegmentationId != null && item.SegmentId != null)
|
||||
{
|
||||
await _segmentBindingRepository.InsertFromDTOAsync(new SegmentBinding
|
||||
{
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
QuestionId = item.QuestionId,
|
||||
RowId = item.RowId,
|
||||
TableQuestionId = item.TableQuestionId,
|
||||
SegmentId = item.SegmentId.Value,
|
||||
SegmentationId = item.SegmentationId.Value,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.SegmentationId != null && item.SegmentId != null)
|
||||
{
|
||||
await _segmentBindingRepository.UpdatePartialFromQueryAsync(x => x.Id == binding.Id, t => new SegmentBinding
|
||||
{
|
||||
SegmentId = item.SegmentId.Value,
|
||||
SegmentationId = item.SegmentationId.Value,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await _segmentBindingRepository.DeleteFromQueryAsync(x => x.Id == binding.Id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 处理问题
|
||||
if (item.RowId != null && item.TableQuestionId != null&&item.QuestionId!=null)
|
||||
{
|
||||
var answer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId&&x.QuestionId==item.QuestionId && x.RowId == item.RowId && x.TableQuestionId == item.TableQuestionId)
|
||||
.FirstOrDefaultAsync();
|
||||
var rowinfo= await _readingTableAnswerRowInfoRepository.Where(x => x.Id==item.RowId)
|
||||
.Include(x=>x.VisitTask)
|
||||
.FirstNotNullAsync();
|
||||
if (answer != null)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => x.Id == answer.Id, t => new ReadingTableQuestionAnswer
|
||||
{
|
||||
Answer = item.Answer
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.InsertFromDTOAsync(new ReadingTableQuestionAnswer
|
||||
{
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = item.RowId.Value,
|
||||
QuestionId=item.QuestionId.Value,
|
||||
TableQuestionId = item.TableQuestionId.Value,
|
||||
Answer = item.Answer,
|
||||
TrialId= rowinfo.VisitTask.TrialId,
|
||||
RowIndex= rowinfo.RowIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var answer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId &&x.ReadingQuestionTrialId==item.QuestionId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (answer != null)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => x.Id == answer.Id, t => new ReadingTaskQuestionAnswer
|
||||
{
|
||||
Answer = item.Answer
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.InsertFromDTOAsync(new ReadingTaskQuestionAnswer
|
||||
{
|
||||
ReadingQuestionTrialId= item.QuestionId.Value,
|
||||
ReadingQuestionCriterionTrialId=taskinfo.TrialReadingCriterionId,
|
||||
TrialId= taskinfo.TrialId,
|
||||
SubjectId= taskinfo.SubjectId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
Answer=item.Answer,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
await _segmentationRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除分割组和分割时的关联数据删除逻辑
|
||||
/// </summary>
|
||||
/// <param name="segmentationId"></param>
|
||||
/// <param name="segmentId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task DeleteBindingsAndAnswersAsync(Guid? segmentationId, Guid? segmentId)
|
||||
{
|
||||
var bindingsQuery = _segmentBindingRepository
|
||||
.WhereIf(segmentationId != null, x => x.SegmentationId == segmentationId)
|
||||
.WhereIf(segmentId != null, x => x.SegmentId == segmentId);
|
||||
|
||||
var bindings = await bindingsQuery.ToListAsync();
|
||||
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
var visited = new HashSet<Guid>();
|
||||
|
||||
// 处理问题
|
||||
if (binding.RowId != null && binding.TableQuestionId != null)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.RowId == binding.RowId && x.TableQuestionId == binding.TableQuestionId);
|
||||
|
||||
await DeleteDependentAnswersAsync(binding.TableQuestionId.Value, binding.VisitTaskId, binding.RowId, visited);
|
||||
}
|
||||
else if (binding.QuestionId != null)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == binding.VisitTaskId && x.ReadingQuestionTrialId == binding.QuestionId);
|
||||
|
||||
await DeleteDependentAnswersAsync(binding.QuestionId.Value, binding.VisitTaskId, null, visited);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理绑定关系
|
||||
if (segmentationId != null)
|
||||
{
|
||||
await _segmentBindingRepository.DeleteFromQueryAsync(x => x.SegmentationId == segmentationId);
|
||||
}
|
||||
else if (segmentId != null)
|
||||
{
|
||||
await _segmentBindingRepository.DeleteFromQueryAsync(x => x.SegmentId == segmentId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归清除依赖此问题的计算问题答案
|
||||
/// </summary>
|
||||
private async Task DeleteDependentAnswersAsync(Guid sourceQuestionId, Guid visitTaskId, Guid? rowId, HashSet<Guid> visited)
|
||||
{
|
||||
if (visited.Contains(sourceQuestionId)) return;
|
||||
visited.Add(sourceQuestionId);
|
||||
|
||||
var sourceQuestionIdStr = sourceQuestionId.ToString();
|
||||
|
||||
var dependentTableQuestions = await _readingTableQuestionTrialRepository
|
||||
.Where(x => x.DataSource == DataSources.Automatic && x.Type == "number" && x.CalculateQuestions.Contains(sourceQuestionIdStr))
|
||||
.Select(x => x.Id)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var tableQuestionId in dependentTableQuestions)
|
||||
{
|
||||
if (rowId != null)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == visitTaskId && x.RowId == rowId && x.TableQuestionId == tableQuestionId);
|
||||
}
|
||||
await DeleteDependentAnswersAsync(tableQuestionId, visitTaskId, rowId, visited);
|
||||
}
|
||||
|
||||
var dependentTaskQuestions = await _readingQuestionTrialRepository
|
||||
.Where(x => x.DataSource == DataSources.Automatic && x.Type == "number" && x.CalculateQuestions.Contains(sourceQuestionIdStr))
|
||||
.Select(x => x.Id)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var taskQuestionId in dependentTaskQuestions)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == visitTaskId && x.ReadingQuestionTrialId == taskQuestionId);
|
||||
await DeleteDependentAnswersAsync(taskQuestionId, visitTaskId, rowId, visited);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
var defaultshortcutKeyList = this.GetDefaultShortcutKey();
|
||||
|
||||
var shortcutKeydic = await _dictionaryRepository.Where(x => x.Parent.Code == "ShortcutKey")
|
||||
.Where(x=>x.ChildGroup.Contains(inQuery.ImageToolType.ToString()))
|
||||
.WhereIf(inQuery.ShortcutKeyEnum != null, x => x.Code == inQuery.ShortcutKeyEnum.ToString()).ToListAsync();
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Reading")]
|
||||
public class UserWLTemplateService(IRepository<UserWLTemplate> _userWLTemplateRepository,
|
||||
IRepository<ReadingUserConfig> _readingUserConfigRepository,
|
||||
IRepository<UserRole> _userRoleRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
|
||||
{
|
||||
|
||||
@@ -82,15 +83,18 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<object> GetAutoCutNextTask()
|
||||
public async Task<object> GetAutoCutNextTask(GetAutoCutNextTaskInDto inDto)
|
||||
{
|
||||
|
||||
var result = await _userRoleRepository.Where(x => x.Id == _userInfo.UserRoleId).Select(x => new
|
||||
var result = await _readingUserConfigRepository.Where(x => x.UserRoleId == _userInfo.UserRoleId&&x.ImageToolType==inDto.ImageToolType).Select(x => new
|
||||
{
|
||||
AutoCutNextTask = x.AutoCutNextTask,
|
||||
IsDoubleScreen = x.IsDoubleScreen,
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
return new
|
||||
@@ -112,14 +116,30 @@ namespace IRaCIS.Core.Application.Service
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetAutoCutNextTask(SetAutoCutNextTaskInDto inDto)
|
||||
{
|
||||
await _userRoleRepository.UpdatePartialFromQueryAsync(_userInfo.UserRoleId, x => new UserRole()
|
||||
|
||||
var userConfig = await _readingUserConfigRepository.FirstOrDefaultNoTrackingAsync(x => x.UserRoleId == _userInfo.UserRoleId && x.ImageToolType == inDto.ImageToolType);
|
||||
|
||||
if (userConfig == null)
|
||||
{
|
||||
await _readingUserConfigRepository.AddAsync(new ReadingUserConfig
|
||||
{
|
||||
UserRoleId = _userInfo.UserRoleId,
|
||||
ImageToolType = inDto.ImageToolType,
|
||||
AutoCutNextTask = inDto.AutoCutNextTask,
|
||||
IsDoubleScreen = inDto.IsDoubleScreen,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await _readingUserConfigRepository.UpdatePartialFromQueryAsync(x=>x.Id==userConfig.Id, x => new ReadingUserConfig
|
||||
{
|
||||
AutoCutNextTask = inDto.AutoCutNextTask,
|
||||
IsDoubleScreen = inDto.IsDoubleScreen,
|
||||
});
|
||||
}
|
||||
|
||||
AutoCutNextTask = inDto.AutoCutNextTask,
|
||||
IsDoubleScreen = inDto.IsDoubleScreen
|
||||
});
|
||||
|
||||
await _userRoleRepository.SaveChangesAsync();
|
||||
await _readingUserConfigRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
@@ -15,6 +15,28 @@ namespace IRaCIS.Core.Application.Service
|
||||
//是否英文环境
|
||||
var isEn_Us = false;
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<Segment, SegmentVersionData>();
|
||||
CreateMap<SegmentVersionData, Segment>();
|
||||
|
||||
CreateMap<Segment, SegmentView>();
|
||||
CreateMap<Segment, SegmentAddOrEdit>().ReverseMap();
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<Segmentation, SegmentationView>();
|
||||
CreateMap<Segmentation, SegmentationAddOrEdit>().ReverseMap();
|
||||
|
||||
CreateMap<SegmentationVersion, SegmentationVersionView>();
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<SegmentBinding, SegmentBindingView>()
|
||||
.ForMember(d => d.SegmentName, u => u.MapFrom(s => s.Segment.SegmentName))
|
||||
.ForMember(d => d.SegmentationName, u => u.MapFrom(s => s.Segmentation.SegmentationName));
|
||||
CreateMap<SegmentBinding, SegmentBindingAddOrEdit>().ReverseMap();
|
||||
|
||||
CreateMap<ReadingQuestionTrial, ReadingReportDto>()
|
||||
.ForMember(d => d.QuestionId, u => u.MapFrom(s => s.Id));
|
||||
|
||||
|
||||
+36
-35
@@ -1,6 +1,7 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
@@ -47,7 +48,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
/// <param name="needChangeType"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ReadingReportDto>> GetReadingReportQuestion(
|
||||
List<ReadingQuestionTrial>? questionList,
|
||||
List<ReadingQuestionTrial>? questionList,
|
||||
List<VisitTaskInfo> taskInfoList,
|
||||
List<Globalanswer>? globalanswerList,
|
||||
List<ReadingTaskQuestionAnswer>? answers,
|
||||
@@ -217,7 +218,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
/// 复制既往新病灶答案
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task CopyHistoryAnswer(VisitTask taskinfo, List<ReadingTableAnswerRowInfo> tableRowList,List<ReadingTableQuestionAnswer> tableAnswerList)
|
||||
public async Task CopyHistoryAnswer(VisitTask taskinfo, List<ReadingTableAnswerRowInfo> tableRowList, List<ReadingTableQuestionAnswer> tableAnswerList)
|
||||
{
|
||||
if (_userInfo.RequestUrl == "ReadingImageTask/resetReadingTask")
|
||||
{
|
||||
@@ -226,16 +227,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
if (taskinfo.IsCopyLesionAnswer)
|
||||
{
|
||||
var historyTaskId = await _visitTaskRepository.Where(x =>
|
||||
var historyTaskId = await _visitTaskRepository.Where(x =>
|
||||
x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
||||
x.DoctorUserId == taskinfo.DoctorUserId &&
|
||||
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
|
||||
x.SubjectId == taskinfo.SubjectId &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.VisitTaskNum == taskinfo.VisitTaskNum &&
|
||||
x.TaskState != TaskState.Effect &&
|
||||
x.SubjectId == taskinfo.SubjectId &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.VisitTaskNum == taskinfo.VisitTaskNum &&
|
||||
x.TaskState != TaskState.Effect &&
|
||||
x.ArmEnum == taskinfo.ArmEnum)
|
||||
.OrderByDescending(x => x.SignTime)
|
||||
.Select(x => x.Id).FirstOrDefaultAsync();
|
||||
@@ -251,9 +252,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
var answerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
|
||||
|
||||
var questionMarkList=await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
var noneDicomMarkList=await _readingNoneDicomMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
var noneDicomMarkBindingList=await _readingNoneDicomMarkBindingRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
var questionMarkList = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
var noneDicomMarkList = await _readingNoneDicomMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
var noneDicomMarkBindingList = await _readingNoneDicomMarkBindingRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||
|
||||
foreach (var item in tableRowList)
|
||||
{
|
||||
@@ -261,32 +262,32 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var historyRow = historyTableRowList.Where(x =>
|
||||
x.QuestionId == item.QuestionId &&
|
||||
x.RowIndex == item.RowIndex &&
|
||||
x.IdentityRowId==item.IdentityRowId &&
|
||||
x.IdentityRowId !=null &&
|
||||
x.OrganInfoId==item.OrganInfoId
|
||||
var historyRow = historyTableRowList.Where(x =>
|
||||
x.QuestionId == item.QuestionId &&
|
||||
x.RowIndex == item.RowIndex &&
|
||||
x.IdentityRowId == item.IdentityRowId &&
|
||||
x.IdentityRowId != null &&
|
||||
x.OrganInfoId == item.OrganInfoId
|
||||
).FirstOrDefault();
|
||||
|
||||
if (historyRow != null)
|
||||
{
|
||||
item.StudyId= historyRow.StudyId;
|
||||
item.SeriesId= historyRow.SeriesId;
|
||||
item.InstanceId= historyRow.InstanceId;
|
||||
item.StudyId = historyRow.StudyId;
|
||||
item.SeriesId = historyRow.SeriesId;
|
||||
item.InstanceId = historyRow.InstanceId;
|
||||
|
||||
item.OtherStudyId = historyRow.OtherStudyId;
|
||||
item.OtherSeriesId = historyRow.OtherSeriesId;
|
||||
item.OtherInstanceId= historyRow.OtherInstanceId;
|
||||
item.OtherInstanceId = historyRow.OtherInstanceId;
|
||||
|
||||
item.MeasureData= historyRow.MeasureData.Replace(historyTaskId.ToString(),taskinfo.Id.ToString());
|
||||
item.MeasureData = historyRow.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString());
|
||||
item.OtherMeasureData = historyRow.OtherMeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString());
|
||||
|
||||
|
||||
tableAnswerList.Where(x => x.RowId == item.Id).ForEach(x =>
|
||||
{
|
||||
x.Answer = x.Answer.IsNullOrEmpty() ?
|
||||
historyTableAnswerList.Where(y => y.RowId == historyRow.Id && y.TableQuestionId == x.TableQuestionId).Select(x => x.Answer).FirstOrDefault()??string.Empty :
|
||||
historyTableAnswerList.Where(y => y.RowId == historyRow.Id && y.TableQuestionId == x.TableQuestionId).Select(x => x.Answer).FirstOrDefault() ?? string.Empty :
|
||||
x.Answer;
|
||||
});
|
||||
|
||||
@@ -304,7 +305,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
|
||||
// 处理标记
|
||||
Dictionary<Guid,Guid> dicomKeys=new Dictionary<Guid, Guid> ();
|
||||
Dictionary<Guid, Guid> dicomKeys = new Dictionary<Guid, Guid>();
|
||||
|
||||
foreach (var item in questionMarkList)
|
||||
{
|
||||
@@ -336,7 +337,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
Dictionary<Guid, Guid> noneKeys = new Dictionary<Guid, Guid>();
|
||||
foreach (var item in noneDicomMarkList)
|
||||
{
|
||||
var newid= NewId.NextGuid();
|
||||
var newid = NewId.NextGuid();
|
||||
|
||||
item.VisitTaskId = taskinfo.Id;
|
||||
if (item.MarkId != null)
|
||||
@@ -372,7 +373,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -388,17 +389,17 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从上传文件中获取Datatable
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<FileToDataTableDto> GetDataTableFromUpload(IFormFile file,string pathCode,Guid trialId)
|
||||
public async Task<FileToDataTableDto> GetDataTableFromUpload(IFormFile file, string pathCode, Guid trialId)
|
||||
{
|
||||
|
||||
FileToDataTableDto result=new FileToDataTableDto ();
|
||||
FileToDataTableDto result = new FileToDataTableDto();
|
||||
|
||||
result.DataTable = new DataTable();
|
||||
var fileFolder = "Upload\\";
|
||||
@@ -419,7 +420,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
file.CopyTo(stream);
|
||||
await stream.CopyToAsync(fileStream);
|
||||
|
||||
result.SheetNames= stream.GetSheetNames();
|
||||
result.SheetNames = stream.GetSheetNames();
|
||||
stream.Position = 0;
|
||||
result.DataTable = stream.QueryAsDataTable(useHeaderRow: false);
|
||||
}
|
||||
@@ -432,15 +433,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
try
|
||||
{
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, "InspectionUpload/"+ pathCode, file.FileName);
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId}/InspectionUpload/" + pathCode, file.FileName, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialId, BatchDataType = BatchDataType.ReadingImportTemplete });
|
||||
await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = file.FileName, RelativePath = ossRelativePath, TrialId = trialId });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -457,7 +458,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
// 遍历每一列,检查值
|
||||
foreach (var item in row.ItemArray)
|
||||
{
|
||||
if (item!=null&&!item.ToString().IsNullOrEmpty())
|
||||
if (item != null && !item.ToString().IsNullOrEmpty())
|
||||
{
|
||||
allEmpty = false;
|
||||
break; // 只要有一个不为空,跳出循环
|
||||
@@ -532,7 +533,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
/// <returns></returns>
|
||||
public async Task<ReadingCalculateDto> GetReadingCalculateDto(Guid visitTaskId)
|
||||
{
|
||||
var visitTask = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x=>x.SourceSubjectVisit).FirstNotNullAsync();
|
||||
var visitTask = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.SourceSubjectVisit).FirstNotNullAsync();
|
||||
|
||||
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTask.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == (visitTask.SourceSubjectVisitId ?? default(Guid))).FirstOrDefaultAsync();
|
||||
@@ -540,7 +541,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == visitTask.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
var rowInfoList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == visitTaskId).Include(x=>x.FristAddTask).ToListAsync();
|
||||
var rowInfoList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == visitTaskId).Include(x => x.FristAddTask).ToListAsync();
|
||||
|
||||
var baseLinetaskId = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == baseLineVisitId && x.TaskState == TaskState.Effect
|
||||
&& x.TrialReadingCriterionId == visitTask.TrialReadingCriterionId
|
||||
|
||||
+54
-26
@@ -51,10 +51,11 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{CriterionType.RECIST1Pointt1_MB,typeof(RECIST1Point1_BMCalculateService) },
|
||||
{CriterionType.IRECIST1Point1,typeof(IRECIST1Point1CalculateService) },
|
||||
{CriterionType.Lugano2014,typeof(LuganoCalculateService) },
|
||||
{CriterionType.Lugano2014WithoutPET,typeof(LuganoWithoutPETCalculateService) },
|
||||
{CriterionType.Lugano2014WithoutPET,typeof(LuganoWithoutPETCalculateService) },
|
||||
{CriterionType.IVUS,typeof(IVUSCalculateService) },
|
||||
{CriterionType.OCT,typeof(OCTCalculateService) },
|
||||
{CriterionType.MRIPDFF,typeof(MRIPDFFCalculateService) },
|
||||
{CriterionType.MRIPDFFAdvance,typeof(MRIPDFFAdvanceCalculateService) },
|
||||
{CriterionType.mRECISTHCC,typeof(MRECISTHCCCalculateService) },
|
||||
};
|
||||
|
||||
@@ -83,7 +84,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
await file.CopyToAsync(streamCopy);
|
||||
// 重置流的位置,以便后续读取
|
||||
streamCopy.Position = 0;
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(streamCopy, $"{visitTaskInfo.TrialId.ToString()}/InspectionUpload/ReadingImport", file.FileName);
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(streamCopy, $"{visitTaskInfo.TrialId.ToString()}/InspectionUpload/ReadingImport", file.FileName, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = visitTaskInfo.TrialId, BatchDataType = BatchDataType.ReadingImportTemplete });
|
||||
|
||||
|
||||
await _readingImportFileRepository.AddAsync(new ReadingImportFile()
|
||||
@@ -293,6 +294,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
});
|
||||
result.ChartDataList = reportData.ChartDataList;
|
||||
result.Unit = reportData.Unit;
|
||||
result.CustomUnit = reportData.CustomUnit;
|
||||
reportData.Type=reportData.Type;
|
||||
result.ValueType=reportData.ValueType;
|
||||
}
|
||||
else if (inDto.QuestionId != null)
|
||||
{
|
||||
@@ -301,6 +305,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
if (question != null)
|
||||
{
|
||||
result.Unit = question.Unit;
|
||||
result.Type = question.Type;
|
||||
result.ValueType = question.ValueType;
|
||||
result.CustomUnit = question.CustomUnit;
|
||||
ReportChartData chartData = new ReportChartData()
|
||||
{
|
||||
Name = question.QuestionName,
|
||||
@@ -329,6 +336,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
if (lesion != null)
|
||||
{
|
||||
result.Unit = lesion.Unit;
|
||||
result.Type = lesion.Type;
|
||||
result.ValueType = lesion.ValueType;
|
||||
result.CustomUnit = lesion.CustomUnit;
|
||||
ReportChartData chartData = new ReportChartData()
|
||||
{
|
||||
Name = lesion.QuestionName,
|
||||
@@ -348,13 +358,14 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
}
|
||||
|
||||
|
||||
private async Task<GetReportsChartDataOutDto> GetReportsChartTypeData(GetReportsChartTypeDataInDto inDto)
|
||||
private async Task<GetReportsChartDataOutDto> GetReportsChartTypeData(GetReportsChartTypeDataInDto inDto)
|
||||
{
|
||||
var visitTaskNameList = inDto.Data.VisitTaskList.Select(x => x.BlindName).ToList();
|
||||
GetReportsChartDataOutDto result = new GetReportsChartDataOutDto() {
|
||||
|
||||
ChartDataList=new List<ReportChartData>() { },
|
||||
VisitTaskNameList= visitTaskNameList,
|
||||
GetReportsChartDataOutDto result = new GetReportsChartDataOutDto()
|
||||
{
|
||||
|
||||
ChartDataList = new List<ReportChartData>() { },
|
||||
VisitTaskNameList = visitTaskNameList,
|
||||
|
||||
};
|
||||
switch (inDto.ReportChartTypeEnum)
|
||||
@@ -389,11 +400,17 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
chartData.Value.Add(item.Childrens.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer[i].Answer).FirstOrDefault());
|
||||
result.Unit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Unit).FirstOrDefault();
|
||||
result.Type = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Type).FirstOrDefault();
|
||||
result.ValueType = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.ValueType).FirstOrDefault();
|
||||
result.CustomUnit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.CustomUnit).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
chartData.Value.Add(item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer[i].Answer).FirstOrDefault());
|
||||
result.Unit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Unit).FirstOrDefault();
|
||||
result.Type = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Type).FirstOrDefault();
|
||||
result.ValueType = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.ValueType).FirstOrDefault();
|
||||
result.CustomUnit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.CustomUnit).FirstOrDefault();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -401,6 +418,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
case CriterionType.Lugano2014WithoutPET:
|
||||
chartData.Value.Add(item.Childrens.Where(x => x.QuestionMark == QuestionMark.PPD).Select(x => x.Answer[i].Answer).FirstOrDefault());
|
||||
result.Unit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.PPD).Select(x => x.Unit).FirstOrDefault();
|
||||
result.Type = item.Childrens.Where(x => x.QuestionMark == QuestionMark.PPD).Select(x => x.Type).FirstOrDefault();
|
||||
result.ValueType = item.Childrens.Where(x => x.QuestionMark == QuestionMark.PPD).Select(x => x.ValueType).FirstOrDefault();
|
||||
result.CustomUnit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.PPD).Select(x => x.CustomUnit).FirstOrDefault();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -432,8 +452,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
chartData.Value.Add(item.Childrens.Where(x => x.QuestionMark == QuestionMark.LesionNumber).Select(x => x.Answer[i].Answer).FirstOrDefault());
|
||||
result.Unit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.LesionNumber).Select(x => x.Unit).FirstOrDefault();
|
||||
|
||||
|
||||
result.Type = item.Childrens.Where(x => x.QuestionMark == QuestionMark.LesionNumber).Select(x => x.Type).FirstOrDefault();
|
||||
result.ValueType = item.Childrens.Where(x => x.QuestionMark == QuestionMark.LesionNumber).Select(x => x.ValueType).FirstOrDefault();
|
||||
result.CustomUnit = item.Childrens.Where(x => x.QuestionMark == QuestionMark.LesionNumber).Select(x => x.CustomUnit).FirstOrDefault();
|
||||
}
|
||||
|
||||
result.ChartDataList.Add(chartData);
|
||||
@@ -455,30 +476,30 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
public async Task<GetReportsChartSummaryOutDto> GetReportsChartSummary(GetReportsChartSummaryInDto inDto)
|
||||
{
|
||||
var criterion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialCriterionId).FirstNotNullAsync();
|
||||
var result= new GetReportsChartSummaryOutDto();
|
||||
var result = new GetReportsChartSummaryOutDto();
|
||||
var r1Data = await GetData(new List<Arm>() { Arm.SingleReadingArm, Arm.DoubleReadingArm1 });
|
||||
var r2Data = await GetData(new List<Arm>() { Arm.DoubleReadingArm2 });
|
||||
|
||||
var alldata = r1Data.VisitTaskList.Count() > r2Data.VisitTaskList.Count() ? r1Data : r2Data;
|
||||
var alldata = r1Data.VisitTaskList.Count() > r2Data.VisitTaskList.Count() ? r1Data : r2Data;
|
||||
var visitTaskName = alldata.VisitTaskList.Select(x => x.BlindName).ToList();
|
||||
var length = alldata.VisitTaskList.Count();
|
||||
|
||||
// -1转为空
|
||||
List<QuestionType?> negativeToString = new List<QuestionType?>()
|
||||
List<QuestionType?> negativeToString = new List<QuestionType?>()
|
||||
{
|
||||
QuestionType.DaysBetween,
|
||||
};
|
||||
|
||||
|
||||
async Task<GetReadingReportEvaluationOutDto> GetData(List<Arm> arms)
|
||||
{
|
||||
var data = new GetReadingReportEvaluationOutDto() { };
|
||||
var task = await _visitTaskRepository.Where(x =>
|
||||
x.SubjectId == inDto.SubjectId
|
||||
&& arms.Contains(x.ArmEnum)
|
||||
&& x.ReadingCategory== ReadingCategory.Visit
|
||||
&& x.ReadingCategory == ReadingCategory.Visit
|
||||
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
|
||||
&& x.TaskState == TaskState.Effect
|
||||
&& x.TrialReadingCriterionId==inDto.TrialCriterionId
|
||||
&& x.TrialReadingCriterionId == inDto.TrialCriterionId
|
||||
).OrderByDescending(x => x.VisitTaskNum).FirstOrDefaultAsync();
|
||||
if (task != null)
|
||||
{
|
||||
@@ -499,13 +520,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
Evaluation = new List<List<EvaluationValue>>() { }
|
||||
};
|
||||
|
||||
var baseLineAnswerType= QuestionType.ExistDisease;
|
||||
var baseLineAnswerType = QuestionType.ExistDisease;
|
||||
|
||||
var visitAnswerType = QuestionType.Tumor;
|
||||
switch (criterion.CriterionType)
|
||||
{
|
||||
case CriterionType.PCWG3:
|
||||
baseLineAnswerType= QuestionType.SiteVisitForTumorEvaluation;
|
||||
baseLineAnswerType = QuestionType.SiteVisitForTumorEvaluation;
|
||||
visitAnswerType = QuestionType.SiteVisitForTumorEvaluation;
|
||||
break;
|
||||
case CriterionType.Lugano2014WithoutPET:
|
||||
@@ -515,14 +536,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
visitAnswerType = QuestionType.ImgOncology;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
result.Evaluation.Add(visitTaskName.Select(x=> new EvaluationValue() {
|
||||
Value=x
|
||||
|
||||
result.Evaluation.Add(visitTaskName.Select(x => new EvaluationValue()
|
||||
{
|
||||
Value = x
|
||||
}).ToList());
|
||||
|
||||
var r1baseLine= r1.TaskQuestions
|
||||
var r1baseLine = r1.TaskQuestions
|
||||
.SelectMany(x => x.Childrens)
|
||||
.Where(x => x.QuestionType == baseLineAnswerType)
|
||||
.SelectMany(x => x.Answer.Select(a => new EvaluationValue
|
||||
@@ -545,7 +567,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
r1data = r1baseLine.Take(1).Concat(r1data.Skip(1)).ToList();
|
||||
|
||||
r1data= r1data.Concat(Enumerable.Repeat(new EvaluationValue() { Value = "" }, length))
|
||||
r1data = r1data.Concat(Enumerable.Repeat(new EvaluationValue() { Value = "" }, length))
|
||||
.Take(length)
|
||||
.ToList();
|
||||
result.Evaluation.Add(r1data);
|
||||
@@ -581,7 +603,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
.ToList();
|
||||
result.Evaluation.Add(r2data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -597,17 +619,17 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
var chartList = new List<ReportChartData>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var itemdata= data.TaskQuestions.SelectMany(x => x.Childrens)
|
||||
var itemdata = data.TaskQuestions.SelectMany(x => x.Childrens)
|
||||
.Where(x => x.QuestionId == item.QuestionId)
|
||||
.FirstOrDefault();
|
||||
var cd = new ReportChartData
|
||||
{
|
||||
Name = item?.QuestionName??string.Empty,
|
||||
Name = item?.QuestionName ?? string.Empty,
|
||||
Value = itemdata?.Answer?.Select(a => a.Answer).ToList() ?? new List<string>()
|
||||
};
|
||||
if (negativeToString.Contains(item.QuestionType))
|
||||
{
|
||||
cd.Value = cd.Value.Select(item => item == "-1"|| item == "-2" ? string.Empty : item).ToList();
|
||||
cd.Value = cd.Value.Select(item => item == "-1" || item == "-2" ? string.Empty : item).ToList();
|
||||
}
|
||||
chartList.Add(cd);
|
||||
}
|
||||
@@ -617,6 +639,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
ChartType = null,
|
||||
GroupName = g.GroupName,
|
||||
Unit = items.FirstOrDefault()?.Unit,
|
||||
CustomUnit= items.FirstOrDefault()?.CustomUnit,
|
||||
Type = items.FirstOrDefault()?.Type,
|
||||
ValueType = items.FirstOrDefault()?.ValueType,
|
||||
VisitTaskNameList = alldata.VisitTaskList.Select(x => x.BlindName).ToList(),
|
||||
LatestScanDateList = alldata.VisitTaskList.Select(x => x.LatestScanDate).ToList(),
|
||||
ChartDataList = chartList
|
||||
@@ -646,6 +671,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
});
|
||||
item.ChartDataList = chart.ChartDataList;
|
||||
item.Unit = chart.Unit;
|
||||
item.CustomUnit = chart.CustomUnit;
|
||||
item.Type = chart.Type;
|
||||
item.ValueType = chart.ValueType;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using MassTransit;
|
||||
using MathNet.Numerics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MiniExcelLibs;
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
@@ -44,7 +46,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
switch (readingImportType)
|
||||
{
|
||||
case ReadingImportType.IVUS_MatchingSegment:
|
||||
case ReadingImportType.ROI:
|
||||
await UploadIVUSTemplate();
|
||||
break;
|
||||
}
|
||||
@@ -273,7 +275,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
/// <returns></returns>
|
||||
public async Task ReadingCalculate(ReadingCalculateDto inDto, List<QuestionType>? calculateType = null)
|
||||
{
|
||||
|
||||
|
||||
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
|
||||
@@ -284,23 +286,34 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
ComputationTrigger.SaveEICRFQuestions,
|
||||
|
||||
};
|
||||
if (!computationTriggers.Contains(inDto.ComputationTrigger))
|
||||
{
|
||||
// 计算斑块统计数据
|
||||
await this.CalculatePatchDataStatisticsAndPVA(inDto);
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
}
|
||||
//if (!computationTriggers.Contains(inDto.ComputationTrigger))
|
||||
//{
|
||||
// // 计算斑块统计数据
|
||||
// await this.CalculatePatchDataStatisticsAndPVA(inDto);
|
||||
// inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
//}
|
||||
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
// 斑块1-PAV
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA},
|
||||
//// 斑块1-PAV
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA},
|
||||
|
||||
// // 斑块2-PAV
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA},
|
||||
|
||||
// // 斑块3-PAV
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA},
|
||||
|
||||
|
||||
// (EEM-Lumen)求和
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.EEMSum,GetDecimalNullFun=GetEmmSum},
|
||||
|
||||
// 斑块2-PAV
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA},
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.EEMSubLumenSum,GetDecimalNullFun=GetEEMLumenSum},
|
||||
|
||||
// PAV(冠状动脉粥样硬化体积百分比)
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.PAV,GetDecimalNullFun=GetPAV},
|
||||
|
||||
// 斑块3-PAV
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA},
|
||||
|
||||
|
||||
|
||||
@@ -461,6 +474,33 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
|
||||
};
|
||||
|
||||
|
||||
decimal? getdecimalEmptyData(string value)
|
||||
{
|
||||
if (value == string.Empty)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
|
||||
}
|
||||
|
||||
string getStringValue(decimal? value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (digitPlaces == -1)
|
||||
{
|
||||
return value.Value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return decimal.Round(value.Value, digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<IVUSMeasuredValue> measuredValueList = new List<IVUSMeasuredValue>();
|
||||
var errorRow = new List<int> { };
|
||||
|
||||
@@ -471,9 +511,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
iVUSMeasuredValue = new IVUSMeasuredValue()
|
||||
{
|
||||
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
Emm = getdecimalData(dataTable.Rows[i]["B"].ToString()),
|
||||
Lumen = getdecimalData(dataTable.Rows[i]["C"].ToString()),
|
||||
//PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
FrameNumber = dataTable.Rows[i]["A"].ToString()??string.Empty,
|
||||
Emm = getdecimalEmptyData(dataTable.Rows[i]["B"].ToString()),
|
||||
Lumen = getdecimalEmptyData(dataTable.Rows[i]["C"].ToString()),
|
||||
};
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -494,15 +535,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
var errorRows= string.Join(',', errorRow.Select(i => i.ToString()));
|
||||
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
|
||||
}
|
||||
List<int> nums = new List<int>() { 1, 2, 3 };
|
||||
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
|
||||
}
|
||||
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
|
||||
//List<int> nums = new List<int>() { 1, 2, 3 };
|
||||
//if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
|
||||
//{
|
||||
// throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
|
||||
//}
|
||||
//measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
|
||||
|
||||
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x =>x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId&& x.LesionType == LesionType.MatchValues).FirstNotNullAsync();
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x =>x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId&& x.LesionType == LesionType.ROI).FirstNotNullAsync();
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
|
||||
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
||||
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
@@ -530,33 +571,35 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
});
|
||||
|
||||
// 编号
|
||||
//tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
//{
|
||||
// Answer = item.PlaqueNum.ToString(),
|
||||
// QuestionId = questionInfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// RowId = newRowId,
|
||||
// RowIndex = maxnum,
|
||||
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
//});
|
||||
|
||||
|
||||
|
||||
// EMM
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.PlaqueNum.ToString(),
|
||||
Answer = item.FrameNumber,
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.FrameNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
var emm = item.Emm.ToString();
|
||||
var lumen=item.Lumen.ToString();
|
||||
var emmSubtractionLumen = item.EmmSubtractionLumen.ToString();
|
||||
|
||||
if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
|
||||
{
|
||||
|
||||
emm = decimal.Round(decimal.Parse(emm ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
lumen = decimal.Round(decimal.Parse(lumen ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
emmSubtractionLumen = decimal.Round(decimal.Parse(emmSubtractionLumen ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
}
|
||||
|
||||
// EMM
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = emm,
|
||||
Answer = getStringValue(item.Emm),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -567,7 +610,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = lumen,
|
||||
Answer = getStringValue(item.Lumen),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -578,7 +621,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = emmSubtractionLumen,
|
||||
Answer = getStringValue(item.EmmSubtractionLumen),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -633,7 +676,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
|
||||
// 测量值集合
|
||||
var matchValuesAnswerList = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
var matchValuesAnswerList = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
// 获取编号
|
||||
var nums = matchValuesAnswerList.SelectMany(x => x.TableQuestionList).Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).Distinct().OrderBy(x => x).ToList();
|
||||
@@ -651,7 +694,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
var newRowId = NewId.NextGuid();
|
||||
|
||||
var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList();
|
||||
var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList();
|
||||
|
||||
// 斑块数据统计
|
||||
tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
|
||||
@@ -834,7 +877,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.PAV && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.ROI && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
|
||||
|
||||
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == question.Id)
|
||||
@@ -891,6 +934,52 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
.Where(x => x.QuestionMark == QuestionMark.PAV).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturnNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取EMM求和
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetEmmSum(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (EEM-Lumen)求和
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetEEMLumenSum(ReadingCalculateDto inDto)
|
||||
{
|
||||
var emm = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
||||
|
||||
var lumen = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.LumenArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
||||
|
||||
return emm - lumen;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PAV(冠状动脉粥样硬化体积百分比)
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetPAV(ReadingCalculateDto inDto)
|
||||
{
|
||||
var eEMLumenSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSubLumenSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0();
|
||||
var eEMSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0();
|
||||
|
||||
decimal pav = 0;
|
||||
if (eEMSum != 0)
|
||||
{
|
||||
pav = eEMLumenSum * 100 / eEMSum;
|
||||
}
|
||||
|
||||
return pav;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 计算NTAV的EEM
|
||||
|
||||
@@ -0,0 +1,561 @@
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "Reading")]
|
||||
public class MRIPDFFAdvanceCalculateService(IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||
IRepository<ReadingGlobalTaskInfo> _readingGlobalTaskInfoRepository,
|
||||
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||
IRepository<SubjectVisit> _subjectVisitRepository,
|
||||
IRepository<OrganInfo> _organInfoRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<ReadingTaskQuestionMark> _readingTaskQuestionMarkRepository,
|
||||
IRepository<DicomStudy> _dicomStudyRepository,
|
||||
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
||||
IRepository<TumorAssessment_RECIST1Point1> _tumorAssessmentRepository,
|
||||
IGeneralCalculateService _generalCalculateService,
|
||||
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ICriterionCalculateService
|
||||
{
|
||||
|
||||
|
||||
private List<SiteVisitForTumor> siteVisitForTumorList = new List<SiteVisitForTumor>();
|
||||
|
||||
/// <summary>
|
||||
/// 阅片导入
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task ReadingImport()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片的计算数据
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<object> GetReadingCalculationData(GetReadingCalculationDataInDto inDto)
|
||||
{
|
||||
return new
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#region 删除病灶获取起始病灶序号
|
||||
/// <summary>
|
||||
/// 删除病灶获取起始病灶序号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetDeleteLesionStatrIndex(DeleteReadingRowAnswerInDto inDto)
|
||||
{
|
||||
return 1;
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取阅片报告
|
||||
/// <summary>
|
||||
/// 获取阅片报告
|
||||
/// </summary>
|
||||
/// <param name="indto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<GetReadingReportEvaluationOutDto> GetReadingReportEvaluation(GetReadingReportEvaluationInDto indto)
|
||||
{
|
||||
GetReadingReportEvaluationOutDto result = new GetReadingReportEvaluationOutDto();
|
||||
|
||||
result.CalculateResult = await this.GetReportVerify(new GetReportVerifyInDto()
|
||||
{
|
||||
VisitTaskId = indto.VisitTaskId
|
||||
});
|
||||
|
||||
var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == indto.VisitTaskId).FirstNotNullAsync();
|
||||
|
||||
|
||||
result.ReadingTaskState = visitTaskInfo.ReadingTaskState;
|
||||
var taskInfoList = await _generalCalculateService.GetReadingReportTaskList(indto.VisitTaskId);
|
||||
|
||||
result.VisitTaskList = taskInfoList;
|
||||
|
||||
var visitTaskIds = taskInfoList.Select(x => x.VisitTaskId).ToList();
|
||||
|
||||
var criterionId = visitTaskInfo.TrialReadingCriterionId;
|
||||
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId && x.ShowQuestion != ShowQuestion.Hide).ToListAsync();
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x => x.ShowOrder).ToListAsync();
|
||||
|
||||
var lesionsIndexs = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).GroupBy(x => new { x.QuestionId }).Select(x => new lesionsIndexDto()
|
||||
{
|
||||
QuestionId = x.Key.QuestionId,
|
||||
Rowindexs = x.Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList()
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == indto.VisitTaskId).ProjectTo<TableAnsweRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
|
||||
var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer()
|
||||
{
|
||||
TaskId = x.TaskId,
|
||||
VisitTaskNum = x.GlobalVisitTask.VisitTaskNum,
|
||||
QuestionId = x.QuestionId,
|
||||
Answer = x.Answer
|
||||
}).ToListAsync();
|
||||
var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
|
||||
var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList();
|
||||
var organInfos = await _organInfoRepository.Where(x => organIds.Contains(x.Id)).ToListAsync();
|
||||
|
||||
var needChangeType = new List<QuestionMark?>() {
|
||||
QuestionMark.Organ,
|
||||
QuestionMark.Location,
|
||||
QuestionMark.Part,
|
||||
};
|
||||
|
||||
// 第一级
|
||||
|
||||
List<ReadingReportDto> questions = await _generalCalculateService.GetReadingReportQuestion
|
||||
(
|
||||
questionList,
|
||||
taskInfoList,
|
||||
globalanswerList,
|
||||
answers,
|
||||
tableAnsweRowInfos,
|
||||
tableQuestionList,
|
||||
alltableAnsweRowInfos,
|
||||
tableAnswers,
|
||||
organInfos,
|
||||
needChangeType
|
||||
);
|
||||
|
||||
|
||||
|
||||
result.TaskQuestions = questions;
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 将上一次的访视病灶添加到这一次
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AddTaskLesionAnswerFromLastTaskOutDto> AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto)
|
||||
{
|
||||
var visitTaskId = inDto.VisitTaskId;
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
var isReadingTaskViewInOrder = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskinfo.TrialReadingCriterionId).Select(x => x.IsReadingTaskViewInOrder).FirstOrDefaultAsync();
|
||||
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||
{
|
||||
|
||||
|
||||
|
||||
var dictionList = await _dictionaryRepository.Where(x => x.Parent.Code == "LiverSegmentation").OrderBy(x => x.ShowOrder).ToListAsync();
|
||||
|
||||
|
||||
var tableQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.FatFraction).FirstNotNullAsync();
|
||||
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == tableQuestion.Id).ToListAsync();
|
||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
||||
x.DoctorUserId == taskinfo.DoctorUserId &&
|
||||
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
|
||||
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect && x.ArmEnum == taskinfo.ArmEnum
|
||||
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
List<TableMarkInfo> marks = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == LastVisitTaskId && x.RowId != null).ProjectTo<TableMarkInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
|
||||
marks.ForEach(x => {
|
||||
|
||||
x.VisitTaskId = visitTaskId;
|
||||
});
|
||||
|
||||
List<ReadingTableAnswerRowInfo> rowlist = new List<ReadingTableAnswerRowInfo>();
|
||||
List<ReadingTableQuestionAnswer> tableAnswerList = new List<ReadingTableQuestionAnswer>();
|
||||
|
||||
decimal num = 1;
|
||||
foreach (var item in dictionList)
|
||||
{
|
||||
var guid = NewId.NextGuid();
|
||||
marks.ForEach(x => {
|
||||
x.RowId = x.RowIndex == num ? guid : x.RowId;
|
||||
});
|
||||
rowlist.Add(new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
FristAddTaskId = visitTaskId,
|
||||
IsCurrentTaskAdd = true,
|
||||
BlindName = taskinfo.TaskBlindName,
|
||||
OrderMark = tableQuestion.OrderMark,
|
||||
VisitTaskId = visitTaskId,
|
||||
TrialId = taskinfo.TrialId,
|
||||
QuestionId = tableQuestion.Id,
|
||||
RowIndex = num,
|
||||
Id = guid,
|
||||
});
|
||||
|
||||
tableAnswerList.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
QuestionId = tableQuestion.Id,
|
||||
Answer = item.Code,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.liverSegmentation).Select(x => x.Id).FirstOrDefault(),
|
||||
VisitTaskId = visitTaskId,
|
||||
TrialId = taskinfo.TrialId,
|
||||
RowIndex = num,
|
||||
RowId = guid,
|
||||
});
|
||||
|
||||
foreach (var otherQuestion in tableQuestionList.Where(x => !tableAnswerList.Any(y => y.RowId == guid && y.TableQuestionId == x.Id)))
|
||||
{
|
||||
tableAnswerList.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = otherQuestion.DefaultValue,
|
||||
QuestionId = tableQuestion.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = guid,
|
||||
RowIndex = num,
|
||||
TableQuestionId = otherQuestion.Id,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
num++;
|
||||
}
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(rowlist);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswerList);
|
||||
|
||||
await _readingTaskQuestionMarkRepository.AddRangeAsync(_mapper.Map<List<ReadingTaskQuestionMark>>(marks));
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
||||
{
|
||||
IsBaseLine = taskinfo.SourceSubjectVisitId == baseLineVisitId,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试计算
|
||||
/// </summary>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task TestCalculate(Guid visitTaskId, QuestionType type)
|
||||
{
|
||||
ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(visitTaskId);
|
||||
await ReadingCalculate(readingData, new List<QuestionType>() { type });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算任务
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task CalculateTask(CalculateTaskInDto inDto)
|
||||
{
|
||||
ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
readingData.IsChangeOtherTask = inDto.IsChangeOtherTask;
|
||||
await ReadingCalculate(readingData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动计算
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <param name="calculateType"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ReadingCalculate(ReadingCalculateDto inDto, List<QuestionType>? calculateType = null)
|
||||
{
|
||||
|
||||
await this.CalculateAvg(inDto);
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
// 脂肪平均
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.TotalMeanFraction,GetStringFun=GetFatFractionAvg},
|
||||
|
||||
// 脂肪分级
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.FattyLiverGrading,GetStringFun=GetFattyLiverGrading},
|
||||
};
|
||||
|
||||
|
||||
if (calculateType != null)
|
||||
{
|
||||
calculateList = calculateList.Where(x => calculateType.Contains(x.QuestionType)).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var calculate in calculateList)
|
||||
{
|
||||
var item = inDto.QuestionInfo.FirstOrDefault(x => x.QuestionType == calculate.QuestionType);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
//计算答案
|
||||
|
||||
|
||||
#region 计算答案
|
||||
if (calculate.GetDecimalFun != null)
|
||||
{
|
||||
item.Answer = (await calculate.GetDecimalFun(inDto)).ToString();
|
||||
|
||||
}
|
||||
else if (calculate.GetDecimalNullFun != null)
|
||||
{
|
||||
var value = await calculate.GetDecimalNullFun(inDto);
|
||||
item.Answer = value == null ? "NA" : value.Value.ToString();
|
||||
}
|
||||
else if (calculate.GetStringFun != null)
|
||||
{
|
||||
item.Answer = await calculate.GetStringFun(inDto);
|
||||
}
|
||||
#endregion
|
||||
// 修改修约小数位数
|
||||
|
||||
List<ValueOfType?> valueOfTypes = new List<ValueOfType?>() {
|
||||
|
||||
ValueOfType.Decimals,
|
||||
ValueOfType.Percentage
|
||||
};
|
||||
|
||||
if (inDto.DigitPlaces != -1 && calculate.GetDecimalFun != null && calculate.GetDecimalNullFun != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (valueOfTypes.Contains(item.ValueType))
|
||||
{
|
||||
item.Answer = decimal.Round(decimal.Parse(item.Answer ?? "0"), inDto.DigitPlaces, MidpointRounding.AwayFromZero).ToString("F" + inDto.DigitPlaces.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var questionIds = needAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => questionIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needAddList.ForEach(x =>
|
||||
{
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.TrialId = inDto.TrialId;
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
});
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取脂肪分数平均值
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetFatFractionAvg(ReadingCalculateDto inDto)
|
||||
{
|
||||
decimal result = 0;
|
||||
|
||||
var rowInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FatFraction)
|
||||
.SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
var tableQuestionList = rowInfo.Where(x=>x.TableQuestionList.Any(x=>x.QuestionMark== QuestionMark.IsMeasurable && x.Answer.EqEnum(YesOrNoOrNa.Yes))).SelectMany(x => x.TableQuestionList).ToList();
|
||||
|
||||
if (rowInfo.Any(x => x.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.AverageValue && x.Answer.IsNullOrEmpty())))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (tableQuestionList.Count() == 0)
|
||||
{
|
||||
return "NE";
|
||||
}
|
||||
result = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.AverageValue).Average(x => x.Answer.IsNullOrEmptyReturn0());
|
||||
return decimal.Round(result, inDto.DigitPlaces, MidpointRounding.AwayFromZero).ToString("F" + inDto.DigitPlaces.ToString()); ;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取脂肪肝分级
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetFattyLiverGrading(ReadingCalculateDto inDto)
|
||||
{
|
||||
var answer = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.TotalMeanFraction).Select(x => x.Answer).FirstIsNullReturnEmpty();
|
||||
if (answer == "NE")
|
||||
{
|
||||
return FattyLiverClassification.NE.GetEnumInt();
|
||||
}
|
||||
else if(answer == string.Empty)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (decimal.TryParse(answer, out var value))
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
< 5 => FattyLiverClassification.Level0.GetEnumInt(),
|
||||
< 10 => FattyLiverClassification.Level1.GetEnumInt(),
|
||||
< 25 => FattyLiverClassification.Level2.GetEnumInt(),
|
||||
_ => FattyLiverClassification.Level3.GetEnumInt()
|
||||
};
|
||||
}
|
||||
|
||||
return FattyLiverClassification.NE.GetEnumInt();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算平均值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task CalculateAvg(ReadingCalculateDto inDto)
|
||||
{
|
||||
// 脂肪分数的表格问题Id
|
||||
var questionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FatFraction).FirstOrDefault();
|
||||
|
||||
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
|
||||
|
||||
foreach (var item in questionInfo.TableRowInfoList)
|
||||
{
|
||||
var avg = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AverageValue).FirstOrDefault();
|
||||
var avgAnswer = string.Empty;
|
||||
List<QuestionMark?> questionMarks = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.FirstMeasurement,
|
||||
QuestionMark.SecondMeasurement,
|
||||
QuestionMark.ThirdMeasurement,
|
||||
QuestionMark.FourthMeasurement,
|
||||
};
|
||||
var answers = item.TableQuestionList.Where(x => questionMarks.Contains(x.QuestionMark)).Select(x=>x.Answer).ToList();
|
||||
if (answers.Count() == 4 && !answers.Any(x => x.IsNullOrEmpty()))
|
||||
{
|
||||
var avgAnswernum= answers.Select(x=>x.IsNullOrEmptyReturn0()).Average(x=>x);
|
||||
avgAnswer = decimal.Round(avgAnswernum, inDto.DigitPlaces, MidpointRounding.AwayFromZero).ToString("F" + inDto.DigitPlaces.ToString());
|
||||
}
|
||||
if(item.TableQuestionList.Where(x => x.QuestionMark== QuestionMark.IsMeasurable).Select(x => x.Answer).FirstOrDefault().EqEnum(YesOrNoOrNa.No))
|
||||
{
|
||||
avgAnswer = "NE";
|
||||
}
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = avgAnswer,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
QuestionId = avg.QuestionId,
|
||||
TableQuestionId = avg.TableQuestionId,
|
||||
TrialId = inDto.TrialId,
|
||||
RowIndex = avg.RowIndex,
|
||||
RowId = avg.RowId,
|
||||
|
||||
});
|
||||
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowId == item.RowId && x.TableQuestionId == avg.TableQuestionId);
|
||||
}
|
||||
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<GetReportVerifyOutDto> GetReportVerify(GetReportVerifyInDto inDto)
|
||||
{
|
||||
return new GetReportVerifyOutDto()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public async Task VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
|
||||
var markList = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync();
|
||||
var rowInfo = readingData.QuestionInfo.Where(x => x.LesionType == LesionType.FatFraction)
|
||||
.SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
var tableQuestionList = rowInfo.Where(x => x.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.AverageValue && x.Answer.IsNotNullOrEmpty())).ToList();
|
||||
|
||||
if (tableQuestionList.Count() != 8)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["MRIPDFF_AllNeedToBeMark"]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
List<QuestionMark?> questionMarkList = new List<QuestionMark?>() { QuestionMark.FirstMeasurement, QuestionMark.SecondMeasurement, QuestionMark.ThirdMeasurement, QuestionMark.FourthMeasurement };
|
||||
var measuredValueList = rowInfo.SelectMany(x => x.TableQuestionList).Where(x =>x.Answer.IsNotNullOrEmpty()&& questionMarkList.Contains(x.QuestionMark)).Select(x => decimal.Parse(x.Answer)).ToList();
|
||||
if (measuredValueList.Any(x => x > 100))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["MRIPDFF_MeasurementGT100"]);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException(_localizer["MRIPDFF_MeasurementGT100"]);
|
||||
}
|
||||
|
||||
var notableQuestionList = rowInfo.Where(x => x.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsMeasurable && x.Answer.EqEnum(YesOrNoOrNa.No))).ToList();
|
||||
|
||||
|
||||
foreach (var item in notableQuestionList)
|
||||
{
|
||||
if (markList.Any(x => x.RowId == item.RowId && x.MeasureData.IsNotNullOrEmpty()))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["MRIPDFF_NeedClearMark"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Office.SpreadSheetML.Y2023.MsForms;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
@@ -40,7 +44,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
switch (readingImportType)
|
||||
{
|
||||
case ReadingImportType.OCT_FCT:
|
||||
case ReadingImportType.ROI:
|
||||
await UploadOCTFCTTemplate();
|
||||
break;
|
||||
|
||||
@@ -332,21 +336,34 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
|
||||
var errorRow = new List<int> { };
|
||||
|
||||
string getNone(string value)
|
||||
{
|
||||
if (value == string.Empty || value == null)
|
||||
{
|
||||
return "无";
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
for (int i = 3; i < dataTable.Rows.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
measuredValueList.Add(new OCTFCTUploadData()
|
||||
{
|
||||
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
|
||||
SecondData = getdecimalData(dataTable.Rows[i]["C"].ToString()),
|
||||
ThirdData = getdecimalData(dataTable.Rows[i]["D"].ToString()),
|
||||
MacrophageInfiltrationMeasurement = dataTable.Rows[i]["E"].ToString() ?? string.Empty,
|
||||
//PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
FrameNumber = dataTable.Rows[i]["A"].ToString() ?? string.Empty,
|
||||
FirstData = getdecimalEmptyData(dataTable.Rows[i]["B"].ToString()),
|
||||
SecondData = getdecimalEmptyData(dataTable.Rows[i]["C"].ToString()),
|
||||
ThirdData = getdecimalEmptyData(dataTable.Rows[i]["D"].ToString()),
|
||||
MacrophageInfiltrationMeasurement = getNone(dataTable.Rows[i]["E"].ToString()),
|
||||
MacrophageInfiltrationAngle = getdecimalEmptyData(dataTable.Rows[i]["F"].ToString() ?? string.Empty),
|
||||
MicrochannelMeasurement =dataTable.Rows[i]["G"].ToString() ?? string.Empty,
|
||||
CholesterolCrystalMeasurement = dataTable.Rows[i]["H"].ToString() ?? string.Empty,
|
||||
LumenAreaMeasurement = getdecimalEmptyData(dataTable.Rows[i]["I"].ToString() ?? string.Empty),
|
||||
MicrochannelMeasurement = getNone(dataTable.Rows[i]["G"].ToString()),
|
||||
CholesterolCrystalMeasurement = getNone(dataTable.Rows[i]["H"].ToString()),
|
||||
LumenAreaMeasurement = getdecimalEmptyData(dataTable.Rows[i]["I"].ToString()),
|
||||
LipidAngle = getdecimalEmptyData(dataTable.Rows[i]["J"].ToString() ?? string.Empty),
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -356,7 +373,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
}
|
||||
|
||||
}
|
||||
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -366,12 +383,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
|
||||
}
|
||||
|
||||
List<int> nums = new List<int>() { 1, 2, 3 };
|
||||
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
|
||||
}
|
||||
|
||||
Dictionary<string, string> isPresent = new Dictionary<string, string>()
|
||||
{
|
||||
{ "有","1"},
|
||||
@@ -413,7 +424,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
|
||||
}
|
||||
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.FCT).FirstNotNullAsync();
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.ROI).FirstNotNullAsync();
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
|
||||
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
||||
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
@@ -442,30 +453,35 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
});
|
||||
|
||||
// 编号
|
||||
//tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
//{
|
||||
// Answer = item.PlaqueNum.ToString(),
|
||||
// QuestionId = questionInfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// RowId = newRowId,
|
||||
// RowIndex = maxnum,
|
||||
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
//});
|
||||
|
||||
// 帧数
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.PlaqueNum.ToString(),
|
||||
Answer = item.FrameNumber,
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.FrameNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
var avg = item.Avg.ToString();
|
||||
|
||||
|
||||
if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
|
||||
{
|
||||
avg = decimal.Round(decimal.Parse(avg ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
|
||||
}
|
||||
|
||||
// 第一次
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.FirstData.ToString(),
|
||||
Answer = item.FirstData.DecimalNullToString(digitPlaces),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -476,7 +492,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.SecondData.ToString(),
|
||||
Answer = item.SecondData.DecimalNullToString(digitPlaces),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -487,7 +503,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.ThirdData.ToString(),
|
||||
Answer = item.ThirdData.DecimalNullToString(digitPlaces),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -498,7 +514,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = avg,
|
||||
Answer = item.Avg.DecimalNullToString(digitPlaces),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
@@ -570,6 +586,18 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LumenAreaMeasurement).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
// 脂质角度
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.LipidAngle.ToString(),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -636,173 +664,176 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
[HttpPost]
|
||||
public async Task UploadOCTLipidAngleTemplate()
|
||||
{
|
||||
var request = httpContext.HttpContext!.Request;
|
||||
var file = request.Form.Files[0];
|
||||
Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
var uploadInfo = await _generalCalculateService.GetDataTableFromUpload(file, "OCTLipidAngle", taskinfo.TrialId);
|
||||
List<string> sheetNames = new List<string>()
|
||||
{
|
||||
"脂质角度","LipidAngle"
|
||||
};
|
||||
#region 这个导入没有了 代码全部注释
|
||||
//var request = httpContext.HttpContext!.Request;
|
||||
//var file = request.Form.Files[0];
|
||||
//Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
|
||||
//var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
//var uploadInfo = await _generalCalculateService.GetDataTableFromUpload(file, "OCTLipidAngle", taskinfo.TrialId);
|
||||
//List<string> sheetNames = new List<string>()
|
||||
//{
|
||||
// "脂质角度","LipidAngle"
|
||||
//};
|
||||
|
||||
if (sheetNames.Intersect(uploadInfo.SheetNames).Count() == 0)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUS_UplpadDataError"]);
|
||||
}
|
||||
var dataTable = uploadInfo.DataTable;
|
||||
//if (sheetNames.Intersect(uploadInfo.SheetNames).Count() == 0)
|
||||
//{
|
||||
// throw new BusinessValidationFailedException(_localizer["IVUS_UplpadDataError"]);
|
||||
//}
|
||||
//var dataTable = uploadInfo.DataTable;
|
||||
|
||||
var values = new TemplateData()
|
||||
{
|
||||
SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
|
||||
TaskBlindName = taskinfo.TaskBlindName,
|
||||
};
|
||||
//var values = new TemplateData()
|
||||
//{
|
||||
// SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
|
||||
// TaskBlindName = taskinfo.TaskBlindName,
|
||||
//};
|
||||
|
||||
if (values.SubjectID != dataTable.Rows[0]["B"].ToString() || values.TaskBlindName != dataTable.Rows[1]["B"].ToString())
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUS_UploadVisitTaskError"]);
|
||||
}
|
||||
//if (values.SubjectID != dataTable.Rows[0]["B"].ToString() || values.TaskBlindName != dataTable.Rows[1]["B"].ToString())
|
||||
//{
|
||||
// throw new BusinessValidationFailedException(_localizer["IVUS_UploadVisitTaskError"]);
|
||||
//}
|
||||
|
||||
var digitPlaces = taskinfo.TrialReadingCriterion.DigitPlaces ?? 0;
|
||||
decimal getdecimalData(string value)
|
||||
{
|
||||
return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
|
||||
}
|
||||
;
|
||||
//var digitPlaces = taskinfo.TrialReadingCriterion.DigitPlaces ?? 0;
|
||||
//decimal getdecimalData(string value)
|
||||
//{
|
||||
// return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
|
||||
//}
|
||||
//;
|
||||
|
||||
List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
|
||||
var errorRow = new List<int> { };
|
||||
//List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
|
||||
//var errorRow = new List<int> { };
|
||||
|
||||
for (int i = 3; i < dataTable.Rows.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
measuredValueList.Add(new OCTFCTUploadData()
|
||||
{
|
||||
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
|
||||
//for (int i = 3; i < dataTable.Rows.Count; i++)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// measuredValueList.Add(new OCTFCTUploadData()
|
||||
// {
|
||||
// PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
|
||||
// FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// });
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
|
||||
errorRow.Add(i+1);
|
||||
}
|
||||
// errorRow.Add(i + 1);
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
|
||||
//measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
|
||||
|
||||
if (errorRow.Count() > 0)
|
||||
{
|
||||
var errorRows = string.Join(',', errorRow.Select(i => i.ToString()));
|
||||
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
|
||||
}
|
||||
//if (errorRow.Count() > 0)
|
||||
//{
|
||||
// var errorRows = string.Join(',', errorRow.Select(i => i.ToString()));
|
||||
// throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
|
||||
//}
|
||||
|
||||
|
||||
List<int> nums = new List<int>() { 1, 2, 3 };
|
||||
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
|
||||
}
|
||||
//List<int> nums = new List<int>() { 1, 2, 3 };
|
||||
//if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
|
||||
//{
|
||||
// throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
|
||||
//}
|
||||
|
||||
|
||||
foreach (var item in measuredValueList)
|
||||
{
|
||||
if (item.FirstData > 360)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["IVUS_LipidAngleLess360"]);
|
||||
}
|
||||
}
|
||||
//foreach (var item in measuredValueList)
|
||||
//{
|
||||
// if (item.FirstData > 360)
|
||||
// {
|
||||
// throw new BusinessValidationFailedException(_localizer["IVUS_LipidAngleLess360"]);
|
||||
// }
|
||||
//}
|
||||
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.LipidAngle).FirstNotNullAsync();
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
|
||||
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
||||
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
//var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.LipidAngle).FirstNotNullAsync();
|
||||
//var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
|
||||
//List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
||||
//List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
|
||||
var maxnum = 0;
|
||||
//var maxnum = 0;
|
||||
|
||||
|
||||
foreach (var item in measuredValueList)
|
||||
{
|
||||
maxnum = maxnum + 1;
|
||||
var newRowId = NewId.NextGuid();
|
||||
// 斑块数据统计
|
||||
tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
Id = newRowId,
|
||||
QuestionId = questionInfo.Id,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
RowIndex = maxnum,
|
||||
IsCurrentTaskAdd = true,
|
||||
BlindName = taskinfo.TaskBlindName,
|
||||
OrderMark = questionInfo.OrderMark,
|
||||
FristAddTaskId = taskinfo.Id,
|
||||
RowMark = questionInfo.OrderMark + decimal.Parse(maxnum.ToString()).GetLesionMark()
|
||||
});
|
||||
//foreach (var item in measuredValueList)
|
||||
//{
|
||||
// maxnum = maxnum + 1;
|
||||
// var newRowId = NewId.NextGuid();
|
||||
// // 斑块数据统计
|
||||
// tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
|
||||
// {
|
||||
// Id = newRowId,
|
||||
// QuestionId = questionInfo.Id,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// RowIndex = maxnum,
|
||||
// IsCurrentTaskAdd = true,
|
||||
// BlindName = taskinfo.TaskBlindName,
|
||||
// OrderMark = questionInfo.OrderMark,
|
||||
// FristAddTaskId = taskinfo.Id,
|
||||
// RowMark = questionInfo.OrderMark + decimal.Parse(maxnum.ToString()).GetLesionMark()
|
||||
// });
|
||||
|
||||
// 编号
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.PlaqueNum.ToString(),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
// // 编号
|
||||
// tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
// {
|
||||
// Answer = item.PlaqueNum.ToString(),
|
||||
// QuestionId = questionInfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// RowId = newRowId,
|
||||
// RowIndex = maxnum,
|
||||
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
// });
|
||||
|
||||
var avg = item.Avg.ToString();
|
||||
// var avg = item.Avg.ToString();
|
||||
|
||||
|
||||
if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
|
||||
{
|
||||
avg = decimal.Round(decimal.Parse(avg ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
// if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
|
||||
// {
|
||||
// avg = decimal.Round(decimal.Parse(avg ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// 脂质角度
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.FirstData.ToString(),
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
// // 脂质角度
|
||||
// tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
// {
|
||||
// Answer = item.FirstData.ToString(),
|
||||
// QuestionId = questionInfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// RowId = newRowId,
|
||||
// RowIndex = maxnum,
|
||||
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
|
||||
// });
|
||||
|
||||
// 添加其他问题答案
|
||||
foreach (var otherQuestion in tableQuestionList.Where(x => !tableAnswers.Any(y => y.TableQuestionId == x.Id && y.RowId == newRowId)))
|
||||
{
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = string.Empty,
|
||||
QuestionId = questionInfo.Id,
|
||||
TrialId = taskinfo.TrialId,
|
||||
VisitTaskId = taskinfo.Id,
|
||||
RowId = newRowId,
|
||||
RowIndex = maxnum,
|
||||
TableQuestionId = otherQuestion.Id,
|
||||
});
|
||||
}
|
||||
}
|
||||
await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
|
||||
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
// // 添加其他问题答案
|
||||
// foreach (var otherQuestion in tableQuestionList.Where(x => !tableAnswers.Any(y => y.TableQuestionId == x.Id && y.RowId == newRowId)))
|
||||
// {
|
||||
// tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
// {
|
||||
// Answer = string.Empty,
|
||||
// QuestionId = questionInfo.Id,
|
||||
// TrialId = taskinfo.TrialId,
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
// RowId = newRowId,
|
||||
// RowIndex = maxnum,
|
||||
// TableQuestionId = otherQuestion.Id,
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
//await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
|
||||
//await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
|
||||
//await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
//await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
|
||||
//await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
//await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
await this.CalculateTask(new CalculateTaskInDto()
|
||||
{
|
||||
//await this.CalculateTask(new CalculateTaskInDto()
|
||||
//{
|
||||
|
||||
// VisitTaskId = taskinfo.Id,
|
||||
//});
|
||||
#endregion
|
||||
|
||||
VisitTaskId = taskinfo.Id,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -824,23 +855,48 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
ComputationTrigger.SaveEICRFQuestions,
|
||||
|
||||
};
|
||||
if (!computationTriggers.Contains(inDto.ComputationTrigger))
|
||||
{
|
||||
// 计算斑块统计数据
|
||||
await this.CalculatePatchDataStatistics(inDto);
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
}
|
||||
//if (!computationTriggers.Contains(inDto.ComputationTrigger))
|
||||
//{
|
||||
// // 计算斑块统计数据
|
||||
// await this.CalculatePatchDataStatistics(inDto);
|
||||
// inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
//}
|
||||
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
// 斑块1-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT},
|
||||
//// 斑块1-匹配动脉段最小FCT
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT},
|
||||
|
||||
// 斑块2-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT},
|
||||
// // 斑块2-匹配动脉段最小FCT
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT},
|
||||
|
||||
// 斑块3-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT},
|
||||
// // 斑块3-匹配动脉段最小FCT
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT},
|
||||
|
||||
|
||||
// 匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.MatchingTheMinimumFCT,GetDecimalNullFun=GetMinFCT},
|
||||
|
||||
// 平均最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.AvgMinFCT,GetDecimalNullFun=GetAvgFCT},
|
||||
|
||||
// 脂质角度平均值
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.AvgLipidAngle,GetDecimalNullFun=GetAvgLipidAngle},
|
||||
|
||||
// 脂质角度最大值
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.MaxLipidAngle,GetDecimalNullFun=GetMaxLipidAngle},
|
||||
|
||||
//巨噬细胞浸润测量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.MacrophageInfiltrationMeasurement,GetStringFun=GetMacrophageInfiltration},
|
||||
|
||||
//巨噬细胞浸润角度测量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.MacrophageInfiltrationAngle,GetStringFun=GetMacrophageExtensionAngle},
|
||||
|
||||
//微通道测量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.MicrochannelMeasurement,GetStringFun=GetMicrochannels},
|
||||
|
||||
//胆固醇结晶测量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.CholesterolCrystalMeasurement,GetStringFun=GetCholesterolCrystallization},
|
||||
};
|
||||
|
||||
|
||||
@@ -942,7 +998,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
public async Task CalculatePatchDataStatistics(ReadingCalculateDto inDto)
|
||||
{
|
||||
// FCT 问题信息
|
||||
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).FirstOrDefault();
|
||||
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).FirstOrDefault();
|
||||
|
||||
List<OCTInfo> oCTFCTInfos=new List<OCTInfo> ();
|
||||
|
||||
@@ -1220,6 +1276,123 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturnNull();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 匹配动脉段最小FCT (平均值的最小值)
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetMinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).Where(x => x != 0).MinOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 平均最小FCT (平均值的平均值)
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetAvgFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).Where(x=>x!=0).DefaultIfEmpty(0).Average();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 脂质角度平均值
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetAvgLipidAngle(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.LipidAngle&&x.Answer.IsNotNullOrEmpty()).Select(x => x.Answer.IsNullOrEmptyReturn0()).DefaultIfEmpty(0).Average();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 脂质角度最大
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetMaxLipidAngle(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Answer.IsNullOrEmptyReturn0()).MaxOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<OCTInfo>> GetOCTInfo(ReadingCalculateDto inDto)
|
||||
{
|
||||
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).FirstOrDefault();
|
||||
List<OCTInfo> oCTFCTInfos = new List<OCTInfo>();
|
||||
foreach (var item in fCTQuestionInfo!.TableRowInfoList)
|
||||
{
|
||||
oCTFCTInfos.Add(new OCTInfo()
|
||||
{
|
||||
|
||||
// Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(),
|
||||
MacrophageInfiltrationMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MacrophageInfiltrationMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
|
||||
MacrophageInfiltrationAngle = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MacrophageInfiltrationAngle).Select(x => x.Answer.IsNullOrEmptyReturnNull()).FirstOrDefault(),
|
||||
MicrochannelMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MicrochannelMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
|
||||
CholesterolCrystalMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.CholesterolCrystalMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
|
||||
});
|
||||
}
|
||||
|
||||
return oCTFCTInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取巨噬细胞浸润测量
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetMacrophageInfiltration(ReadingCalculateDto inDto)
|
||||
{
|
||||
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
|
||||
return oCTFCTInfos.Any(x => x.MacrophageInfiltrationMeasurement != string.Empty) ?
|
||||
oCTFCTInfos.Any(x => x.MacrophageInfiltrationMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
|
||||
: IsPresent.NonExistence.GetEnumInt();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 巨噬细胞浸润角度测量
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetMacrophageExtensionAngle(ReadingCalculateDto inDto)
|
||||
{
|
||||
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
|
||||
return oCTFCTInfos.Where(x =>x.MacrophageInfiltrationAngle != null).Count() == 0 ? string.Empty : oCTFCTInfos.Max(x => x.MacrophageInfiltrationAngle ?? 0).ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取微通道汇总
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetMicrochannels(ReadingCalculateDto inDto)
|
||||
{
|
||||
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
|
||||
return oCTFCTInfos.Any(x => x.MicrochannelMeasurement != string.Empty) ?
|
||||
oCTFCTInfos.Any(x => x.MicrochannelMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
|
||||
: IsPresent.NonExistence.GetEnumInt();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取胆固醇结晶汇总
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetCholesterolCrystallization(ReadingCalculateDto inDto)
|
||||
{
|
||||
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
|
||||
return oCTFCTInfos.Any(x => x.CholesterolCrystalMeasurement != string.Empty) ?
|
||||
oCTFCTInfos.Any(x => x.CholesterolCrystalMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
|
||||
: IsPresent.NonExistence.GetEnumInt();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
/// </summary>
|
||||
@@ -1229,7 +1402,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.PatchDataStatistics && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.ROI && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
|
||||
|
||||
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId== question.Id)
|
||||
@@ -1261,7 +1434,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
public async Task<decimal?> GetAllMinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
|
||||
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.MinFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).MinOrDefault();
|
||||
if (allMinFCT == 0)
|
||||
{
|
||||
@@ -1277,7 +1450,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetAvgMinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.MinFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).ToList();
|
||||
if (allMinFCT.Count() == 0)
|
||||
{
|
||||
|
||||
@@ -1191,7 +1191,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
var userEmail = item.Key;
|
||||
|
||||
var userTypeIdList = item.Select(t => t.UserTypeId).ToList();
|
||||
var userTypeIdList = item.Select(t => t.UserTypeId).Distinct().ToList();
|
||||
|
||||
var existSysUser = await _identityUserRepository.Where(t => t.EMail == userEmail, true).Include(t => t.UserRoleList).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
@@ -287,6 +287,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public Guid? SponsorId { get; set; }
|
||||
|
||||
public string TrialStatusStr { get; set; } = string.Empty;
|
||||
|
||||
public CriterionType? CriterionType { get; set; }
|
||||
|
||||
public string? PM_EMail { get; set; }
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class TrialProcessConfig
|
||||
{
|
||||
public TrialDataStore TrialDataStoreType { get; set; }
|
||||
|
||||
public List<Guid> CriterionIds { get; set; } = new List<Guid>();
|
||||
|
||||
@@ -395,6 +396,17 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
}
|
||||
public class GetTrialReadingInfoOutDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 定圆工具默认半径
|
||||
/// </summary>
|
||||
public decimal? CircleRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认SegmentName
|
||||
/// </summary>
|
||||
public DefaultSegmentNameDto DefaultSegmentName { get; set; }
|
||||
|
||||
public ReadingVersion ReadingVersionEnum { get; set; }
|
||||
|
||||
public List<KeyFile> KeyFileList { get; set; }
|
||||
@@ -404,6 +416,12 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
/// </summary>
|
||||
public List<string> ReadingToolList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分割工具
|
||||
/// </summary>
|
||||
public List<string> SegmentToolList { get; set; } = new List<string>();
|
||||
|
||||
|
||||
public string TrialModalitys { get; set; }
|
||||
|
||||
public bool IsImageFilter { get; set; }
|
||||
@@ -934,8 +952,24 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class SetCriterionReadingInfoInDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 默认SegmentName
|
||||
/// </summary>
|
||||
public DefaultSegmentNameDto DefaultSegmentName { get; set; } = new DefaultSegmentNameDto() { };
|
||||
|
||||
/// <summary>
|
||||
/// 定圆工具默认半径
|
||||
/// </summary>
|
||||
public decimal CircleRadius { get; set; }
|
||||
|
||||
public List<string> ReadingToolList { get; set; } = new List<string>() { };
|
||||
|
||||
/// <summary>
|
||||
/// 分割工具
|
||||
/// </summary>
|
||||
public List<string> SegmentToolList { get; set; } = new List<string>();
|
||||
|
||||
public List<KeyFile> KeyFileList { get; set; }=new List<KeyFile>() { };
|
||||
|
||||
public bool IsImageFilter { get; set; }
|
||||
@@ -1084,6 +1118,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class TrialConfigDTO : BasicTrialConfig
|
||||
{
|
||||
public TrialDataStore TrialDataStoreType { get; set; }
|
||||
|
||||
[Comment("阅片任务产生之前 采集影像")]
|
||||
public CollectImagesType CollectImagesEnum { get; set; }
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace IRaCIS.Application.Contracts
|
||||
/// <summary>
|
||||
/// 打开失访可读
|
||||
/// </summary>
|
||||
public bool IsOpenLostVistRead { get; set; } = false;
|
||||
public bool IsOpenLostVistRead { get; set; } = true;
|
||||
|
||||
|
||||
|
||||
@@ -288,6 +288,8 @@ namespace IRaCIS.Application.Contracts
|
||||
|
||||
public bool IsExternalViewTrialChart { get; set; }
|
||||
#endregion
|
||||
|
||||
public TrialDataStore TrialDataStoreType { get; set; }
|
||||
}
|
||||
|
||||
public class TrialPacsInfo
|
||||
|
||||
@@ -1427,6 +1427,7 @@ namespace IRaCIS.Core.Application
|
||||
|
||||
|
||||
var query = _trialRepository.AsQueryable().IgnoreQueryFilters()
|
||||
.WhereIf(inQuery.TrialStatusStr.IsNotNullOrEmpty(),x=>x.TrialStatusStr==inQuery.TrialStatusStr)
|
||||
.WhereIf(inQuery.SponsorId != null, o => o.SponsorId == inQuery.SponsorId)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace IRaCIS.Core.Application
|
||||
foreach (var item in systemCriterionKeyFile)
|
||||
{
|
||||
|
||||
var path = await _oSSService.UploadToOSSAsync(item.FilePath, $"{trialCriterion.TrialId}/ReadingModule/{trialCriterion.CriterionName}", true, true);
|
||||
var path = await _oSSService.UploadToOSSAsync(item.FilePath, $"{trialCriterion.TrialId}/ReadingModule/{trialCriterion.CriterionName}", true, true, uploadInfo: new FileUploadRecordAddOrEdit() { TrialId = trialCriterion.TrialId, BatchDataType = BatchDataType.ReadingKeyFile });
|
||||
|
||||
trialCriterionKeyFiles.Add(new TrialCriterionKeyFile
|
||||
{
|
||||
@@ -610,7 +610,11 @@ namespace IRaCIS.Core.Application
|
||||
|
||||
toolList = toolList.Distinct().ToList();
|
||||
|
||||
if (tabletoolList.Except(trialCriterion.ReadingToolList).Count() > 0)
|
||||
|
||||
var alltool = trialCriterion.ReadingToolList.Union(trialCriterion.SegmentToolList).ToList();
|
||||
|
||||
|
||||
if (tabletoolList.Except(alltool).Count() > 0)
|
||||
{
|
||||
//---问题的阅片工具不在标准配置的阅片工具列表中
|
||||
throw new BusinessValidationFailedException(_localizer["TrialConfig_TableToolNotInStdTool"]);
|
||||
@@ -628,13 +632,16 @@ namespace IRaCIS.Core.Application
|
||||
|
||||
await _readingQuestionCriterionTrialRepository.UpdatePartialFromQueryAsync(inDto.TrialReadingCriterionId, x => new ReadingQuestionCriterionTrial()
|
||||
{
|
||||
CircleRadius = inDto.CircleRadius,
|
||||
ReadingToolList = inDto.ReadingToolList,
|
||||
SegmentToolList = inDto.SegmentToolList,
|
||||
IsImageFilter = inDto.IsImageFilter,
|
||||
ImageDownloadEnum = inDto.ImageDownloadEnum,
|
||||
ImageUploadEnum = inDto.ImageUploadEnum,
|
||||
CriterionModalitys = inDto.CriterionModalitys,
|
||||
ReadingTool = inDto.ReadingTool,
|
||||
IsReadingPeriod = inDto.IsReadingPeriod,
|
||||
DefaultSegmentName=inDto.DefaultSegmentName,
|
||||
//DigitPlaces=inDto.DigitPlaces,
|
||||
IsReadingTaskViewInOrder = inDto.IsReadingTaskViewInOrder,
|
||||
ReadingTaskViewEnum = inDto.ReadingTaskViewEnum,
|
||||
@@ -1327,7 +1334,7 @@ namespace IRaCIS.Core.Application
|
||||
await _trialRepository.BatchUpdateNoTrackingAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.Now });
|
||||
|
||||
|
||||
if (_readingQuestionCriterionTrialRepository.Any(t => t.IsSigned && t.ImageUploadEnum != ReadingImageUpload.None))
|
||||
if (_readingQuestionCriterionTrialRepository.Any(t => t.TrialId == trial.Id && t.IsSigned && t.ImageUploadEnum != ReadingImageUpload.None))
|
||||
{
|
||||
await _oSSService.SetImmediateArchiveRule($"{trial.Id}/Image/");
|
||||
await _oSSService.SetImmediateArchiveRule($"{trial.Id}/TaskImage/");
|
||||
@@ -1559,18 +1566,18 @@ namespace IRaCIS.Core.Application
|
||||
[AllowAnonymous]
|
||||
public async Task<TrialConfigInfo> GetTrialExtralConfig(Guid trialId)
|
||||
{
|
||||
var extralObj = _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.TrialExtraConfigJsonStr, t.IsExternalViewTrialChart, t.TrialObjectNameList, t.CollectImagesEnum, t.IsIQCAutoNextTask,t.IsImageQualityControl }).FirstOrDefault();
|
||||
var extralObj = _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.TrialExtraConfigJsonStr,t.TrialDataStoreType, t.IsExternalViewTrialChart, t.TrialObjectNameList, t.CollectImagesEnum, t.IsIQCAutoNextTask, t.IsImageQualityControl }).FirstOrDefault();
|
||||
|
||||
var extralConfig = JsonConvert.DeserializeObject<TrialExtraConfig>(extralObj?.TrialExtraConfigJsonStr) ?? new TrialExtraConfig();
|
||||
|
||||
var trialConfig = _mapper.Map<TrialConfigInfo>(extralConfig);
|
||||
|
||||
trialConfig.IsImageQualityControl= extralObj.IsImageQualityControl;
|
||||
trialConfig.IsImageQualityControl = extralObj.IsImageQualityControl;
|
||||
trialConfig.TrialObjectNameList = extralObj.TrialObjectNameList;
|
||||
trialConfig.IsExternalViewTrialChart = extralObj.IsExternalViewTrialChart;
|
||||
trialConfig.CollectImagesEnum = extralObj.CollectImagesEnum;
|
||||
trialConfig.IsIQCAutoNextTask = extralObj.IsIQCAutoNextTask;
|
||||
|
||||
trialConfig.TrialDataStoreType = extralObj.TrialDataStoreType;
|
||||
|
||||
return trialConfig;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public class TrialStatService(
|
||||
{
|
||||
UploadedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
|
||||
.Where(t => t.SubmitState == SubmitStateEnum.Submitted).Count(),
|
||||
QCFinishedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
|
||||
QCFinishedCount = t.QCProcessEnum == TrialQCProcess.NotAudit ? null : t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
|
||||
.Where(t => t.AuditState == AuditStateEnum.QCPassed || t.AuditState == AuditStateEnum.QCFailed).Count(),
|
||||
CheckFinishedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
|
||||
CheckFinishedCount = t.IsImageConsistencyVerification == false ? null : t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
|
||||
.Where(t => t.CheckState == CheckStateEnum.CVPassed).Count(),
|
||||
|
||||
CriterionList = t.TrialReadingCriterionList.Where(t => inQuery.TrialReadingCriterionId != null ? t.Id == inQuery.TrialReadingCriterionId : true)
|
||||
|
||||
@@ -276,6 +276,54 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string BodyPartForEditOther { get; set; }
|
||||
|
||||
|
||||
#region 核验
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public string PatientSex { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 体重
|
||||
/// </summary>
|
||||
public string PatientWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总剂量
|
||||
/// </summary>
|
||||
public string RadionuclideTotalDose { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 半衰期
|
||||
/// </summary>
|
||||
public string RadionuclideHalfLife { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 注射时间
|
||||
/// </summary>
|
||||
public string RadiopharmaceuticalStartTime { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 成像 / 采集时间
|
||||
/// </summary>
|
||||
public string AcquisitionTime { get; set; } = null!;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在空字符串字段(PatientSex、PatientWeight、RadionuclideTotalDose、RadionuclideHalfLife、RadiopharmaceuticalStartTime、AcquisitionTime 任意一个为空/空字符串)
|
||||
/// </summary>
|
||||
public bool IsHasEmptyPatientInfo =>
|
||||
string.IsNullOrWhiteSpace(PatientSex) ||
|
||||
string.IsNullOrWhiteSpace(PatientWeight) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideTotalDose) ||
|
||||
string.IsNullOrWhiteSpace(RadionuclideHalfLife) ||
|
||||
string.IsNullOrWhiteSpace(RadiopharmaceuticalStartTime) ||
|
||||
string.IsNullOrWhiteSpace(AcquisitionTime);
|
||||
|
||||
public List<DicomSeriesDTO> SeriesList { get; set; } = new List<DicomSeriesDTO>();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
@@ -29,6 +30,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
IRepository<DicomInstance> _dicomInstanceRepository,
|
||||
IRepository<TaskStudy> _taskStudyRepository,
|
||||
IRepository<TaskSeries> _taskSeriesRepository,
|
||||
IRepository<Segmentation> _segmentationRepository,
|
||||
IRepository<TaskInstance> _taskInstanceRepository,
|
||||
IServiceProvider _serviceProvider,
|
||||
IRepository<DicomSeries> _dicomSeriesRepository,
|
||||
@@ -254,7 +256,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
.Where(t => isImageFilter ? ("|" + criterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.WhereIf(isReading == 1 || isQCFinished, s => s.IsDeleted == false)
|
||||
//预览靶段标注上传的影像 影像后处理 上传了新的影像 还要原始dsa
|
||||
.WhereIf(isImageSegmentLabel == true && isVisitTask && (criterionType == CriterionType.OCT || criterionType == CriterionType.IVUS), t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT")
|
||||
.WhereIf(isImageSegmentLabel == true && isVisitTask && (criterionType == CriterionType.OCT || criterionType == CriterionType.IVUS), t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT")
|
||||
.Select(k => new VisitStudyDTO()
|
||||
{
|
||||
InstanceCount = k.InstanceCount,
|
||||
@@ -269,7 +271,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
var instanceList = await _dicomInstanceRepository.Where(t => studyIds.Contains(t.StudyId)).IgnoreQueryFilters()
|
||||
.WhereIf(isReading == 1, s => s.IsReading && s.IsDeleted == false)
|
||||
.WhereIf(isQCFinished, t => t.IsDeleted == false)
|
||||
.Select(t => new { t.SeriesId, t.Id, t.InstanceNumber, t.Path, t.NumberOfFrames, t.HtmlPath, t.IsReading, t.IsDeleted, t.FileSize }).ToListAsync();
|
||||
.Select(t => new { t.SeriesId, t.Id, t.InstanceNumber, t.Path, t.NumberOfFrames, t.HtmlPath, t.IsReading, t.IsDeleted, t.FileSize, t.ImagePositionPatient, t.ImageOrientationPatient }).ToListAsync();
|
||||
|
||||
foreach (var t in studyList)
|
||||
{
|
||||
@@ -283,7 +285,17 @@ namespace IRaCIS.Core.Application.Services
|
||||
t.SeriesList.ForEach(series =>
|
||||
{
|
||||
|
||||
series.InstanceInfoList = instanceList.Where(t => t.SeriesId == series.Id).OrderBy(t => t.InstanceNumber).Select(k =>
|
||||
var instances = instanceList.Where(x => x.SeriesId == series.Id);
|
||||
|
||||
// ⭐ DICOM 空间排序(带兜底)
|
||||
var sorted = DicomSortHelper.SortSlices(
|
||||
instances,
|
||||
x => x.ImagePositionPatient,
|
||||
x => x.ImageOrientationPatient,
|
||||
x => x.InstanceNumber
|
||||
);
|
||||
|
||||
series.InstanceInfoList = sorted.Select(k =>
|
||||
new InstanceBasicInfo()
|
||||
{
|
||||
Id = k.Id,
|
||||
@@ -362,7 +374,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
series = await _taskSeriesRepository .Where(s => s.Id == inDto.SeriesId).ProjectTo<DicomSeriesDTO>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
series = await _taskSeriesRepository.Where(s => s.Id == inDto.SeriesId).ProjectTo<DicomSeriesDTO>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
|
||||
var instanceList = await _taskInstanceRepository.Where(t => t.SeriesId == inDto.SeriesId)
|
||||
.Select(t => new { t.SeriesId, t.StudyId, t.Id, t.InstanceNumber, t.Path, t.NumberOfFrames, t.WindowCenter, t.WindowWidth, t.HtmlPath, t.SliceLocation, t.FileSize }).ToListAsync();
|
||||
@@ -556,13 +568,13 @@ namespace IRaCIS.Core.Application.Services
|
||||
.WhereIf(isManualGenerate, t => t.SubjectCriteriaEvaluationVisitStudyFilterList.Any(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsConfirmed && t.IsReading))
|
||||
//影像后处理 上传了新的影像 还要原始dsa
|
||||
.WhereIf(taskInfo.IsHaveTaskStudy && taskInfo.CriterionType == CriterionType.OCT,
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" )
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA")
|
||||
|
||||
.WhereIf(taskInfo.CriterionType == CriterionType.IVUS,
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "IVUS")
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "IVUS")
|
||||
|
||||
.WhereIf(taskInfo.IsHaveTaskStudy == false && taskInfo.CriterionType == CriterionType.OCT,
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT")
|
||||
t => t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT")
|
||||
|
||||
|
||||
//其他 不应该看原始影像
|
||||
@@ -577,7 +589,14 @@ namespace IRaCIS.Core.Application.Services
|
||||
StudyId = k.Id,
|
||||
|
||||
BodyPartForEdit = k.BodyPartForEdit,
|
||||
BodyPartForEditOther = k.BodyPartForEditOther
|
||||
BodyPartForEditOther = k.BodyPartForEditOther,
|
||||
PatientSex=k.PatientSex,
|
||||
PatientWeight=k.PatientWeight,
|
||||
RadionuclideTotalDose=k.RadionuclideTotalDose,
|
||||
RadionuclideHalfLife=k.RadionuclideHalfLife,
|
||||
RadiopharmaceuticalStartTime=k.RadiopharmaceuticalStartTime,
|
||||
AcquisitionTime= k.AcquisitionTime,
|
||||
|
||||
|
||||
|
||||
}).ToListAsync();
|
||||
@@ -588,7 +607,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
if (studyIds.Count > 0)
|
||||
{
|
||||
var instanceList = await _dicomInstanceRepository.Where(t => studyIds.Contains(t.StudyId) && t.IsReading)
|
||||
.Select(t => new { t.SeriesId, t.Id, t.InstanceNumber, t.Path, t.NumberOfFrames, t.WindowCenter, t.WindowWidth, t.HtmlPath, t.IsReading, t.FileSize }).ToListAsync();
|
||||
.Select(t => new { t.SeriesId, t.Id, t.InstanceNumber, t.Path, t.NumberOfFrames, t.WindowCenter, t.WindowWidth, t.HtmlPath, t.IsReading, t.FileSize, t.ImagePositionPatient, t.ImageOrientationPatient,t.PhotometricInterpretation }).ToListAsync();
|
||||
|
||||
List<DicomSeriesDTO> seriesLists = await _dicomSeriesRepository.Where(s => studyIds.Contains(s.StudyId))
|
||||
.WhereIf(isManualGenerate == false, t => t.IsReading)
|
||||
@@ -597,11 +616,23 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
foreach (var t in dicomStudyList)
|
||||
{
|
||||
|
||||
t.SeriesList = seriesLists.Where(s => s.StudyId == t.StudyId).OrderBy(s => s.SeriesNumber).ThenBy(s => s.SeriesTime).ToList();
|
||||
|
||||
t.SeriesList.ForEach(series =>
|
||||
{
|
||||
series.InstanceInfoList = instanceList.Where(t => t.SeriesId == series.Id).OrderBy(t => t.InstanceNumber).Select(k =>
|
||||
|
||||
var instances = instanceList.Where(x => x.SeriesId == series.Id);
|
||||
|
||||
// ⭐ DICOM 空间排序(带兜底)
|
||||
var sorted = DicomSortHelper.SortSlices(
|
||||
instances,
|
||||
x => x.ImagePositionPatient,
|
||||
x => x.ImageOrientationPatient,
|
||||
x => x.InstanceNumber
|
||||
);
|
||||
|
||||
series.InstanceInfoList = sorted.Select(k =>
|
||||
new InstanceBasicInfo()
|
||||
{
|
||||
Id = k.Id,
|
||||
@@ -609,7 +640,8 @@ namespace IRaCIS.Core.Application.Services
|
||||
HtmlPath = k.HtmlPath,
|
||||
Path = k.Path,
|
||||
InstanceNumber = k.InstanceNumber,
|
||||
FileSize = k.FileSize
|
||||
FileSize = k.FileSize,
|
||||
PhotometricInterpretation=k.PhotometricInterpretation
|
||||
|
||||
}).ToList();
|
||||
|
||||
@@ -642,6 +674,20 @@ namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
study.SeriesList = study.SeriesList.OrderBy(s => s.SeriesNumber).ThenBy(s => s.SeriesTime).ToList();
|
||||
|
||||
study.SeriesList.ForEach(series =>
|
||||
{
|
||||
|
||||
// ⭐ DICOM 空间排序(带兜底)
|
||||
var sorted = DicomSortHelper.SortSlices(
|
||||
series.InstanceInfoList,
|
||||
x => x.ImagePositionPatient,
|
||||
x => x.ImageOrientationPatient,
|
||||
x => x.InstanceNumber
|
||||
);
|
||||
|
||||
series.InstanceInfoList = sorted;
|
||||
});
|
||||
|
||||
study.InstanceCount = study.SeriesList.SelectMany(t => t.InstanceInfoList).Count();
|
||||
}
|
||||
|
||||
@@ -731,7 +777,8 @@ namespace IRaCIS.Core.Application.Services
|
||||
InstanceNumber = k.InstanceNumber,
|
||||
StudyId = k.StudyId,
|
||||
SeriesId = k.SeriesId,
|
||||
FileSize = k.FileSize
|
||||
FileSize = k.FileSize,
|
||||
PhotometricInterpretation=k.PhotometricInterpretation,
|
||||
}).ToListAsync();
|
||||
|
||||
item.InstanceInfoList.ForEach(x =>
|
||||
@@ -823,7 +870,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
var instanceCount = await _noneDicomStudyFileRepository.Where(t => t.IsReading)
|
||||
.WhereIf(taskInfo.IsHaveTaskNoneDicomStudyFile == false && taskInfo.IsMarkNoneDicomStudy == true, x => x.ImageLabelNoneDicomStudyId == item.StudyId)
|
||||
.WhereIf(taskInfo.IsHaveTaskNoneDicomStudyFile && taskInfo.IsMarkNoneDicomStudy, x => x.OriginNoneDicomStudyId == item.StudyId && x.VisitTaskId==indto.VisitTaskId)
|
||||
.WhereIf(taskInfo.IsHaveTaskNoneDicomStudyFile && taskInfo.IsMarkNoneDicomStudy, x => x.OriginNoneDicomStudyId == item.StudyId && x.VisitTaskId == indto.VisitTaskId)
|
||||
.WhereIf(taskInfo.IsHaveTaskNoneDicomStudyFile == false && taskInfo.IsMarkNoneDicomStudy == false, x => x.NoneDicomStudyId == item.StudyId)
|
||||
.Where(t => !t.FileType.Contains(StaticData.FileType.Zip))
|
||||
.CountAsync();
|
||||
@@ -875,6 +922,19 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
#endregion
|
||||
|
||||
#region 处理分割
|
||||
|
||||
var segmentatSeriesList =await _segmentationRepository.Where(x => x.VisitTaskId == indto.VisitTaskId && x.SEGUrl != string.Empty).Select(x => x.SeriesId).ToListAsync();
|
||||
result.ForEach(x =>
|
||||
{
|
||||
x.SeriesList.ForEach(y =>
|
||||
{
|
||||
y.IsBeSegment = segmentatSeriesList.Any(z => z == y.Id);
|
||||
});
|
||||
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace IRaCIS.Application.Contracts
|
||||
public List<TrialCriterionReadingCategory> CriterionReadingCategoryList { get; set; }
|
||||
|
||||
//任务阅片状态
|
||||
public List<DoctorUserTask> ReadingTaskStateList { get; set; } = new List<DoctorUserTask>();
|
||||
public List<DoctorTaskStat> ReadingTaskStateList { get; set; } = new List<DoctorTaskStat>();
|
||||
|
||||
public List<CriterionFile> CriterionFileList { get; set; } = new List<CriterionFile>();
|
||||
|
||||
@@ -299,11 +299,17 @@ namespace IRaCIS.Application.Contracts
|
||||
new CriterionReadingCategory()
|
||||
{
|
||||
EnrollId = EnrollId,
|
||||
PendingCount = ReadingTaskStateList.Where(x => x.ReadingTaskState != ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
//PendingCount = ReadingTaskStateList.Where(x => x.ReadingTaskState != ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
|
||||
ComplectedCount = ReadingTaskStateList.Where(x => x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
//ComplectedCount = ReadingTaskStateList.Where(x => x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
|
||||
TotalCount = ReadingTaskStateList.Where(x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
//TotalCount = ReadingTaskStateList.Where(x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).Count(),
|
||||
|
||||
PendingCount = ReadingTaskStateList.Where(x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).FirstOrDefault()?.PendingCount,
|
||||
|
||||
ComplectedCount = ReadingTaskStateList.Where(x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).FirstOrDefault()?.ComplectedCount,
|
||||
|
||||
TotalCount = ReadingTaskStateList.Where(x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).FirstOrDefault()?.TotalCount,
|
||||
|
||||
StatementCriterionFileList = CriterionFileList.Where(x => x.CriterionType == t.CriterionType && x.FileType == CriterionFileType.Statement)
|
||||
.WhereIf(t.CriterionType == CriterionType.SelfDefine, x => x.TrialReadingCriterionId == t.TrialReadingCriterionId).ToList(),
|
||||
@@ -348,6 +354,19 @@ namespace IRaCIS.Application.Contracts
|
||||
public Guid TrialReadingCriterionId { get; set; }
|
||||
}
|
||||
|
||||
public class DoctorTaskStat
|
||||
{
|
||||
public CriterionType? CriterionType { get; set; }
|
||||
|
||||
public Guid TrialReadingCriterionId { get; set; }
|
||||
|
||||
public int PendingCount { get; set; }
|
||||
|
||||
public int ComplectedCount { get; set; }
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
|
||||
public class TrialReadingCriterionDto
|
||||
{
|
||||
public ReadingOrder IsReadingTaskViewInOrder { get; set; }
|
||||
@@ -435,11 +454,11 @@ namespace IRaCIS.Application.Contracts
|
||||
/// <summary>
|
||||
/// 待办数量
|
||||
/// </summary>
|
||||
public int PendingCount { get; set; }
|
||||
public int? PendingCount { get; set; }
|
||||
|
||||
public int ComplectedCount { get; set; }
|
||||
public int? ComplectedCount { get; set; }
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
public int? TotalCount { get; set; }
|
||||
|
||||
public List<CriterionFile> StatementCriterionFileList { get; set; }
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
public async Task<IResponseOutput> SetEnrollReadingCategory(SetEnrollReadingCategoryInDto inDto)
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <param name="inCommand"></param>
|
||||
/// <returns></returns>
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
public async Task<IResponseOutput> UpdateTrialReviewerState(SetEnrollEnableCommand inCommand)
|
||||
{
|
||||
await _taskAllocationRuleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == inCommand.TrialId && t.EnrollId == inCommand.EnrollId, u => new TaskAllocationRule() { IsEnable = inCommand.IsEnable }, true);
|
||||
@@ -181,7 +181,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{trialId}/{doctorId}/{type}")]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
public async Task<IResponseOutput> UpdateReviewerReadingType(Guid trialId, Guid doctorId, int type)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
TrialReadingCriterionList = intoGroup.Trial.TrialReadingCriterionList.Where(t => t.IsConfirm).Select(t => new TrialReadingCriterionDto() { TrialReadingCriterionId = t.Id, TrialReadingCriterionName = t.CriterionName, CriterionType = t.CriterionType, IsOncologyReading = t.IsOncologyReading, IsArbitrationReading = t.IsArbitrationReading, IsGlobalReading = t.IsGlobalReading, ReadingInfoSignTime = t.ReadingInfoSignTime, ReadingType = t.ReadingType }).ToList(),
|
||||
|
||||
DoctorCriterionStatusList = intoGroup.EnrollReadingCriteriaList.Where(t=>t.TrialReadingCriterion.IsConfirm).Select(t => new DoctorCriterionStatus()
|
||||
DoctorCriterionStatusList = intoGroup.EnrollReadingCriteriaList.Where(t => t.TrialReadingCriterion.IsConfirm).Select(t => new DoctorCriterionStatus()
|
||||
{
|
||||
EnrollId = t.Id,
|
||||
Id = t.Id,
|
||||
@@ -230,7 +230,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CriterionReadingCategoryList = intoGroup.EnrollReadingCategoryList.Where(t => t.TrialReadingCriterion.IsConfirm).Select(t => new TrialCriterionReadingCategory() { EnrollId = t.EnrollId, ReadingCategory = t.ReadingCategory, TrialReadingCriterionId = t.TrialReadingCriterionId }).ToList(),
|
||||
|
||||
CriterionFileList = doctor.CriterionFileList.Where(t => t.TrialReadingCriterion.IsConfirm || t.TrialReadingCriterionId==null).Where(x => x.IsEnable && (x.TrialId == null || x.TrialId == trialId)).Select(x => new CriterionFile()
|
||||
CriterionFileList = doctor.CriterionFileList.Where(t => t.TrialReadingCriterion.IsConfirm || t.TrialReadingCriterionId == null).Where(x => x.IsEnable && (x.TrialId == null || x.TrialId == trialId)).Select(x => new CriterionFile()
|
||||
{
|
||||
CriterionType = x.CriterionType,
|
||||
DoctorId = x.DoctorId,
|
||||
@@ -242,13 +242,17 @@ namespace IRaCIS.Core.Application.Service
|
||||
Id = x.Id
|
||||
}).ToList(),
|
||||
|
||||
ReadingTaskStateList = intoGroup.DoctorUser.VisitTaskList.Where(t => t.TrialReadingCriterion.IsConfirm).Where(x => x.TaskState == TaskState.Effect && x.TrialId == trialId).Select(x => new DoctorUserTask()
|
||||
{
|
||||
ReadingTaskState = x.ReadingTaskState,
|
||||
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||
CriterionType = x.TrialReadingCriterion.CriterionType,
|
||||
//ReadingTaskStateList = intoGroup.DoctorUser.VisitTaskList.Where(t => t.TrialReadingCriterion.IsConfirm).Where(x => x.TaskState == TaskState.Effect && x.TrialId == trialId).GroupBy(x => new { x.TrialReadingCriterionId, x.TrialReadingCriterion.CriterionType }).Select(g => new DoctorTaskStat()
|
||||
//{
|
||||
|
||||
}).ToList(),
|
||||
|
||||
// PendingCount = g.Count(x => x.ReadingTaskState != ReadingTaskState.HaveSigned),
|
||||
// TotalCount = g.Count(),
|
||||
// ComplectedCount = g.Count(x => x.ReadingTaskState == ReadingTaskState.HaveSigned),
|
||||
// TrialReadingCriterionId = g.Key.TrialReadingCriterionId,
|
||||
// CriterionType = g.Key.CriterionType,
|
||||
|
||||
//}).ToList(),
|
||||
|
||||
DoctorId = doctor.Id,
|
||||
Code = doctor.ReviewerCode,
|
||||
|
||||
@@ -114,13 +114,102 @@ namespace IRaCIS.Core.Application.Service
|
||||
public async Task<IResponseOutput> PostModelVerify(ModelVerifyCommand modelVerify)
|
||||
{
|
||||
var webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cdd97aab-d256-4f07-9145-a0a2b1555322";
|
||||
//await WeComNotifier.SendErrorAsync(webhook, "http://irc.test.extimaging.com/login", new Exception("测试异常"), new[] { "ZhouHang" });
|
||||
//await WeComNotifier.SendErrorAsync(webhook, "http://irc.test.extimaging.com/login", new Exception("测试异常"), new[] { "ZhouHang" });
|
||||
|
||||
//throw new Exception("手动测试异常抛出");
|
||||
return ResponseOutput.Ok(modelVerify);
|
||||
return ResponseOutput.Ok(_userInfo.Domain);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 遮挡影像
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> MaskImage()
|
||||
{
|
||||
|
||||
var sourceDir = @"C:\work\gitea\irc-netcore-api\DownloadImage";
|
||||
var targetDir = @"C:\work\gitea\irc-netcore-api\DownloadImage\after";
|
||||
|
||||
Directory.CreateDirectory(targetDir);
|
||||
var regions = new[]
|
||||
{
|
||||
new MaskRegion(0, 0, 200, 200)
|
||||
};
|
||||
|
||||
foreach (var inputPath in Directory.EnumerateFiles(sourceDir, "IM_*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
var relativePath = Path.GetRelativePath(sourceDir, inputPath);
|
||||
var outputPath = Path.Combine(targetDir, relativePath);
|
||||
var outputFolder = Path.GetDirectoryName(outputPath);
|
||||
if (!string.IsNullOrEmpty(outputFolder))
|
||||
{
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
}
|
||||
await using var input = File.OpenRead(inputPath);
|
||||
await using var output = File.Create(outputPath);
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"开始处理: {relativePath}");
|
||||
|
||||
await DicomPixelMasker.MaskAsync(input, output, regions);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 跳过该文件
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"error: {relativePath} —————— {ex.Message}");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
Console.WriteLine($"处理结束: {relativePath}");
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置生命周期
|
||||
/// </summary>
|
||||
/// <param name="modelVerify"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> SetTrialLifeCycel()
|
||||
{
|
||||
var trialIdList = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialCompleted).Select(t => t.Id).ToList();
|
||||
|
||||
foreach (var trialId in trialIdList)
|
||||
{
|
||||
if (_readingQuestionCriterionTrialRepository.Any(t => t.TrialId == trialId && t.IsSigned && t.ImageUploadEnum != ReadingImageUpload.None))
|
||||
{
|
||||
await _IOSSService.SetImmediateArchiveRule($"{trialId}/Image/");
|
||||
await _IOSSService.SetImmediateArchiveRule($"{trialId}/TaskImage/");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await _IOSSService.SetImmediateArchiveRule($"{trialId}/Image/");
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 归档直读
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> ConvertPrefixToStandard()
|
||||
{
|
||||
_IOSSService.ConvertPrefixToStandard("601a0000-3e2c-0016-56de-08dae983124b/Image");
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user