|
@@ -81,12 +81,13 @@ class ONUController extends Controller
|
|
|
|
|
|
/*
|
|
|
* Queda pendiente enviar un comando para actualizar masivamente los devices
|
|
|
- *
|
|
|
+ * /admin/ftth/onu/onu_save?_=1508847664462&limit=100&mapId=3&offset=0&clientId=1
|
|
|
*/
|
|
|
public function onuSaveAction(Request $request)
|
|
|
{
|
|
|
$em = $this->get('doctrine')->getManager();
|
|
|
$webservice = $this->get("webservice");
|
|
|
+ $tenancy_service = $this->get("base_tenancy.tenancy_service");
|
|
|
|
|
|
$mapId = $request->get('mapId');
|
|
|
$clientId = $request->get('clientId');
|
|
@@ -115,38 +116,37 @@ class ONUController extends Controller
|
|
|
$object = $em->getRepository("FTTHBundle:ONU")->findOneByPonSerialNumber($onu['text']);
|
|
|
if(is_null($object)) {
|
|
|
$object = new ONU();
|
|
|
- $object->setClientId(1);
|
|
|
- $object->setTenancyId(1);
|
|
|
+ $object->setClientId($clientId);
|
|
|
+ $object->setTenancyId($tenancy_service->getTenancyIdCurrent());
|
|
|
$object->setPonSerialNumber($onu['text']);
|
|
|
$em->persist($object);
|
|
|
+ $em->flush();
|
|
|
$return[] = "ONU create {$onu['text']}";
|
|
|
}
|
|
|
- $location = $object->getLocation();
|
|
|
-
|
|
|
- $data = json_decode($onu['vector']['data'],true);
|
|
|
- $mapLocation = $data[0];
|
|
|
-
|
|
|
- $mapLocation['zoom'] = 17;
|
|
|
- $mapLocation['onu'] = "{$object->getPonSerialNumber()}";
|
|
|
- $mapLocation['map_object_id'] = $onu['id'];
|
|
|
|
|
|
+ $location = $object->getLocation();
|
|
|
$action = "update";
|
|
|
if(is_null($location)) {
|
|
|
$location = new Location();
|
|
|
$em->persist($location);
|
|
|
- $object->setLocation($location);
|
|
|
- $em->persist($object);
|
|
|
$em->flush();
|
|
|
+ $object->setLocation($location);
|
|
|
$action = "create";
|
|
|
}
|
|
|
|
|
|
- $return[] = "LOCATION (id {$location->getId()}) {$action} - ONU (id {$object->getId()}) {$onu['text']} - ".json_encode($mapLocation);
|
|
|
+ $data = json_decode($onu['vector']['data'],true);
|
|
|
+ $mapLocation = $data[0];
|
|
|
+ $mapLocation['zoom'] = 17;
|
|
|
+ $mapLocation['onu'] = "{$object->getPonSerialNumber()}";
|
|
|
+ $mapLocation['map_object_id'] = $onu['id'];
|
|
|
|
|
|
$location->setJsonExtraData($mapLocation);
|
|
|
$location->setObjectTypeId($objectTypeId);
|
|
|
$location->setMapId($mapId);
|
|
|
|
|
|
$em->persist($location);
|
|
|
+
|
|
|
+ $return[] = "LOCATION (id {$location->getId()}) {$action} - ONU (id {$object->getId()}) {$onu['text']} - ".json_encode($mapLocation);
|
|
|
}
|
|
|
|
|
|
$em->flush();
|