设备控制完善日志

master
lld 2026-01-31 22:18:53 +08:00
parent d4be7bbd5d
commit 29ba2bd5bb
1 changed files with 18 additions and 20 deletions

View File

@ -162,7 +162,7 @@ public class DeviceStatusHandler {
log.warn("【设备回执】prop包含多个功能码仅处理第一个{}", propObj.keySet()); log.warn("【设备回执】prop包含多个功能码仅处理第一个{}", propObj.keySet());
} }
log.info("【设备回执】设备{}的{}功能执行完成,已释放锁:{},{}", deviceId, funcType, lockKey, delete); log.info("【设备回执】设备{}的{}功能执行完成,已释放锁:{},{}", deviceId, funcType, lockKey, delete);
int runTime = 0;
// 回执成功且值=1时启动自动关闭任务保留原有逻辑 // 回执成功且值=1时启动自动关闭任务保留原有逻辑
boolean suc = payloadObj.getBooleanValue("suc"); boolean suc = payloadObj.getBooleanValue("suc");
if (suc && StringUtils.hasText(funcType) && funcValue != null && funcValue == 1) { if (suc && StringUtils.hasText(funcType) && funcValue != null && funcValue == 1) {
@ -173,12 +173,16 @@ public class DeviceStatusHandler {
if (agriLimit != null) { if (agriLimit != null) {
autoOffSeconds = LIMIT_MAP.getOrDefault(funcType, k -> 0).apply(agriLimit); autoOffSeconds = LIMIT_MAP.getOrDefault(funcType, k -> 0).apply(agriLimit);
} }
runTime = autoOffSeconds;
// 新增:判断是否真的需要执行自动关任务(延迟秒数>0才是有效任务 // 新增:判断是否真的需要执行自动关任务(延迟秒数>0才是有效任务
if (autoOffSeconds > 0) { if (autoOffSeconds > 0) {
mqttAutoOffManager.scheduleAutoOff(deviceId, funcType, autoOffSeconds); mqttAutoOffManager.scheduleAutoOff(deviceId, funcType, autoOffSeconds);
log.debug("【自动关任务】标记需要执行deviceId={}, funcType={}, delay={}s", deviceId, funcType, autoOffSeconds); log.debug("【自动关任务】标记需要执行deviceId={}, funcType={}, delay={}s", deviceId, funcType, autoOffSeconds);
} }
}
if (suc && StringUtils.hasText(funcType) && funcValue != null && funcValue == 0) {
mqttAutoOffManager.cancelAutoOff(deviceId, funcType);
}
sysDevOperLogService.lambdaUpdate() sysDevOperLogService.lambdaUpdate()
.eq(SysDevOperLog::getImei, deviceId) .eq(SysDevOperLog::getImei, deviceId)
.eq(SysDevOperLog::getFuncCode, funcType) .eq(SysDevOperLog::getFuncCode, funcType)
@ -186,22 +190,16 @@ public class DeviceStatusHandler {
.eq(SysDevOperLog::getLockAcquired,1) .eq(SysDevOperLog::getLockAcquired,1)
.orderByDesc(SysDevOperLog::getCreateTime) .orderByDesc(SysDevOperLog::getCreateTime)
.last("LIMIT 1") .last("LIMIT 1")
.set(SysDevOperLog::getExecResult,1)
.set(SysDevOperLog::getAckReceived,1) .set(SysDevOperLog::getAckReceived,1)
.set(SysDevOperLog::getIsLockSuc,1) .set(SysDevOperLog::getAckSuc, suc?1:0)
.set(SysDevOperLog::getAckSuc, 1) .set(SysDevOperLog::getIsLockSuc,delete?1:0)
.set(SysDevOperLog::getIsTask,runTime > 0?1:0)
.set(SysDevOperLog::getRunTime, runTime)
.set(SysDevOperLog::getNoTaskReason,runTime > 0?null:"【自动关任务】标记不符合执行运行时间未配置,当前运行时间:【"+runTime+" s】")
.set(SysDevOperLog::getUpdateBy,"设备回执") .set(SysDevOperLog::getUpdateBy,"设备回执")
.set(SysDevOperLog::getIsTask,autoOffSeconds > 0?1:0)
.set(SysDevOperLog::getNoTaskReason,autoOffSeconds > 0?null:"【自动关任务】标记不符合执行运行时间未配置,当前运行时间:【"+autoOffSeconds+"】")
.set(SysDevOperLog::getAck, payload) .set(SysDevOperLog::getAck, payload)
.set(SysDevOperLog::getExecResult, 1)
.update(); .update();
} }
if (suc && StringUtils.hasText(funcType) && funcValue != null && funcValue == 0) {
mqttAutoOffManager.cancelAutoOff(deviceId, funcType);
}
}
} }
// 第三步仅处理非回执的设备状态包且仅当是8个功能码结构就写入Redis // 第三步仅处理非回执的设备状态包且仅当是8个功能码结构就写入Redis