refactor(mqtt): 优化MQTT消息处理机制并修复空指针异常

- 修复EventServiceImpl中SagSource为空时的空指针异常
- 在HeartbeatServiceImpl中统一心跳超时级别命名规范
- 将Redis操作合并为原子方法减少网络调用次数
- 新增MQTT消息异步处理线程池避免Paho回调阻塞
- 将MQTT消息处理逻辑重构为异步提交模式提升性能
- 为Cloud事件添加数据报文日志便于调试追踪
- 优化心跳消息处理确保关键操作同步执行
This commit is contained in:
xy
2026-07-08 10:08:52 +08:00
parent b32219c1c1
commit c6f46cc319
7 changed files with 808 additions and 202 deletions

View File

@@ -308,6 +308,9 @@ public class StatServiceImpl implements IStatService {
tags.put(InfluxDBTableConstant.LINE_ID,lineId);
tags.put(InfluxDBTableConstant.PHASIC_TYPE,dataArrayList.get(i).getPhase());
tags.put(InfluxDBTableConstant.VALUE_TYPE,statMethod.toUpperCase());
tags.put(InfluxDBTableConstant.CL_DID,clDid.toString());
tags.put(InfluxDBTableConstant.PROCESS,process.toString());
if (Objects.isNull(item.getDataTag())) {
tags.put(InfluxDBTableConstant.QUALITY_FLAG,"0");
} else {
@@ -320,8 +323,6 @@ public class StatServiceImpl implements IStatService {
} else {
fields.put(dataArrayList.get(i).getInfluxDbName(),Objects.equals(floats.get(i),3.14159f) ? null:floats.get(i));
}
fields.put(InfluxDBTableConstant.CL_DID,clDid.toString());
fields.put(InfluxDBTableConstant.PROCESS,process.toString());
Point point = influxDbUtils.pointBuilder(tableName, adjustedTimeSec, TimeUnit.SECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
@@ -387,8 +388,8 @@ public class StatServiceImpl implements IStatService {
data.forEach(item->{
DataArrayLiteDto dataArrayLiteDto = new DataArrayLiteDto();
dataArrayLiteDto.setName(item.getName());
dataArrayLiteDto.setInfluxDbName(item.getInfluxDbName());
dataArrayLiteDto.setPhase(item.getPhase());
dataArrayLiteDto.setInfluxDbName(item.getInfluxDbName());
result.add(dataArrayLiteDto);
});
}