更新控制指令锁过期时间
parent
c9652702db
commit
2d8edaccfc
|
|
@ -170,4 +170,7 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||||
"org.springframework", "org.apache", "com.agri.common.utils.file", "com.agri.common.config", "com.agri.generator" };
|
"org.springframework", "org.apache", "com.agri.common.utils.file", "com.agri.common.config", "com.agri.generator" };
|
||||||
|
|
||||||
|
public static final String JM1G = "jm1g";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,12 @@ public class FrontendControlHandler {
|
||||||
// 2. 分布式锁:设备ID+功能类型(避免同设备同功能并发控制)
|
// 2. 分布式锁:设备ID+功能类型(避免同设备同功能并发控制)
|
||||||
String lockKey = "lock:" + deviceId + ":" + funcType;
|
String lockKey = "lock:" + deviceId + ":" + funcType;
|
||||||
Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent(
|
Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent(
|
||||||
lockKey, clientId, 15, TimeUnit.SECONDS // 延长至15秒,适配设备回执场景
|
lockKey, clientId, 60, TimeUnit.SECONDS // 延长至15秒,适配设备回执场景
|
||||||
);
|
);
|
||||||
if (lockSuccess == null || !lockSuccess) {
|
if (lockSuccess == null || !lockSuccess) {
|
||||||
String errorTopic = "frontend/" + clientId + "/dtu/" + deviceId + "/listener";
|
String errorTopic = "frontend/" + clientId + "/dtu/" + deviceId + "/listener";
|
||||||
mqttMessageSender.publish(errorTopic, "{\"msg\":\"设备" + funcType + "功能忙,请稍后重试\"}");
|
mqttMessageSender.publish(errorTopic, "{\"msg\":\"设备" + funcType + "功能忙,请稍后重试\"}");
|
||||||
log.warn("【分布式锁】前端{}操作设备{}的{}功能失败", clientId, deviceId, funcType);
|
log.warn("【分布式锁】前端{}操作设备{}的{}功能失败;可能其他用户正在操作此功能", clientId, deviceId, funcType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ public class MqttAutoOffManager {
|
||||||
// 新增:自动关也走分布式锁(避免与前端并发控制同一功能导致乱序/互相覆盖)
|
// 新增:自动关也走分布式锁(避免与前端并发控制同一功能导致乱序/互相覆盖)
|
||||||
String lockKey = "lock:" + deviceId + ":" + funcType;
|
String lockKey = "lock:" + deviceId + ":" + funcType;
|
||||||
Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent(
|
Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent(
|
||||||
lockKey, "autooff", 15, TimeUnit.SECONDS
|
lockKey, "autooff", 60, TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
if (lockSuccess == null || !lockSuccess) {
|
if (lockSuccess == null || !lockSuccess) {
|
||||||
log.info("【自动关任务】{}功能忙(锁占用),跳过自动关闭:deviceId={}, funcType={}", funcType, deviceId, funcType);
|
log.info("【自动关任务】{}功能忙(锁占用),跳过自动关闭:deviceId={}, funcType={}", funcType, deviceId, funcType);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue