|
|
@@ -0,0 +1,71 @@
|
|
|
+package com.nb.app.assistant.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.nb.app.assistant.api.bean.DeviceAlarmBean;
|
|
|
+import com.nb.app.assistant.api.feign.IAppIphoneClient;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
+import com.nb.web.api.feign.IDeviceAlarmClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : LocalAppIphoneService
|
|
|
+ * @Description :
|
|
|
+ * @Author : LF
|
|
|
+ * @Date: 2024年09月10日
|
|
|
+ */
|
|
|
+@Service("iosService")
|
|
|
+public class LocalAppIphoneService implements IAppIphoneClient {
|
|
|
+ @Autowired
|
|
|
+ private RedissonClient redissonClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private IDeviceAlarmClient deviceAlarmClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private LocalAppIphoneService self;
|
|
|
+
|
|
|
+// public void addDeviceToken(IphoneDeviceDTO source){
|
|
|
+// RSet<IphoneDeviceTokenUserDTO> tenantSet = redissonClient.getSet("ios:"+source.getTenantId());
|
|
|
+// tenantSet.add(IphoneDeviceTokenUserDTO.of(source.getDeviceToken(),source.getUserId(),new Date()));
|
|
|
+// }
|
|
|
+
|
|
|
+// public void removeDeviceToken(IphoneDeviceDTO source){
|
|
|
+// RSet<IphoneDeviceTokenUserDTO> tenantSet = redissonClient.getSet("ios:"+source.getTenantId());
|
|
|
+// Set<IphoneDeviceTokenUserDTO> iphoneDeviceTokenUserDTOS = tenantSet.readAll();
|
|
|
+// HashSet<IphoneDeviceTokenUserDTO> removeAll = new HashSet<IphoneDeviceTokenUserDTO>();
|
|
|
+// for (IphoneDeviceTokenUserDTO deviceTokenUser : iphoneDeviceTokenUserDTOS) {
|
|
|
+// if(StrUtil.equals(source.getDeviceToken(),deviceTokenUser.getDeviceToken())){
|
|
|
+// removeAll.add(deviceTokenUser);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(CollectionUtil.isNotEmpty(removeAll)){
|
|
|
+// tenantSet.removeAll(removeAll);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendAlarmMsg(String tenantId, DeviceAlarmBean source) {
|
|
|
+// self.sendMsg(tenantId,source);
|
|
|
+ }
|
|
|
+
|
|
|
+// public void sendMsg(String tenantId, DeviceAlarmBean source){
|
|
|
+// RSet<IphoneDeviceTokenUserDTO> tenantSet = redissonClient.getSet("ios:"+tenantId);
|
|
|
+// Set<IphoneDeviceTokenUserDTO> deviceTokenSet = tenantSet.readAll();
|
|
|
+// if (CollectionUtil.isNotEmpty(deviceTokenSet)) {
|
|
|
+// deviceTokenSet.parallelStream()
|
|
|
+// .forEach(deviceTokenUser->{
|
|
|
+// try {
|
|
|
+// Long alarmCount = deviceAlarmClient.count(tenantId, deviceTokenUser.getOfflineTime());
|
|
|
+// ApnsUtils.sendMsg(deviceTokenUser.getDeviceToken(),source,alarmCount>99?99:alarmCount);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+}
|