mirror of
https://gitee.com/zhijiantianya/yudao-cloud.git
synced 2025-12-25 23:00:06 +08:00
fix:【iot 物联网】增强 jdk8 的兼容性
This commit is contained in:
parent
09b332ef42
commit
4e4dc22740
@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* IoT 网关 HTTP 订阅者:接收下行给设备的消息
|
||||
*
|
||||
|
||||
@ -125,7 +125,7 @@ public class IotMqttConnectionManager {
|
||||
*/
|
||||
public IotMqttConnectionManager.ConnectionInfo getConnectionInfoByDeviceId(Long deviceId) {
|
||||
// 通过设备 ID 获取连接端点
|
||||
var endpoint = getDeviceEndpoint(deviceId);
|
||||
MqttEndpoint endpoint = getDeviceEndpoint(deviceId);
|
||||
if (endpoint == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
||||
*/
|
||||
private final LoadingCache<Long, IotDeviceRespDTO> deviceCaches = buildAsyncReloadingCache(
|
||||
CACHE_EXPIRE,
|
||||
new CacheLoader<>() {
|
||||
new CacheLoader<Long, IotDeviceRespDTO>() {
|
||||
|
||||
@Override
|
||||
public IotDeviceRespDTO load(Long id) {
|
||||
@ -51,7 +51,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
||||
*/
|
||||
private final LoadingCache<KeyValue<String, String>, IotDeviceRespDTO> deviceCaches2 = buildAsyncReloadingCache(
|
||||
CACHE_EXPIRE,
|
||||
new CacheLoader<>() {
|
||||
new CacheLoader<KeyValue<String, String>, IotDeviceRespDTO>() {
|
||||
|
||||
@Override
|
||||
public IotDeviceRespDTO load(KeyValue<String, String> kv) {
|
||||
|
||||
@ -40,19 +40,19 @@ public class IotDeviceApiImpl implements IotDeviceCommonApi {
|
||||
IotGatewayProperties.RpcProperties rpc = gatewayProperties.getRpc();
|
||||
restTemplate = new RestTemplateBuilder()
|
||||
.rootUri(rpc.getUrl() + "/rpc-api/iot/device")
|
||||
.readTimeout(rpc.getReadTimeout())
|
||||
.connectTimeout(rpc.getConnectTimeout())
|
||||
.setReadTimeout(rpc.getReadTimeout())
|
||||
.setConnectTimeout(rpc.getConnectTimeout())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> authDevice(IotDeviceAuthReqDTO authReqDTO) {
|
||||
return doPost("/auth", authReqDTO, new ParameterizedTypeReference<>() { });
|
||||
return doPost("/auth", authReqDTO, new ParameterizedTypeReference<CommonResult<Boolean>>() { });
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<IotDeviceRespDTO> getDevice(IotDeviceGetReqDTO getReqDTO) {
|
||||
return doPost("/get", getReqDTO, new ParameterizedTypeReference<>() { });
|
||||
return doPost("/get", getReqDTO, new ParameterizedTypeReference<CommonResult<IotDeviceRespDTO>>() { });
|
||||
}
|
||||
|
||||
private <T, R> CommonResult<R> doPost(String url, T body,
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.iot.framework.web.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springdoc.core.GroupedOpenApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@ -219,14 +219,14 @@ public class IotSceneRuleServiceImpl implements IotSceneRuleService {
|
||||
IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
|
||||
if (device == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
|
||||
return List.of();
|
||||
return ListUtil.of();
|
||||
}
|
||||
|
||||
// 1.2 通过 productId 获取产品信息
|
||||
IotProductDO product = productService.getProductFromCache(device.getProductId());
|
||||
if (product == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
|
||||
return List.of();
|
||||
return ListUtil.of();
|
||||
}
|
||||
|
||||
// 1.3 获取匹配的规则场景
|
||||
|
||||
@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
@ -48,17 +49,17 @@ public class IotSceneRuleMatcherManager {
|
||||
List<IotSceneRuleMatcher> allMatchers = matchers.stream()
|
||||
.filter(IotSceneRuleMatcher::isEnabled)
|
||||
.sorted(Comparator.comparing(IotSceneRuleMatcher::getPriority))
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 分离触发器匹配器和条件匹配器
|
||||
List<IotSceneRuleTriggerMatcher> triggerMatchers = allMatchers.stream()
|
||||
.filter(matcher -> matcher instanceof IotSceneRuleTriggerMatcher)
|
||||
.map(matcher -> (IotSceneRuleTriggerMatcher) matcher)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
List<IotSceneRuleConditionMatcher> conditionMatchers = allMatchers.stream()
|
||||
.filter(matcher -> matcher instanceof IotSceneRuleConditionMatcher)
|
||||
.map(matcher -> (IotSceneRuleConditionMatcher) matcher)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建触发器匹配器映射表
|
||||
this.triggerMatchers = convertMap(triggerMatchers, IotSceneRuleTriggerMatcher::getSupportedTriggerType,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user