diff --git a/sec-beidou/src/main/resources/static/js/device-overview-module/device-markers.js b/sec-beidou/src/main/resources/static/js/device-overview-module/device-markers.js index e3e17f98..436c17bc 100644 --- a/sec-beidou/src/main/resources/static/js/device-overview-module/device-markers.js +++ b/sec-beidou/src/main/resources/static/js/device-overview-module/device-markers.js @@ -209,13 +209,35 @@ var DeviceMarkers = (function() { } function findDeviceById(deviceId) { + // console.log('搜索设备:', deviceId, '(类型:', typeof deviceId, ')'); + // console.log('当前设备总数:', allFeatures.length); + + var searchTerm = String(deviceId).trim(); + for (var i = 0; i < allFeatures.length; i++) { var feature = allFeatures[i]; var deviceInfo = feature.get('deviceInfo'); - if (deviceInfo && deviceInfo.deviceid === deviceId) { - return feature; + if (deviceInfo) { + var currentDeviceId = String(deviceInfo.deviceid); + // console.log('检查设备:', currentDeviceId, '(类型:', typeof deviceInfo.deviceid, ')'); + + if (currentDeviceId === searchTerm) { + // console.log('精确匹配找到设备:', currentDeviceId); + return feature; + } + + if (currentDeviceId.indexOf(searchTerm) !== -1) { + // console.log('部分匹配找到设备:', currentDeviceId); + return feature; + } + + if (currentDeviceId.replace(/\s+/g, '') === searchTerm.replace(/\s+/g, '')) { + // console.log('去除空格后匹配找到设备:', currentDeviceId); + return feature; + } } } + console.log('未找到设备:', deviceId); return null; } @@ -230,7 +252,9 @@ var DeviceMarkers = (function() { zoom: Math.max(map.getView().getZoom(), 15), duration: 1000 }); + return true; } + return false; } /**