Selaa lähdekoodia

Cambios para no sobrecargar RAM

Christian 3 vuotta sitten
vanhempi
commit
d1ab357d9f
1 muutettua tiedostoa jossa 35 lisäystä ja 38 poistoa
  1. 35 38
      application/libraries/ParserFile.php

+ 35 - 38
application/libraries/ParserFile.php Näytä tiedosto

@@ -29,9 +29,13 @@ class ParserFile
29 29
         $this->CI->load->library('parserdatabaselimpio');
30 30
     }
31 31
 
32
+    public function __destruct()
33
+    {
34
+    }
35
+
32 36
     public function index($rutaDiariaDownloader, $fechaInicioParser, $datosPerfil)
33 37
     {
34
-        $this->rutaDiaria = $rutaDiariaDownloader . "/format/";
38
+        $this->rutaDiaria = $rutaDiariaDownloader . "/format";
35 39
         $this->fechaInicioParser = $fechaInicioParser;
36 40
         $files = get_filenames($this->rutaDiaria, true);
37 41
         $filename = "";
@@ -39,24 +43,16 @@ class ParserFile
39 43
         $json = "";
40 44
         $array = "";
41 45
         $aux = 0;
42
-        $this->arrayLicitacionExiste = array();
43 46
         $resultEntries = array();
44
-
45
-        guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "----------------------------------", false);
46
-
47
-        guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA Inicio archivos: " . $this->echo_memory_usage(), false);
47
+        $contador = 0;
48 48
 
49 49
         foreach ($files as $file) {
50 50
             $filename = basename($file);
51
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA leyendo archivo - " . $filename . "-" . $this->echo_memory_usage(), false);
52
-            $xml = simplexml_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA);
53
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA xml- " . $filename . "-" . $this->echo_memory_usage(), false);
54
-            //$json = ;
55
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA json_encode- " . $filename . "-" . $this->echo_memory_usage(), false);
51
+            $contador++;
52
+            $entrada = file_get_contents($file);
53
+            $xml = simplexml_load_string($entrada, "SimpleXMLElement", LIBXML_NOCDATA);
56 54
             $array = json_decode(json_encode($xml), true);
57
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA json_decode- " . $filename . "-" . $this->echo_memory_usage(), false);
58
-            //$array = (array) $xml;
59
-            //var_dump($array);
55
+
60 56
             $aux = 0;
61 57
 
62 58
             $tablasTruncate = $this->CI->Parser_model->getMapaTablas();
@@ -76,53 +72,54 @@ class ParserFile
76 72
 
77 73
                     $resultEntries[$filename]['general'][$aux] = $this->nodoEntry($row, $xml->entry[$clave], $datosPerfil->id);
78 74
 
79
-                    $resultEntries[$filename]['contractInfo'][$aux] = $this->nodoContractFolderStatus($row, $xml->entry[$clave]);
75
+                    $contractFolder = $this->nodoContractFolderStatus($row, $xml->entry[$clave]);
80 76
 
