Kaynağa Gözat

vincular perfil a las tablas y a los logs

Nermosis 3 yıl önce
ebeveyn
işleme
c6255e07a8

+ 1 - 1
application/controllers/Parser.php Dosyayı Görüntüle

@@ -43,7 +43,7 @@ class Parser extends CI_Controller
43 43
 
44 44
                         $this->downloadProcess($row->url_descarga);
45 45
 
46
-                        $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta);
46
+                        $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row);
47 47
                     }
48 48
                 }
49 49
             } else {

+ 28 - 25
application/libraries/ParserDatabaseBruto.php Dosyayı Görüntüle

@@ -6,6 +6,7 @@ class ParserDatabaseBruto
6 6
     protected $idLicitacion = 0;
7 7
     protected $fechaInicioParser = "";
8 8
     protected $CI;
9
+    protected $nombreLog = "setLicitacion__";
9 10
 
10 11
     public function __construct()
11 12
     {
@@ -13,13 +14,15 @@ class ParserDatabaseBruto
13 14
         $this->CI->load->model("Parser_model");
14 15
     }
15 16
 
16
-    public function setDatosParser($arrayDatosSucios, $fecha)
17
+    public function setDatosParser($arrayDatosSucios, $fecha, $datosPerfil)
17 18
     {
18 19
         $this->fechaInicioParser = $fecha;
20
+        $this->nombreLog .= $datosPerfil->prefijos_tablas . "__" . $this->fechaInicioParser;
21
+
19 22
         if (!empty($arrayDatosSucios)) {
20 23
 
21 24
             foreach ($arrayDatosSucios as $nombreArchivo => $datosArchivo) {
22
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "ARCHIVO ---" . $nombreArchivo, false);
25
+                guardar_log($this->nombreLog, "ARCHIVO ---" . $nombreArchivo, false);
23 26
 
24 27
                 foreach ($datosArchivo as $row) {
25 28
                     $idLicitacion = $this->setInicioLicitacion($row['general']);
@@ -68,10 +71,10 @@ class ParserDatabaseBruto
68 71
 
69 72
         if ($insertLicitacion) {
70 73
             $result = array("result" => true, "id" => $insertLicitacion);
71
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, "Licitacion ID " . $datosInicioLicitacion['id_licitacion'] . " - BBDD Licitación ID " . $insertLicitacion, "false");
74
+            guardar_log($this->nombreLog, "Licitacion ID " . $datosInicioLicitacion['id_licitacion'] . " - BBDD Licitación ID " . $insertLicitacion, "false");
72 75
         } else {
73 76
             $result = array("result" => true, "id" => 0);
74
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, "Licitacion ID " . $datosInicioLicitacion['id_licitacion'], "false", 2);
77
+            guardar_log($this->nombreLog, "Licitacion ID " . $datosInicioLicitacion['id_licitacion'], "false", 2);
75 78
         }
76 79
 
77 80
         return $result;
@@ -113,7 +116,7 @@ class ParserDatabaseBruto
113 116
                 unset($setInsert[$aux]['itemClassification']);
114 117
 
115 118
                 if (!empty($setInsert)) {
116
-                    $resultInsert = insertBucle($setInsert, "BRUTO_procurement_project_lot", "setLicitacion_" . $this->fechaInicioParser);
119
+                    $resultInsert = insertBucle($setInsert, "BRUTO_procurement_project_lot", $this->nombreLog);
117 120
                     if (array_key_exists('itemClassification', $row)) {
118 121
                         $this->setDatosMultiples($row, "itemClassification", "BRUTO_procurement_project_lot_item", $resultInsert, "ProcurementLotItem");
119 122
                     }
@@ -123,13 +126,13 @@ class ParserDatabaseBruto
123 126
 
124 127
             if ($resultInsert) {
125 128
                 $result = array("result" => true);
126
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "ProcurementLot Finalizada Inserción", "false");
129
+                guardar_log($this->nombreLog, "ProcurementLot Finalizada Inserción", "false");
127 130
             } else {
128 131
                 $result = array("result" => true, "id" => 0);
129
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "ProcurementLot Fallida", "false", 2);
132
+                guardar_log($this->nombreLog, "ProcurementLot Fallida", "false", 2);
130 133
             }
131 134
         } else {
132
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, "ProcurementLot vacio", "false");
135
+            guardar_log($this->nombreLog, "ProcurementLot vacio", "false");
133 136
         }
