From 8aea3ecc955f5c55024686375bc6b2fc3a989a35 Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期三, 03 七月 2024 15:44:32 +0800 Subject: [PATCH] zjh 2024/07/3-1 --- ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java | 59 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 43 insertions(+), 16 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java index 8f243c6..201cad1 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java @@ -12,6 +12,7 @@ import com.ltkj.web.wxUtils.HttpClientUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -33,8 +34,10 @@ @Slf4j @Component public class HisApiGetMethodService { + + // 鏁版嵁搴撻厤缃枃浠惰矾寰� - private static final String CONFIG_PATH = "D:\\ltkjprojectconf\\config.properties"; +// private static final String CONFIG_PATH = url; // private static final String CONFIG_PATH = "/Users/chacca/寮�鍙戠浉鍏�/浠g爜/ltkj_peis/ltkj-admin/src/main/resources/config.properties"; // 鏁版嵁搴撳悕 private static String DB_NAME = ""; @@ -47,27 +50,51 @@ @Autowired private HisApiConfigService hisApiConfigService; + private static String url; + + + @Value ("${config.properties}") + public void set(String urls){ + url=urls; + FileInputStream inputStream = null; + try { + inputStream = new FileInputStream(url); + Properties props = new Properties(); + props.load(inputStream); + DB_NAME = props.getProperty("name"); + DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + "" + + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; + DATA_USER = props.getProperty("username"); + DATA_PASS = props.getProperty("password"); + String apiUrl = props.getProperty("his_api_url"); + String apiPort = props.getProperty("his_api_port"); + HIS_URL = apiUrl+":"+apiPort+"/api/His/HisRequest"; + } catch (IOException e) { + System.out.println("鍒濆鍖栨暟鎹簱寮傚父 ->"+e.getMessage()); + } + } + static { try { Class.forName("com.mysql.cj.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } - try { - InputStreamReader reader = new InputStreamReader(new FileInputStream(CONFIG_PATH), StandardCharsets.UTF_8); - Properties props = new Properties(); - props.load(reader); - String api_url = props.getProperty("his_api_url"); - String port = props.getProperty("his_api_port"); - DB_NAME = props.getProperty("name"); - DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + - "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; - DATA_USER = props.getProperty("username"); - DATA_PASS = props.getProperty("password"); - HIS_URL=api_url+":"+port; - } catch (IOException throwables) { - throwables.printStackTrace(); - } +// try { +// InputStreamReader reader = new InputStreamReader(new FileInputStream(url), StandardCharsets.UTF_8); +// Properties props = new Properties(); +// props.load(reader); +// String api_url = props.getProperty("his_api_url"); +// String port = props.getProperty("his_api_port"); +// DB_NAME = props.getProperty("name"); +// DATA_URL = "jdbc:mysql://" + props.getProperty("ip") + ":" + props.getProperty("prot") + "/" + DB_NAME + +// "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8"; +// DATA_USER = props.getProperty("username"); +// DATA_PASS = props.getProperty("password"); +// HIS_URL=api_url+":"+port; +// } catch (IOException throwables) { +// throwables.printStackTrace(); +// } } -- Gitblit v1.8.0