|
@@ -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;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|