Selaa lähdekoodia

Parametrizacion fechas importacion, para crear vista de exportar excel

Nermosis 3 vuotta sitten
vanhempi
commit
9f50851540

+ 15 - 7
application/controllers/Parser.php Näytä tiedosto

@@ -26,16 +26,19 @@ class Parser extends CI_Controller
26 26
     public function index()
27 27
     {
28 28
         $existCronRun = $this->Parser_model->existCronRun();
29
-
29
+        $fechaCarpeta = "";
30 30
         if ($existCronRun['num_rows'] > 0) {
31 31
             if ($existCronRun['datos']->cron_ejecucion == 0) {
32 32
 
33 33
                 $this->Parser_model->inicioParser();
34 34
 
35 35
                 $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
36
+                $fechaCarpeta = date("Y-m-d_H-i-s");
37
+                $fechaImportacionLog = date("Y-m-d H:i:s");
36 38
 
37 39
                 foreach ($resultSetPerfiles['datos'] as $row) {
38
-                    $fechaCarpeta = date("Y-m-d_H-i-s");
40
+
41
+                    $idUltimaImportacion = $this->Parser_model->setFechaNuevaImportacion($fechaImportacionLog);
39 42
                     $this->fechaCreacionLog = $fechaCarpeta;
40 43
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
41 44
 
@@ -47,9 +50,16 @@ class Parser extends CI_Controller
47 50
                         //$this->downloadProcess($row->url_descarga);
48 51
                         $this->downloadZip($row->url_descarga);
49 52
                     }
53
+
54
+                    $files = get_filenames($this->rutaDiariaFecha . "/format");
55
+                    emailInicioProcesoDescarga($fechaImportacionLog, $files);
56
+
57
+                    $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row, $idUltimaImportacion);
50 58
                 }
51 59
 
52
-                $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row);
60
+                $this->tablasCalculadas($idUltimaImportacion);
61
+
62
+                emailFinProcesoDescarga($fechaImportacionLog);
53 63
 
