Bläddra i källkod

add
苹果手机报警推送

18339543638 1 år sedan
förälder
incheckning
6d3b4aaebd

+ 11 - 6
nb-service/app-assistant/src/main/java/com/nb/app/assistant/service/LocalAppIphoneService.java

@@ -8,6 +8,8 @@ import com.nb.app.assistant.utils.ApnsUtils;
 import lombok.AllArgsConstructor;
 import org.redisson.api.RSet;
 import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -19,10 +21,14 @@ import java.util.Set;
  * @Author : LF
  * @Date: 2024年09月10日
  */
-@Service
-@AllArgsConstructor
+@Service("iosService")
 public class LocalAppIphoneService implements IAppIphoneClient {
-    private final RedissonClient redissonClient;
+    @Autowired
+    private  RedissonClient redissonClient;
+
+    @Autowired
+    @Lazy
+    private LocalAppIphoneService self;
 
     public void addDeviceToken(IphoneDeviceDTO source){
         RSet<String> tenantSet = redissonClient.getSet(source.getTenantId());
@@ -35,12 +41,11 @@ public class LocalAppIphoneService implements IAppIphoneClient {
     }
 
     @Override
-    @Async
     public void sendAlarmMsg(String tenantId, DeviceAlarmBean source) {
-        this.sendMsg(tenantId,source);
+        self.sendMsg(tenantId,source);
     }
 
-    private void sendMsg(String tenantId, DeviceAlarmBean source){
+    public void sendMsg(String tenantId, DeviceAlarmBean source){
         RSet<String> tenantSet = redissonClient.getSet(tenantId);
         Set<String> deviceTokenSet = tenantSet.readAll();
         if (CollectionUtil.isNotEmpty(deviceTokenSet)) {