Przeglądaj źródła

al acabar de leer un archivo, insertar bruto y posteriormente a limpio

Nermosis 3 lat temu
rodzic
commit
2adf405a87

+ 1 - 2
application/controllers/Parser.php Wyświetl plik

18
         $this->load->helper('file');
18
         $this->load->helper('file');
19
         $this->load->helper('xml');
19
         $this->load->helper('xml');
20
         $this->load->library('parserfile');
20
         $this->load->library('parserfile');
21
-        $this->load->library('parserdatabaselimpio');
21
+        
22
         $this->load->model("Parser_model");
22
         $this->load->model("Parser_model");
23
     }
23
     }
24
 
24
 
48
                     }
48
                     }
49
                 }
49
                 }
50
 
50
 
51
-                $this->parserdatabaselimpio->index();
52
             } else {
51
             } else {
53
                 echo "EXISTE UN CRON EN MARCHA.";
52
                 echo "EXISTE UN CRON EN MARCHA.";
54
             }
53
             }

+ 1 - 1
application/helpers/funciones_helper.php Wyświetl plik

40
 
40
 
41
         //SI ES NECESARIO SE MUESTRA POR PANTALLA
41
         //SI ES NECESARIO SE MUESTRA POR PANTALLA
42
         if ($echo == true) {
42
         if ($echo == true) {
43
-            echo $registro . '<br>';
43
+            //echo $registro . '<br>';
44
         }
44
         }
45
 
45
 
46
         return $texto . '<br>';
46
         return $texto . '<br>';

+ 3 - 1
application/libraries/ParserDatabaseBruto.php Wyświetl plik

70
         $insertLicitacion = $this->CI->Parser_model->setInicioLicitacion($datosInicioLicitacion);
70
         $insertLicitacion = $this->CI->Parser_model->setInicioLicitacion($datosInicioLicitacion);
71
 
71
 
72
         if ($insertLicitacion) {
72
         if ($insertLicitacion) {
73
-            $result = array("result" => true, "id" => $insertLicitacion);
73
+            $result = array("result" => true, "id" => $datosInicioLicitacion['id_licitacion']);
74
             guardar_log($this->nombreLog, "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");
75
         } else {
75
         } else {
76
             $result = array("result" => true, "id" => 0);
76
             $result = array("result" => true, "id" => 0);
225
                 $arrayInsertar[0][$txtIdAjena] = $idAjena;
225
                 $arrayInsertar[0][$txtIdAjena] = $idAjena;
226
                 $arrayInsertar[0]["fecha_creacion_log"] = $this->fechaInicioParser;
226
                 $arrayInsertar[0]["fecha_creacion_log"] = $this->fechaInicioParser;
227
             }
227
             }
228
+            unset($arrayInsertar[0]['id']);
228
 
229
 
229
             $insertedId = insertBucle($arrayInsertar, $tabla, $this->nombreLog);
230
             $insertedId = insertBucle($arrayInsertar, $tabla, $this->nombreLog);
230
 
231
 
254
                     if ($idAjena > 0) {
255
                     if ($idAjena > 0) {
255
                         $setInsert[$aux][$txtIdAjena] = $idAjena;
256
                         $setInsert[$aux][$txtIdAjena] = $idAjena;
256
                         $setInsert[$aux]["fecha_creacion_log"] = $this->fechaInicioParser;
257
                         $setInsert[$aux]["fecha_creacion_log"] = $this->fechaInicioParser;
258
+                        unset($setInsert[$aux]['id']);
257
                     }
259
                     }
258
 
260
 
259
                     $aux++;
261
                     $aux++;

+ 6 - 4
application/libraries/ParserFile.php Wyświetl plik

19
         $this->CI = &get_instance();
19
         $this->CI = &get_instance();
20
         $this->CI->load->helper('file');
20
         $this->CI->load->helper('file');
21
         $this->CI->load->library('parserdatabasebruto');
21
         $this->CI->load->library('parserdatabasebruto');
22
+        $this->CI->load->library('parserdatabaselimpio');
22
     }
23
     }
23
 
24
 
24
     public function index($rutaDiariaDownloader, $fechaInicioParser, $datosPerfil)
25
     public function index($rutaDiariaDownloader, $fechaInicioParser, $datosPerfil)
28
 
29
 
29
         guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "----------------------------------", false);
30
         guardar_log("setLicitacion__" . $datosPerfil->prefijos_tablas . "__" . $fechaInicioParser, "----------------------------------", false);
30
 
31
 
31
-        $resultEntries = array();
32
         foreach ($files as $file) {
32
         foreach ($files as $file) {
33
-
33
+            $resultEntries = array();
34
             $entrada = file_get_contents($file);
34
             $entrada = file_get_contents($file);
35
             $xml = simplexml_load_string($entrada);
35
             $xml = simplexml_load_string($entrada);
36
             $filename = basename($file);
36
             $filename = basename($file);
69
                 $aux++;
69
                 $aux++;
70
             }
70
             }
71
 
71
 
72
+            $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser, $datosPerfil);
73
+
74
+            $this->CI->parserdatabaselimpio->index();
75
+
72
             //$str = print_r($resultEntries, true);
76
             //$str = print_r($resultEntries, true);
73
 
77
 
74
             //file_put_contents($this->rutaDiaria . "/text_" . $filename . ".txt", $str);
78
             //file_put_contents($this->rutaDiaria . "/text_" . $filename . ".txt", $str);
75
         }
79
         }
76
 
80
 
77
-        $this->CI->parserdatabasebruto->setDatosParser($resultEntries, $fechaInicioParser, $datosPerfil);
78
-
79
         return;
81
         return;
80
     }
82
     }
81
 
83
 

+ 4 - 1
application/libraries/Parserdatabaselimpio.php Wyświetl plik

4
 class Parserdatabaselimpio
4
 class Parserdatabaselimpio
5
 {
5
 {
6
 
6
 
7
-    //TODO: Vincular nombre de columnas en bruto con nombres de columnas en maestros
8
     protected $CI;
7
     protected $CI;
9
 
8
 
10
     public function __construct()
9
     public function __construct()
25
                 $datosTablaToInsert = $this->CI->Parser_model->getDatosBrutos($row->tabla_sucia);
24
                 $datosTablaToInsert = $this->CI->Parser_model->getDatosBrutos($row->tabla_sucia);
26
 
25
 
27
                 if ($datosTablaToInsert['num_rows'] > 0) {
26
                 if ($datosTablaToInsert['num_rows'] > 0) {
27
+                    if ($row->tabla_maestra == "maestro_datos_iniciales_licitacion") {
28
+                        pretty_dump($datosTablaToInsert['datos']);
29
+                    }
30
+
28
                     insertBucleDuplicateOnKey($datosTablaToInsert['datos'], $row->tabla_maestra, "brutoToMaestro_" . $now);
31
                     insertBucleDuplicateOnKey($datosTablaToInsert['datos'], $row->tabla_maestra, "brutoToMaestro_" . $now);
29
                 }
32
                 }
30
             }
33
             }