修改配置和协议解析

This commit is contained in:
chy
2026-05-11 00:11:02 +08:00
parent 5f351425b9
commit de71466c0a
9 changed files with 42 additions and 35 deletions

View File

@@ -56,7 +56,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/lideeiot_2.0?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:3306/lideeiot_2.0?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: root password: gryy@8888
filters: stat,wall filters: stat,wall
filter: filter:
stat: stat:
@@ -111,12 +111,12 @@ spring:
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# mqtt 配置 # mqtt 配置
mqtt: mqtt:
username: iotweib # 账号 # username: iotweib # 账号
password: gryy@8888 # 密码 # password: gryy@8888 # 密码
host-url: tcp://192.168.1.252:1883 # mqtt连接tcp地址 # host-url: tcp://192.168.1.251:1883 # mqtt连接tcp地址
# username: admin # 账号 username: admin # 账号
# password: lidee666 # 密码 password: lidee666 # 密码
# host-url: tcp://127.0.0.1:1883 # mqtt连接tcp地址 host-url: tcp://127.0.0.1:1883 # mqtt连接tcp地址
client-id: ${random.int} # 客户端Id不能相同采用随机数 ${random.value} client-id: ${random.int} # 客户端Id不能相同采用随机数 ${random.value}
default-topic: test # 默认主题 default-topic: test # 默认主题
timeout: 30 # 超时时间 timeout: 30 # 超时时间

View File

@@ -143,11 +143,11 @@ sip:
# 日志配置 # 日志配置
logging: logging:
level: level:
iot.lidee: debug iot.lidee: error
com.yomahub: debug com.yomahub: error
org.dromara: warn org.dromara: error
org.springframework: warn org.springframework: error
com.baomidou: debug com.baomidou: error
# Swagger配置 # Swagger配置
swagger: swagger:

View File

@@ -56,7 +56,7 @@ server:
spring: spring:
# 环境配置dev=开发环境prod=生产环境 # 环境配置dev=开发环境prod=生产环境
profiles: profiles:
active: prod # 环境配置dev=开发环境prod=生产环境 active: dev # 环境配置dev=开发环境prod=生产环境
# 资源信息 # 资源信息
messages: messages:
# 国际化资源文件路径 # 国际化资源文件路径

View File

@@ -1,7 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!--
TRACE用于输出详细的跟踪信息通常用于开发阶段。
DEBUG用于输出调试信息有助于开发者了解程序的运行状态。
INFO用于输出程序运行的一般信息例如程序启动、停止等。
WARN用于输出警告信息表明可能存在潜在问题。
ERROR用于输出错误信息表明程序出现了异常或错误。
-->
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" scope="context" value="/logs" /> <property name="log.path" scope="context" value="/opt/logs" />
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
@@ -28,7 +35,7 @@
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 DEBUG--> <!-- 过滤的级别 DEBUG-->
<level>DEBUG</level> <level>ERROR</level>
<!-- 匹配时的操作:接收(记录) --> <!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch> <onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) --> <!-- 不匹配时的操作:拒绝(不记录) -->
@@ -51,7 +58,7 @@
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 --> <!-- 过滤的级别 -->
<level>INFO</level> <level>ERROR</level>
<!-- 匹配时的操作:接收(记录) --> <!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch> <onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) --> <!-- 不匹配时的操作:拒绝(不记录) -->
@@ -129,9 +136,9 @@
</appender> </appender>
<!-- 系统模块日志级别控制 --> <!-- 系统模块日志级别控制 -->
<logger name="iot.lidee" level="debug" /> <logger name="iot.lidee" level="error" />
<!-- Spring日志级别控制 --> <!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" /> <logger name="org.springframework" level="error" />
<root level="info"> <root level="info">
<appender-ref ref="console" /> <appender-ref ref="console" />
@@ -145,16 +152,16 @@
</root> </root>
<!--系统用户操作日志--> <!--系统用户操作日志-->
<logger name="sys-user" level="info"> <logger name="sys-user" level="error">
<appender-ref ref="sys-user"/> <appender-ref ref="sys-user"/>
</logger> </logger>
<!--规则引擎日志--> <!--规则引擎日志-->
<logger name="script" level="info"> <logger name="script" level="error">
<appender-ref ref="script"/> <appender-ref ref="script"/>
</logger> </logger>
<logger name="scene" level="info"> <logger name="scene" level="error">
<appender-ref ref="scene"/> <appender-ref ref="scene"/>
</logger> </logger>

View File

