ソースを参照

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,6 +11,7 @@ class Parser extends CI_Controller
11 11
 
12 12
     protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/";
13 13
     protected $enlaceAtom = "";
14
+    protected $fechaCreacionLog = "";
14 15
 
15 16
     public function __construct()
16 17
     {
@@ -31,10 +32,17 @@ class Parser extends CI_Controller
31 32
 
32 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 41
                 $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
35 42
 
36 43
                 foreach ($resultSetPerfiles['datos'] as $row) {
37 44
                     $fechaCarpeta = date("Y-m-d_H-i-s");
45
+                    $this->fechaCreacionLog = $fechaCarpeta;
38 46
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
39 47
 
40 48
                     $this->newFolder($rutaPerfil);
@@ -57,6 +65,8 @@ class Parser extends CI_Controller
57 65
 
58 66
         $this->Parser_model->stopParser();
59 67
 
68
+        $this->tablasCalculadas($this->fechaCreacionLog);
69
+
60 70
         /*$resultSetPerfiles = $this->Parser_model->getUrlArchivos();
61 71
     foreach ($resultSetPerfiles['datos'] as $row) {
62 72
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-10_09-02-17", date("Y-m-n"), $row);
@@ -176,4 +186,16 @@ class Parser extends CI_Controller
176 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,6 +82,11 @@ class Parser_model extends CI_Model
82 82
         return $datos;
83 83
     }
84 84
 
85
+    public function truncateTables($tabla)
86
+    {
87
+        $this->db->truncate($tabla);
88
+    }
89
+
85 90
     public function getDatosBrutos($tabla)
86 91
     {
87 92
         $sql = "SELECT * FROM $tabla";