Browse Source

Se actualiza el comando para vincular la onu con el deviceId que posee
en FTTH.

Maximiliano Schvindt 7 years ago
parent
commit
d0973a4b86
1 changed files with 31 additions and 2 deletions
  1. 31 2
      src/StatsBundle/Command/StatsOnuCommand.php

+ 31 - 2
src/StatsBundle/Command/StatsOnuCommand.php

@@ -55,12 +55,20 @@ class StatsOnuCommand extends BaseCommand
         }
 
         $onus = $this->getData($key_olt_scan, true);
-        
+
+        $devices = $this->getDevices($oltServerId);
+
         foreach($onus as $index => $onu) {
             $sn = $onu['serialNumber'];
+            $lowSn = strtolower($sn);
             $row = array();
             $row['deviceServer'] = $deviceServerId;
-            $row['deviceId'] = "NULL";
+            
+            if(isset($devices[$lowSn])) {
+                $row['deviceId'] = $devices[$lowSn];
+            } else {
+                $row['deviceId'] = "NULL";
+            }
             $row['oltDeviceId'] = $oltDeviceId;
             $row['tenancyId'] = $tenancyId;
             $row['ip'] = "NULL";
@@ -98,4 +106,25 @@ class StatsOnuCommand extends BaseCommand
 
     }
 
+    public function getDevices($oltServerId) 
+    {
+
+        $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
+
+        $data = array();
+        $onus = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\ONU'));
+
+        foreach($onus as $k => $device) {
+
+            $extra = $device->jsonExtraData();
+            if(isset($extra['ponSerialNumber'])) {
+                $sn = strtolower($extra['ponSerialNumber']);
+                $data[$sn] = $device->getDeviceId();
+            }
+        }
+
+        return $data;
+
+    }
+
 }