@@ -69,7 +69,7 @@ public class HttpUtils
try try
{ {
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url; String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
log.info("sendGet - {}", urlNameString); //log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection(); URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*"); connection.setRequestProperty("accept", "*/*");
@@ -84,7 +84,7 @@ public class HttpUtils
{ {
result.append(line); result.append(line);
} }
log.info("recv - {}", result); //log.info("recv - {}", result);
} }
catch (ConnectException e) catch (ConnectException e)
{ {
@@ -133,7 +133,7 @@ public class HttpUtils
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
try try
{ {
log.info("sendPost - {}", url); // log.info("sendPost - {}", url);
URL realUrl = new URL(url); URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection(); URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
@@ -152,7 +152,7 @@ public class HttpUtils
{ {
result.append(line); result.append(line);
} }
log.info("recv - {}", result); //log.info("recv - {}", result);
} }
catch (ConnectException e) catch (ConnectException e)
{ {
@@ -197,7 +197,7 @@ public class HttpUtils
String urlNameString = url + "?" + param; String urlNameString = url + "?" + param;
try try
{ {
log.info("sendSSLPost - {}", urlNameString); //log.info("sendSSLPost - {}", urlNameString);
SSLContext sc = SSLContext.getInstance("SSL"); SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
URL console = new URL(urlNameString); URL console = new URL(urlNameString);
@@ -223,7 +223,7 @@ public class HttpUtils
result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8)); result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
} }
} }
log.info("recv - {}", result); //log.info("recv - {}", result);
conn.disconnect(); conn.disconnect();
br.close(); br.close();
} }

View File

@@ -32,9 +32,9 @@ public class subscribeCallback implements IMqttMessageListener {
@Override @Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
String message = new String(mqttMessage.getPayload()); String message = new String(mqttMessage.getPayload());
log.info("接收消息主题 : " + topic); // log.info("接收消息主题 : " + topic);
log.info("接收消息Qos : " + mqttMessage.getQos()); // log.info("接收消息Qos : " + mqttMessage.getQos());
log.info("接收消息内容 : " + message); // log.info("接收消息内容 : " + message);
//这里默认设备编号长度超过9位 //这里默认设备编号长度超过9位
String[] split = topic.split("/"); String[] split = topic.split("/");

View File

@@ -86,7 +86,7 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
String serialNumber = bo.getSerialNumber(); String serialNumber = bo.getSerialNumber();
switch (bo.getServerType()) { switch (bo.getServerType()) {
case MQTT: case MQTT:
log.debug("=>MQ*收到设备主题[{}],消息:[{}]", bo.getTopicName(), bo.getData()); // log.debug("=>MQ*收到设备主题[{}],消息:[{}]", bo.getTopicName(), bo.getData());
//构建消息 //构建消息
DeviceStatusVO deviceStatusVO = buildReport(bo); DeviceStatusVO deviceStatusVO = buildReport(bo);
Long productId = bo.getProductId(); Long productId = bo.getProductId();
@@ -117,7 +117,7 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
processNoSub(reportMessage, bo.getTopicName()); processNoSub(reportMessage, bo.getTopicName());
break; break;
case TCP: case TCP:
log.debug("*MQ收到TCP推送消息[{}]", JSON.toJSON(bo.getThingsModelSimpleItem())); // log.debug("*MQ收到TCP推送消息[{}]", JSON.toJSON(bo.getThingsModelSimpleItem()));
DeviceStatusVO deviceStatusVO1 = deviceService.selectDeviceStatusAndTransportStatus(serialNumber); DeviceStatusVO deviceStatusVO1 = deviceService.selectDeviceStatusAndTransportStatus(serialNumber);
Optional.ofNullable(deviceStatusVO1).orElseThrow(() -> new ServiceException("设备不存在")); Optional.ofNullable(deviceStatusVO1).orElseThrow(() -> new ServiceException("设备不存在"));
//同步设备状态 //同步设备状态
@@ -144,7 +144,7 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
*/ */
@Override @Override
public void parseReplyMsg(DeviceReportBo bo) { public void parseReplyMsg(DeviceReportBo bo) {
log.debug("=>MQ*收到设备回调消息,[{}]", bo); //log.debug("=>MQ*收到设备回调消息,[{}]", bo);
buildReport(bo); buildReport(bo);
//获取解析协议 //获取解析协议
IProtocol protocol = selectedProtocol(bo.getProductId()); IProtocol protocol = selectedProtocol(bo.getProductId());

View File

@@ -50,7 +50,7 @@ public class MessageAdapter implements MessageDecoder, MessageEncoder{
Long productId = null; Long productId = null;
String devNum = new String(ByteBufUtil.getBytes(buf)); String devNum = new String(ByteBufUtil.getBytes(buf));
String dump = ByteBufUtil.hexDump(buf); String dump = ByteBufUtil.hexDump(buf);
log.info("=>上报hex数据:{}", dump); // log.info("=>上报hex数据:{}", dump);
//这里兼容一下TCP整包发送的数据(整包==设备编号,数据一起发送) //这里兼容一下TCP整包发送的数据(整包==设备编号,数据一起发送)
if (clientId == null){ if (clientId == null){

View File

@@ -64,7 +64,7 @@ swagger-ui:
# [可选] 日志配置, 一般不需要改 # [可选] 日志配置, 一般不需要改
logging: logging:
file: file:
name: logs/record.log name: /opt/logs/record.log
max-history: 30 max-history: 30
max-size: 10MB max-size: 10MB
total-size-cap: 300MB total-size-cap: 300MB