瀏覽代碼

Parametrizacion fechas importacion, para crear vista de exportar excel

Nermosis 3 年之前
父節點
當前提交
9f50851540
共有 3 個文件被更改,包括 45 次插入32 次删除
  1. 15 7
      application/controllers/Parser.php
  2. 9 0
      application/models/Parser_model.php
  3. 21 25
      application/models/Xlsexport_model.php

+ 15 - 7
application/controllers/Parser.php 查看文件

26
     public function index()
26
     public function index()
27
     {
27
     {
28
         $existCronRun = $this->Parser_model->existCronRun();
28
         $existCronRun = $this->Parser_model->existCronRun();
29
-
29
+        $fechaCarpeta = "";
30
         if ($existCronRun['num_rows'] > 0) {
30
         if ($existCronRun['num_rows'] > 0) {
31
             if ($existCronRun['datos']->cron_ejecucion == 0) {
31
             if ($existCronRun['datos']->cron_ejecucion == 0) {
32
 
32
 
33
                 $this->Parser_model->inicioParser();
33
                 $this->Parser_model->inicioParser();
34
 
34
 
35
                 $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
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
                 foreach ($resultSetPerfiles['datos'] as $row) {
39
                 foreach ($resultSetPerfiles['datos'] as $row) {
38
-                    $fechaCarpeta = date("Y-m-d_H-i-s");
40
+
41
+                    $idUltimaImportacion = $this->Parser_model->setFechaNuevaImportacion($fechaImportacionLog);
39
                     $this->fechaCreacionLog = $fechaCarpeta;
42
                     $this->fechaCreacionLog = $fechaCarpeta;
40
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
43
                     $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
41
 
44
 
47
                         //$this->downloadProcess($row->url_descarga);
50
                         //$this->downloadProcess($row->url_descarga);
48
                         $this->downloadZip($row->url_descarga);
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
             } else {
64
             } else {
55
                 echo "EXISTE UN CRON EN MARCHA.";
65
                 echo "EXISTE UN CRON EN MARCHA.";
60
 
70
 
61
         $this->Parser_model->stopParser();
71
         $this->Parser_model->stopParser();
62
 
72
 
63
-        $this->tablasCalculadas($this->fechaCreacionLog);
64
-
65
         /* $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
73
         /* $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
66
     foreach ($resultSetPerfiles['datos'] as $row) {
74
     foreach ($resultSetPerfiles['datos'] as $row) {
67
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-17_20-38-16", date("Y-m-d"), $row);
75
     $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-17_20-38-16", date("Y-m-d"), $row);
186
         return $result;
194
         return $result;
187
     }
195
     }
188
 
196
 
189
-    private function tablasCalculadas($fechaInicioParser)
197
+    private function tablasCalculadas($idUltimaImportacion)
190
     {
198
     {
191
         $this->Parser_model->truncateTables("import_licitaciones_temp");
199
         $this->Parser_model->truncateTables("import_licitaciones_temp");
192
 
200
 
193
         $this->Parser_model->truncateTables("vista_datos_licitacion");
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
         insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
205
         insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
198
 
206
 

+ 9 - 0
application/models/Parser_model.php 查看文件

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
 /* End of file Parser_model.php */
148
 /* End of file Parser_model.php */

+ 21 - 25
application/models/Xlsexport_model.php 查看文件

19
 class Xlsexport_model extends CI_Model
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
     public function __construct()
24
     public function __construct()
25
     {
25
     {
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
                     CF.id,
35
                     CF.id,
36
                     LI.id_licitacion,
36
                     LI.id_licitacion,
37
                     GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
37
                     GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
72
                     RTPU.nombre AS urgency,
72
                     RTPU.nombre AS urgency,
73
                     LI.fecha_creacion_log
73
                     LI.fecha_creacion_log
74
                 FROM
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
                 GROUP BY
92
                 GROUP BY
94
-                    id_licitacion
95
-                $having
96
-                ORDER BY
97
-                    CF.id";
93
+                    id_licitacion";
98
         $result = $this->db->query($sql);
94
         $result = $this->db->query($sql);
99
         $datos['datos'] = $result->result();
95
         $datos['datos'] = $result->result();
100
         $datos['num_rows'] = $result->num_rows();
96
         $datos['num_rows'] = $result->num_rows();