| | |
| | | |
| | | import cn.hutool.core.text.CharPool; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| | | import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; |
| | | import cn.iocoder.yudao.framework.common.util.spring.SpringUtils; |
| | | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| | | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| | | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO; |
| | | import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum; |
| | | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | return StrUtil.isNotBlank(expectedIdentifier) && expectedIdentifier.equals(actualIdentifier); |
| | | } |
| | | |
| | | /** |
| | | * 校验匹配器中的产品和设备是否一致 |
| | | * |
| | | * @param message 消息 |
| | | * @param productId 产品编号 |
| | | * @param deviceId 设备编号 |
| | | * @return 校验结果 |
| | | */ |
| | | public static boolean productAndDeviceNotMatched(IotDeviceMessage message, Long productId, Long deviceId) { |
| | | if (message == null || message.getDeviceId() == null) { |
| | | return false; |
| | | } |
| | | if (deviceId != null && !IotDeviceDO.DEVICE_ID_ALL.equals(deviceId)) { |
| | | return ObjectUtil.notEqual(message.getDeviceId(), deviceId); |
| | | } |
| | | if (productId == null) { |
| | | return false; |
| | | } |
| | | IotDeviceDO device = SpringUtils.getBean(IotDeviceService.class).getDeviceFromCache(message.getDeviceId()); |
| | | return device == null || ObjectUtil.notEqual(device.getProductId(), productId); |
| | | } |
| | | |
| | | } |