Sfoglia il codice sorgente

添加taos多数据源

全业务考评 1 anno fa
parent
commit
807102d081

+ 6 - 0
power-fitting-JN/pom.xml

@@ -142,6 +142,12 @@
             <artifactId>spring-data-redis</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.taosdata.jdbc</groupId>
+            <artifactId>taos-jdbcdriver</artifactId>
+            <version>3.2.2</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 1 - 1
power-fitting-JN/src/main/java/com.gyee.power.fitting/common/config/DataSourceConfig.java

@@ -14,7 +14,7 @@ import javax.sql.DataSource;
 public class DataSourceConfig {
 
     @Bean
-    @ConfigurationProperties(prefix = "spring.datasource")
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource")
     public DataSource druidDataSource() {
         DruidDataSource druidDataSource = new DruidDataSource();
         return druidDataSource;

+ 5 - 7
power-fitting-JN/src/main/java/com.gyee.power.fitting/model/custom/PowerPointData.java

@@ -18,7 +18,6 @@ public class PowerPointData {
 
     public PowerPointData(String[] str, boolean isFilter){
         DecimalFormat df = new DecimalFormat("0.00");
-        if (str.length >= 9){
             this.time = str[0];
             this.power = Double.valueOf(df.format(Double.valueOf(str[1])));
             this.speed = Double.valueOf(df.format(Double.valueOf(str[2])));
@@ -33,12 +32,11 @@ public class PowerPointData {
             this.yp1 = Double.valueOf(df.format(Double.valueOf(str[11])));
             this.yp2 = Double.valueOf(df.format(Double.valueOf(str[12])));
             this.yp3 = Double.valueOf(df.format(Double.valueOf(str[13])));
-        }
-        if (isFilter){
-            BigDecimal bd = new BigDecimal(str[str.length - 1]);
-            bd = bd.setScale(2, RoundingMode.HALF_UP);
-            this.filter =  bd.doubleValue()>0 ? 1 :0;
-        }
+            if (isFilter){
+                BigDecimal bd = new BigDecimal(str[str.length - 1]);
+                bd = bd.setScale(2, RoundingMode.HALF_UP);
+                this.filter =  bd.intValue();
+            }
 
 
     }

+ 42 - 28
power-fitting-JN/src/main/resources/application.yaml

@@ -38,35 +38,49 @@ spring:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
-    # 宁夏三区oracle
-    url: jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN
-    username: postgres
-    password: gd123
-    driver-class-name: org.postgresql.Driver
+    dynamic:
+      primary: master #设置默认的数据源或者数据源组,默认值即为master
+      strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
+      datasource:
+        master:
+        # 宁夏三区oracle
+        url: jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN
+        username: postgres
+        password: gd123
+        driver-class-name: org.postgresql.Driver
+      #配置初始化连接数大小
+      initial-size: 10
+      # 最大连接数
+      max-active: 50
+      #最小连接数
+      min-idle: 10
+      #获取连接等待超时时间
+      max-wait: 5000
+      pool-prepared-statements: true #是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。
+      max-pool-prepared-statement-per-connection-size: 20
+      validation-query: SELECT 1 FROM DUAL
+      validation-query-timeout: 20000
+      test-on-borrow: false #申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
+      test-on-return: false #归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
+      test-while-idle: true #建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
+      time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      min-evictable-idle-time-millis: 300000  #一个连接在池中最小生存的时间,单位是毫秒
+      #StatViewServlet配置。(因为暴露的监控信息比较敏感,支持密码加密和访问ip限定)
+      stat-view-servlet:
+        enabled: true
+        url-pattern: /druid/*
+        #可以增加访问账号密码【去掉注释就可以】
+        #login-username: admin
+        #login-password: admin
+      filter:
+        stat:
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: false
+        wall:
+          config:
+            multi-statement-allow: true
 
-    # 华为云oracle(功率预测的环境)
-#    driver-class-name: oracle.jdbc.OracleDriver
-#    url: jdbc:oracle:thin:@120.46.129.85:1521:ORCL
-#    username: gyee
-#    password: FRWIND
-
-    druid:
-      # 初始化大小,最小,最大
-      initial-size: 1
-      min-idle: 1
-      max-active: 1
-      max-wait: 60000
-      # 每次使用连接时进行校验,会影响系统性能。默认为false
-      test-on-borrow: false
-      test-on-return: false
-      # 验证使用的SQL语句
-      validation-query: SELECT 1
-      # 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
-      while: true
-      # 每30秒运行一次空闲连接回收器(默认-1)
-      time-between-eviction-runs-millis: 60000
-      # 池中的连接空闲30分钟后被回收(默认30分钟)
-      min-evictable-idle-time-millis: 1800000
   redis:
     host: 127.0.0.1
     #host: 10.81.3.155