From 76a95c63bb63b5d03f5a97968d3930917710d203 Mon Sep 17 00:00:00 2001 From: 赵文轩 <1652863494@qq.com> Date: 星期一, 20 一月 2025 08:49:52 +0800 Subject: [PATCH] 20250120 --- src/main/java/com/example/scheudleds/DictSyncCommon.java | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/scheudleds/DictSyncCommon.java b/src/main/java/com/example/scheudleds/DictSyncCommon.java index 31f9fae..ef5c502 100644 --- a/src/main/java/com/example/scheudleds/DictSyncCommon.java +++ b/src/main/java/com/example/scheudleds/DictSyncCommon.java @@ -1,11 +1,49 @@ package com.example.scheudleds; - +import com.example.factory.ServiceFactory; +import com.example.service.HisService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; @Slf4j @Component public class DictSyncCommon { -} + private final ServiceFactory serviceFactory; + + @Autowired + public DictSyncCommon(ServiceFactory serviceFactory) { + this.serviceFactory = serviceFactory; + } + + private final ExecutorService executorService = Executors.newFixedThreadPool(4); + + @Scheduled(cron = "0 0 22 * * ?") + public void executeTasks() { + List<String> list = Arrays.asList("shanxiqinxamjyy","shanxiqinpbkwyy"); + log.info("寮�濮嬫墽琛屽畾鏃朵换鍔★細{}", System.currentTimeMillis()); + try { + for (String hosp : list) { + executorService.submit(() -> { + try { + log.info("寮�濮嬪悓姝ュ尰闄㈡暟鎹細{}", hosp); + HisService hisService = serviceFactory.getService(hosp); + hisService.syncDict(hosp); + log.info("瀹屾垚鍚屾鍖婚櫌鏁版嵁锛歿}", hosp); + } catch (Exception e) { + log.error("鍚屾鍖婚櫌鏁版嵁澶辫触锛屽尰闄細{}锛屽紓甯革細{}", hosp, e.getMessage()); + } + }); + } + } catch (Exception e) { + log.error("瀹氭椂浠诲姟鎵ц寮傚父锛�", e); + } + } +} \ No newline at end of file -- Gitblit v1.8.0