54 64
             } else {
55 65
                 echo "EXISTE UN CRON EN MARCHA.";
@@ -60,8 +70,6 @@ class Parser extends CI_Controller
60 70
 
61 71
         $this->Parser_model->stopParser();
62 72
 
63
-        $this->tablasCalculadas($this->fechaCreacionLog);
64
-
65 73
         /* $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
66 74
     foreach ($resultSetPerfiles['datos'] as $row) {
67 75
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-17_20-38-16", date("Y-m-d"), $row);
@@ -186,13 +194,13 @@ class Parser extends CI_Controller
186 194
         return $result;
187 195
     }
188 196
 
189
-    private function tablasCalculadas($fechaInicioParser)
197
+    private function tablasCalculadas($idUltimaImportacion)
190 198
     {
191 199
         $this->Parser_model->truncateTables("import_licitaciones_temp");
192 200
 
193 201
         $this->Parser_model->truncateTables("vista_datos_licitacion");
194 202
 
195
-        $licitaciones = $this->Xlsexport_model->getLicitaciones("HAVING LI.fecha_creacion_log = '" . $fechaInicioParser . "'");
203
+        $licitaciones = $this->Xlsexport_model->getLicitaciones($idUltimaImportacion);
196 204
 
197 205
         insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
198 206
 

+ 9 - 0
application/models/Parser_model.php Näytä tiedosto

@@ -134,6 +134,15 @@ class Parser_model extends CI_Model
134 134
 
135 135
     }
136 136
 
137
+    public function setFechaNuevaImportacion($fechaImportacionLog)
138
+    {
139
+        $data = array(
140
+            "fecha" => $fechaImportacionLog,
141
+        );
142
+        $this->db->insert('fecha_importaciones', $data);
143
+        return $this->db->insert_id();
144
+    }
145
+
137 146
 }
138 147
 
139 148
 /* End of file Parser_model.php */

+ 21 - 25
application/models/Xlsexport_model.php Näytä tiedosto

@@ -19,7 +19,7 @@ defined('BASEPATH') or exit('No direct script access allowed');
19 19
 class Xlsexport_model extends CI_Model
20 20
 {
21 21
 
22
-    protected $fechaLog = "2022-02-25 08:08:51";
22
+    protected $fechaLog = "2022-02-28 08:42:06";
23 23
 
24 24
     public function __construct()
25 25
     {
@@ -29,9 +29,9 @@ class Xlsexport_model extends CI_Model
29 29
     // ------------------------------------------------------------------------
30 30
 
31 31
     // ------------------------------------------------------------------------
32
-    public function getLicitaciones($having = "")
32
+    public function getLicitaciones($idUltimaImportacion)
33 33
     {
34
-        $sql = "SELECT
34
+        $sql = " SELECT
35 35
                     CF.id,
36 36
                     LI.id_licitacion,
37 37
                     GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
@@ -72,29 +72,25 @@ class Xlsexport_model extends CI_Model
72 72
                     RTPU.nombre AS urgency,
73 73
                     LI.fecha_creacion_log
74 74
                 FROM
75
-                maestro_datos_iniciales_licitacion LI
76
-                JOIN maestro_contract_folder CF ON CF.id_ajena_licitacion = LI.id_licitacion
77
-                JOIN maestro_located_contracting_party LP ON LP.id_ajena_licitacion = LI.id_licitacion
78
-                JOIN maestro_party MP ON MP.id_ajena_licitacion = LI.id_licitacion
79
-                JOIN maestro_party_party_idenfitication MPI on MPI.id_ajena_licitacion = LI.id_licitacion AND MPI.attr = 'DIR3'
80
-                JOIN maestro_procurement_project PROJ ON PROJ.id_ajena_licitacion = LI.id_licitacion
81
-                JOIN maestro_procurement_project_itemclass PROJI ON PROJI.id_ajena_licitacion = LI.id_licitacion
82
-                JOIN maestro_tendering_process TP ON TP.id_ajena_licitacion = LI.id_licitacion
83
-                JOIN maestro_tendering_terms TT ON TT.id_ajena_licitacion = LI.id_licitacion
84
-                JOIN relacionada_contract_status RCF ON RCF.CODE = CF.contractFolderStatusCode
85
-                JOIN relacionada_located_contracting_party RLP ON RLP.CODE = LP.contractingPartyTypeCode
86
-                JOIN relacionada_tipo_contrato TPC ON TPC.CODE = PROJ.typeCode
87
-                JOIN relacionada_tender_process RTP ON RTP.CODE = TP.procedureCode
88
-                JOIN relacionada_tender_process_contracting_code RTPC ON RTPC.CODE = TP.contractingSystemCode
89
-                JOIN relacionada_tender_process_submission RTPS ON RTPS.CODE = TP.submissionMethodCode
90
-                JOIN relacionada_tender_process_urgency_code RTPU ON RTPU.CODE = TP.urgencyCode /*WHERE
91
-                LI.id < 17174 */
92
-
75
+                    maestro_datos_iniciales_licitacion LI
76
+                    JOIN maestro_contract_folder CF ON CF.id_ajena_licitacion = LI.id_licitacion
77
+                    JOIN maestro_located_contracting_party LP ON LP.id_ajena_licitacion = LI.id_licitacion
78
+                    JOIN maestro_party MP ON MP.id_ajena_licitacion = LI.id_licitacion
79
+                    JOIN maestro_party_party_idenfitication MPI on MPI.id_ajena_licitacion = LI.id_licitacion AND MPI.attr = 'DIR3'
80
+                    JOIN maestro_procurement_project PROJ ON PROJ.id_ajena_licitacion = LI.id_licitacion
81
+                    JOIN maestro_procurement_project_itemclass PROJI ON PROJI.id_ajena_licitacion = LI.id_licitacion
82
+                    JOIN maestro_tendering_process TP ON TP.id_ajena_licitacion = LI.id_licitacion
83
+                    JOIN maestro_tendering_terms TT ON TT.id_ajena_licitacion = LI.id_licitacion
84
+                    JOIN relacionada_contract_status RCF ON RCF.CODE = CF.contractFolderStatusCode
85
+                    JOIN relacionada_located_contracting_party RLP ON RLP.CODE = LP.contractingPartyTypeCode
86
+                    JOIN relacionada_tipo_contrato TPC ON TPC.CODE = PROJ.typeCode
87
+                    JOIN relacionada_tender_process RTP ON RTP.CODE = TP.procedureCode
88
+                    JOIN relacionada_tender_process_contracting_code RTPC ON RTPC.CODE = TP.contractingSystemCode
89
+                    JOIN relacionada_tender_process_submission RTPS ON RTPS.CODE = TP.submissionMethodCode
90
+                    JOIN relacionada_tender_process_urgency_code RTPU ON RTPU.CODE = TP.urgencyCode
91
+                WHERE LI.id_importacion = $idUltimaImportacion
93 92
                 GROUP BY
94
-                    id_licitacion
95
-                $having
96
-                ORDER BY
97
-                    CF.id";
93
+                    id_licitacion";
98 94
         $result = $this->db->query($sql);
99 95
         $datos['datos'] = $result->result();
100 96
         $datos['num_rows'] = $result->num_rows();