134 137
     }
135 138
 
@@ -145,7 +148,7 @@ class ParserDatabaseBruto
145 148
             $setInsert['tenderingTerms'][0]['id_ajena'] = $this->idLicitacion;
146 149
 
147 150
             if (!empty($setInsert)) {
148
-                $resultInsert = insertBucle($setInsert['tenderingTerms'], "BRUTO_tendering_terms", "setLicitacion_" . $this->fechaInicioParser);
151
+                $resultInsert = insertBucle($setInsert['tenderingTerms'], "BRUTO_tendering_terms", $this->nombreLog);
149 152
 
150 153
                 if ($resultInsert > 0) {
151 154
                     $this->setDatosMultiples($tenderingTermsInfo, 1, "BRUTO_tendering_terms_awarding_terms", $resultInsert, "TenderingTermsAwardingTerms");
@@ -160,13 +163,13 @@ class ParserDatabaseBruto
160 163
 
161 164
             if ($resultInsert) {
162 165
                 $result = array("result" => true);
163
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "TenderingTerms Finalizada Inserción", "false");
166
+                guardar_log($this->nombreLog, "TenderingTerms Finalizada Inserción", "false");
164 167
             } else {
165 168
                 $result = array("result" => true, "id" => 0);
166
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "TenderingTerms Fallida", "false", 2);
169
+                guardar_log($this->nombreLog, "TenderingTerms Fallida", "false", 2);
167 170
             }
168 171
         } else {
169
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, "TenderingTerms vacio", "false");
172
+            guardar_log($this->nombreLog, "TenderingTerms vacio", "false");
170 173
         }
171 174
     }
172 175
 
@@ -186,7 +189,7 @@ class ParserDatabaseBruto
186 189
                 unset($setInsert[$aux]['fechas']);
187 190
 
188 191
                 if (!empty($setInsert)) {
189
-                    $resultInsert = insertBucle($setInsert, "BRUTO_valid_notice_info", "setLicitacion_" . $this->fechaInicioParser);
192
+                    $resultInsert = insertBucle($setInsert, "BRUTO_valid_notice_info", $this->nombreLog);
190 193
 
191 194
                     if ($resultInsert > 0) {
192 195
                         $this->setDatosMultiples($row, "documento", "BRUTO_valid_notice_info_documento", $resultInsert, "validNoticeInfoFechas");
@@ -199,13 +202,13 @@ class ParserDatabaseBruto
199 202
 
200 203
             if ($resultInsert) {
201 204
                 $result = array("result" => true);
202
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "validNoticeInfo Finalizada Inserción", "false");
205
+                guardar_log($this->nombreLog, "validNoticeInfo Finalizada Inserción", "false");
203 206
             } else {
204 207
                 $result = array("result" => true, "id" => 0);
205
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, "validNoticeInfo Fallida", "false", 2);
208
+                guardar_log($this->nombreLog, "validNoticeInfo Fallida", "false", 2);
206 209
             }
207 210
         } else {
208
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, "validNoticeInfo vacio", "false");
211
+            guardar_log($this->nombreLog, "validNoticeInfo vacio", "false");
209 212
         }
210 213
     }
211 214
 
@@ -221,15 +224,15 @@ class ParserDatabaseBruto
221 224
                 $arrayInsertar[0]['id_ajena'] = $idAjena;
222 225
             }
223 226
 
224
-            $insertedId = insertBucle($arrayInsertar, $tabla, "setLicitacion_" . $this->fechaInicioParser);
227
+            $insertedId = insertBucle($arrayInsertar, $tabla, $this->nombreLog);
225 228
 
