修改Cmove 推送命令
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2025-02-07 11:25:08 +08:00
parent 0d7a04f1e8
commit fdb0b74296
5 changed files with 37 additions and 8 deletions

View File

@ -35,7 +35,10 @@
"LoginMaxFailCount": 5, "LoginMaxFailCount": 5,
"LoginFailLockMinutes": 30, "LoginFailLockMinutes": 30,
"AutoLoginOutMinutes": 120, "AutoLoginOutMinutes": 120,
"AESKey": "HIR_System_AES_Key_Info" "AESKey": "HIR_System_AES_Key_Info",
"CmoveIntervalMinutes": 1,
"CmoveInstanceIntervalMinutes": 1
}, },
"SystemHospitalConfig": { "SystemHospitalConfig": {
"HospitalCode": "EI", "HospitalCode": "EI",

View File

@ -34,7 +34,9 @@
"LoginMaxFailCount": 5, "LoginMaxFailCount": 5,
"LoginFailLockMinutes": 30, "LoginFailLockMinutes": 30,
"AutoLoginOutMinutes": 120, "AutoLoginOutMinutes": 120,
"AESKey": "HIR_System_AES_Key_Info" "AESKey": "HIR_System_AES_Key_Info",
"CmoveIntervalMinutes": 1,
"CmoveInstanceIntervalMinutes": 1
}, },
"SystemHospitalConfig": { "SystemHospitalConfig": {
"HospitalCode": "EI", "HospitalCode": "EI",

View File

@ -38,6 +38,11 @@ public class ServiceVerifyConfigOption
public string AESKey { get; set; } public string AESKey { get; set; }
public int CmoveIntervalMinutes { get; set; }
public int CmoveInstanceIntervalMinutes { get; set; }
} }
public class SystemEmailSendConfig public class SystemEmailSendConfig
@ -68,7 +73,7 @@ public class SystemEmailSendConfig
public bool IsOpenErrorNoticeEmail { get; set; } public bool IsOpenErrorNoticeEmail { get; set; }
public List<string> ErrorNoticeEmailList { get; set; } =new List<string>(); public List<string> ErrorNoticeEmailList { get; set; } = new List<string>();
} }
public class SystemEmailSendConfigView public class SystemEmailSendConfigView

View File

@ -58,6 +58,9 @@ public static class CacheKeys
/// <returns></returns> /// <returns></returns>
public static string StartRestTime(Guid userId) => $"{userId}StartRestTime"; public static string StartRestTime(Guid userId) => $"{userId}StartRestTime";
public static string CmoveStudyId(string studyIdStr) => $"CmoveStudyId:{studyIdStr}";
} }
public static class CacheHelper public static class CacheHelper

View File

@ -49,6 +49,7 @@ using System;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory; using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
using DocumentFormat.OpenXml.Vml.Office; using DocumentFormat.OpenXml.Vml.Office;
using IRaCIS.Core.Infra.EFCore.Migrations; using IRaCIS.Core.Infra.EFCore.Migrations;
using System.Dynamic;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
@ -65,7 +66,7 @@ namespace IRaCIS.Application.Services
IRepository<SCPImageUpload> _SCPImageUploadRepository, IRepository<SCPImageUpload> _SCPImageUploadRepository,
IRepository<User> _userRepository, IRepository<User> _userRepository,
ILogger<PatientService> _logger, ILogger<PatientService> _logger,
IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer, IFusionCache _fusionCache
) : BaseService ) : BaseService
@ -3119,8 +3120,13 @@ namespace IRaCIS.Application.Services
/// </summary> /// </summary>
/// <param name="inCommand"></param> /// <param name="inCommand"></param>
/// <param name="_dicomAEReposiotry"></param> /// <param name="_dicomAEReposiotry"></param>
/// <param name="_scpInstanceRepository"></param>
/// <param name="_basicSystemConfigConfig"></param>
/// <returns></returns> /// <returns></returns>
public async Task<IResponseOutput> CmoveStudyList(SCUCmoveCommand inCommand, [FromServices] IRepository<DicomAE> _dicomAEReposiotry) public async Task<IResponseOutput> CmoveStudyList(SCUCmoveCommand inCommand,
[FromServices] IRepository<DicomAE> _dicomAEReposiotry,
[FromServices] IRepository<SCPInstance> _scpInstanceRepository,
[FromServices] IOptionsMonitor<ServiceVerifyConfigOption> _basicSystemConfigConfig)
{ {
var result = new List<SCUStudyView>(); var result = new List<SCUStudyView>();
@ -3163,12 +3169,22 @@ namespace IRaCIS.Application.Services
foreach (var item in inCommand.StudyInstanceUIDList) foreach (var item in inCommand.StudyInstanceUIDList)
{ {
var cmoveRequest = new DicomCMoveRequest(hirServer.CalledAE, item); var cmoveConfig = _basicSystemConfigConfig.CurrentValue;
var exsitStudyId = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.CmoveStudyId(item), null);
cmoveRequest.OnResponseReceived += responseDelegate; var latestInstance = await _scpInstanceRepository.Where(t => t.StudyInstanceUid == item).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync();
//缓存不存在当前检查或者instance表最新的记录时间与当前时间之差超过1分钟认为完成归档可以重复拉取
if (exsitStudyId == null && (latestInstance == null || latestInstance.CreateTime.AddMinutes(cmoveConfig.CmoveInstanceIntervalMinutes) > DateTime.Now))
{
await _fusionCache.SetAsync(CacheKeys.CmoveStudyId(item), item, TimeSpan.FromMinutes(cmoveConfig.CmoveIntervalMinutes));
cmoveRequestList.Add(cmoveRequest); var cmoveRequest = new DicomCMoveRequest(hirServer.CalledAE, item);
cmoveRequest.OnResponseReceived += responseDelegate;
cmoveRequestList.Add(cmoveRequest);
}
} }
await client.AddRequestsAsync(cmoveRequestList); await client.AddRequestsAsync(cmoveRequestList);