From c98ce463624a858503ae32e63ca128a8923c80cf Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期二, 12 十二月 2023 11:29:05 +0800
Subject: [PATCH] zjh 2023/12/12--2

---
 ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java |  131 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 118 insertions(+), 13 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 f967e4e..21a21ab 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
@@ -58,12 +58,42 @@
                 }
                 File file = new File("D:\\ltkjprojectconf\\config.properties");
                 try {
-                        FileWriter fileWriter = new FileWriter(file);
-                        fileWriter.write("ip = 浣犵殑鏁版嵁搴撹繛鎺p鍦板潃\n");
-                        fileWriter.write("prot = 浣犵殑鏁版嵁搴撹繛鎺ョ鍙n");
-                        fileWriter.write("name = 浣犵殑鏁版嵁搴撹繛鎺ュ悕绉癨n");
-                        fileWriter.write("username = 浣犵殑鏁版嵁搴撹繛鎺ョ敤鎴峰悕\n");
-                        fileWriter.write("password = 浣犵殑鏁版嵁搴撹繛鎺ュ瘑鐮乗n");
+                    FileWriter fileWriter = new FileWriter(file);
+                    fileWriter.write("ip = 浣犵殑涓绘暟鎹簱杩炴帴ip鍦板潃\n");
+                    fileWriter.write("prot = 浣犵殑涓绘暟鎹簱杩炴帴绔彛\n");
+                    fileWriter.write("name = 浣犵殑涓绘暟鎹簱杩炴帴鍚嶇О\n");
+                    fileWriter.write("username = 浣犵殑涓绘暟鎹簱杩炴帴鐢ㄦ埛鍚峔n");
+                    fileWriter.write("password = 浣犵殑涓绘暟鎹簱杩炴帴瀵嗙爜\n");
+                    fileWriter.write("\n");
+
+
+                    fileWriter.write("hisenabled = 鏄惁寮�鍚� his 浠庡簱鏁版嵁搴撹繛鎺� (浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴 fales)\n");
+                    fileWriter.write("hisip = 浣犵殑 his 鏁版嵁搴撹繛鎺p鍦板潃\n");
+                    fileWriter.write("hisprot = 浣犵殑 his 鏁版嵁搴撹繛鎺ョ鍙n");
+                    fileWriter.write("hisname = 浣犵殑 his 鏁版嵁搴撹繛鎺ュ悕绉癨n");
+                    fileWriter.write("hisusername = 浣犵殑 his 鏁版嵁搴撹繛鎺ョ敤鎴峰悕\n");
+                    fileWriter.write("hispassword = 浣犵殑 his 鏁版嵁搴撹繛鎺ュ瘑鐮乗n");
+                    fileWriter.write("\n");
+
+                    fileWriter.write("pacsenabled = 鏄惁寮�鍚痯acs浠庡簱鏁版嵁搴撹繛鎺� (浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴 fales)\n");
+                    fileWriter.write("pacsip = 浣犵殑pacs鏁版嵁搴撹繛鎺p鍦板潃\n");
+                    fileWriter.write("pacsprot = 浣犵殑pacs鏁版嵁搴撹繛鎺ョ鍙n");
+                    fileWriter.write("pacsname = 浣犵殑pacs鏁版嵁搴撹繛鎺ュ悕绉癨n");
+                    fileWriter.write("pacsusername = 浣犵殑pacs鏁版嵁搴撹繛鎺ョ敤鎴峰悕\n");
+                    fileWriter.write("pacspassword = 浣犵殑pacs鏁版嵁搴撹繛鎺ュ瘑鐮乗n");
+                    fileWriter.write("\n");
+
+
+                    fileWriter.write("lisenabled = 鏄惁寮�鍚� lis 浠庡簱鏁版嵁搴撹繛鎺� (浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴 fales)\n");
+                    fileWriter.write("lisip = 浣犵殑 lis 鏁版嵁搴撹繛鎺p鍦板潃\n");
+                    fileWriter.write("lisprot = 浣犵殑 lis 鏁版嵁搴撹繛鎺ョ鍙n");
+                    fileWriter.write("lisname = 浣犵殑 lis 鏁版嵁搴撹繛鎺ュ悕绉癨n");
+                    fileWriter.write("lisusername = 浣犵殑 lis 鏁版嵁搴撹繛鎺ョ敤鎴峰悕\n");
+                    fileWriter.write("lispassword = 浣犵殑 lis 鏁版嵁搴撹繛鎺ュ瘑鐮乗n");
+
+
+
+
                         fileWriter.close();
                         log.info("鏁版嵁搴撹繛鎺ユ枃浠跺垱寤烘垚鍔燂紒");
                 } catch (IOException ioException) {
@@ -78,7 +108,7 @@
             Properties properties = new Properties();
             // 杩欓噷鏄祴璇曞啓娉曪紝鍏蜂綋鐨剉alue鍙互閫氳繃璇锋眰鍙傛暟浼犻�掕繃鏉�
             properties.setProperty("druid.url","jdbc:mysql://"+props.getProperty("ip")+":"+props.getProperty("prot")+"/"+props.getProperty("name")+"" +
-                    "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8");
+                    "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8");
             properties.setProperty("druid.username",props.getProperty("username"));
             properties.setProperty("druid.password",props.getProperty("password"));
             dataSource.restart(properties);
@@ -91,26 +121,101 @@
     }
 
     @Bean
