From ba307163560efa29f33366f32efd5de19da5f0b8 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 26 Jun 2024 09:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=EF=BC=9A=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=8D=87=E7=BA=A7-=E7=AB=AF=E5=8F=A3=E5=8F=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 82 ---------------------- .../com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java | 82 ++++++++++++++++++++++ .../hnac/hzims/alarm/MiddleApplicationTests.java | 16 ----- .../hnac/hzims/basic/BasicApplicationTests.java | 15 ---- hzims-service/hzims-big-model/pom.xml | 5 +- .../hnac/hzims/middle/MiddleApplicationTests.java | 30 ++++---- .../src/main/resources/template/template.yml | 2 +- hzims-service/ticket/pom.xml | 4 ++ .../src/main/resources/template/template.yml | 2 +- .../launcher/DemoTestLauncherServiceImpl.java | 45 ------------ 10 files changed, 107 insertions(+), 176 deletions(-) delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java delete mode 100644 hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java delete mode 100644 hzims-service/hzims-basic/src/test/java/com/hnac/hzims/basic/BasicApplicationTests.java delete mode 100644 hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/launcher/DemoTestLauncherServiceImpl.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java deleted file mode 100644 index 6a2c34e..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.hnac.hzims.alarm.mqtt; - -import com.hnac.hzinfo.subscribe.AnalysisSubscribe; -import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; -import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; -import com.hnac.hzinfo.subscribe.SoeSubscribe; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.paho.client.mqttv3.MqttAsyncClient; -import org.eclipse.paho.client.mqttv3.MqttException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.util.Collections; - -/** - * @Author: ty - */ - -@Component -@Slf4j -public class MqttConfig { - - @Autowired - FdpMqttConsumer fdpMqttConsumer; - @Autowired - DroolsMqttConsumer droolsMqttConsumer; - @Autowired - HZ300MqttConsumer hz300MqttConsumer; - @Autowired - VideoMqttConsumer videoMqttConsumer; - @Autowired - SoeMqttConsumer soeMqttConsumer; - - @Value("${hzims.mqtt.url}") - private String mqtt_fdp_url; - @Value("${hzims.mqtt.group}") - private String mqtt_fdp_group; - @Value("${hzims.mqtt.password}") - private String mqtt_fdp_password; - @Value("${hzims.mqtt.username}") - private String mqtt_fdp_username; -// @Value("${hzims.mqtt.fdp.topname}") -// private String mqtt_fdp_topname; -// @Value("${hzims.mqtt.drools.topname}") -// private String mqtt_drools_topname; -// @Value("${hzims.mqtt.system.topname}") -// private String mqtt_system_topname; - @PostConstruct - public void registerMqtt(){ - try{ - com.hnac.hzinfo.subscribe.MqttConfig mqttConfig = new com.hnac.hzinfo.subscribe.MqttConfig(); - mqttConfig.setUrl(mqtt_fdp_url); - mqttConfig.setGroup(mqtt_fdp_group); - mqttConfig.setPassword(mqtt_fdp_password); - mqttConfig.setUsername(mqtt_fdp_username); - //fdp - AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); - MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer); - log.info(fdpClient.toString()+fdpClient.getClientId()); - //drools - DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); - MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); - log.info(droolsClient.toString()+droolsClient.getClientId()); - //Soe - SoeSubscribe soeSubscribe = new SoeSubscribe(); - MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); - log.info(soeClient.toString()+soeClient.getClientId()); - //hz3000 - HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); - MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); - log.info(hz3000Client.toString()+hz3000Client.getClientId()); - //视频 - SoeSubscribe subscribe = new SoeSubscribe(); - MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); - log.info(videoClient.toString()+videoClient.getClientId()); - }catch (MqttException e){ - log.error(e.toString()) ; - } - } -} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java new file mode 100644 index 0000000..8c75506 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java @@ -0,0 +1,82 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.hnac.hzinfo.subscribe.AnalysisSubscribe; +import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; +import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; +import com.hnac.hzinfo.subscribe.SoeSubscribe; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.paho.client.mqttv3.MqttAsyncClient; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.Collections; + +/** + * @Author: ty + */ + +@Component +@Slf4j +public class MqttConfigHzims { + + @Autowired + FdpMqttConsumer fdpMqttConsumer; + @Autowired + DroolsMqttConsumer droolsMqttConsumer; + @Autowired + HZ300MqttConsumer hz300MqttConsumer; + @Autowired + VideoMqttConsumer videoMqttConsumer; + @Autowired + SoeMqttConsumer soeMqttConsumer; + + @Value("${hzims.mqtt.url}") + private String mqtt_fdp_url; + @Value("${hzims.mqtt.group}") + private String mqtt_fdp_group; + @Value("${hzims.mqtt.password}") + private String mqtt_fdp_password; + @Value("${hzims.mqtt.username}") + private String mqtt_fdp_username; +// @Value("${hzims.mqtt.fdp.topname}") +// private String mqtt_fdp_topname; +// @Value("${hzims.mqtt.drools.topname}") +// private String mqtt_drools_topname; +// @Value("${hzims.mqtt.system.topname}") +// private String mqtt_system_topname; + @PostConstruct + public void registerMqtt(){ + try{ + com.hnac.hzinfo.subscribe.MqttConfig mqttConfig = new com.hnac.hzinfo.subscribe.MqttConfig(); + mqttConfig.setUrl(mqtt_fdp_url); + mqttConfig.setGroup(mqtt_fdp_group); + mqttConfig.setPassword(mqtt_fdp_password); + mqttConfig.setUsername(mqtt_fdp_username); + //fdp + AnalysisSubscribe analysisSubscribe = new AnalysisSubscribe(); + MqttAsyncClient fdpClient = analysisSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), fdpMqttConsumer); + log.info(fdpClient.toString()+fdpClient.getClientId()); + //drools + DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe(); + MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer); + log.info(droolsClient.toString()+droolsClient.getClientId()); + //Soe + SoeSubscribe soeSubscribe = new SoeSubscribe(); + MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer); + log.info(soeClient.toString()+soeClient.getClientId()); + //hz3000 + HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); + MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); + log.info(hz3000Client.toString()+hz3000Client.getClientId()); + //视频 + SoeSubscribe subscribe = new SoeSubscribe(); + MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); + log.info(videoClient.toString()+videoClient.getClientId()); + }catch (MqttException e){ + log.error(e.toString()) ; + } + } +} diff --git a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java b/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java deleted file mode 100644 index 0d3f950..0000000 --- a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.alarm; - -import com.hnac.hzims.AlarmApplication; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = AlarmApplication.class) -class AlarmApplicationTests { - - @Test - void contextLoads() { - - System.out.println("1"); - } - -} diff --git a/hzims-service/hzims-basic/src/test/java/com/hnac/hzims/basic/BasicApplicationTests.java b/hzims-service/hzims-basic/src/test/java/com/hnac/hzims/basic/BasicApplicationTests.java deleted file mode 100644 index 97918a4..0000000 --- a/hzims-service/hzims-basic/src/test/java/com/hnac/hzims/basic/BasicApplicationTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.basic; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = BasicApplication.class) -class BasicApplicationTests { - - @Test - void contextLoads() { - - System.out.println("1"); - } - -} diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index 19bc3a3..fa26e50 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -27,7 +27,10 @@ 4.0.0-SNAPSHOT compile - + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + org.springframework.boot diff --git a/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java b/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java index b63584e..7b34694 100644 --- a/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java +++ b/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java @@ -1,15 +1,15 @@ -package com.hnac.hzims.middle; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = MiddleApplication.class) -class MiddleApplicationTests { - - @Test - void contextLoads() { - - System.out.println("1"); - } - -} +//package com.hnac.hzims.middle; +// +//import org.junit.jupiter.api.Test; +//import org.springframework.boot.test.context.SpringBootTest; +// +//@SpringBootTest(classes = MiddleApplication.class) +//class MiddleApplicationTests { +// +// @Test +// void contextLoads() { +// +// System.out.println("1"); +// } +// +//} diff --git a/hzims-service/inspect/src/main/resources/template/template.yml b/hzims-service/inspect/src/main/resources/template/template.yml index edd63bb..c47c12a 100644 --- a/hzims-service/inspect/src/main/resources/template/template.yml +++ b/hzims-service/inspect/src/main/resources/template/template.yml @@ -1,6 +1,6 @@ #服务器端口 server: - port: 8200 + port: 8132 ##oss配置 oss: diff --git a/hzims-service/ticket/pom.xml b/hzims-service/ticket/pom.xml index 8c7028c..56e0868 100644 --- a/hzims-service/ticket/pom.xml +++ b/hzims-service/ticket/pom.xml @@ -44,6 +44,10 @@ ticket-api + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + + com.hnac.hzims common-api diff --git a/hzims-service/ticket/src/main/resources/template/template.yml b/hzims-service/ticket/src/main/resources/template/template.yml index 3c3e591..9a48544 100644 --- a/hzims-service/ticket/src/main/resources/template/template.yml +++ b/hzims-service/ticket/src/main/resources/template/template.yml @@ -1,6 +1,6 @@ #服务器端口 server: - port: 8200 + port: 8216 #oss配置 oss: diff --git a/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/launcher/DemoTestLauncherServiceImpl.java b/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/launcher/DemoTestLauncherServiceImpl.java deleted file mode 100644 index 6aa0159..0000000 --- a/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/launcher/DemoTestLauncherServiceImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package com.hnac.hzims.ticket.launcher; - -import org.springblade.core.auto.service.AutoService; -import org.springblade.core.launch.service.LauncherService; -import org.springframework.boot.builder.SpringApplicationBuilder; - -import java.util.Properties; - -/** - * 启动参数拓展 - * - * @author Chill - */ -@AutoService(LauncherService.class) -public class DemoTestLauncherServiceImpl implements LauncherService { - - @Override - public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { - Properties props = System.getProperties(); - props.setProperty("spring.cloud.nacos.discovery.server-addr", "http://175.6.40.67:3301"); - props.setProperty("spring.cloud.nacos.config.server-addr", "http://175.6.40.67:3301"); - //props.setProperty("spring.cloud.sentinel.transport.dashboard", LauncherConstant.SENTINEL_DEV_ADDR); - } - - @Override - public int getOrder() { - return 10; - } -}