diff --git a/backend/app/services/snmp_service.py b/backend/app/services/snmp_service.py index bfe24f8..ba12566 100644 --- a/backend/app/services/snmp_service.py +++ b/backend/app/services/snmp_service.py @@ -258,16 +258,18 @@ class SNMPService: db.commit() - # 更新 IP 资产台账中的 MAC 地址 + # 更新 IP 资产台账中的 MAC 地址和厂商信息 for entry in arp_entries: from app.models.network import IPAddress as IPAddressModel ip_addr = db.query(IPAddressModel).filter( IPAddressModel.ip_address == entry['ip_address'] ).first() - if ip_addr and not ip_addr.mac_address: - ip_addr.mac_address = entry['mac_address'] - # 识别厂商 - ip_addr.vendor = EnhancedScanService.get_mac_vendor(entry['mac_address']) + if ip_addr: + if not ip_addr.mac_address: + ip_addr.mac_address = entry['mac_address'] + # 始终尝试补全厂商(有 MAC 但没厂商时也需要) + if not ip_addr.vendor and ip_addr.mac_address: + ip_addr.vendor = EnhancedScanService.get_mac_vendor(ip_addr.mac_address) db.commit() device.last_successful_poll = now