-    @ConfigurationProperties("spring.datasource.druid.slavehis")
-    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavehis", name = "enabled", havingValue = "true")
+//    @ConfigurationProperties("spring.datasource.druid.slavehis")
+//    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavehis", name = "enabled", havingValue = "true")
     public DataSource slaveHisDataSource(DruidProperties druidProperties) {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        Properties props = new Properties();
+        try {
+            // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
+            FileInputStream fis = null;
+            try {
+                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+            } catch (FileNotFoundException e) {
+                log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌锛�");
+            }
+            props.load(fis);
+            fis.close();
+            // 鑾峰彇灞炴�у�煎苟璧嬪��
+            Properties properties = new Properties();
+            // 杩欓噷鏄祴璇曞啓娉曪紝鍏蜂綋鐨剉alue鍙互閫氳繃璇锋眰鍙傛暟浼犻�掕繃鏉�
+            properties.setProperty("druid.enabled",props.getProperty("hisenabled"));
+            properties.setProperty("druid.driverClassName","com.microsoft.sqlserver.jdbc.SQLServerDriver");
+            properties.setProperty("druid.url","jdbc:sqlserver://"+props.getProperty("hisip")+":"+props.getProperty("hisprot")+";DatabaseName="+props.getProperty("hisname"));
+            properties.setProperty("druid.username",props.getProperty("hisusername"));
+            properties.setProperty("druid.password",props.getProperty("hispassword"));
+            dataSource.restart(properties);
+            log.info("鏁版嵁搴撹繛鎺ユ垚鍔�!!!");
+        } catch (Exception e) {
+            log.info("鏁版嵁搴撹繛鎺ュけ璐�  璇疯仈绯荤鐞嗗憳锛�");
+            e.printStackTrace();
+        }
         return druidProperties.dataSource(dataSource);
     }
 
     @Bean
-    @ConfigurationProperties("spring.datasource.druid.slavelis")
-    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavelis", name = "enabled", havingValue = "true")
+//    @ConfigurationProperties("spring.datasource.druid.slavelis")
+//    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavelis", name = "enabled", havingValue = "true")
     public DataSource slaveDataLisSource(DruidProperties druidProperties) {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        Properties props = new Properties();
+        try {
+            // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
+            FileInputStream fis = null;
+            try {
+                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+            } catch (FileNotFoundException e) {
+                log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌锛�");
+            }
+            props.load(fis);
+            fis.close();
+            // 鑾峰彇灞炴�у�煎苟璧嬪��
+            Properties properties = new Properties();
+            // 杩欓噷鏄祴璇曞啓娉曪紝鍏蜂綋鐨剉alue鍙互閫氳繃璇锋眰鍙傛暟浼犻�掕繃鏉�
+            properties.setProperty("druid.enabled",props.getProperty("lisenabled"));
+            properties.setProperty("druid.driverClassName","com.microsoft.sqlserver.jdbc.SQLServerDriver");
+            properties.setProperty("druid.url","jdbc:sqlserver://"+props.getProperty("lisip")+":"+props.getProperty("lisprot")+";DatabaseName="+props.getProperty("lisname"));
+            properties.setProperty("druid.username",props.getProperty("lisusername"));
+            properties.setProperty("druid.password",props.getProperty("lispassword"));
+            dataSource.restart(properties);
+            log.info("鏁版嵁搴撹繛鎺ユ垚鍔�!!!");
+        } catch (Exception e) {
+            log.info("鏁版嵁搴撹繛鎺ュけ璐�  璇疯仈绯荤鐞嗗憳锛�");
+            e.printStackTrace();
+        }
         return druidProperties.dataSource(dataSource);
     }
 
     @Bean
-    @ConfigurationProperties("spring.datasource.druid.slavepacs")
-    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavepacs", name = "enabled", havingValue = "true")
+//    @ConfigurationProperties("spring.datasource.druid.slavepacs")
+//    @ConditionalOnProperty(prefix = "spring.datasource.druid.slavepacs", name = "enabled", havingValue = "true")
     public DataSource slaveDataPacsSource(DruidProperties druidProperties) {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        Properties props = new Properties();
+        try {
+            // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
+            FileInputStream fis = null;
+            try {
+                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+            } catch (FileNotFoundException e) {
+                log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌");
+            }
+            props.load(fis);
+            fis.close();
+            // 鑾峰彇灞炴�у�煎苟璧嬪��
+            Properties properties = new Properties();
+            // 杩欓噷鏄祴璇曞啓娉曪紝鍏蜂綋鐨剉alue鍙互閫氳繃璇锋眰鍙傛暟浼犻�掕繃鏉�
+            properties.setProperty("druid.enabled",props.getProperty("pacsenabled"));
+            properties.setProperty("druid.driverClassName","com.microsoft.sqlserver.jdbc.SQLServerDriver");
+            properties.setProperty("druid.url","jdbc:sqlserver://"+props.getProperty("pacsip")+":"+props.getProperty("pacsprot")+";DatabaseName="+props.getProperty("pacsname"));
+            properties.setProperty("druid.username",props.getProperty("pacsusername"));
+            properties.setProperty("druid.password",props.getProperty("pacspassword"));
+            dataSource.restart(properties);
+            log.info("鏁版嵁搴撹繛鎺ユ垚鍔�!!!");
+        } catch (Exception e) {
+            log.info("鏁版嵁搴撹繛鎺ュけ璐�  璇疯仈绯荤鐞嗗憳锛�");
+            e.printStackTrace();
+        }
         return druidProperties.dataSource(dataSource);
     }
 

--
Gitblit v1.8.0