浏览代码

descargar archivos de la primera semana de febrero hasta el 27/01/22

Nermosis 3 年前
父节点
当前提交
cf4ce93d59
共有 2 个文件被更改,包括 36 次插入29 次删除
  1. 33 28
      application/controllers/Parser.php
  2. 3 1
      application/libraries/Parserdatabaselimpio.php

+ 33 - 28
application/controllers/Parser.php 查看文件

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
-        
21
+
22
         $this->load->model("Parser_model");
22
         $this->load->model("Parser_model");
23
     }
23
     }
24
 
24
 
62
     private function downloadProcess($urlXML)
62
     private function downloadProcess($urlXML)
63
     {
63
     {
64
         $fileName = basename($urlXML);
64
         $fileName = basename($urlXML);
65
-        $downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
66
-
67
-        if ($downladedZip) {
68
-            $zip = new ZipArchive;
69
-            if ($zip->open($this->rutaDiariaFecha . $fileName)) {
70
-                $zip->extractTo($this->rutaDiariaFecha);
71
-                $zip->close();
72
-                unlink($this->rutaDiariaFecha . $fileName);
73
-                $archivosTotales = get_filenames($this->rutaDiariaFecha);
74
-
75
-                foreach ($archivosTotales as $file) {
76
-                    $this->getFile($this->rutaDiariaFecha . $file, $file);
77
-                }
78
-
79
-            }
65
+        //$downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
66
+
67
+        /* if ($downladedZip) {
68
+        $zip = new ZipArchive;
69
+        if ($zip->open($this->rutaDiariaFecha . $fileName)) {
70
+        $zip->extractTo($this->rutaDiariaFecha);
71
+        $zip->close();
72
+        unlink($this->rutaDiariaFecha . $fileName);
73
+        $archivosTotales = get_filenames($this->rutaDiariaFecha);
74
+
75
+        foreach ($archivosTotales as $file) {
76
+        $this->getFile($this->rutaDiariaFecha . $file, $file);
77
+        }
80
 
78
 
81
         }
79
         }
82
 
80
 
83
-        /*$archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
84
-    $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
81
+        } */
82
+        $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
83
+        $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
84
+        $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
85
 
85
 
86
-    while ($nuevoAtomAttrNext !== "") {
87
-    //$aux = 0;
88
-    //while ($aux <= 3) {
86
+        while ($nuevoAtomAttrNext !== "") {
87
+            //$aux = 0;
88
+            //while ($aux <= 3) {
89
 
89
 
90
-    $fileName = basename($nuevoAtomAttrNext);
91
-    $this->downloadFile($fileName, $nuevoAtomAttrNext, $this->rutaDiariaFecha);
92
-    $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
90
+            $fileName = basename($nuevoAtomAttrNext);
91
+            $this->downloadFile($fileName, $nuevoAtomAttrNext, $this->rutaDiariaFecha);
92
+            $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
93
 
93
 
94
-    $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
95
-    //$aux++;
96
-    }*/
94
+            $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
95
+            //$aux++;
96
+        }
97
     }
97
     }
98
 
98
 
99
     private function getFile($url, $fileName)
99
     private function getFile($url, $fileName)
134
             $attrHref = $row['@attributes']['href'];
134
             $attrHref = $row['@attributes']['href'];
135
 
135
 
136
             if ($attrNext === "next") {
136
             if ($attrNext === "next") {
137
-                $enlace = $attrHref;
137
+                if (!strpos($attrHref, "20220127_")) {
138
+                    $enlace = $attrHref;
139
+                } else {
140
+                    $enlace = "";
141
+                }
142
+
138
             }
143
             }
139
         }
144
         }
140
 
145
 

+ 3 - 1
application/libraries/Parserdatabaselimpio.php 查看文件

25
 
25
 
26
                 if ($datosTablaToInsert['num_rows'] > 0) {
26
                 if ($datosTablaToInsert['num_rows'] > 0) {
27
                     if ($row->tabla_maestra == "maestro_datos_iniciales_licitacion") {
27
                     if ($row->tabla_maestra == "maestro_datos_iniciales_licitacion") {
28
-                        pretty_dump($datosTablaToInsert['datos']);
28
+                        foreach ($datosTablaToInsert['datos'] as $datos) {
29
+                            unset($datos->id);
30
+                        }
29
                     }
31
                     }
30
 
32
 
31
                     insertBucleDuplicateOnKey($datosTablaToInsert['datos'], $row->tabla_maestra, "brutoToMaestro_" . $now);
33
                     insertBucleDuplicateOnKey($datosTablaToInsert['datos'], $row->tabla_maestra, "brutoToMaestro_" . $now);