ソースを参照

Campos y filtro de cliente en el listado de ONUs

Maximiliano Schvindt 6 年 前
コミット
d76cea6477

+ 2 - 1
composer.json

@@ -175,7 +175,8 @@
             "options": {
                 "local_pk": "./keys/bitbucket.id_rsa"
             }
-        }
+        },
+        "packagist": false
     },
     "require": {
         "php": ">=5.5.9",

+ 10 - 10
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "459b2183499a5a4ee718beb040889f81",
+    "content-hash": "9c35ef8addd3827a56efd4b9cd3e9c71",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1711,7 +1711,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/LeafletBundle.git",
-                "reference": "db4aba82a00ac8af06d5445c4473648959798127"
+                "reference": "5fa33e67613667d93dbaa9e878b38420fe3518a5"
             },
             "require": {
                 "ext-curl": "*",
@@ -1724,7 +1724,7 @@
                 }
             },
             "description": "The Flowdat3 Leaflet Resource",
-            "time": "2018-03-06T18:03:24+00:00"
+            "time": "2018-12-05T12:04:14+00:00"
         },
         {
             "name": "ik/migrations-bundle",
@@ -1755,7 +1755,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "596bc7b28ad90ba558da5b3eb5d7f26c583b148d"
+                "reference": "1c60fd91f1bb0fe5125da70908670629d4d341e6"
             },
             "require": {
                 "ext-curl": "*",
@@ -1774,7 +1774,7 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2018-10-23T15:06:48+00:00"
+            "time": "2018-12-04T13:12:24+00:00"
         },
         {
             "name": "ik/owner-voter-bundle",
@@ -1805,7 +1805,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/RedisBundle.git",
-                "reference": "e7ac03ffd884b57cfd8fcf7a14c1d3f2b3b47d80"
+                "reference": "f0ea0beb0e6a10325fabac65a24d9ae461497457"
             },
             "require": {
                 "predis/predis": "^1.1"
@@ -1821,7 +1821,7 @@
                 "php-redis-service",
                 "redis"
             ],
-            "time": "2018-07-11T17:32:59+00:00"
+            "time": "2018-12-05T14:01:46+00:00"
         },
         {
             "name": "ik/stats/base-stats-bundle",
@@ -2039,7 +2039,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "13431443af6cd4038230a15e05f593363a642ad1"
+                "reference": "8919bf2fec49fa73cd31b07a83a542bbd0767136"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -2069,7 +2069,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-11-22T18:10:58+00:00"
+            "time": "2018-11-23T13:16:02+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",
@@ -6794,7 +6794,7 @@
         "voryx/restgeneratorbundle": 20
     },
     "prefer-stable": false,
-    "prefer-lowest": false,
+    "prefer-lowest": true,
     "platform": {
         "php": ">=5.5.9"
     },

+ 42 - 1
src/StatsBundle/Admin/OnuAdmin.php

@@ -10,6 +10,8 @@ use Sonata\AdminBundle\Show\ShowMapper;
 use DeviceBundle\Utils\DeviceTypes;
 use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 use Sonata\AdminBundle\Route\RouteCollection;
