Преглед изворни кода

Truncate tablas brutas y tablas calculadas. After insert tablas maestras, calcular e insert tabla calculada

Christian пре 3 година
родитељ
комит
9522bf6791
2 измењених фајлова са 27 додато и 0 уклоњено
  1. 22 0
      application/controllers/Parser.php
  2. 5 0
      application/models/Parser_model.php

+ 22 - 0
application/controllers/Parser.php Прегледај датотеку

11
 
11
 
12
     protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/";
12
     protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/";
13
     protected $enlaceAtom = "";
13
     protected $enlaceAtom = "";
14
+    protected $fechaCreacionLog = "";
14
 
15
 
15
     public function __construct()
16
     public function __construct()
16
     {
17
     {
31
 
32
 
32
                 $this->Parser_model->inicioParser();
33
                 $this->Parser_model->inicioParser();
33
 
34
 
35
+                $tablasTruncate = $this->Parser_model->getMapaTablas();
36
+
37
+                foreach ($tablasTruncate['datos'] as $row) {
38
+                    $this->Parser_model->truncateTables($row->tabla_sucia);
39
+                }
40
+
34
                 $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
41
                 $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
35
 
42
 
36
                 foreach ($resultSetPerfiles['datos'] as $row) {
43
                 foreach ($resultSetPerfiles['datos'] as $row) {
37
                     $fechaCarpeta = date("Y-m-d_H-i-s");
44
                     $fechaCarpeta = date("Y-m-d_H-i-s");
45
+                    $this->fechaCreacionLog = $fechaCarpeta;
38
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
46
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
39
 
47
 
40
                     $this->newFolder($rutaPerfil);
48
                     $this->newFolder($rutaPerfil);
57
 
65
 
58
         $this->Parser_model->stopParser();
66
         $this->Parser_model->stopParser();
59
 
67
 
68
+        $this->tablasCalculadas($this->fechaCreacionLog);
69
+
60
         /*$resultSetPerfiles = $this->Parser_model->getUrlArchivos();
70
         /*$resultSetPerfiles = $this->Parser_model->getUrlArchivos();
61
     foreach ($resultSetPerfiles['datos'] as $row) {
71
     foreach ($resultSetPerfiles['datos'] as $row) {
62
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-10_09-02-17", date("Y-m-n"), $row);
72
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-10_09-02-17", date("Y-m-n"), $row);
176
         return $result;
186
         return $result;
177
     }
187
     }
178
 
188
 
189
+    private function tablasCalculadas($fechaInicioParser)
190
+    {
191
+        $this->Parser_model->truncateTables("import_licitaciones_temp");
192
+
193
+        $this->Parser_model->truncateTables("vista_datos_licitacion");
194
+
195
+        $licitaciones = $this->Xlsexport_model->getLicitaciones("HAVING LI.fecha_creacion_log = '" . $fechaInicioParser . "'");
196
+
197
+        insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
198
+
199
+    }
200
+
179
 }
201
 }

+ 5 - 0
application/models/Parser_model.php Прегледај датотеку

82
         return $datos;
82
         return $datos;
83
     }
83
     }
84
 
84
 
85
+    public function truncateTables($tabla)
86
+    {
87
+        $this->db->truncate($tabla);
88
+    }
89
+
85
     public function getDatosBrutos($tabla)
90
     public function getDatosBrutos($tabla)
86
     {
91
     {
87
         $sql = "SELECT * FROM $tabla";
92
         $sql = "SELECT * FROM $tabla";