From 1dadda6acc379a8e5a033687d595d2b6044a7174 Mon Sep 17 00:00:00 2001 From: rui_li <877258667@qq.com> Date: Fri, 12 Jun 2026 18:26:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=B7=BB=E5=8A=A0=E7=BA=BF=E7=A8=8B=E6=B1=A0=20?= =?UTF-8?q?=E7=9B=AE=E5=89=8D=E9=85=8D=E7=BD=AE=E6=9C=80=E5=A4=9A10?= =?UTF-8?q?=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/spring/config/ScheduleConfig.java | 23 +++++++++++++++++++ src/main/resources/application-dev.yml | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/spring/config/ScheduleConfig.java diff --git a/src/main/java/com/spring/config/ScheduleConfig.java b/src/main/java/com/spring/config/ScheduleConfig.java new file mode 100644 index 00000000..67bbd98a --- /dev/null +++ b/src/main/java/com/spring/config/ScheduleConfig.java @@ -0,0 +1,23 @@ +package com.spring.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +import java.util.concurrent.Executors; + +/** + * @author LR + * @version 1.0 + * @description: 定时任务多线程控制器 + * @date 2026-6-12 14:50 + */ +public class ScheduleConfig implements SchedulingConfigurer { + + @Value("${task.pool.schedulerSize}") + private int schedulerSize; + @Override + public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { + scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(schedulerSize)); + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index b9f890ca..bb5f0e27 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -102,9 +102,11 @@ task: syncDataToPLM: 0 0 0 29 2 ? # 每4年执行 syncLocationToPLM: 0 0 0 29 2 ? # 每4年执行 sync_part_catalog_to_plm: 0 0 0 29 2 ? # 每1分钟执行 - syncInventoryPartToPlm: 0 0 0 29 2 ? # 每4年执行 + syncInventoryPartToPlm: 0 */10 * * * ? # 每10分钟执行 refreshLdapAccountToRedis: 0 0 0 * * ? # flag: false + pool: + schedulerSize: 10 # 单点登录 login-token-url: 'http://192.168.1.160:8881/#/login-token'