forked from dyf/fys-Multi-tenant
修改灯光上报状态
This commit is contained in:
@ -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;
|
||||
@ -12,6 +16,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
|
||||
|
||||
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
|
||||
} catch (Exception e) {
|
||||
log.error("处理灯光模式命令时出错", e);
|
||||
log.error("处理激光模式命令时出错", e);
|
||||
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.FAILED.getCode(), Duration.ofSeconds(30));
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,7 @@ import java.time.Duration;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
|
||||
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
|
||||
|
||||
/**
|
||||
* 灯光模式订阅设备回传消息
|
||||
@ -39,6 +38,7 @@ public class BjqModeRule implements MqttMessageRule {
|
||||
Object[] convertArr = context.getConvertArr();
|
||||
|
||||
String mainLightMode = convertArr[1].toString();
|
||||
String batteryRemainingTime = convertArr[2].toString();
|
||||
if(StringUtils.isNotBlank(mainLightMode)){
|
||||
if("0".equals(mainLightMode)){
|
||||
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
|
||||
@ -46,6 +46,10 @@ public class BjqModeRule implements MqttMessageRule {
|
||||
}
|
||||
// 发送设备状态和位置信息到Redis
|
||||
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
|
||||
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + context.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX;
|
||||
|
||||
// 存储到Redis
|
||||
RedisUtils.setCacheObject(deviceRedisKey, batteryRemainingTime);
|
||||
}
|
||||
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(20));
|
||||
} catch (Exception e) {
|
||||
|
@ -232,7 +232,7 @@ xss:
|
||||
# 如使用JDK21请直接使用虚拟线程 不要开启此配置
|
||||
thread-pool:
|
||||
# 是否开启线程池
|
||||
enabled: false
|
||||
enabled: true
|
||||
# 队列最大长度
|
||||
queueCapacity: 128
|
||||
# 线程池维护线程所允许的空闲时间
|
||||
|
Reference in New Issue
Block a user