Commit 203e3b581947eb21bde627e299fb0f358bce96c8

Authored by 芯火源
1 parent dc4d4f4c

refactor: 缓存场景联动设备信息

... ... @@ -445,6 +445,12 @@ caffeine:
445 445 taskCenterInfos:
446 446 timeToLiveInMinutes: "${CACHE_SPECS_TASK_CENTER_TTL:1440}"
447 447 maxSize: "${CACHE_SPECS_TASK_CENTER_MAX_SIZE:10000}"
  448 + organization:
  449 + timeToLiveInMinutes: "${CACHE_SPECS_ORG_TTL:1440}"
  450 + maxSize: "${CACHE_SPECS_ORG_MAX_SIZE:10000}"
  451 + sceneReact:
  452 + timeToLiveInMinutes: "${CACHE_SPECS_SCENE_TTL:1440}"
  453 + maxSize: "${CACHE_SPECS_SCENE_MAX_SIZE:10000}"
448 454 redis:
449 455 # standalone or cluster
450 456 connection:
... ... @@ -1217,4 +1223,4 @@ logging:
1217 1223 # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
1218 1224 frp:
1219 1225 server:
1220   - address: ${FRP_SERVER_ADDRESS:http://127.0.0.1}
\ No newline at end of file
  1226 + address: ${FRP_SERVER_ADDRESS:http://127.0.0.1}
... ...
... ... @@ -30,6 +30,8 @@ public interface FastIotConstants {
30 30 String TASK_CENTER_EXECUTE_TIME = "taskCenterExecuteTime";
31 31 String TASK_CENTER_DEVICE_EXECUTE_TIME = "taskCenterDeviceExecuteTime";
32 32 String TASK_IMMEDIATE_EXECUTE = "taskImmediateExecute";
  33 + String ORGANIZATION = "organization";
  34 + String SCENE_REACT = "sceneReact";
33 35 }
34 36
35 37 interface TBCacheConfig {
... ... @@ -175,6 +177,13 @@ public interface FastIotConstants {
175 177 /**RPC单项双向*/
176 178 public static String ONEWAY = "oneway";
177 179 }
  180 + class Scene{
  181 +
  182 + /**触发器*/
  183 + public static String CONDITION_TRIGGER = "trigger";
  184 + /**执行条件*/
  185 + public static String CONDITION_CONDITION = "condition";
  186 + }
178 187 class Alarm{
179 188
180 189 /**遥测指标标识符*/
... ...
... ... @@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
11 11 import org.apache.commons.lang3.StringUtils;
12 12 import org.jetbrains.annotations.NotNull;
13 13 import org.jetbrains.annotations.Nullable;
  14 +import org.springframework.cache.annotation.Cacheable;
14 15 import org.springframework.stereotype.Service;
15 16 import org.springframework.transaction.annotation.Transactional;
16 17 import org.thingsboard.common.util.JacksonUtil;
... ... @@ -661,7 +662,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
661 662 }
662 663 return baseMapper.findDeviceInfo(tenantId, tbDeviceId);
663 664 }
664   -
  665 + @Cacheable(cacheNames = FastIotConstants.CacheConfigKey.SCENE_REACT, key = "{#tenantId, #organizationId, #projectId}")
665 666 @Override
666 667 public List<String> rpcDevices(String tenantId, String organizationId, String projectId) {
667 668 List<String> orgIds = organizationService.organizationAllIds(tenantId, organizationId);
... ...