Commit b776dc2a0636b67c7cd89b9ef03dde032c11e93e
1 parent
215d0ce8
refactor(mes): update comments and improve code readability in condition matchers
Showing
3 changed files
with
9 additions
and
6 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/IotSceneRuleMatcherHelper.java
| ... | ... | @@ -254,14 +254,16 @@ public final class IotSceneRuleMatcherHelper { |
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * 校验匹配器中的产品和设备是否一致 |
| 257 | + * | |
| 257 | 258 | * @param message 消息 |
| 258 | - * @param productId 产品ID | |
| 259 | - * @param deviceId 设备id | |
| 259 | + * @param productId 产品编号 | |
| 260 | + * @param deviceId 设备编号 | |
| 260 | 261 | * @return 校验结果 |
| 261 | 262 | */ |
| 262 | 263 | public static boolean productAndDeviceNotMatched(IotDeviceMessage message, Long productId, Long deviceId) { |
| 263 | 264 | IotDeviceDO device = SpringUtils.getBean(IotDeviceService.class).getDeviceFromCache(message.getDeviceId()); |
| 264 | - | |
| 265 | - return IotDeviceDO.DEVICE_ID_ALL.equals(deviceId) ? ObjectUtil.notEqual(device.getProductId(), productId) : ObjectUtil.notEqual(message.getDeviceId(), deviceId); | |
| 265 | + return IotDeviceDO.DEVICE_ID_ALL.equals(deviceId) ? ObjectUtil.notEqual(device.getProductId(), productId) | |
| 266 | + : ObjectUtil.notEqual(message.getDeviceId(), deviceId); | |
| 266 | 267 | } |
| 268 | + | |
| 267 | 269 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotCurrentTimeConditionMatcher.java
| ... | ... | @@ -43,7 +43,7 @@ public class IotCurrentTimeConditionMatcher implements IotSceneRuleConditionMatc |
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - // 1.3 验证操作符是否为支持的时间操作符 | |
| 46 | + // 1.4 验证操作符是否为支持的时间操作符 | |
| 47 | 47 | String operator = condition.getOperator(); |
| 48 | 48 | IotSceneRuleConditionOperatorEnum operatorEnum = IotSceneRuleConditionOperatorEnum.operatorOf(operator); |
| 49 | 49 | if (operatorEnum == null) { |
| ... | ... | @@ -51,6 +51,7 @@ public class IotCurrentTimeConditionMatcher implements IotSceneRuleConditionMatc |
| 51 | 51 | return false; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | + // 1.5 验证操作符是否为时间相关的操作符 | |
| 54 | 55 | if (IotSceneRuleTimeHelper.isTimeOperator(operatorEnum)) { |
| 55 | 56 | IotSceneRuleMatcherHelper.logConditionMatchFailure(message, condition, "不支持的时间操作符: " + operator); |
| 56 | 57 | return false; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/matcher/condition/IotDevicePropertyConditionMatcher.java
| ... | ... | @@ -43,7 +43,7 @@ public class IotDevicePropertyConditionMatcher implements IotSceneRuleConditionM |
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - // 1.3 检查操作符和参数是否有效 | |
| 46 | + // 1.4 检查操作符和参数是否有效 | |
| 47 | 47 | if (!IotSceneRuleMatcherHelper.isConditionOperatorAndParamValid(condition)) { |
| 48 | 48 | IotSceneRuleMatcherHelper.logConditionMatchFailure(message, condition, "操作符或参数无效"); |
| 49 | 49 | return false; | ... | ... |