修改配置和协议解析

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

View File

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

View File

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

View File

@@ -1,7 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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" />
@@ -28,7 +35,7 @@
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 DEBUG-->
<level>DEBUG</level>
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
@@ -51,7 +58,7 @@
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
@@ -129,9 +136,9 @@
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="iot.lidee" level="debug" />
<logger name="iot.lidee" level="error" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<logger name="org.springframework" level="error" />
<root level="info">
<appender-ref ref="console" />
@@ -145,16 +152,16 @@
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<logger name="sys-user" level="error">
<appender-ref ref="sys-user"/>
</logger>
<!--规则引擎日志-->
<logger name="script" level="info">
<logger name="script" level="error">
<appender-ref ref="script"/>
</logger>
<logger name="scene" level="info">
<logger name="scene" level="error">
<appender-ref ref="scene"/>
</logger>

View File

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

View File

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

View File

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

View File

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

View File

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