From 7f3e0cd59c16c12792c0b986e72ac844ceb1f483 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 10 Apr 2024 09:04:57 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83app?= =?UTF-8?q?=E5=8D=B3=E6=97=B6=E6=8E=A8=E9=80=81=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PushMessageServiceImpl.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java index 4d7a943..b094107 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; /** @@ -112,14 +113,20 @@ public class PushMessageServiceImpl implements IMessageService { * @param tenantId 租户ID * @return 推送结果 */ - public R sendAndroidMsg(String subject,String content,List userIds,String tenantId) { + public synchronized R sendAndroidMsg(String subject,String content,List userIds,String tenantId) { PushInfoVO pushInfoVO = new PushInfoVO(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience); pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setTenantId(tenantId); - return pushClient.tenantPush(pushInfoVO); + R pushResponseR = pushClient.tenantPush(pushInfoVO); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return pushResponseR; } /** @@ -130,13 +137,19 @@ public class PushMessageServiceImpl implements IMessageService { * @param tenantId 租户ID * @return 推送结果 */ - public R sendIOSMsg(String subject,String content,List userIds,String tenantId) { + public synchronized R sendIOSMsg(String subject,String content,List userIds,String tenantId) { PushInfoVO pushInfoVO = new PushInfoVO(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience); pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setTenantId(tenantId); - return pushClient.tenantPush(pushInfoVO); + R pushResponseR = pushClient.tenantPush(pushInfoVO); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return pushResponseR; } }