226 229
             if ($insertedId == 0) {
227
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Fallido", "false");
230
+                guardar_log($this->nombreLog, $nodoLog . " Fallido", "false");
228 231
             } else {
229
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Finalizada Inserción", "false");
232
+                guardar_log($this->nombreLog, $nodoLog . " Finalizada Inserción", "false");
230 233
             }
231 234
         } else {
232
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
235
+            guardar_log($this->nombreLog, $nodoLog . " vacio", "false");
233 236
         }
234 237
 
235 238
         return $insertedId;
@@ -254,21 +257,21 @@ class ParserDatabaseBruto
254 257
                 }
255 258
 
256 259
                 if (!empty($setInsert)) {
257
-                    $resultInsert = insertBucle($setInsert, $tabla, "setLicitacion_" . $this->fechaInicioParser);
260
+                    $resultInsert = insertBucle($setInsert, $tabla, $this->nombreLog);
258 261
                 }
259 262
 
260 263
                 if ($resultInsert) {
261 264
                     $result = array("result" => true);
262
-                    guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Finalizada Inserción", "false");
265
+                    guardar_log($this->nombreLog, $nodoLog . " Finalizada Inserción", "false");
263 266
                 } else {
264 267
                     $result = array("result" => true, "id" => 0);
265
-                    guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Fallida", "false", 2);
268
+                    guardar_log($this->nombreLog, $nodoLog . " Fallida", "false", 2);
266 269
                 }
267 270
             } else {
268
-                guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
271
+                guardar_log($this->nombreLog, $nodoLog . " vacio", "false");
269 272
             }
270 273
         } else {
271
-            guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
274
+            guardar_log($this->nombreLog, $nodoLog . " vacio", "false");
272 275
         }
273 276
     }
274 277
 

+ 6 - 6
application/libraries/ParserFile.php Dosyayı Görüntüle

@@ -17,12 +17,12 @@ class ParserFile
17 17
         $this->CI->load->library('parserdatabasebruto');
18 18
     }
19 19
 
20
-    public function index($rutaDiariaDownloader, $fechaInicioParser)
20
+    public function index($rutaDiariaDownloader, $fechaInicioParser, $datosPerfil)
21 21
     {
22 22
         $this->rutaDiaria = $rutaDiariaDownloader . "/format/";
23 23
         $files = get_filenames($this->rutaDiaria, true);
24 24
 
25
-        guardar_log("setLicitacion_" . $fechaInicioParser, "----------------------------------", false);
25
+        guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "----------------------------------", false);
26 26
 
27 27
         $resultEntries = array();
28 28
         foreach ($files as $file) {
@@ -34,7 +34,7 @@ class ParserFile
34 34
             foreach ($xml->entry as $clave => $row) {
35 35
                 $arrayDeletedEntries = $xml->children('at', true);
36 36
 
37
-                $resultEntries[$filename][$aux]['general'] = $this->nodoEntry($row);
37
+                $resultEntries[$filename][$aux]['general'] = $this->nodoEntry($row, $datosPerfil->id);
38 38
 
39 39
                 $resultEntries[$filename][$aux]['contractInfo'] = $this->nodoContractFolderStatus($row); //
40 40
 
@@ -70,12 +70,12 @@ class ParserFile
70 70
             file_put_contents($this->rutaDiaria . "/text_" . $filename . ".txt", $str);
71 71
         }
72 72
 
73
-        $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser);
73
+        $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser, $datosPerfil);
74 74
 
75 75
         return;
76 76
     }
77 77
 
78
-    private function nodoEntry($xml)
78
+    private function nodoEntry($xml, $tipoPerfil)
79 79
     {
80 80
         $resultEntries = array();
81 81
 
@@ -85,7 +85,7 @@ class ParserFile
85 85
         $resultEntries['summary'] = (string) $xml->summary;
86 86
         $resultEntries['title'] = (string) $xml->title;
87 87
         $resultEntries['updated'] = (string) $xml->updated;
88
-        $resultEntries['tipo_perfil_licitacion'] = 1;
88
+        $resultEntries['tipo_perfil_licitacion'] = $tipoPerfil;
89 89
         return $resultEntries;
90 90
     }
91 91