From aa93e512a60379c6373d10023f49dae4403b51c4 Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期五, 21 二月 2025 17:55:09 +0800 Subject: [PATCH] 金堆成同步字典服务 --- src/main/java/com/example/scheudleds/DictSyncCommon.java | 40 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/example/scheudleds/DictSyncCommon.java b/src/main/java/com/example/scheudleds/DictSyncCommon.java index 31f9fae..d4b2adb 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(40); + + @Scheduled(cron = "0 0 22 * * ?") + public void executeTasks() { + List<String> list = Arrays.asList("shanxiqinxamjyy","shanxiqinpbkwyy","shanxiqinjdczgzyy"); + 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); + } + } } -- Gitblit v1.8.0