From 84edc5644e2cf964822555d56fd809d57080afcc Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Tue, 25 Mar 2025 14:57:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?change-params:=E9=A2=84=E8=AD=A6=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=BB=E4=BD=93=E6=9F=A5=E8=AF=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7id=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Warning/GetWarningRuleInput.cs | 7 ++++++- .../Services/Warning/WarningService.cs | 2 +- .../Aggregates/WarningAggregate/IWarningRuleRepository.cs | 2 +- .../Repositories/WarningRuleRepository.cs | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs index 8fe2a151..8ec6831e 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Warning/GetWarningRuleInput.cs @@ -11,10 +11,15 @@ public class GetWarningRuleInput public int? SubSystemId { get; set; } /// - /// 关键字(kpi/客户名称 模糊) + /// 关键字(kpi名称 模糊查询) /// public string? Keywords { get; set; } + /// + /// 客户id + /// + public int? CustomId { get; set; } + /// /// 是否启用(留null查全部) /// diff --git a/src/SJZY.Track.Application/Services/Warning/WarningService.cs b/src/SJZY.Track.Application/Services/Warning/WarningService.cs index 478883b6..ced9e491 100644 --- a/src/SJZY.Track.Application/Services/Warning/WarningService.cs +++ b/src/SJZY.Track.Application/Services/Warning/WarningService.cs @@ -38,7 +38,7 @@ public class WarningService : ApplicationService [HttpPost("GetWarningRule")] public async Task>> GetWarningRule(GetWarningRuleInput input) { - var result = await _warningRuleRepository.GetWarningRuleListAsync(input.SubSystemId, input.Keywords, input.IsEnabled, input.WarningType); + var result = await _warningRuleRepository.GetWarningRuleListAsync(input.SubSystemId, input.CustomId, input.Keywords, input.IsEnabled, input.WarningType); if (result.Count == 0) return new UnifyResultDto>(true, new List()); diff --git a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs index 13df653f..b137a06c 100644 --- a/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs @@ -25,7 +25,7 @@ public interface IWarningRuleRepository : IBasicRepository Task UpdateVersionAsync(WarningRuleEntity entity); // 模糊查询预警规则主体 - Task> GetWarningRuleListAsync(int? subsystemId, string? keyword, bool? isEnabled, int? warningType); + Task> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keyword, bool? isEnabled, int? warningType); // 获取启用的预警规则主体 Task GetWarningRuleForEnabledAsync(int subSystemId, int customId, WarningRuleType warningType); diff --git a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs index 13d7c255..811dbe8e 100644 --- a/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/WarningRuleRepository.cs @@ -76,14 +76,14 @@ public class WarningRuleRepository : BasicRepository, IWarnin return version; } - public Task> GetWarningRuleListAsync(int? subsystemId, string? keywords, bool? isEnabled, int? warningType) + public Task> GetWarningRuleListAsync(int? subsystemId, int? customId, string? keywords, bool? isEnabled, int? warningType) { return Context.Queryable() + .WhereIF(customId.HasValue, x => x.CustomId == customId!.Value) .WhereIF(subsystemId.HasValue, x => x.SubSystemId == subsystemId!.Value) - // todo: 客户/kpi名称 改成客户下拉 - .WhereIF(!string.IsNullOrWhiteSpace(keywords), x => x.Name.Contains(keywords!)) - .WhereIF(isEnabled.HasValue, x => x.IsEnabled == isEnabled!.Value) .WhereIF(warningType.HasValue, x => x.WarningType == warningType!.Value) + .WhereIF(isEnabled.HasValue, x => x.IsEnabled == isEnabled!.Value) + .WhereIF(!string.IsNullOrWhiteSpace(keywords), x => x.Name.Contains(keywords!)) .ToListAsync(); } From cfccd59ce1d49ebd5d9e87308719df823cd99423 Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Tue, 25 Mar 2025 17:11:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dhangfire=E7=9A=84redi?= =?UTF-8?q?sKey=E5=89=8D=E7=BC=80=E5=A2=9E=E5=8A=A0:=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E8=AE=BE=E7=BD=AE=E7=BB=88=E6=AD=A2=E6=80=81=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=8F=AA=E4=BF=9D=E7=95=991=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SJZY.Track.Application/SjzyTrackApplicationModule.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs index 002317a4..53284c7a 100644 --- a/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs +++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs @@ -221,12 +221,13 @@ public class SjzyTrackApplicationModule : AbpModule context.Services.Configure(configuration.GetSection("WarningTask")); context.Services.AddHangfire(o => { - var options = new RedisStorageOptions() + var options = new RedisStorageOptions { - Prefix = GlobalConst.TrackHangfireKeyPrefix, + Prefix = $"{GlobalConst.TrackHangfireKeyPrefix}:", Db = int.Parse(configuration["Redis:Database"]!), }; - o.UseRedisStorage(connectionString,options); + o.UseRedisStorage(connectionString, options) + .WithJobExpirationTimeout(TimeSpan.FromHours(1)); // 终止态任务只保留1小时 }); context.Services.AddHangfireServer(o => {