Browse Source

# 消息中心app即时推送逻辑修改

zhongwei
haungxing 8 months ago
parent
commit
7f3e0cd59c
  1. 21
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java

21
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.Callable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
/** /**
@ -112,14 +113,20 @@ public class PushMessageServiceImpl implements IMessageService {
* @param tenantId 租户ID * @param tenantId 租户ID
* @return 推送结果 * @return 推送结果
*/ */
public R<PushResponse> sendAndroidMsg(String subject,String content,List<String> userIds,String tenantId) { public synchronized R<PushResponse> sendAndroidMsg(String subject,String content,List<String> userIds,String tenantId) {
PushInfoVO pushInfoVO = new PushInfoVO(); PushInfoVO pushInfoVO = new PushInfoVO();
PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build();
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build();
PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience); PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience);
pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setPushInfo(pushInfo);
pushInfoVO.setTenantId(tenantId); pushInfoVO.setTenantId(tenantId);
return pushClient.tenantPush(pushInfoVO); R<PushResponse> 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 * @param tenantId 租户ID
* @return 推送结果 * @return 推送结果
*/ */
public R<PushResponse> sendIOSMsg(String subject,String content,List<String> userIds,String tenantId) { public synchronized R<PushResponse> sendIOSMsg(String subject,String content,List<String> userIds,String tenantId) {
PushInfoVO pushInfoVO = new PushInfoVO(); PushInfoVO pushInfoVO = new PushInfoVO();
PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build(); PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build();
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build();
PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience); PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience);
pushInfoVO.setPushInfo(pushInfo); pushInfoVO.setPushInfo(pushInfo);
pushInfoVO.setTenantId(tenantId); pushInfoVO.setTenantId(tenantId);
return pushClient.tenantPush(pushInfoVO); R<PushResponse> pushResponseR = pushClient.tenantPush(pushInfoVO);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return pushResponseR;
} }
} }

Loading…
Cancel
Save