|
@@ -3,9 +3,6 @@ defined('BASEPATH') or exit('No direct script access allowed');
|
3
|
3
|
|
4
|
4
|
class ParserDatabase
|
5
|
5
|
{
|
6
|
|
-
|
7
|
|
- //TODO: Functions return void
|
8
|
|
-
|
9
|
6
|
protected $idLicitacion = 0;
|
10
|
7
|
protected $fechaInicioParser = "";
|
11
|
8
|
|
|
@@ -29,13 +26,9 @@ class ParserDatabase
|
29
|
26
|
if ($idLicitacion['result']) {
|
30
|
27
|
$this->idLicitacion = $idLicitacion['id'];
|
31
|
28
|
|
32
|
|
- if ($row['general']['id_licitacion'] == "8500237") {
|
33
|
|
- $var = 1;
|
34
|
|
- }
|
35
|
|
-
|
36
|
|
- $this->setDatosSingular($row['contractInfo'], "BRUTO_contract_folder", $this->idLicitacion, "ContractInfo");
|
|
29
|
+ $this->setDatosSingular($row, "contractInfo", "BRUTO_contract_folder", $this->idLicitacion, "ContractInfo");
|
37
|
30
|
|
38
|
|
- $this->setDatosSingular($row['tenderingProcess'], "BRUTO_tendering_process", $this->idLicitacion, "TenderingProcess");
|
|
31
|
+ $this->setDatosSingular($row, "tenderingProcess", "BRUTO_tendering_process", $this->idLicitacion, "TenderingProcess");
|
39
|
32
|
|
40
|
33
|
$this->setProcurementProject($row['procurementProject']);
|
41
|
34
|
|
|
@@ -49,16 +42,15 @@ class ParserDatabase
|
49
|
42
|
|
50
|
43
|
$this->setValidNoticeInfo($row['validNoticeInfo']);
|
51
|
44
|
|
52
|
|
- $this->setDatosMultiples($row['tenderingResult'], "BRUTO_tender_result", $this->idLicitacion, "TenderResult");
|
|
45
|
+ $this->setDatosMultiples($row, "tenderingResult", "BRUTO_tender_result", $this->idLicitacion, "TenderResult");
|
53
|
46
|
|
54
|
|
- $this->setDatosMultiples($row['legalDocs'], "BRUTO_legal_documents", $this->idLicitacion, "LegalDocs");
|
|
47
|
+ $this->setDatosMultiples($row, "legalDocs", "BRUTO_legal_documents", $this->idLicitacion, "LegalDocs");
|
55
|
48
|
|
56
|
|
- $this->setDatosMultiples($row['technicalDocs'], "BRUTO_technical_documents", $this->idLicitacion, "TechnicalDocs");
|
|
49
|
+ $this->setDatosMultiples($row, "technicalDocs", "BRUTO_technical_documents", $this->idLicitacion, "TechnicalDocs");
|
57
|
50
|
|
58
|
|
- $this->setDatosMultiples($row['generalDocs'], "BRUTO_general_documents", $this->idLicitacion, "GeneralDocs");
|
59
|
|
-
|
60
|
|
- $this->setDatosMultiples($row['additionalDocs'], "BRUTO_additional_documents", $this->idLicitacion, "AdditionalDocs");
|
|
51
|
+ $this->setDatosMultiples($row, "generalDocs", "BRUTO_general_documents", $this->idLicitacion, "GeneralDocs");
|
61
|
52
|
|
|
53
|
+ $this->setDatosMultiples($row, "additionalDocs", "BRUTO_additional_documents", $this->idLicitacion, "AdditionalDocs");
|
62
|
54
|
}
|
63
|
55
|
}
|
64
|
56
|
}
|
|
@@ -84,31 +76,29 @@ class ParserDatabase
|
84
|
76
|
|
85
|
77
|
private function setLocatedContractingParty($contractInfo): void
|
86
|
78
|
{
|
87
|
|
- $locatedContractingPartyId = $this->setDatosSingular($contractInfo['locatedContractingParty'], "BRUTO_located_contracting_party", $this->idLicitacion, "locatedContractingParty");
|
|
79
|
+ $locatedContractingPartyId = $this->setDatosSingular($contractInfo, "locatedContractingParty", "BRUTO_located_contracting_party", $this->idLicitacion, "locatedContractingParty");
|
|
80
|
+
|
|
81
|
+ $this->setDatosMultiples($contractInfo, "activity", "BRUTO_located_contracting_party_activity", $locatedContractingPartyId, "locatedContractingParty_Activity");
|
88
|
82
|
|
89
|
|
- $this->setDatosMultiples($contractInfo['activity'], "BRUTO_located_contracting_party_activity", $locatedContractingPartyId, "locatedContractingParty_Activity");
|
90
|
83
|
}
|
91
|
84
|
|
92
|
85
|
private function setParty($partyInfo): void
|
93
|
86
|
{
|
94
|
|
- $partyId = $this->setDatosSingular($partyInfo['party'], "BRUTO_party", $this->idLicitacion, "PartyInfo");
|
|
87
|
+ $partyId = $this->setDatosSingular($partyInfo, "party", "BRUTO_party", $this->idLicitacion, "PartyInfo");
|
|
88
|
+
|
|
89
|
+ $this->setDatosMultiples($partyInfo, "partyIdentification", "BRUTO_party_party_idenfitication", $partyId, "PartyInfo_PartyIdentification");
|
95
|
90
|
|
96
|
|
- $this->setDatosMultiples($partyInfo['partyIdentification'], "BRUTO_party_party_idenfitication", $partyId, "PartyInfo_PartyIdentification");
|
97
|
91
|
}
|
98
|
92
|
|
99
|
93
|
private function setProcurementProject($procurementInfo): void
|
100
|
94
|
{
|
101
|
|
- $procurementProjectId = $this->setDatosSingular($procurementInfo['budget'], "BRUTO_procurement_project", $this->idLicitacion, "ProcurementProject");
|
102
|
|
-
|
103
|
|
- if (array_key_exists("itemClass", $procurementInfo)) {
|
104
|
|
- $this->setDatosMultiples($procurementInfo['itemClass'], "BRUTO_procurement_project_itemClass", $procurementProjectId, "ProcurementProject_ItemClass");
|
105
|
|
- }
|
|
95
|
+ $procurementProjectId = $this->setDatosSingular($procurementInfo, "budget", "BRUTO_procurement_project", $this->idLicitacion, "ProcurementProject");
|
106
|
96
|
|
|
97
|
+ $this->setDatosMultiples($procurementInfo, "itemClass", "BRUTO_procurement_project_itemClass", $procurementProjectId, "ProcurementProject_ItemClass");
|
107
|
98
|
}
|
108
|
99
|
|
109
|
100
|
private function setProcurementProjectLot($procurementLotInfo): void
|
110
|
101
|
{
|
111
|
|
-
|
112
|
102
|
$resultInsert = 0;
|
113
|
103
|
|
114
|
104
|
if (!empty($procurementLotInfo)) {
|
|
@@ -121,8 +111,8 @@ class ParserDatabase
|
121
|
111
|
|
122
|
112
|
if (!empty($setInsert)) {
|
123
|
113
|
$resultInsert = insertBucle($setInsert, "BRUTO_procurement_project_lot", "setLicitacion_" . $this->fechaInicioParser);
|
124
|
|
- if ($row['itemClassification']) {
|
125
|
|
- $this->setDatosMultiples($row['itemClassification'], "BRUTO_procurement_project_lot_item", $resultInsert, "ProcurementLotItem");
|
|
114
|
+ if (array_key_exists('itemClassification', $row)) {
|
|
115
|
+ $this->setDatosMultiples($row, "itemClassification", "BRUTO_procurement_project_lot_item", $resultInsert, "ProcurementLotItem");
|
126
|
116
|
}
|
127
|
117
|
}
|
128
|
118
|
$aux++;
|
|
@@ -146,8 +136,7 @@ class ParserDatabase
|
146
|
136
|
$resultInsert = 0;
|
147
|
137
|
|
148
|
138
|
if (!empty($tenderingTermsInfo)) {
|
149
|
|
- $aux = 0;
|
150
|
|
- //foreach ($tenderingTermsInfo as $clave => $row) {
|
|
139
|
+
|
151
|
140
|
$setInsert = array();
|
152
|
141
|
$setInsert['tenderingTerms'][0] = $tenderingTermsInfo[0];
|
153
|
142
|
$setInsert['tenderingTerms'][0]['id_ajena'] = $this->idLicitacion;
|
|
@@ -156,25 +145,15 @@ class ParserDatabase
|
156
|
145
|
$resultInsert = insertBucle($setInsert['tenderingTerms'], "BRUTO_tendering_terms", "setLicitacion_" . $this->fechaInicioParser);
|
157
|
146
|
|
158
|
147
|
if ($resultInsert > 0) {
|
159
|
|
- if (array_key_exists(1, $tenderingTermsInfo)) {
|
160
|
|
- $this->setDatosMultiples($tenderingTermsInfo[1], "BRUTO_tendering_terms_awarding_terms", $resultInsert, "TenderingTermsAwardingTerms");
|
161
|
|
- }
|
|
148
|
+ $this->setDatosMultiples($tenderingTermsInfo, 1, "BRUTO_tendering_terms_awarding_terms", $resultInsert, "TenderingTermsAwardingTerms");
|
162
|
149
|
|
163
|
|
- if (array_key_exists(2, $tenderingTermsInfo)) {
|
164
|
|
- $this->setDatosMultiples($tenderingTermsInfo[2], "BRUTO_tendering_terms_qualification_request", $resultInsert, "TenderingTermsQualificationRequest");
|
165
|
|
- }
|
|
150
|
+ $this->setDatosMultiples($tenderingTermsInfo, 2, "BRUTO_tendering_terms_qualification_request", $resultInsert, "TenderingTermsQualificationRequest");
|
166
|
151
|
|
167
|
|
- if (array_key_exists(3, $tenderingTermsInfo)) {
|
168
|
|
- $this->setDatosMultiples($tenderingTermsInfo[3], "BRUTO_tendering_terms_financial_evaluation", $resultInsert, "TenderingTermsFinancialEvaluation");
|
169
|
|
- }
|
|
152
|
+ $this->setDatosMultiples($tenderingTermsInfo, 3, "BRUTO_tendering_terms_financial_evaluation", $resultInsert, "TenderingTermsFinancialEvaluation");
|
170
|
153
|
|
171
|
|
- if (array_key_exists(4, $tenderingTermsInfo)) {
|
172
|
|
- $this->setDatosMultiples($tenderingTermsInfo[4], "BRUTO_tendering_terms_specific_terms", $resultInsert, "TenderingTermsSpecificRequirement");
|
173
|
|
- }
|
|
154
|
+ $this->setDatosMultiples($tenderingTermsInfo, 4, "BRUTO_tendering_terms_specific_terms", $resultInsert, "TenderingTermsSpecificRequirement");
|
174
|
155
|
}
|
175
|
156
|
}
|
176
|
|
- //$aux++;
|
177
|
|
- //}
|
178
|
157
|
|
179
|
158
|
if ($resultInsert) {
|
180
|
159
|
$result = array("result" => true);
|
|
@@ -205,12 +184,11 @@ class ParserDatabase
|
205
|
184
|
|
206
|
185
|
if (!empty($setInsert)) {
|
207
|
186
|
$resultInsert = insertBucle($setInsert, "BRUTO_valid_notice_info", "setLicitacion_" . $this->fechaInicioParser);
|
208
|
|
- if (array_key_exists("documento", $row)) {
|
209
|
|
- $this->setDatosMultiples($row['documento'], "BRUTO_valid_notice_info_documento", $resultInsert, "validNoticeInfoFechas");
|
210
|
|
- }
|
211
|
187
|
|
212
|
|
- if (array_key_exists("fechas", $row)) {
|
213
|
|
- $this->setDatosMultiples($row['fechas'], "BRUTO_valid_notice_info_fecha", $resultInsert, "validNoticeInfoDocumento");
|
|
188
|
+ if ($resultInsert > 0) {
|
|
189
|
+ $this->setDatosMultiples($row, "documento", "BRUTO_valid_notice_info_documento", $resultInsert, "validNoticeInfoFechas");
|
|
190
|
+
|
|
191
|
+ $this->setDatosMultiples($row, "fechas", "BRUTO_valid_notice_info_fecha", $resultInsert, "validNoticeInfoDocumento");
|
214
|
192
|
}
|
215
|
193
|
}
|
216
|
194
|
$aux++;
|
|
@@ -228,13 +206,13 @@ class ParserDatabase
|
228
|
206
|
}
|
229
|
207
|
}
|
230
|
208
|
|
231
|
|
- private function setDatosSingular($arrayDatos, $tabla, $idAjena = 0, $nodoLog): int
|
|
209
|
+ private function setDatosSingular($arrayDatos, $arrayKey, $tabla, $idAjena = 0, $nodoLog): int
|
232
|
210
|
{
|
233
|
211
|
$insertedId = 0;
|
234
|
|
- if (!empty($arrayDatos)) {
|
|
212
|
+ if (!empty($arrayDatos) && array_key_exists($arrayKey, $arrayDatos)) {
|
235
|
213
|
$arrayInsertar = array();
|
236
|
214
|
|
237
|
|
- $arrayInsertar[0] = $arrayDatos;
|
|
215
|
+ $arrayInsertar[0] = $arrayDatos[$arrayKey];
|
238
|
216
|
|
239
|
217
|
if ($idAjena > 0) {
|
240
|
218
|
$arrayInsertar[0]['id_ajena'] = $idAjena;
|
|
@@ -247,7 +225,6 @@ class ParserDatabase
|
247
|
225
|
} else {
|
248
|
226
|
guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Finalizada Inserción", "false");
|
249
|
227
|
}
|
250
|
|
-
|
251
|
228
|
} else {
|
252
|
229
|
guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
|
253
|
230
|
}
|
|
@@ -255,33 +232,37 @@ class ParserDatabase
|
255
|
232
|
return $insertedId;
|
256
|
233
|
}
|
257
|
234
|
|
258
|
|
- private function setDatosMultiples($arrayDatos, $tabla, $idAjena = 0, $nodoLog): void
|
|
235
|
+ private function setDatosMultiples($arrayDatos, $arrayKey, $tabla, $idAjena = 0, $nodoLog): void
|
259
|
236
|
{
|
260
|
237
|
$setInsert = array();
|
261
|
238
|
$resultInsert = 0;
|
262
|
239
|
|
263
|
|
- if (!empty($arrayDatos)) {
|
264
|
|
- $aux = 0;
|
265
|
|
- foreach ($arrayDatos as $row) {
|
266
|
|
- $setInsert[$aux] = $row;
|
|
240
|
+ if (array_key_exists($arrayKey, $arrayDatos)) {
|
|
241
|
+ if (!empty($arrayDatos[$arrayKey])) {
|
|
242
|
+ $aux = 0;
|
|
243
|
+ foreach ($arrayDatos[$arrayKey] as $row) {
|
|
244
|
+ $setInsert[$aux] = $row;
|
267
|
245
|
|
268
|
|
- if ($idAjena > 0) {
|
269
|
|
- $setInsert[$aux]['id_ajena'] = $idAjena;
|
270
|
|
- }
|
|
246
|
+ if ($idAjena > 0) {
|
|
247
|
+ $setInsert[$aux]['id_ajena'] = $idAjena;
|
|
248
|
+ }
|
271
|
249
|
|
272
|
|
- $aux++;
|
273
|
|
- }
|
|
250
|
+ $aux++;
|
|
251
|
+ }
|
274
|
252
|
|
275
|
|
- if (!empty($setInsert)) {
|
276
|
|
- $resultInsert = insertBucle($setInsert, $tabla, "setLicitacion_" . $this->fechaInicioParser);
|
277
|
|
- }
|
|
253
|
+ if (!empty($setInsert)) {
|
|
254
|
+ $resultInsert = insertBucle($setInsert, $tabla, "setLicitacion_" . $this->fechaInicioParser);
|
|
255
|
+ }
|
278
|
256
|
|
279
|
|
- if ($resultInsert) {
|
280
|
|
- $result = array("result" => true);
|
281
|
|
- guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Finalizada Inserción", "false");
|
|
257
|
+ if ($resultInsert) {
|
|
258
|
+ $result = array("result" => true);
|
|
259
|
+ guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Finalizada Inserción", "false");
|
|
260
|
+ } else {
|
|
261
|
+ $result = array("result" => true, "id" => 0);
|
|
262
|
+ guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Fallida", "false", 2);
|
|
263
|
+ }
|
282
|
264
|
} else {
|
283
|
|
- $result = array("result" => true, "id" => 0);
|
284
|
|
- guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " Fallida", "false", 2);
|
|
265
|
+ guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
|
285
|
266
|
}
|
286
|
267
|
} else {
|
287
|
268
|
guardar_log("setLicitacion_" . $this->fechaInicioParser, $nodoLog . " vacio", "false");
|