|
|
@@ -42,6 +42,7 @@ import org.dromara.common.sse.dto.SseMessageContentDto;
|
|
|
import org.dromara.common.sse.dto.SseMessageContentTypeDto;
|
|
|
import org.dromara.common.sse.dto.SseMessageDto;
|
|
|
import org.dromara.common.sse.utils.SseMessageUtils;
|
|
|
+import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
@@ -78,6 +79,10 @@ public class SmsbDeviceServiceImpl implements ISmsbDeviceService {
|
|
|
@Value("${server.minio.ip}")
|
|
|
private String minioServerIp;
|
|
|
|
|
|
+ private final static String REDIS_KEY_IDENTIFIER = "global:msr:device:identifier";
|
|
|
+
|
|
|
+ private final static String REDIS_KEY_ID = "global:msr:device:id";
|
|
|
+
|
|
|
/**
|
|
|
* 查询设备
|
|
|
*
|
|
|
@@ -494,4 +499,22 @@ public class SmsbDeviceServiceImpl implements ISmsbDeviceService {
|
|
|
deviceMultiCardVoList = RedisUtils.getCacheObject(DeviceConstants.REDIS_DEVICE_MULTI_CARD_KEY + smsbDeviceVo.getIdentifier());
|
|
|
return deviceMultiCardVoList;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean refreshCache() {
|
|
|
+ // 查询出所有设备信息
|
|
|
+ List<SmsbDeviceVo> deviceVoList = TenantHelper.ignore(() -> baseMapper.selectVoList());
|
|
|
+ if (CollectionUtils.isEmpty(deviceVoList)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 删除所有设备缓存
|
|
|
+ RedisUtils.deleteKeys(REDIS_KEY_IDENTIFIER);
|
|
|
+ RedisUtils.deleteKeys(REDIS_KEY_ID);
|
|
|
+ // 重新缓存设备信息
|
|
|
+ for (SmsbDeviceVo smsbDeviceVo : deviceVoList) {
|
|
|
+ RedisUtils.setCacheMapValue(REDIS_KEY_IDENTIFIER,smsbDeviceVo.getIdentifier(), smsbDeviceVo);
|
|
|
+ RedisUtils.setCacheMapValue(REDIS_KEY_ID,smsbDeviceVo.getId().toString(), smsbDeviceVo);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|