+use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery;
+use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
 
 class OnuAdmin extends BaseAdmin
 {
@@ -33,9 +35,45 @@ class OnuAdmin extends BaseAdmin
 
         $datagridMapper
             ->add('oltDeviceId', 'doctrine_orm_string', array(), 'choice', array('choices' => $choices))
-            ->add('ponSerialNumber')
             ->add('ponPort')
             ->add('status')
+            ->add('ponSerialNumber', CallbackFilter::class, array(
+                'callback' => function (ProxyQuery $query, $alias, $field, $data) {
+                    if (!$data || !is_array($data) || !array_key_exists('value', $data) || !isset($data['value'])) {
+                        return;
+                    }
+
+                    $alias = $query->getRootAlias();
+                    $query
+                        ->andWhere("{$alias}.serialNumber LIKE :id OR
+                                    {$alias}.ponSerialNumber LIKE :id")
+                        ->setParameter('id', "%{$data['value']}%");
+                        
+                    return true;
+                },), null, [
+                    'attr' => [
+                        'placeholder' => $this->trans('sonata.filter.onu_id')
+                    ]
+                ])
+            ->add('clientName', CallbackFilter::class, array(
+                'callback' => function (ProxyQuery $query, $alias, $field, $data) {
+                    if (!$data || !is_array($data) || !array_key_exists('value', $data) || !isset($data['value'])) {
+                        return;
+                    }
+
+                    $alias = $query->getRootAlias();
+                    $query
+                        ->andWhere("{$alias}.clientExternalId LIKE :id OR
+                                    {$alias}.clientAddress LIKE :id OR
+                                    {$alias}.clientName LIKE :id")
+                        ->setParameter('id', "%{$data['value']}%");
+                        
+                    return true;
+                },), null, [
+                    'attr' => [
+                        'placeholder' => $this->trans('sonata.filter.onu_client')
+                    ]
+                ])
         ;
     }
 
@@ -79,6 +117,9 @@ class OnuAdmin extends BaseAdmin
             ->add('outOctets',null, array('template' => 'StatsBundle:Onu:field_octets.html.twig'))
             ->add('rxPowerOlt', 'string', array('template' => 'StatsBundle:Onu:field_rx_in_olt.html.twig'))
             ->add('uptime', 'string', array('template' => 'StatsBundle:Onu:field_uptime.html.twig'))
+            ->add('clientExternalId','string',array('attr' => array('title' => 'External ID del cliente')))
+            ->add('clientName')
+            ->add('clientAddress')
         ;
     }
 

+ 24 - 2
src/StatsBundle/Command/BaseCommand.php

@@ -226,7 +226,7 @@ abstract class BaseCommand extends ContainerAwareCommand
 
                 $sn = strtolower($extra['ponSerialNumberAux']);
 
-                $lat = $lng = NULL;
+                $clientId = $lat = $lng = NULL;
                 if(isset($extra['location']) && isset($extra['location']['extraData'])) 
                 {
                     if(isset($extra['location']['extraData']['lat'])) 
@@ -237,7 +237,11 @@ abstract class BaseCommand extends ContainerAwareCommand
 
                 }
 
-                $data[$sn] = array('deviceId' => $device->getDeviceId(), 'lat' => $lat, 'lng' => $lng);
+                if(isset($extra['clientId'])) {
+                    $clientId = $extra['clientId'];
+                }
+
+                $data[$sn] = array('deviceId' => $device->getDeviceId(), 'lat' => $lat, 'lng' => $lng, 'clientId' => $clientId);
             }
         }
 
@@ -286,4 +290,22 @@ abstract class BaseCommand extends ContainerAwareCommand
         return $data;
 
     }
+
+    /**
+     * @return array
+     *
+     * Description: Retorna los clientes almacenados en Redis (obtenidos en módulo Base)
+     */
+    public function getClientsFromRedis()
+    {
+        $clients = array();
+        $_clients = $this->hgetData('clients');
+
+        foreach($_clients as $id => $data) {
+            $clients[$id] = json_decode($data,true);
+        }
+
+        return $clients;
+
+    }
 }

+ 17 - 1
src/StatsBundle/Command/StatsOnuCommand.php

@@ -60,6 +60,7 @@ class StatsOnuCommand extends BaseCommand
         $onus = $this->getData($key_olt_scan, true);
 
         $devices = $this->getOnusFromDevices($oltServerId);
+        $clients = $this->getClientsFromRedis();
 
         foreach($onus as $index => $onu) {
             $sn = $onu['serialNumber'];
@@ -110,6 +111,21 @@ class StatsOnuCommand extends BaseCommand
 
             (isset($oltRx[$ponPort]))? $row['rxPowerOlt'] = $oltRx[$ponPort] : $row['rxPowerOlt'] = "NULL";
 
+            $row['clientId'] = "NULL";
+            $row['clientExternalId'] = "NULL";
+            $row['clientName'] = "NULL";
+            $row['clientAddress'] = "NULL";
+
+            if(isset($devices[$lowSn]) && isset($devices[$lowSn]['clientId'])) {
+                $clientId = $devices[$lowSn]['clientId'];
+                if(isset($clients[$clientId])) {
+                    $row['clientId'] = $clientId;
+                    $row['clientExternalId'] = "'".$clients[$clientId]['externalId']."'";
+                    $row['clientName'] = "'".$clients[$clientId]['name']."'";
+                    $row['clientAddress'] = "'".$clients[$clientId]['address']."'";
+                }
+            } 
+
             $data[] = "(".implode(",",$row).")".PHP_EOL;
         }
 
