|
@@ -56,7 +56,7 @@ class StatsOnuCommand extends BaseCommand
|
|
|
|
|
|
$onus = $this->getData($key_olt_scan, true);
|
|
|
|
|
|
- $devices = $this->getDevices($oltServerId);
|
|
|
+ $devices = $this->getOnusFromDevices($oltServerId);
|
|
|
|
|
|
foreach($onus as $index => $onu) {
|
|
|
$sn = $onu['serialNumber'];
|
|
@@ -64,8 +64,11 @@ class StatsOnuCommand extends BaseCommand
|
|
|
$row = array();
|
|
|
$row['deviceServer'] = $deviceServerId;
|
|
|
|
|
|
+ $lat = $lng = "NULL";
|
|
|
if(isset($devices[$lowSn])) {
|
|
|
- $row['deviceId'] = $devices[$lowSn];
|
|
|
+ $row['deviceId'] = $devices[$lowSn]['deviceId'];
|
|
|
+ $lat = $devices[$lowSn]['lat'];
|
|
|
+ $lng = $devices[$lowSn]['lng'];
|
|
|
} else {
|
|
|
$row['deviceId'] = "NULL";
|
|
|
}
|
|
@@ -87,11 +90,13 @@ class StatsOnuCommand extends BaseCommand
|
|
|
|
|
|
$row['uptime'] = "NULL";
|
|
|
$row['update'] = "'".date("Y-m-d H:i:s")."'";
|
|
|
+
|
|
|
+ $row['lat'] = $lat;
|
|
|
+ $row['lng'] = $lng;
|
|
|
|
|
|
$data[] = "(".implode(",",$row).")".PHP_EOL;
|
|
|
}
|
|
|
|
|
|
- //print_r($data);
|
|
|
|
|
|
$conn = $doctrine->getConnection();
|
|
|
$sql = "DELETE FROM `onu` WHERE device_server_id = {$deviceServerId} AND olt_device_id = {$oltDeviceId};";
|
|
@@ -99,32 +104,10 @@ class StatsOnuCommand extends BaseCommand
|
|
|
$conn->close();
|
|
|
|
|
|
$conn = $doctrine->getConnection();
|
|
|
- $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`) VALUES ". implode(",", $data).";";
|
|
|
+ $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`) VALUES ". implode(",", $data).";";
|
|
|
$conn->query($sql);
|
|
|
$conn->close();
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- 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;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|