Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
765ced2954
@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.thingsboard.common.util.ListeningExecutor;
|
||||
import org.thingsboard.rule.engine.api.MailService;
|
||||
import org.thingsboard.rule.engine.api.RuleEngineAlarmService;
|
||||
@ -47,6 +48,7 @@ import org.thingsboard.server.common.data.rule.RuleNodeState;
|
||||
import org.thingsboard.server.common.msg.TbActorMsg;
|
||||
import org.thingsboard.server.common.msg.TbMsg;
|
||||
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
||||
import org.thingsboard.server.common.msg.queue.ServiceQueue;
|
||||
import org.thingsboard.server.common.msg.queue.ServiceType;
|
||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
||||
import org.thingsboard.server.dao.asset.AssetService;
|
||||
@ -183,6 +185,9 @@ class DefaultTbContext implements TbContext {
|
||||
}
|
||||
|
||||
private TopicPartitionInfo resolvePartition(TbMsg tbMsg, String queueName) {
|
||||
if (StringUtils.isEmpty(queueName)) {
|
||||
queueName = ServiceQueue.MAIN;
|
||||
}
|
||||
return mainCtx.resolve(ServiceType.TB_RULE_ENGINE, queueName, getTenantId(), tbMsg.getOriginator());
|
||||
}
|
||||
|
||||
|
||||
@ -74,6 +74,8 @@ public class DefaultTbDeviceProfileCache implements TbDeviceProfileCache {
|
||||
if (device != null) {
|
||||
profileId = device.getDeviceProfileId();
|
||||
devicesMap.put(deviceId, profileId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return get(tenantId, profileId);
|
||||
|
||||
@ -392,7 +392,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
|
||||
if (stateData != null) {
|
||||
DeviceState state = stateData.getState();
|
||||
state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout());
|
||||
if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime())) {
|
||||
if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && stateData.getDeviceCreationTime() + state.getInactivityTimeout() < ts) {
|
||||
state.setLastInactivityAlarmTime(ts);
|
||||
pushRuleEngineMessage(stateData, INACTIVITY_EVENT);
|
||||
save(deviceId, INACTIVITY_ALARM_TIME, ts);
|
||||
@ -479,6 +479,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
|
||||
return DeviceStateData.builder()
|
||||
.tenantId(device.getTenantId())
|
||||
.deviceId(device.getId())
|
||||
.deviceCreationTime(device.getCreatedTime())
|
||||
.metaData(md)
|
||||
.state(deviceState).build();
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -30,8 +30,8 @@ class DeviceStateData {
|
||||
|
||||
private final TenantId tenantId;
|
||||
private final DeviceId deviceId;
|
||||
|
||||
private final long deviceCreationTime;
|
||||
private TbMsgMetaData metaData;
|
||||
private final DeviceState state;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user