|
@@ -75,6 +75,7 @@ class Parser extends CI_Controller
|
75
|
75
|
} */
|
76
|
76
|
}
|
77
|
77
|
|
|
78
|
+ //TODO ELIMINAR PARA PROCESAR ZIPS, NO EL DIARIO
|
78
|
79
|
private function downloadProcess($urlXML)
|
79
|
80
|
{
|
80
|
81
|
|
|
@@ -96,10 +97,31 @@ class Parser extends CI_Controller
|
96
|
97
|
}
|
97
|
98
|
}
|
98
|
99
|
|
|
100
|
+ private function readNextAttribute($archivo)
|
|
101
|
+ {
|
|
102
|
+ $enlace = "";
|
|
103
|
+ foreach ($archivo['link'] as $row) {
|
|
104
|
+ $attrNext = $row['@attributes']['rel'];
|
|
105
|
+ $attrHref = $row['@attributes']['href'];
|
|
106
|
+
|
|
107
|
+ if ($attrNext === "next") {
|
|
108
|
+ if (!strpos($attrHref, "licitacionesPerfilesContratanteCompleto3_2021")) { //"20220127_")) {
|
|
109
|
+ $enlace = $attrHref;
|
|
110
|
+ } else {
|
|
111
|
+ $enlace = "";
|
|
112
|
+ }
|
|
113
|
+ //$enlace = $attrHref;
|
|
114
|
+ }
|
|
115
|
+ }
|
|
116
|
+
|
|
117
|
+ return $enlace;
|
|
118
|
+ }
|
|
119
|
+
|
99
|
120
|
private function downloadZip($urlXML)
|
100
|
121
|
{
|
|
122
|
+ $fechaDescarga = $this->getFechaForDownloadZip();
|
101
|
123
|
$fileName = basename($urlXML);
|
102
|
|
- $downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
|
|
124
|
+ $downladedZip = $this->downloadFile($fileName, $urlXML . $fechaDescarga, $this->rutaDiariaFecha);
|
103
|
125
|
|
104
|
126
|
if ($downladedZip) {
|
105
|
127
|
$zip = new ZipArchive;
|
|
@@ -112,10 +134,23 @@ class Parser extends CI_Controller
|
112
|
134
|
foreach ($archivosTotales as $file) {
|
113
|
135
|
$this->getFile($this->rutaDiariaFecha . $file, $file);
|
114
|
136
|
}
|
115
|
|
-
|
116
|
137
|
}
|
|
138
|
+ }
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ private function getFechaForDownloadZip(): String
|
|
142
|
+ {
|
|
143
|
+ $result = "_";
|
|
144
|
+ $anyo = date("Y");
|
|
145
|
+ $mes = date("m", strtotime("-1 months"));
|
|
146
|
+ $dia = date("d");
|
117
|
147
|
|
|
148
|
+ if ($dia == "01") {
|
|
149
|
+ $result .= $anyo . $mes . ".zip";
|
|
150
|
+ } else {
|
|
151
|
+ $result .= $anyo . $mes . ".zip";
|
118
|
152
|
}
|
|
153
|
+ return $result;
|
119
|
154
|
}
|
120
|
155
|
|
121
|
156
|
private function getFile($url, $fileName)
|
|
@@ -148,26 +183,6 @@ class Parser extends CI_Controller
|
148
|
183
|
file_put_contents($this->rutaDiariaFecha . "/format/" . $fileName, $closureFormat);
|
149
|
184
|
}
|
150
|
185
|
|
151
|
|
- private function readNextAttribute($archivo)
|
152
|
|
- {
|
153
|
|
- $enlace = "";
|
154
|
|
- foreach ($archivo['link'] as $row) {
|
155
|
|
- $attrNext = $row['@attributes']['rel'];
|
156
|
|
- $attrHref = $row['@attributes']['href'];
|
157
|
|
-
|
158
|
|
- if ($attrNext === "next") {
|
159
|
|
- if (!strpos($attrHref, "licitacionesPerfilesContratanteCompleto3_2021")) { //"20220127_")) {
|
160
|
|
- $enlace = $attrHref;
|
161
|
|
- } else {
|
162
|
|
- $enlace = "";
|
163
|
|
- }
|
164
|
|
- //$enlace = $attrHref;
|
165
|
|
- }
|
166
|
|
- }
|
167
|
|
-
|
168
|
|
- return $enlace;
|
169
|
|
- }
|
170
|
|
-
|
171
|
186
|
private function downloadFile($fileName, $url, $ruta)
|
172
|
187
|
{
|
173
|
188
|
if (file_put_contents($ruta . $fileName, file_get_contents($url))) {
|
|
@@ -195,8 +210,6 @@ class Parser extends CI_Controller
|
195
|
210
|
|
196
|
211
|
private function tablasCalculadas($idUltimaImportacion)
|
197
|
212
|
{
|
198
|
|
- $this->Parser_model->truncateTables("import_licitaciones_temp");
|
199
|
|
-
|
200
|
213
|
$this->Parser_model->truncateTables("vista_datos_licitacion");
|
201
|
214
|
|
202
|
215
|
$licitaciones = $this->Xlsexport_model->getLicitaciones($idUltimaImportacion);
|