瀏覽代碼

Actualizado el comando

Maximiliano Schvindt 7 年之前
父節點
當前提交
af2f2956de
共有 1 個文件被更改,包括 8 次插入23 次删除
  1. 8 23
      src/StatsBundle/Command/StatsGeoOnuCommand.php

+ 8 - 23
src/StatsBundle/Command/StatsGeoOnuCommand.php

@@ -120,8 +120,7 @@ class StatsGeoOnuCommand extends BaseCommand
 
                 $geoJson = json_encode($geoData);
 
-                $file_name = "onu_stats_tenancy_{$tenancy}".".json";
-                $shape_name = "onu_stats_tenancy_{$tenancy}".".shp";
+                $file_name = "onu_stats_tenancy_{$tenancy}";
                 $dir = "$path/deviceServer_{$oltServerId}";
 
                 if(!is_dir($dir)) {
@@ -129,12 +128,12 @@ class StatsGeoOnuCommand extends BaseCommand
                     chown($dir, "www-data");
                 }
                 
-                $file = fopen($dir."/".$file_name, "a+");
+                $file = fopen($dir."/"."{$file_name}.json", "a+");
                 fwrite($file, $geoJson);
                 
                 
-                if($this->getContainer()->getParameter('geoserver_service') && file_exists($dir."/".$file_name)) {
-                    $this->generateShapes($dir, $file_name, $shape_name);
+                if($this->getContainer()->getParameter('geoserver_service') && file_exists($dir."/"."{$file_name}.json")) {
+                    $this->generateShapes($dir, $file_name);
                     $workspace = "deviceServer_{$oltServerId}";
 
                     $geoserver = $this->getContainer()->get('geoserver.api');
@@ -146,30 +145,16 @@ class StatsGeoOnuCommand extends BaseCommand
         }
     }
 
-    public function generateShapes($dir, $file_name, $shape_name) 
+    public function generateShapes($dir, $file_name) 
     {
-        $process = new Process("ogr2ogr -f 'ESRI Shapefile' {$dir}/{$shape_name} {$dir}/{$file_name}");
+        $process = new Process("ogr2ogr -f 'ESRI Shapefile' {$dir}/{$file_name}.shp {$dir}/{$file_name}.json");
 
-        //$process->run();
-        $process->start();
-
-        while ($process->isRunning()) {
-            // waiting for process to finish
-        }
-                    
+        $process->run();
+        //while ($process->isRunning()) {print_r("Procesando..".PHP_EOL);}
         if (!$process->isSuccessful()) {throw new ProcessFailedException($process);}
                     
         echo $process->getOutput();
 
-        $files = scandir($dir); 
-        foreach($files as $file)
-        {
-            if(is_file($dir."/".$file)) {
-                chmod($dir."/".$file, 0777);
-                chgrp($dir."/".$file, "www-data");
-                chown($dir."/".$file, "www-data");
-            }
-        }
     }
 
     public function getDevices($oltServerId)