@@ -120,7 +136,7 @@ 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`,`lat`,`lng`,`index`,`in_octets`,`out_octets`,`rx_power_olt`) 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`,`index`,`in_octets`,`out_octets`,`rx_power_olt`,`client_id`,`client_external_id`,`client_name`,`client_address`) VALUES ".  implode(",", $data).";";
             $conn->query($sql);
             $conn->close();
         } else {

+ 2 - 0
src/StatsBundle/Entity/Onu.php

@@ -8,6 +8,7 @@ use Symfony\Component\Validator\Constraints as Assert;
 use JMS\Serializer\Annotation as JMS;
 use Base\AdminBundle\Traits\TenancyIdTrait;
 use Base\AdminBundle\Traits\TenancyIdTraitInterface;
+use StatsBundle\Traits\ClientTrait;
 
 
 /**
@@ -18,6 +19,7 @@ use Base\AdminBundle\Traits\TenancyIdTraitInterface;
  */
 class Onu implements TenancyIdTraitInterface
 {
+    use ClientTrait;
     use TenancyIdTrait;
     
     /**

+ 29 - 23
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -22,11 +22,11 @@ filter:
     label_short_type: Tipo
     label_tenancy_id: Tenencia
     label_olt_device_id: OLT
-    label_pon_serial_number: Pon Serial Number
+    label_pon_serial_number: Identificador
     label_pon_port: PonPort
     label_status: Online
-    label_rx_power: RX Power
-    label_tx_power: TX Power
+    label_rx_power: RX
+    label_tx_power: TX
     label_voltage: Voltage
     label_temperature: Temperatura
     label_uptime: Uptime
@@ -46,10 +46,11 @@ filter:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: RX Power Ups
+    label_rx_power_cmts: RX Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
-    label_rx_power_olt: RX Power Port
+    label_rx_power_olt: RX Port
+    label_client_name: Cliente
 
 form:
     label_name: Nombre
@@ -77,10 +78,10 @@ form:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: RX Power Ups
+    label_rx_power_cmts: RX Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
-    label_rx_power_olt: RX Power Port
+    label_rx_power_olt: RX Port
     label_time_cm_stats: Estadísticas y SLA de CMs
 
 show:
@@ -97,8 +98,8 @@ show:
     label_pon_serial_number: Pon Serial Number
     label_pon_port: PonPort
     label_status: Online
-    label_rx_power: RX Power
-    label_tx_power: TX Power
+    label_rx_power: RX
+    label_tx_power: TX
     label_voltage: Voltage
     label_temperature: Temperatura
     label_uptime: Uptime
@@ -122,10 +123,10 @@ show:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: RX Power Ups
+    label_rx_power_cmts: RX Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
-    label_rx_power_olt: RX Power Port
+    label_rx_power_olt: RX Port
     label_port: Port
     label_olt_name: Nombre
     label_olt_host: Host
@@ -143,17 +144,17 @@ list:
     label_short_type: Tipo
     label_tenancy_id: Tenencia
     label_olt_device_id: OLT
-    label_pon_serial_number: Pon Serial Number
+    label_pon_serial_number: P. Serial Number
     label_pon_port: PonPort
     label_status: Online
-    label_rx_power: RX Power
-    label_tx_power: TX Power
+    label_rx_power: RX
+    label_tx_power: TX
     label_voltage: Voltage
     label_temperature: Temperatura
     label_uptime: Uptime
     label_updated: Actualizado
     label_bias_current: Bias Current
-    label_array_rx_power: Rx Power
+    label_array_rx_power: Rx
     label_save_historic: Guardar Históricos
     label_olt_mark: Marca
     label_olt_library: Librería
@@ -174,10 +175,10 @@ list:
     label_mac: MAC
     label_up_if: Upstream
     label_down_if: Downstream
-    label_rx_power_cmts: RX Power Ups
+    label_rx_power_cmts: RX Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflexiones Ups
-    label_rx_power_olt: RX Power Port
+    label_rx_power_olt: RX Port
     label_client: Cliente
     label_client_externalId: External ID
     label_client_name: Nombre
@@ -247,7 +248,7 @@ list:
     label_olt_name: Nombre
     label_olt_host: Host
     label_olt_model: Modelo
-    label_tx_power_average: TX Power AVG
+    label_tx_power_average: TX AVG
     label_psn: Pon Serial Number
     label_sn: Serial Number
     status_onus: Estado de ONU
@@ -264,6 +265,9 @@ list:
     label_usage_total: % sobre el total
     label_disp: Diferencia (GB)
     label_serial_number: Serial Number
+    label_client_external_id: External ID
+    label_client_name: Cliente
+    label_client_name: Dirección
 
 info:
     info_onu_1: Información básica de ONU obtenida desde API FTTH
@@ -331,7 +335,7 @@ olt_consumption: Consumo de OLT (en Gb)
 olt_report_no_data_found: No se encontraron puntos
 olt_reports: Alertas sobre la OLT (últimos 5 días)
 olt_report_no_alerts_found: No se encontraron alertas en los últimos 5 días
-onu_signals: Señal de ONU(TX Power, RX Power en OLT)
+onu_signals: Señal de ONU(TX, RX en OLT)
 action_cmts_show_report: Informe
 action_cmts_show_cablemodem: CMs
 action_cmts_show_cmtsinterface: Interfaces
@@ -341,7 +345,7 @@ cm_state_count: Cantidad
 cm_total_count: Total
 cmts_consumption: Consumo de CMTS (medido por interfaces y en Gb)
 cmts_bandwidth: Bandwidth de CMTS (medido por interfaces y en Mb)
-cm_signals: Señal de CM(TX Power, RX Power en CMTS)
+cm_signals: Señal de CM(TX, RX en CMTS)
 cmts_reports: Alertas sobre el CMTS (últimos 5 días)
 msg_no_enable_geoserver_service: El servicio Geoserver no se encuentra habilitado.
 no_defined: No reportado
@@ -358,7 +362,7 @@ interface_cms_map_title: RX de cablemodems en la Interface
 consumption_subtitle: Consumo mensual acumulado
 ponport_onu_map_title: RX de onus conectadas al PonPort
 onus_with_lat_lng: onus geolocalizadas
-tx_title: TX Power
+tx_title: TX
 memory_cards_percent: Memory Cards
 cpu_cards_percent: CPU Cards
 description: descripción
@@ -413,5 +417,7 @@ star_table_daily_header: Consumo(GB) por día
 star_table_daily_sub_header: Puede ordenarse la tabla haciendo click en la cabecera
 Map: Mapa
 Status: Estado
-RX Power: RX Power
-TX Power: TX Power
+RX: RX
+TX: TX
+sonata.filter.onu_id: Serial Number|P. Serial Number
+sonata.filter.onu_client: Nombre Cliente|External ID|Dirección

+ 132 - 0
src/StatsBundle/Traits/ClientTrait.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace StatsBundle\Traits;
+
+/**
+ * Trait ClientTrait
+ *
+ * @package StatsBundle\Traits
+ */
+trait ClientTrait
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(type="integer", nullable=true)
+     */
+    protected $clientId;
+    
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    protected $clientExternalId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    protected $clientName;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=100, nullable=true)
+     */
+    protected $clientAddress;
+
+    /**
+     * Set clientId
+     *
+     * @param integer $clientId
+     *
+     */
+    public function setClientId($clientId)
+    {
+        $this->clientId = $clientId;
+
+        return $this;
+    }
+
+    /**
+     * Get clientId
+     *
+     * @return integer
+     */
+    public function getClientId()
+    {
+        return $this->clientId;
+    }
+
+    /**
+     * Set clientExternalId
+     *
+     * @param string $clientExternalId
+     *
+     */
+    public function setClientExternalId($clientExternalId)
+    {
+        $this->clientExternalId = $clientExternalId;
+
+        return $this;
+    }
+
+    /**
+     * Get clientExternalId
+     *
+     * @return string
+     */
+    public function getClientExternalId()
+    {
+        return $this->clientExternalId;
+    }
+
+    /**
+     * Set clientName
+     *
+     * @param string $clientName
+     *
+     */
+    public function setClientName($clientName)
+    {
+        $this->clientName = $clientName;
+
+        return $this;
+    }
+
+    /**
+     * Get clienName
+     *
+     * @return string
+     */
+    public function getClientName()
+    {
+        return $this->clientName;
+    }
+
+    /**
+     * Set clientAddress
+     *
+     * @param string $clientAddress
+     *
+     */
+    public function setClientAddress($clientAddress)
+    {
+        $this->clientAddress = $clientAddress;
+
+        return $this;
+    }
+
+    /**
+     * Get clientAddress
+     *
+     * @return string
+     */
+    public function getClientAddress()
+    {
+        return $this->clientAddress;
+    }
+
+}