vince
2023-12-18 092d4d994a95a9df6775c90401887dfba684e8ee
增加授权
已修改5个文件
已添加2个文件
327 ■■■■ 文件已修改
src/main/java/com/fzzy/gateway/GatewayTimerScheduled.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/utils/NumberUtil.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-devGatewayCommon.yml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-pro5012.yml 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-pro5338.yml 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-proGateway.yml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/GatewayTimerScheduled.java
@@ -17,7 +17,9 @@
import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * ç½‘关相关的定时器
@@ -84,6 +86,13 @@
            if (null == url) {
                url = DEFAULT_URL;
            }
            Map<String ,String> parameMap = new HashMap<>();
            parameMap.put("unescape","1");
            parameMap.put("version","v61");
            parameMap.put("appid",DEFAULT_APP_ID);
            parameMap.put("appsecret",DEFAULT_APP_SECRET);
            parameMap.put("cityid",DEFAULT_CITYID);
            url = url.replace("{appId}", DEFAULT_APP_ID).replace("{appsecret}", DEFAULT_APP_SECRET).replace("{cityid}", DEFAULT_CITYID);
            url = url.replace("{appId}", DEFAULT_APP_ID).replace("{appsecret}", DEFAULT_APP_SECRET);
@@ -94,7 +103,7 @@
            }
            log.debug("------气象请求信息URL---{}", url);
            String result = GatewayHttpUtil.doGet(url);
            String result = GatewayHttpUtil.doGet(url,parameMap);
            if (null == result) {
                log.error("当前外网获取气象信息失败……");
@@ -112,7 +121,7 @@
            log.info("===========================系统定时获获取气象信息===={}==================", dto);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
    }
@@ -160,4 +169,22 @@
            gatewayRemoteManager.getSyncWeightService(device.getSyncProtocol()).syncWeightInfo(reqData);
        }
    }
    public static void main(String[] args) {
        try {
            Map<String ,String> parameMap = new HashMap<>();
            parameMap.put("unescape","1");
            parameMap.put("version","v61");
            parameMap.put("appid","49421971");
            parameMap.put("appsecret","JmJE48Fv");
            parameMap.put("cityid","101270101");
            String result = GatewayHttpUtil.doGet("https://v1.yiketianqi.com/api?unescape=1&version=v61&appid=49421971&appsecret=JmJE48Fv&cityid=101270101", parameMap);
            System.out.println(result);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java
@@ -18,6 +18,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -271,15 +272,16 @@
        WeatherWebDto weather = WeatherWebDto.contextMap.get("default");
        double tMIn = 20, tMax = 25;
        double tMIn = 10, tMax = 15;
        if (null != weather) {
            double tOut = Double.valueOf(weather.getTem());
            tMIn = tOut - 4;
            if (tMIn < 4) tMIn = 5;
            tMax = tOut + 0;
            if (tMax < 15) tMax = 15;
            tMIn = tOut - 5;
            tMax = tOut;
        }
        if (tMIn < 10) tMIn = 10;
        if (tMIn > 20) tMIn = 20;
        if (tMax < 15) tMax = 15;
        if (tMax > 25) tMax = 25;
        //数据封装
        GrainData grain = new GrainData();
@@ -309,24 +311,22 @@
        double randomNumber = tMIn;
        int x = 0, y = 0, z = 0;
        for (int i = 0; i < sumNum; i++) {
            if ((i) % Integer.valueOf(cableRule[0]) == 0) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 1) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 2) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 3) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 4) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            log.info("i=:" + i);
            if (i % cableZ == 0) {
                randomNumber = RandomUtils.nextDouble(tMIn, tMax+1.5);
                log.info("第1层温度:" + randomNumber);
            } else if (i % cableZ == 1)  {
                randomNumber = RandomUtils.nextDouble(tMIn-1, tMax-0);
                log.info("第2层温度:" + randomNumber);
            } else if (i % cableZ == 2)  {
                randomNumber = RandomUtils.nextDouble(tMIn-2, tMax-1.5);
                log.info("第3层温度:" + randomNumber);
            } else if (i % cableZ == 3)  {
                randomNumber = RandomUtils.nextDouble(tMIn-3, tMax-3);
                log.info("第4层温度:" + randomNumber);
            } else if (i % cableZ == 4)  {
                randomNumber = RandomUtils.nextDouble(tMIn-4, tMax-4.5);
                log.info("第5层温度:" + randomNumber);
            }
            // randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            curTemp = NumberUtil.keepPrecision(randomNumber, 1);
src/main/java/com/fzzy/utils/NumberUtil.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
package com.fzzy.utils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
/**
 * æ•°å­—格式化工具类
 */
