mqtt初始化链接调试

This commit is contained in:
Timer
2026-02-24 15:34:56 +08:00
parent e35f300cff
commit 0093cc70dd
5 changed files with 58 additions and 40 deletions

View File

@ -127,7 +127,7 @@ public class PushCallback implements MqttCallbackExtended {
public void messageArrived(String topic, MqttMessage message) {
try {
JSONArray jsonArray = JSONArray.parseArray(message.toString());
// System.out.println(topic + "===开始===" + CommUtil.nowDate() + "===" + jsonArray.size());
System.out.println(topic + "===开始===" + CommUtil.nowDate() + "===" + jsonArray.size());
String unitId = topic.substring(0, 4);//截取topic的前面部分作为厂id
MqttService mqttService = (MqttService) SpringContextUtil.getBean("mqttService");
//正常的主题 -- 数据处理

View File

@ -93,7 +93,7 @@ public class MqttServiceImpl implements MqttService {
@Async("getAsyncMqttHandle")
@Override
public void doHandle(String bizId, String topic, String ip4, String port, JSONArray jsonArray) {
// System.out.println("MQTT接收: biz=" + bizId + " topic=" + topic + " msgCount=" + jsonArray.size());
System.out.println("MQTT接收: biz=" + bizId + " topic=" + topic + " msgCount=" + jsonArray.size());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
// 解析时间戳

View File

@ -6,5 +6,6 @@ package com.sipai.tools;
public enum DataSourceEnum {
master
//
,SCADA_JS1C,SCADA_JS2C,SCADA_JSBZ
// ,SCADA_JS1C,SCADA_JS2C,SCADA_JSBZ,
,SCADA_JSWS,
}

View File

@ -35,28 +35,35 @@ public class MyBatisConfig {
/**
* 下面为管网
*/
@Bean("SCADA_JS1C")
@ConfigurationProperties(prefix = "spring.datasource.js1")
// @Bean("SCADA_JS1C")
// @ConfigurationProperties(prefix = "spring.datasource.js1")
//根据数据源前缀到application.yml读取数据源信息//可以配置更多数据源到前提是application.yml中存在而且也需要在枚举类中添加枚举类型
public DataSource fssk() throws Exception {
return DataSourceBuilder.create().build();
}
// public DataSource fssk() throws Exception {
// return DataSourceBuilder.create().build();
// }
/**
* 下面为管网
*/
@Bean("SCADA_JS2C")
@ConfigurationProperties(prefix = "spring.datasource.js2")
// @Bean("SCADA_JS2C")
// @ConfigurationProperties(prefix = "spring.datasource.js2")
//根据数据源前缀到application.yml读取数据源信息//可以配置更多数据源到前提是application.yml中存在而且也需要在枚举类中添加枚举类型
public DataSource fssk2() throws Exception {
return DataSourceBuilder.create().build();
}
// public DataSource fssk2() throws Exception {
// return DataSourceBuilder.create().build();
// }
/**
* 下面为管网
*/
@Bean("SCADA_JSBZ")
@ConfigurationProperties(prefix = "spring.datasource.js3")
// @Bean("SCADA_JSBZ")
// @ConfigurationProperties(prefix = "spring.datasource.js3")
//根据数据源前缀到application.yml读取数据源信息//可以配置更多数据源到前提是application.yml中存在而且也需要在枚举类中添加枚举类型
// public DataSource fssk3() throws Exception {
// return DataSourceBuilder.create().build();
// }
@Bean("SCADA_JSWS")
@ConfigurationProperties(prefix = "spring.datasource.jsws")
//根据数据源前缀到application.yml读取数据源信息//可以配置更多数据源到前提是application.yml中存在而且也需要在枚举类中添加枚举类型
public DataSource fssk3() throws Exception {
return DataSourceBuilder.create().build();
@ -68,15 +75,18 @@ public class MyBatisConfig {
*/
@Bean("dynamicDataSource")
public DynamicDataSource dynamicDataSource(@Qualifier("masterDataSource") DataSource masterDataSource,
@Qualifier("SCADA_JS1C") DataSource SCADA_JS1C,
@Qualifier("SCADA_JS2C") DataSource SCADA_JS2C,
@Qualifier("SCADA_JSBZ") DataSource SCADA_JSBZ) {
// @Qualifier("SCADA_JS1C") DataSource SCADA_JS1C,
// @Qualifier("SCADA_JS2C") DataSource SCADA_JS2C,
// @Qualifier("SCADA_JSBZ") DataSource SCADA_JSBZ
@Qualifier("SCADA_JSWS") DataSource SCADA_JSWS
) {
Map<Object, Object> targetDataSources = new HashMap<Object, Object>();
targetDataSources.put(DataSourceEnum.master, masterDataSource);
targetDataSources.put(DataSourceEnum.SCADA_JS1C, SCADA_JS1C);
targetDataSources.put(DataSourceEnum.SCADA_JS2C, SCADA_JS2C);
targetDataSources.put(DataSourceEnum.SCADA_JSBZ, SCADA_JSBZ);
// targetDataSources.put(DataSourceEnum.SCADA_JS1C, SCADA_JS1C);
// targetDataSources.put(DataSourceEnum.SCADA_JS2C, SCADA_JS2C);
// targetDataSources.put(DataSourceEnum.SCADA_JSBZ, SCADA_JSBZ);
targetDataSources.put(DataSourceEnum.SCADA_JSWS, SCADA_JSWS);
DynamicDataSource dataSource = new DynamicDataSource();
dataSource.setTargetDataSources(targetDataSources);// 该方法是AbstractRoutingDataSource的方法

View File

@ -37,23 +37,30 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
#生产库
js1:
username: sa
password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
# js1:
# username: sa
# password: P76XB3nm36aMkN6n
# jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
#生产库
js2:
username: sa
password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
# js2:
# username: sa
# password: P76XB3nm36aMkN6n
# jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
#生产库
js3:
# js3:
# username: sa
# password: P76XB3nm36aMkN6n
# jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
jsws:
username: sa
password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
@ -146,14 +153,14 @@ app:
max-points: 200 #实时数据接口一次最多点位数
mqtt:
# broker-address: "tcp://192.168.10.17:1883"
# dashboard-01: "http://192.168.10.17:18083"
# username: "admin"
# password: "sipai@64368180"
broker-address: "tcp://121.5.164.6:1883"
dashboard-01: "http://121.5.164.6:18083"
broker-address: "tcp://122.51.194.184:1883"
dashboard-01: "http://122.51.194.184:18083"
username: "dmbroker"
password: "qwer1234"
# broker-address: "tcp://121.5.164.6:1883"
# dashboard-01: "http://121.5.164.6:18083"
# username: "dmbroker"
# password: "qwer1234"
# udp服务
udp: