From dedacd79c93f8ef95e0cb986f5e7fbd27ddbd907 Mon Sep 17 00:00:00 2001
From: zhaowenxuan <chacca165@163.com>
Date: 星期四, 03 七月 2025 09:12:49 +0800
Subject: [PATCH] 2025-07-03

---
 ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 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..a66a17e 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,63 @@
     }
 
 
+
+    @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 {
+        // -Djdk.tls.client.protocols=TLSv1.2 JVM鍚姩鍙傛暟
         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");
+                ";trustServerCertificate=true;encrypt=false;characterEncoding=utf8");
         properties.setProperty("druid.username", user);
         properties.setProperty("druid.password", password);
         dataSource.restart(properties);
@@ -305,6 +356,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