From c2976b80e8850be2d28dc2132c6659856b871f3c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 08 五月 2025 21:10:42 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java new file mode 100644 index 0000000..ae28607 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/DyFmListener.java @@ -0,0 +1,67 @@ +package com.dy.pipIrrWebFile.fm; + +import com.dy.common.util.NumUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.core.env.Environment; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +@Component +public class DyFmListener implements ApplicationListener<ApplicationReadyEvent> { + + @Autowired + private Environment env; + + public static DyFileSvConf.Group dyFileGroup = new DyFileSvConf.Group() ; + + /** + * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡 + * @param event 浜嬩欢 + */ + @Override + public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { + try { + //绛�1绉掞紝绛夊緟com.alibaba.druid.pool.DruidDataSource瀹炲鍖栧畬鎴� + Thread.sleep(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + }finally { + try{ + parseConfig() ; + }catch(Exception e){ + e.printStackTrace(); + dyFileGroup = null ; + } + } + } + private void parseConfig() throws Exception{ + String fmUrl = env.getProperty("dy.webFile.fmUrl"); + for(int i = 1 ; i <= 12 ; i++){ + String id = env.getProperty("dy.webFile.sv" + i + ".id"); + String absolutePath = env.getProperty("dy.webFile.sv" + i + ".absolutePath"); + String relativePath = env.getProperty("dy.webFile.sv" + i + ".relativePath"); + String hashStart = env.getProperty("dy.webFile.sv" + i + ".hashStart"); + String hashEnd = env.getProperty("dy.webFile.sv" + i + ".hashEnd"); + String restUrl = env.getProperty("dy.webFile.sv" + i + ".restUrl"); + String webUrl = env.getProperty("dy.webFile.sv" + i + ".webUrl"); + String webDownloadPath = env.getProperty("dy.webFile.sv" + i + ".webDownloadPath"); + if(!NumUtil.isPlusIntNumber(hashStart)){ + throw new Exception("閰嶇疆dy.webFile.sv" + i + ".hashStart 涓嶆槸鏁存暟") ; + } + if(!NumUtil.isPlusIntNumber(hashEnd)){ + throw new Exception("閰嶇疆dy.webFile.sv" + i + ".hashEnd 涓嶆槸鏁存暟") ; + } + dyFileGroup.add(new DyFileSvConf.Vo(id, + absolutePath, + relativePath, + restUrl, + webUrl, + webDownloadPath, + Integer.parseInt(hashStart), + Integer.parseInt(hashEnd))) ; + } + dyFileGroup.check(); + } +} -- Gitblit v1.8.0