public class NumberUtil {
    /**
     * å¯¹double类型的数值保留指定位数的小数。<br>
     * è¯¥æ–¹æ³•舍入模式:向“最接近的”数字舍入,如果与两个相邻数字的距离相等,则为向上舍入的舍入模式。<br>
     * <b>注意:</b>如果精度要求比较精确请使用 keepPrecision(String number, int precision)方法
     * @param number  è¦ä¿ç•™å°æ•°çš„æ•°å­—
     * @param precision å°æ•°ä½æ•°
     * @return double å¦‚果数值较大,则使用科学计数法表示
     */
    public static double keepPrecision(Double number, int precision) {
        if(null == number || 0.0 == number ) return 0.0;
        BigDecimal bg = new BigDecimal(number);
        return bg.setScale(precision, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
    /**
     * å¯¹float类型的数值保留指定位数的小数。<br>
     * è¯¥æ–¹æ³•舍入模式:向“最接近的”数字舍入,如果与两个相邻数字的距离相等,则为向上舍入的舍入模式。<br>
     * <b>注意:</b>如果精度要求比较精确请使用 keepPrecision(String number, int precision)方法
     * @param number  è¦ä¿ç•™å°æ•°çš„æ•°å­—
     * @param precision å°æ•°ä½æ•°
     * @return float å¦‚果数值较大,则使用科学计数法表示
     */
    public static float keepPrecision(Float number, int precision) {
        if(null == number) return 0f;
        BigDecimal bg = new BigDecimal(number);
        return bg.setScale(precision, BigDecimal.ROUND_HALF_UP).floatValue();
    }
    /**
     * double转字符串,避免出现科学计数法
     * @param d
     * @return
     */
    public static String doubleToStr(Double d) {
        if(null == d) return "";
        DecimalFormat df = new DecimalFormat("0.0");
        return df.format(d);
    }
    public static void main(String[] args) {
        System.out.println((8) % Integer.valueOf(4) == 0);
    }
}
src/main/resources/application-devGatewayCommon.yml
@@ -69,7 +69,6 @@
      auto-offset-reset: latest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
  mqtt:
    host: tcp://127.0.0.1:1883
    username: admin
@@ -83,3 +82,15 @@
    isOpen: false
    default-topic: mqtt/+/test1
    topics: /device-message-sender/#
license:
  subject: ld_license
  publicAlias: publicCert
  storePass: PUBLICFZZYXXJSGFYXGS888888
  licensePath: D:/IGDS/license/license.lic
  publicKeysStorePath: D:/IGDS/license/publicCerts.keystore
igds:
  default:
  companyId: 5338
  file-path: D:/app/igds-api
  img-path: D:/IGDS/FILE/
  weather-url: https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}
src/main/resources/application-pro5012.yml
@@ -1,20 +1,18 @@
server:
  port: 8081
  jetty:
    max-http-post-size: 209715200
  tomcat:
    max-http-post-size: 209715200
  port: 8090
spring:
  datasource:
    #主数据源
    primary:
      url: jdbc:mysql://127.0.0.1:3306/igds_api?useUnicode=true&characterEncoding=utf-8
      url: jdbc:mysql://127.0.0.1:3306/igds_api_2023?useUnicode=true&useSSL=false&characterEncoding=utf-8
      username: root
      password: Abc123..
      driver-class-name: com.mysql.jdbc.Driver
    #次数据源
    secondary:
      url: jdbc:mysql://127.0.0.1:3306/igds_dl?useUnicode=true&characterEncoding=utf-8
      url: jdbc:mysql://127.0.0.1:3306/igds_v4?useUnicode=true&useSSL=false&characterEncoding=utf-8
      username: root
      password: Abc123..
      driver-class-name: com.mysql.jdbc.Driver
@@ -37,7 +35,7 @@
          dialect: org.hibernate.dialect.MySQL5InnoDBDialect
  # Redis相关配置
  redis:
    database: 0
    database: 5
    host: 127.0.0.1
    port: 6379
    password:
@@ -47,4 +45,52 @@
      max-wait: -1
      max-idle: 10
      min-idle: 0
      timeout: 6000
      timeout: 6000
  kafka:
    bootstrap-servers: 103.203.217.16:9092
    producer:
      retries: 0
      acks: 1
      batch-size: 16384
      buffer-memory: 33554432
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer
    properties:
      security.protocol: SASL_PLAINTEXT
      sasl.mechanism: PLAIN
      sasl.username: sc001
      sasl.password: wCV0ISwmoKwbx1lpBKMW
      sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username='sc001' password='wCV0ISwmoKwbx1lpBKMW';
    consumer:
      group-id: fzzygroup
      enable-auto-commit: true
      auto-commit-interval: 100
      auto-offset-reset: latest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
  mqtt:
    host: tcp://127.0.0.1:1883
    username: admin
    password: admin123321
    client-inId: fzzy_client_id_in_igds_api
    client-outId: fzzy_client_id_out_igds_api
    completionTimeout: 3000
    keep-alive-interval: 2
    max-connect-times: 5
    qos: 0
    isOpen: false
    default-topic: mqtt/+/test1
    topics: /device-message-sender/#
license:
  subject: ld_license
  publicAlias: publicCert
  storePass: PUBLICFZZYXXJSGFYXGS888888
  licensePath: D:/IGDS/license/license.lic
  publicKeysStorePath: D:/IGDS/license/publicCerts.keystore
igds:
  default:
  companyId: 5338
  file-path: D:/app/igds-api
  img-path: D:/IGDS/FILE/
  weather-url: https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}
