Selaa lähdekoodia

feat:es正式环境已升级

lihao16 2 kuukautta sitten
vanhempi
sitoutus
adeaa32d10

+ 2 - 2
smsb-admin/src/main/java/org/dromara/SmsbApplication.java

@@ -11,8 +11,8 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
  * @author Lion Li
  */
 
-// @SpringBootApplication(scanBasePackages = {"org.dromara", "com.inspur"})
-@SpringBootApplication(scanBasePackages = {"org.dromara", "com.inspur"},exclude = {EasyEsConfiguration.class})
+@SpringBootApplication(scanBasePackages = {"org.dromara", "com.inspur"})
+// @SpringBootApplication(scanBasePackages = {"org.dromara", "com.inspur"},exclude = {EasyEsConfiguration.class})
 public class SmsbApplication {
 
     public static void main(String[] args) {

+ 1 - 1
smsb-admin/src/main/resources/application-dev.yml

@@ -127,7 +127,7 @@ redisson:
 # es
 easy-es:
   # 默认为true,若为false时,则认为不启用本框架
-  enable: false
+  enable: true
   # es连接地址+端口 格式必须为ip:port,如果是集群则可用逗号隔开
   address : 192.168.100.5:9200
   #如果无账号密码则可不配置此行

+ 20 - 0
smsb-admin/src/main/resources/application-prod.yml

@@ -125,6 +125,26 @@ redisson:
     # 发布和订阅连接池大小
     subscriptionConnectionPoolSize: 50
 
+# es
+easy-es:
+  # 默认为true,若为false时,则认为不启用本框架
+  enable: true
+  # es连接地址+端口 格式必须为ip:port,如果是集群则可用逗号隔开
+  address : 127.0.0.1:9201
+  #如果无账号密码则可不配置此行
+  username: elastic
+  #如果无账号密码则可不配置此行
+  password: WG7WVmuNMtM4GwNYkyWH
+  # 兼容开关,默值为认false,若您当前es客户端版本低于7.x,必须设置为true才能使用,es8.x+则可忽略此配置
+  compatible: false
+  # 禁用 SSL 证书验证
+  ssl:
+    verify: false
+  # 指定请求头
+  request-headers:
+    # 指定 Accept 头为 ES 支持的格式
+    Accept: application/json
+
 --- # mail 邮件发送
 mail:
   enabled: false

+ 12 - 9
smsb-modules/smsb-netty/src/main/java/com/inspur/netty/controller/SmsbEsController.java

@@ -40,18 +40,21 @@ public class SmsbEsController {
     @SaIgnore
     public R<String> createIndex() {
         JSONObject resultJson = new JSONObject();
-        if (!esSmsbSourcePlayRecordMapper.existsIndex(INDEX_NAME_SOURCE_PLAY_RECORD)) {
-            esSmsbSourcePlayRecordMapper.createIndex();
-            resultJson.set(INDEX_NAME_SOURCE_PLAY_RECORD, "创建成功");
+        if (esSmsbSourcePlayRecordMapper.existsIndex(INDEX_NAME_SOURCE_PLAY_RECORD)) {
+            esSmsbSourcePlayRecordMapper.deleteIndex(INDEX_NAME_SOURCE_PLAY_RECORD);
         }
-        if (!esSmsbDeviceHeartRecordMapper.existsIndex(INDEX_NAME_DEVICE_HEART_RECORD)) {
-            esSmsbDeviceHeartRecordMapper.createIndex();
-            resultJson.set(INDEX_NAME_DEVICE_HEART_RECORD, "创建成功");
+        esSmsbSourcePlayRecordMapper.createIndex();
+        resultJson.set(INDEX_NAME_SOURCE_PLAY_RECORD, "创建成功");
+        if (esSmsbDeviceHeartRecordMapper.existsIndex(INDEX_NAME_DEVICE_HEART_RECORD)) {
+            esSmsbDeviceHeartRecordMapper.deleteIndex(INDEX_NAME_DEVICE_HEART_RECORD);
         }
-        if (!esSmsbDeviceRunInfoMapper.existsIndex(INDEX_NAME_DEVICE_RUN_INFO)) {
-            esSmsbDeviceRunInfoMapper.createIndex();
-            resultJson.set(INDEX_NAME_DEVICE_RUN_INFO, "创建成功");
+        esSmsbDeviceHeartRecordMapper.createIndex();
+        resultJson.set(INDEX_NAME_DEVICE_HEART_RECORD, "创建成功");
+        if (esSmsbDeviceRunInfoMapper.existsIndex(INDEX_NAME_DEVICE_RUN_INFO)) {
+            esSmsbDeviceRunInfoMapper.deleteIndex(INDEX_NAME_DEVICE_RUN_INFO);
         }
+        esSmsbDeviceRunInfoMapper.createIndex();
+        resultJson.set(INDEX_NAME_DEVICE_RUN_INFO, "创建成功");
         return R.ok(resultJson.toString());
     }