修改灯光上报状态

This commit is contained in:
2025-08-15 18:16:37 +08:00
parent adc3834ddc
commit f8c53451c0
4 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,9 @@
package com.fuyuanshen.global.mqtt.base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.Comparator;
@ -11,7 +15,10 @@ import java.util.List;
*/
@Component
public class MqttRuleEngine {
@Autowired
@Qualifier("threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final LinkedHashMap<String, MqttMessageRule> rulesMap = new LinkedHashMap<>();
public MqttRuleEngine(List<MqttMessageRule> rules) {
@ -30,7 +37,7 @@ public class MqttRuleEngine {
int commandType = context.getCommandType();
MqttMessageRule mqttMessageRule = rulesMap.get("Light_"+commandType);
if (mqttMessageRule != null) {
mqttMessageRule.execute(context);
threadPoolTaskExecutor.execute(() -> mqttMessageRule.execute(context));
return true;
}