This commit is contained in:
孙小云 2026-02-04 15:02:38 +08:00
parent a6f6231562
commit 86b7ffe93d
2 changed files with 18 additions and 16 deletions

View File

@ -156,12 +156,11 @@ public class SynService {
for (List<DeviceInfo> gatewayBatch : gatewayDevices) { for (List<DeviceInfo> gatewayBatch : gatewayDevices) {
for (DeviceInfo gatewayInfo : gatewayBatch) { for (DeviceInfo gatewayInfo : gatewayBatch) {
try { try {
// 按照名字过滤网关设备 // 按照名字过滤网关设备已禁用不再过滤 TH 开头的设备
if (shouldExcludeDevice(gatewayInfo.getName())) { // if (shouldExcludeDevice(gatewayInfo.getName())) {
// log.info("网关 {} 匹配过滤规则,跳过同步", gatewayInfo.getName()); // skippedCount++;
skippedCount++; // continue;
continue; // }
}
// 同步网关设备本身 // 同步网关设备本身
// log.info("开始同步网关: {}", gatewayInfo.getName()); // log.info("开始同步网关: {}", gatewayInfo.getName());
@ -182,12 +181,11 @@ public class SynService {
continue; continue;
} }
// 按照名字过滤子设备 // 按照名字过滤子设备已禁用不再过滤 TH 开头的设备
if (shouldExcludeDevice(childDeviceInfo.getName())) { // if (shouldExcludeDevice(childDeviceInfo.getName())) {
// log.info("子设备 {} 匹配过滤规则,跳过同步", childDeviceInfo.getName()); // skippedCount++;
skippedCount++; // continue;
continue; // }
}
try { try {
String deviceName = childDeviceInfo.getName(); String deviceName = childDeviceInfo.getName();
@ -452,11 +450,15 @@ public class SynService {
Long aircraftId = newAircraft.getAircraftId(); Long aircraftId = newAircraft.getAircraftId();
log.info("插入新无人机成功: deviceId={}, aircraftName={}, aircraftId={}", log.info("插入新无人机成功: deviceId={}, aircraftName={}, aircraftId={}",
deviceId, deviceName, aircraftId); deviceId, deviceName, aircraftId);
// 新插入的无人机直接返回 aircraftId不需要处理 PSDK 设备
return aircraftId; return aircraftId;
} else {
log.info("无人机已存在,跳过插入: deviceId={}, aircraftName={}", deviceId, deviceName);
} }
// 无人机已存在记录日志
log.info("无人机已存在: deviceId={}, aircraftName={}, aircraftId={}",
deviceId, deviceName, existingAircraft.getAircraftId());
Device device = deviceDomain.selectDeviceByDeviceId(deviceId); Device device = deviceDomain.selectDeviceByDeviceId(deviceId);
TelemetryMap telemetryMap = iThingsBoardDomain.getPredefinedDeviceTelemetry(device.getIotDeviceId()); TelemetryMap telemetryMap = iThingsBoardDomain.getPredefinedDeviceTelemetry(device.getIotDeviceId());

View File

@ -32,8 +32,8 @@ device:
sync: sync:
# 设备名称过滤正则表达式(多个用逗号分隔) # 设备名称过滤正则表达式(多个用逗号分隔)
# 匹配这些正则表达式的设备将被跳过,不进行同步 # 匹配这些正则表达式的设备将被跳过,不进行同步
# 当前配置:过滤所有以 TH 开头的设备 # 留空表示不过滤任何设备
exclude-patterns: TH.* exclude-patterns:
machine: machine:
state: state:
store: store: