From 69ba128c58bfb9f5a79481e4997558aafc6f46c6 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期二, 23 九月 2025 15:21:51 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/task/ShuttleExecuteScheduler.java | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/zy/core/task/ShuttleExecuteScheduler.java b/src/main/java/com/zy/core/task/ShuttleExecuteScheduler.java index a3d5036..df063f7 100644 --- a/src/main/java/com/zy/core/task/ShuttleExecuteScheduler.java +++ b/src/main/java/com/zy/core/task/ShuttleExecuteScheduler.java @@ -8,10 +8,12 @@ import com.zy.core.action.ShuttleAction; import com.zy.core.enums.RedisKeyType; import com.zy.core.enums.SlaveType; +import com.zy.core.utils.TimeoutExecutor; import org.springframework.scheduling.annotation.Scheduled; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; public class ShuttleExecuteScheduler implements Runnable { @@ -19,11 +21,6 @@ private DeviceConfigService deviceConfigService; private RedisUtil redisUtil; private int threadControlCount; - - @Scheduled(cron = "0/1 * * * * ? ") - public void execute() { - - } public ShuttleExecuteScheduler(ShuttleAction shuttleAction, DeviceConfigService deviceConfigService, RedisUtil redisUtil, int threadControlCount) { this.shuttleAction = shuttleAction; @@ -68,10 +65,15 @@ if (taskNo != 0) { //瀛樺湪浠诲姟闇�瑕佹墽琛� long startTime = System.currentTimeMillis(); - News.info("execute {},{}", deviceConfig.getDeviceNo(), taskNo); - boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo); + News.info("[RCS Debug] Execute {},{}", deviceConfig.getDeviceNo(), taskNo); + // 鍦ㄥ惊鐜腑浣跨敤 + boolean result = TimeoutExecutor.executeWithTimeout( + () -> shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo), + 30, // 30绉掕秴鏃� + TimeUnit.SECONDS + ); Thread.sleep(100); - News.info("execute end {},{},{}", deviceConfig.getDeviceNo(), taskNo, System.currentTimeMillis() - startTime); + News.info("[RCS Debug] Execute end {},{},{}", deviceConfig.getDeviceNo(), taskNo, System.currentTimeMillis() - startTime); } } }catch (Exception e){ -- Gitblit v1.9.1