【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -146,7 +146,7 @@ public class IotProductController {
|
||||
public CommonResult<List<IotProductRespVO>> getProductSimpleList() {
|
||||
List<IotProductDO> list = productService.getProductList();
|
||||
return success(convertList(list, product -> // 只返回 id、name 字段
|
||||
new IotProductRespVO().setId(product.getId()).setName(product.getName())
|
||||
new IotProductRespVO().setId(product.getId()).setName(product.getName()).setStatus(product.getStatus())
|
||||
.setDeviceType(product.getDeviceType()).setLocationType(product.getLocationType())));
|
||||
}
|
||||
|
||||
|
||||
@@ -241,13 +241,13 @@ public class IotSceneRuleServiceImpl implements IotSceneRuleService {
|
||||
*/
|
||||
private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
|
||||
// 1.1 通过 deviceId 获取设备信息
|
||||
IotDeviceDO device = getSelf().deviceService.getDeviceFromCache(message.getDeviceId());
|
||||
IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
|
||||
if (device == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
|
||||
return ListUtil.of();
|
||||
}
|
||||
// 1.2 通过 productId 获取产品信息
|
||||
IotProductDO product = getSelf().productService.getProductFromCache(device.getProductId());
|
||||
IotProductDO product = productService.getProductFromCache(device.getProductId());
|
||||
if (product == null) {
|
||||
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
|
||||
return ListUtil.of();
|
||||
|
||||
@@ -48,13 +48,13 @@ public class IotDeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatc
|
||||
// 2. 对于事件触发器,通常不需要检查操作符和值,只要事件发生即匹配
|
||||
// 但如果配置了操作符和值,则需要进行条件匹配
|
||||
if (StrUtil.isNotBlank(trigger.getOperator()) && StrUtil.isNotBlank(trigger.getValue())) {
|
||||
Object eventData = message.getData();
|
||||
if (eventData == null) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件数据为空");
|
||||
Object eventParams = message.getParams();
|
||||
if (eventParams == null) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件参数为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventData, trigger.getOperator(), trigger.getValue());
|
||||
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventParams, trigger.getOperator(), trigger.getValue());
|
||||
if (!matched) {
|
||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "事件数据条件不匹配");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user