소스 검색

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

Nermosis 3 년 전
부모
커밋
2adf405a87

+ 1 - 2
application/controllers/Parser.php 파일 보기

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

+ 1 - 1
application/helpers/funciones_helper.php 파일 보기

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

+ 3 - 1
application/libraries/ParserDatabaseBruto.php 파일 보기

@@ -70,7 +70,7 @@ class ParserDatabaseBruto
70 70
         $insertLicitacion = $this->CI->Parser_model->setInicioLicitacion($datosInicioLicitacion);
71 71
 
72 72
         if ($insertLicitacion) {
73
-            $result = array("result" => true, "id" => $insertLicitacion);
73
+            $result = array("result" => true, "id" => $datosInicioLicitacion['id_licitacion']);
74 74
             guardar_log($this->nombreLog, "Licitacion ID " . $datosInicioLicitacion['id_licitacion'] . " - BBDD Licitación ID " . $insertLicitacion, "false");
75 75
         } else {
76 76
             $result = array("result" => true, "id" => 0);
@@ -225,6 +225,7 @@ class ParserDatabaseBruto
225 225
                 $arrayInsertar[0][$txtIdAjena] = $idAjena;
226 226
                 $arrayInsertar[0]["fecha_creacion_log"] = $this->fechaInicioParser;
227 227
             }
228
+            unset($arrayInsertar[0]['id']);
228 229
 
229 230
             $insertedId = insertBucle($arrayInsertar, $tabla, $this->nombreLog);
230 231
 
@@ -254,6 +255,7 @@ class ParserDatabaseBruto
254 255
                     if ($idAjena > 0) {
255 256
                         $setInsert[$aux][$txtIdAjena] = $idAjena;
256 257
                         $setInsert[$aux]["fecha_creacion_log"] = $this->fechaInicioParser;
258
+                        unset($setInsert[$aux]['id']);
257 259
                     }
258 260
 
259 261
                     $aux++;

+ 6 - 4
application/libraries/ParserFile.php 파일 보기

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

+ 4 - 1
application/libraries/Parserdatabaselimpio.php 파일 보기

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