From 524a0867c6e8343607d343a4f708498c21baf9d4 Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期五, 28 二月 2025 15:25:34 +0800 Subject: [PATCH] 修改药品处方从表里拿处方类型以及sqlserver连接去除ssl --- ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 52 insertions(+), 1 deletions(-) diff --git a/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java b/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java index 8b6b86f..892b157 100644 --- a/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java +++ b/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java @@ -42,6 +42,7 @@ @Slf4j public class DruidConfig { + @Value ("${config.properties}") private String url; @@ -259,13 +260,62 @@ } + + @Bean +// @ConfigurationProperties("spring.datasource.druid.slavepacs") +// @ConditionalOnProperty(prefix = "spring.datasource.druid.slavepacs", name = "enabled", havingValue = "true") + public DataSource slaveDataWsSource(DruidProperties druidProperties) { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + Properties props = new Properties(); + try { + // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅 + FileInputStream fis = null; + try { + fis = new FileInputStream(url); + } catch (FileNotFoundException e) { + log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌"); + } + props.load(fis); + fis.close(); + // 杩欓噷鏄祴璇曞啓娉曪紝鍏蜂綋鐨剉alue鍙互閫氳繃璇锋眰鍙傛暟浼犻�掕繃鏉� + String pacsenabled = props.getProperty("wsenabled"); + if (pacsenabled.equals("false")) + return null; + String pacsdbtype = props.getProperty("wsdbtype"); + switch (pacsdbtype){ + case "sqlserver": + dataSource = creatSqlServer(pacsenabled, props.getProperty("wsip"),props.getProperty("wsprot"), + props.getProperty("wsname"),props.getProperty("wsusername"),props.getProperty("wspassword")); + break; + case "mysql": + dataSource = creatMysql(pacsenabled, props.getProperty("wsip"), + props.getProperty("wsprot"),props.getProperty("wsname"),props.getProperty("wsusername"),props.getProperty("wspassword")); + break; + case "oracle": + dataSource = creatOracle(pacsenabled, props.getProperty("wsip"), + props.getProperty("wsprot"),props.getProperty("wsname"),props.getProperty("wsusername"),props.getProperty("wspassword")); + break; + default: + dataSource = creatOracle(pacsenabled, props.getProperty("wsip"),props.getProperty("wsprot"),props.getProperty("wsname"),props.getProperty("wsusername") + ,props.getProperty("wspassword")); + break; + } + log.info("鏁版嵁搴撹繛鎺ユ垚鍔�!!!"); + } catch (Exception e) { + log.info("鏁版嵁搴撹繛鎺ュけ璐� 璇疯仈绯荤鐞嗗憳锛�"); + e.printStackTrace(); + } + return druidProperties.dataSource(dataSource); + } + + private DruidDataSource creatSqlServer(String enabled, String ip,String port,String db,String user,String password) throws SQLException { DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); Properties properties = new Properties(); properties.setProperty("druid.enabled", enabled); properties.setProperty("druid.driverClassName","com.microsoft.sqlserver.jdbc.SQLServerDriver"); properties.setProperty("druid.url","jdbc:sqlserver://"+ ip+":"+ port+";DatabaseName="+ db+ - ";&characterEncoding=utf8"); + ";&characterEncoding=utf8;encrypt=false"); properties.setProperty("druid.username", user); properties.setProperty("druid.password", password); dataSource.restart(properties); @@ -305,6 +355,7 @@ setDataSource(targetDataSources, DataSourceType.SLAVE_HIS.name(), "slaveHisDataSource"); setDataSource(targetDataSources, DataSourceType.SLAVE_LIS.name(), "slaveDataLisSource"); setDataSource(targetDataSources, DataSourceType.SLAVE_PACS.name(), "slaveDataPacsSource"); + setDataSource(targetDataSources, DataSourceType.SLAVE_WS.name(), "slaveDataWsSource"); return new DynamicDataSource(masterDataSource, targetDataSources); } -- Gitblit v1.8.0