BJQ6075 设备控制类

This commit is contained in:
2025-11-06 10:39:12 +08:00
parent 1dc3386284
commit c7ff118bfe
12 changed files with 421 additions and 145 deletions

View File

@ -21,26 +21,31 @@ public class MqttRuleEngine {
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final LinkedHashMap<String, MqttMessageRule> rulesMap = new LinkedHashMap<>();
public MqttRuleEngine(List<MqttMessageRule> rules) {
// 按优先级排序
rules.sort(Comparator.comparing(MqttMessageRule::getPriority));
rules.forEach(rule -> rulesMap.put(rule.getCommandType(), rule)
);
}
/**
* 执行匹配
*
* @param context 处理上下文
* @return
*/
public boolean executeRule(MqttRuleContext context) {
int commandType = context.getCommandType();
MqttMessageRule mqttMessageRule = rulesMap.get("Light_"+commandType);
MqttMessageRule mqttMessageRule = rulesMap.get("Light_" + commandType);
if (mqttMessageRule != null) {
threadPoolTaskExecutor.execute(() -> mqttMessageRule.execute(context));
return true;
}
return false;
}
}

View File

@ -3,7 +3,6 @@ package com.fuyuanshen.global.mqtt.constants;
public interface MqttConstants {
/**
* 全局发布消息的key
*/
@ -13,4 +12,5 @@ public interface MqttConstants {
* 全局订阅消息的key
*/
String GLOBAL_SUB_KEY = "A/";
}

View File

@ -25,6 +25,8 @@ import java.util.Objects;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/**
* 6075
*
* @author: 默苍璃
* @date: 2025-11-05 17:41
*/