From f50dccebe836be233f23308c528a615eb993dc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com> Date: Fri, 15 Mar 2024 09:53:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/ITrackPushCacheService.cs | 8 ++++++++ .../EventHandlers/TrackUpsertEventHandler.cs | 3 ++- .../Services/TrackPush/TrackPushCacheService.cs | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs index 04369975..378d2d02 100644 --- a/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs +++ b/src/SJZY.Track.Application.Contract/Services/ITrackPushCacheService.cs @@ -9,6 +9,14 @@ public interface ITrackPushCacheService /// Task IsPushAsync(int customId); + /// + /// 判断客户是否需要推送 + /// + /// + /// + /// + Task IsPushAsync(int subSystemId, int customId); + /// /// 更新缓存 /// diff --git a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs index 21ddffc0..fd33d3e1 100644 --- a/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs +++ b/src/SJZY.Track.Application/EventHandlers/TrackUpsertEventHandler.cs @@ -99,7 +99,8 @@ public class TrackUpsertEventHandler : ITransientDependency, ICapSubscribe }; // todo:推送只做新增的,更新和删除的不做先 - if (!@event.IsPushCompleted && await _trackPushCacheService.IsPushAsync(@event.CustomId)) + if (!@event.IsPushCompleted && + await _trackPushCacheService.IsPushAsync(@event.SubSystemId, @event.CustomId)) { //await PushTrack(); } diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index 046ea943..ba084f93 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -32,6 +32,21 @@ public class TrackPushCacheService : ITrackPushCacheService, ITransientDependenc return (bool)isPush; } + public async Task IsPushAsync(int subSystemId, int customId) + { + var isPush = + await RedisHelper.Client.GetAsync(RedisKey(customId)); + + if (isPush == null) + { + isPush = await _trackPushConfigQuery.GetFirstAsync(x => x.CustomId == customId, + x => x.IsAutoPush); + await RedisHelper.Client.SetAsync(RedisKey(customId), isPush); + } + + return (bool)isPush; + } + public async Task UpdateAsync(int customId, bool isPush) { await RedisHelper.Client.SetAsync(RedisKey(customId), isPush);