81
-                    $resultEntries[$filename]['locatedContractingParty'][$aux] = $this->nodoLocatedContractingParty($row, $xml->entry[$clave]);
77
+                    if ($contractFolder) {
78
+                        $resultEntries[$filename]['contractInfo'][$aux] = $contractFolder;
82 79
 
83
-                    $resultEntries[$filename]['party'][$aux] = $this->nodoParty($row, $xml->entry[$clave]);
80
+                        $resultEntries[$filename]['locatedContractingParty'][$aux] = $this->nodoLocatedContractingParty($row, $xml->entry[$clave]);
84 81
 
85
-                    $resultEntries[$filename]['procurementProject'][$aux] = $this->nodoPresupuesto($row, $xml->entry[$clave]);
82
+                        $resultEntries[$filename]['party'][$aux] = $this->nodoParty($row, $xml->entry[$clave]);
86 83
 
87
-                    $resultEntries[$filename]['procurementProjectLot'][$aux] = $this->nodoProcurementProjectLot($row, $xml->entry[$clave]);
84
+                        $resultEntries[$filename]['procurementProject'][$aux] = $this->nodoPresupuesto($row, $xml->entry[$clave]);
88 85
 
89
-                    $resultEntries[$filename]['tenderingTerms'][$aux] = $this->nodoTenderingTerms($row, $xml->entry[$clave]);
86
+                        $resultEntries[$filename]['procurementProjectLot'][$aux] = $this->nodoProcurementProjectLot($row, $xml->entry[$clave]);
90 87
 
91
-                    $resultEntries[$filename]['tenderingProcess'][$aux] = $this->nodoTenderingProcess($row, $xml->entry[$clave]);
88
+                        $resultEntries[$filename]['tenderingTerms'][$aux] = $this->nodoTenderingTerms($row, $xml->entry[$clave]);
92 89
 
93
-                    $resultEntries[$filename]['tenderingResult'][$aux] = $this->nodoTenderResult($row, $xml->entry[$clave]);
90
+                        $resultEntries[$filename]['tenderingProcess'][$aux] = $this->nodoTenderingProcess($row, $xml->entry[$clave]);
94 91
 
95
-                    //$resultEntries[$filename]['validNoticeInfo'][$aux] = $this->nodoValidNoticeInfo($row);
92
+                        $resultEntries[$filename]['tenderingResult'][$aux] = $this->nodoTenderResult($row, $xml->entry[$clave]);
96 93
 
97
-                    $resultEntries[$filename]['legalDocs'][$aux] = $this->nodoLegalDoc($row, $xml->entry[$clave]);
94
+                        //$resultEntries[$filename]['validNoticeInfo'][$aux] = $this->nodoValidNoticeInfo($row);
98 95
 
99
-                    $resultEntries[$filename]['technicalDocs'][$aux] = $this->nodoTechnicalDocumentReference($row, $xml->entry[$clave]);
96
+                        $resultEntries[$filename]['legalDocs'][$aux] = $this->nodoLegalDoc($row, $xml->entry[$clave]);
100 97
 
101
-                    $resultEntries[$filename]['generalDocs'][$aux] = $this->nodoGeneralDocuments($row, $xml->entry[$clave]);
98
+                        $resultEntries[$filename]['technicalDocs'][$aux] = $this->nodoTechnicalDocumentReference($row, $xml->entry[$clave]);
102 99
 
103
-                    $resultEntries[$filename]['additionalDocs'][$aux] = $this->nodoAdditionalDocumentReference($row, $xml->entry[$clave]);
100
+                        $resultEntries[$filename]['generalDocs'][$aux] = $this->nodoGeneralDocuments($row, $xml->entry[$clave]);
101
+
102
+                        $resultEntries[$filename]['additionalDocs'][$aux] = $this->nodoAdditionalDocumentReference($row, $xml->entry[$clave]);
103
+
104
+                        $aux++;
105
+                    } else {
106
+                        $var = 1;
107
+                    }
104 108
 
105
-                    $aux++;
106 109
                 }
107 110
 
108 111
                 //$this->recurseXML($array['entry'], true);
109 112
             }
110
-            //guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, count($resultEntries));
111
-            //guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, count($resultEntries[$filename]));
112
-            //guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA insertando tabla bruta - " . $filename . "-" . $this->echo_memory_usage(), false);
113
+
113 114
             $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser, $datosPerfil);
114 115
             unset($resultEntries[$filename]);
115 116
             unset($resultEntries);
116
-            unset($this->arrayLicitacionExiste);
117
+            $this->arrayLicitacionExiste = array();
117 118
             unset($xml);
118
-            //unset($json);
119 119
             unset($array);
120
-
121 120
             unset($tablasTruncate);
122
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA borrando arrays - " . $filename . "-" . $this->echo_memory_usage(), false);
123 121
             $this->CI->parserdatabaselimpio->index($fechaInicioParser, $filename);
124
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "MEMORIA insertando maestros - " . $filename . "-" . $this->echo_memory_usage(), false);
125
-            guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "--------------------------------" . $this->echo_memory_usage(), false);
122
+
126 123
             gc_mem_caches();
127 124
             gc_collect_cycles();
128 125
 
@@ -154,7 +151,7 @@ class ParserFile
154 151
         $this->fechaUpdateLicitacion = $fechaUpdated;
155 152
         $result = false;
156 153
 
157
-        if ($idLicitacion == "9282002") {
154
+        if ($idLicitacion == "") {
158 155
             $var = 1;
159 156
         }
160 157