From b86bd76c4ef904aca8f3813e256b2b5db3d4c3e9 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Wed, 19 Nov 2025 11:24:35 +0800 Subject: [PATCH] 1119 --- .../DiagnosisFunctionAppService.cs | 3 +- .../PacsBusiness/PacsBusinessAppService.cs | 50 ++++++++++++++++++- .../PatientRegisterAppService.cs | 2 +- src/Shentun.Peis.DbMigrator/appsettings.json | 4 +- .../IDuplicateRequestService.cs | 44 ++++++++++++++++ .../RegisterChecks/RegisterCheckManager.cs | 2 - .../PeisHttpApiHostModule.cs | 1 - .../appsettings.json | 2 +- 8 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 src/Shentun.Peis.Domain/IDuplicateRequestService.cs diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs index d5cce32f..e872d430 100644 --- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs +++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs @@ -890,7 +890,8 @@ namespace Shentun.Peis.DiagnosisFunctions result = result.Replace(num, ""); } //将结果通过英文;解析到数组中 - string[] resultArry = result.Split(";"); + //string[] resultArry = result.Split(";"); + string[] resultArry = result.Split(";",StringSplitOptions.RemoveEmptyEntries); return resultArry; } #region 执行项目计算函数 diff --git a/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs index ce7b3aa3..e263c628 100644 --- a/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs +++ b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs @@ -79,6 +79,7 @@ namespace Shentun.Peis.PacsBusiness private readonly ICurrentPrincipalAccessor _principalAccessor; private readonly SignInManager _signInManager; private readonly IRepository _userRepository; + private readonly IDuplicateRequestService _duplicateRequestService; public PacsBusinessAppService( IConfiguration configuration, @@ -108,7 +109,8 @@ namespace Shentun.Peis.PacsBusiness DiagnosisFunctionAppService diagnosisFunctionAppService, ICurrentPrincipalAccessor principalAccessor, SignInManager signInManager, - IRepository userRepository) + IRepository userRepository, + IDuplicateRequestService duplicateRequestService) { _configuration = configuration; _registerCheckRepository = registerCheckRepository; @@ -138,6 +140,7 @@ namespace Shentun.Peis.PacsBusiness _principalAccessor = principalAccessor; _signInManager = signInManager; _userRepository = userRepository; + _duplicateRequestService = duplicateRequestService; } @@ -240,6 +243,15 @@ namespace Shentun.Peis.PacsBusiness [HttpPost("api/app/PacsBusiness/ImportElectrocardiogramPictureByPatientRegisterNo")] public async Task ImportElectrocardiogramPictureByPatientRegisterNoAsync(ImportElectrocardiogramPictureByPatientRegisterNoInputDto input) { + // 生成请求唯一标识 + var requestKey = $"ElectrocardiogramPicture_{input.PatientRegisterNo}"; + + // 检查是否重复请求(5秒内) + if (await _duplicateRequestService.IsDuplicateAsync(requestKey, TimeSpan.FromSeconds(120))) + { + throw new UserFriendlyException("请求过于频繁,请稍后重试"); + } + Random rd = new Random(); string AbsolutePath = _configuration.GetValue("PacsVirtualPath:RealPath"); @@ -352,6 +364,31 @@ namespace Shentun.Peis.PacsBusiness [DisableAuditing] public async Task ImportElectrocardiogramResultByPatientRegisterNoAsync(ImportElectrocardiogramResultByPatientRegisterNoInputDto input) { + + // 生成请求唯一标识 + var requestKey = $"ElectrocardiogramResult_{input.PatientRegisterNo}"; + + // 检查是否重复请求(5秒内) + if (await _duplicateRequestService.IsDuplicateAsync(requestKey, TimeSpan.FromSeconds(120))) + { + throw new UserFriendlyException("请求过于频繁,请稍后重试"); + } + + #region 处理结果 + if (string.IsNullOrWhiteSpace(input.ItemResult)) + { + throw new UserFriendlyException("结果不能为空"); + } + StringBuilder itemResult = new StringBuilder(); + var resultList = input.ItemResult.Split("\r\n", StringSplitOptions.RemoveEmptyEntries).ToList(); + foreach (var itemRes in resultList) + { + itemResult.Append($"{resultList.IndexOf(itemRes) + 1}.{itemRes} "); + } + + input.ItemResult = itemResult.ToString(); + #endregion + Random rd = new Random(); string AbsolutePath = _configuration.GetValue("PacsVirtualPath:RealPath"); @@ -468,6 +505,15 @@ namespace Shentun.Peis.PacsBusiness [DisableAuditing] public async Task ImportDeviceReportFileByPatientRegisterNoAsync(ImportDeviceReportFileByPatientRegisterNoInputDto input) { + // 生成请求唯一标识 + var requestKey = $"DeviceReport_{input.PatientRegisterNo}"; + + // 检查是否重复请求(5秒内) + if (await _duplicateRequestService.IsDuplicateAsync(requestKey, TimeSpan.FromSeconds(120))) + { + throw new UserFriendlyException("请求过于频繁,请稍后重试"); + } + Random rd = new Random(); string AbsolutePath = _configuration.GetValue("PacsVirtualPath:RealPath"); @@ -596,7 +642,7 @@ namespace Shentun.Peis.PacsBusiness } - + /// /// 导入pacs dicom数据 diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index c9bbbbd1..eca4d310 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -986,7 +986,7 @@ namespace Shentun.Peis.PatientRegisters } else if (!string.IsNullOrWhiteSpace(input.IdNo)) { - patientRegisterList = query.Where(m => m.Patient.IdNo == input.IdNo).OrderByDescending(o => o.MedicalTimes).ToList(); + patientRegisterList = query.Where(m => m.Patient.IdNo == input.IdNo).OrderByDescending(o => o.CreationTime).ToList(); if (patientRegisterList.Count == 0) { throw new UserFriendlyException("未找到人员信息"); diff --git a/src/Shentun.Peis.DbMigrator/appsettings.json b/src/Shentun.Peis.DbMigrator/appsettings.json index 5279017a..7d3e4091 100644 --- a/src/Shentun.Peis.DbMigrator/appsettings.json +++ b/src/Shentun.Peis.DbMigrator/appsettings.json @@ -3,8 +3,8 @@ //"Default": "Host=140.143.162.39;Port=5432;Database=ShentunPeis240701;User ID=postgres;Password=shentun123;" //"Default": "Host=192.168.2.67;Port=5432;Database=ShentunPeis;User ID=postgres;Password=st123;" //"Default": "Host=localhost;Port=5432;Database=ShentunPeis1218;User ID=postgres;Password=wxd123;" - //"Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;" - "Default": "Host=192.168.0.188;Port=5432;Database=ShentunPeis;User ID=postgres;Password=St123456;" + "Default": "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;" + //"Default": "Host=192.168.0.188;Port=5432;Database=ShentunPeis;User ID=postgres;Password=St123456;" }, "OpenIddict": { "Applications": { diff --git a/src/Shentun.Peis.Domain/IDuplicateRequestService.cs b/src/Shentun.Peis.Domain/IDuplicateRequestService.cs new file mode 100644 index 00000000..80250436 --- /dev/null +++ b/src/Shentun.Peis.Domain/IDuplicateRequestService.cs @@ -0,0 +1,44 @@ +using Microsoft.Extensions.Caching.Distributed; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; + +namespace Shentun.Peis +{ + public interface IDuplicateRequestService + { + Task IsDuplicateAsync(string key, TimeSpan expiration); + } + + public class DuplicateRequestService : IDuplicateRequestService, ITransientDependency + { + private readonly IDistributedCache _cache; + + public DuplicateRequestService(IDistributedCache cache) + { + _cache = cache; + } + + public async Task IsDuplicateAsync(string key, TimeSpan expiration) + { + var cacheKey = $"DuplicateRequest:{key}"; + var existing = await _cache.GetAsync(cacheKey); + + if (existing != null) + { + return true; + } + + await _cache.SetAsync(cacheKey, DateTime.UtcNow.ToString(), new DistributedCacheEntryOptions + { + AbsoluteExpirationRelativeToNow = expiration + }); + + return false; + } + } +} diff --git a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs index fc4fa164..2ab7398f 100644 --- a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs +++ b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs @@ -399,8 +399,6 @@ namespace Shentun.Peis.RegisterChecks - - /// /// 生成检查单号(规则,先找体检中心的配置,如未找到,就直接使用全局的) /// 模式(0 日期+尾号 1.顺序递增) diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 2990ea73..ea0ebc60 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -88,7 +88,6 @@ namespace Shentun.Peis; typeof(AbpAspNetCoreSerilogModule), typeof(AbpSwashbuckleModule), typeof(AbpBackgroundWorkersHangfireModule) - )] public class PeisHttpApiHostModule : AbpModule { diff --git a/src/Shentun.Peis.HttpApi.Host/appsettings.json b/src/Shentun.Peis.HttpApi.Host/appsettings.json index e7011bbc..4b5aa47f 100644 --- a/src/Shentun.Peis.HttpApi.Host/appsettings.json +++ b/src/Shentun.Peis.HttpApi.Host/appsettings.json @@ -63,7 +63,7 @@ "IsEnabled": true, "IsEnabledDashboard": true, "ConnectionStrings": "192.168.0.188:6379,password=shentun123", - "Db": 4 + "Db": 6 }, "Pacs": { "AuthString": "peis:peis@123",