src/main/resources/application-pro5338.yml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,99 @@
##########################  ä»å¯¿   ##########################
server:
  port: 8090
  jetty:
    max-http-post-size: 209715200
  tomcat:
    max-http-post-size: 209715200
spring:
  datasource:
    #主数据源
    primary:
      url: jdbc:mysql://127.0.0.1:3306/igds_api?useUnicode=true&characterEncoding=utf-8
      username: root
      password: Fzzy@#$%5432..K
      driver-class-name: com.mysql.jdbc.Driver
    #次数据源
    secondary:
      url: jdbc:mysql://127.0.0.1:3306/igds_master?useUnicode=true&characterEncoding=utf-8
      username: root
      password: Fzzy@#$%5432..K
      driver-class-name: com.mysql.jdbc.Driver
  jpa:
    #主jpa配置
    primary:
      show-sql: true
      properties:
        hibernate:
          hbm2ddl:
            auto: update
          dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    #次jpa配置
    secondary:
      show-sql: true
      properties:
        hibernate:
          hbm2ddl:
            auto: none
          dialect: org.hibernate.dialect.MySQL5InnoDBDialect
  # Redis相关配置
  redis:
    database: 1
    host: 127.0.0.1
    port: 6379
    password: Redispwd..
    # è¿žæŽ¥æ± æœ€å¤§è¿žæŽ¥æ•°ï¼ˆä½¿ç”¨è´Ÿå€¼è¡¨ç¤ºæ²¡æœ‰é™åˆ¶ï¼‰
    pool:
      max-active: 200
      max-wait: -1
      max-idle: 10
      min-idle: 0
      timeout: 6000
  kafka:
    bootstrap-servers: 103.203.217.16:9092
    producer:
      retries: 0
      acks: 1
      batch-size: 16384
      buffer-memory: 33554432
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer
    properties:
      security.protocol: SASL_PLAINTEXT
      sasl.mechanism: PLAIN
      sasl.username: sc001
      sasl.password: wCV0ISwmoKwbx1lpBKMW
      sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username='sc001' password='wCV0ISwmoKwbx1lpBKMW';
    consumer:
      group-id: fzzygroup
      enable-auto-commit: true
      auto-commit-interval: 100
      auto-offset-reset: latest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
  mqtt:
    host: tcp://127.0.0.1:1883
    username: admin
    password: admin123321
    client-inId: fzzy_client_id_in_igds_api
    client-outId: fzzy_client_id_out_igds_api
    completionTimeout: 3000
    keep-alive-interval: 2
    max-connect-times: 5
    qos: 0
    isOpen: false
    default-topic: mqtt/+/test1
    topics: /device-message-sender/#
license:
  subject: ld_license
  publicAlias: publicCert
  storePass: PUBLICFZZYXXJSGFYXGS888888
  licensePath: D:/IGDS/license/license.lic
  publicKeysStorePath: D:/IGDS/license/publicCerts.keystore
igds:
  default:
  companyId: 5338
  file-path: D:/app/igds-api
  img-path: D:/IGDS/FILE/
  weather-url: https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}
src/main/resources/application-proGateway.yml
@@ -5,13 +5,13 @@
  datasource:
    #主数据源
    primary:
      url: jdbc:mysql://127.0.0.1:3306/igds_api_2023?useUnicode=true&useSSL=false&characterEncoding=utf-8
      url: jdbc:mysql://127.0.0.1:3306/igds_api?useUnicode=true&useSSL=false&characterEncoding=utf-8
      username: root
      password: Abc123..
      driver-class-name: com.mysql.jdbc.Driver
    #次数据源
    secondary:
      url: jdbc:mysql://127.0.0.1:3306/igds_v4?useUnicode=true&useSSL=false&characterEncoding=utf-8
      url: jdbc:mysql://127.0.0.1:3306/igdsv4?useUnicode=true&useSSL=false&characterEncoding=utf-8
      username: root
      password: Abc123..
@@ -69,7 +69,6 @@
      auto-offset-reset: latest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
  mqtt:
    host: tcp://127.0.0.1:1883
    username: admin
@@ -82,4 +81,16 @@
    qos: 0
    isOpen: false
    default-topic: mqtt/+/test1
    topics: /device-message-sender/#
    topics: /device-message-sender/#
license:
  subject: ld_license
  publicAlias: publicCert
  storePass: PUBLICFZZYXXJSGFYXGS888888
  licensePath: D:/IGDS/license/license.lic
  publicKeysStorePath: D:/IGDS/license/publicCerts.keystore
igds:
  default:
  companyId: 5338
  file-path: D:/app/igds-api
  img-path: D:/IGDS/FILE/
  weather-url: https://v1.yiketianqi.com/api?unescape=1&version=v61&appid={appId}&appsecret={appsecret}&cityid={cityid}