feat: 优化设备状态检查逻辑,更新空闲设备的完成原因记录,注释掉定时任务的执行注解

This commit is contained in:
yahaozhang
2025-09-25 14:23:42 +08:00
parent d6afa0a054
commit 83fd8b02d7
3 changed files with 699 additions and 3 deletions

View File

@@ -74,13 +74,13 @@ public class DeviceStatusCheckService {
// 3. 如果设备空闲,通过完成检测服务进行判定(含缓冲与二次确认)。
// 若未能直接判定完成,则执行兜底:将该设备上 LOGGED_IN 的任务批量置为 COMPLETED并写入原因。
if (statusInfo.isIdle()) {
String source = "TIMER_TASK";
String source = reason != null ? reason : "UNKNOWN_REASON";
com.gameplatform.server.util.AuditLogger.debug("IdleDetected: device={}, source={}, status={}, points={}", machineId, source, statusInfo.getStatus(), statusInfo.getPoints());
// 调用完成检测服务(包含登录缓冲与二次确认)
boolean done = completionDetectionService.detectGameCompletion(machineId, statusInfo.getStatus(), source);
if (!done) {
// 兜底完成:当设备空闲,直接将 LOGGED_IN 任务置为完成
String completionReason = "状态:已完成(空闲兜底)";
String completionReason = String.format("状态:已完成(空闲兜底,触发原因:%s", reason != null ? reason : "checkDeviceStatusAndUpdateTasks 未知");
Integer points = statusInfo.getPoints();
try {
int affected = linkTaskMapper.completeLoggedInTasksByMachine(machineId, completionReason, points);

View File

@@ -30,7 +30,7 @@ public class DeviceStatusCheckTask {
/**
* 每分钟检查一次空闲设备,并更新相关链接任务状态
*/
@Scheduled(fixedRate = 60000) // 每60秒执行一次
// @Scheduled(fixedRate = 60000) // 每60秒执行一次
public void checkIdleDevicesAndUpdateTasks() {
log.debug("开始定时检查空闲设备");