|
|
@@ -1644,20 +1644,12 @@ SQL;
|
|
|
'fields' => [
|
|
|
'nip' => 'nip',
|
|
|
'regon' => 'regon',
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'budynek',
|
|
|
- 'nrLokalu' => 'lokal',
|
|
|
],
|
|
|
'base' => '1',
|
|
|
],
|
|
|
'BI_audit_CEIDG_pelnomocnicy' => [
|
|
|
'fields' => [
|
|
|
'nip' => 'nip',
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'budynek',
|
|
|
- 'nrLokalu' => 'lokal',
|
|
|
],
|
|
|
'base' => '1',
|
|
|
],
|
|
|
@@ -1673,21 +1665,12 @@ SQL;
|
|
|
'nip' => 'nip',
|
|
|
'regon' => 'regon',
|
|
|
'pesel' => 'pesel',
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'nr',
|
|
|
- 'nrLokalu' => 'nrLokalu',
|
|
|
],
|
|
|
'base' => '0',
|
|
|
//'where' => '',
|
|
|
],
|
|
|
'BI_audit_ENERGA_PRACOWNICY_adresy' => [
|
|
|
- 'fields' => [
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'nrBudynku',
|
|
|
- 'nrLokalu' => 'nrLokalu',
|
|
|
- ],
|
|
|
+ 'fields' => [],
|
|
|
'base' => '0',
|
|
|
//'where' => '',
|
|
|
],
|
|
|
@@ -1698,10 +1681,6 @@ SQL;
|
|
|
'nip' => 'NIP',
|
|
|
'regon' => 'REGON',
|
|
|
'pesel' => 'PESEL',
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'Numer_budynku',
|
|
|
- 'nrLokalu' => 'Numer_mieszkania_lokalu',
|
|
|
],
|
|
|
'base' => '0',
|
|
|
'where' => "and ownCompany != 'Y'",
|
|
|
@@ -1711,20 +1690,11 @@ SQL;
|
|
|
'krs' => 'krs',
|
|
|
'nip' => 'nip',
|
|
|
'regon' => 'regon',
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'A_nrDomu',
|
|
|
- 'nrLokalu' => 'A_nrLokalu',
|
|
|
],
|
|
|
'base' => '1',
|
|
|
],
|
|
|
'BI_audit_KRS_address' => [
|
|
|
- 'fields' => [
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'A_nrDomu',
|
|
|
- 'nrLokalu' => 'A_nrLokalu',
|
|
|
- ],
|
|
|
+ 'fields' => [],
|
|
|
'base' => '1',
|
|
|
],
|
|
|
'BI_audit_KRS_company' => [
|
|
|
@@ -1749,12 +1719,7 @@ SQL;
|
|
|
'base' => '1',
|
|
|
],
|
|
|
'BI_audit_MSIG_address' => [
|
|
|
- 'fields' => [
|
|
|
- 'TERYT_SYM' => 'TERYT_SYM',
|
|
|
- 'TERYT_SYM_UL' => 'TERYT_SYM_UL',
|
|
|
- 'nrDomu' => 'A_nrDomu',
|
|
|
- 'nrLokalu' => 'A_nrLokalu',
|
|
|
- ],
|
|
|
+ 'fields' => [],
|
|
|
'base' => '1',
|
|
|
],
|
|
|
'BI_audit_MSIG_company' => [
|
|
|
@@ -1855,8 +1820,10 @@ SQL;
|
|
|
|
|
|
if ($full) {
|
|
|
foreach ($tablesConf as $table => $tableConf) if (!$tableConf['base']) $queries[] = "update `{$table}` set `cached` = 0";
|
|
|
- $queries[] = "delete from BI_audit_ALL where BASE = 0";
|
|
|
- $queries[] = "delete from BI_audit_ALL_ref where BASE = 0";
|
|
|
+ $queries[] = "delete from `BI_audit_ALL` where `BASE` = 0";
|
|
|
+// $queries[] = "optimize table `BI_audit_ALL`";
|
|
|
+ $queries[] = "delete from `BI_audit_ALL_ref` where `BASE` = 0";
|
|
|
+// $queries[] = "optimize table `BI_audit_ALL_ref`";
|
|
|
|
|
|
$allTables = [];
|
|
|
foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
@@ -1876,6 +1843,7 @@ SQL;
|
|
|
foreach ($allTables as $refTableTo) {
|
|
|
if ($refTable = BiAuditRefTables::getRefTable($refTableFrom, $refTableTo, false)) {
|
|
|
$queries[] = "delete from `{$refTable}` where `TRANSACTION_ID` = '-1'";
|
|
|
+ $queries[] = "optimize table `{$refTable}`";
|
|
|
$queries[] = "insert into `{$refTable}` (`PRIMARY_KEY`, `REMOTE_PRIMARY_KEY`, `TRANSACTION_ID`, `A_STATUS`) select `all1`.`ID`, `all2`.`ID`, '-1', 'NORMAL' from `BI_audit_ALL` as `all1` join `BI_audit_ALL_ref` as `ref` on `all1`.`ID` = `ref`.`ID1` join `BI_audit_ALL` as `all2` on `ref`.`ID2` = `all2`.`ID` left join `${refTable}` as `ref2` on `all1`.`ID` = `ref2`.`PRIMARY_KEY` and `all2`.`ID` = `ref2`.`REMOTE_PRIMARY_KEY` where `all1`.`REMOTE_TABLE` = '{$refTableFrom}' and `all2`.`REMOTE_TABLE` = '{$refTableTo}' and `ref2`.`PRIMARY_KEY` is null";
|
|
|
}
|
|
|
}
|
|
|
@@ -1900,12 +1868,6 @@ SQL;
|
|
|
$queries[] = "update `BI_audit_ALL` set `regon` = null where `regon` = 0";
|
|
|
$queries[] = "update `BI_audit_ALL` set `krs` = null where `krs` = 0";
|
|
|
$queries[] = "update `BI_audit_ALL` set `pesel` = null where `pesel` = 0";
|
|
|
- //$queries[] = "update `BI_audit_ALL` set `TERYT_SYM` = null where `TERYT_SYM` = 0";
|
|
|
- //$queries[] = "update `BI_audit_ALL` set `TERYT_SYM_UL` = null where `TERYT_SYM_UL` = 0";
|
|
|
- $queries[] = "update `BI_audit_ALL` set `nrDomu` = null where trim(`nrDomu`) = ''";
|
|
|
- $queries[] = "update `BI_audit_ALL` set `nrLokalu` = null where trim(`nrLokalu`) = ''";
|
|
|
-
|
|
|
- $queries[] = "update `BI_audit_ALL` set `nrDomu` = substring(`nrDomu`, 1, position('/' in `nrDomu`) - 1), `nrLokalu` = substring(`nrDomu`, position('/' in `nrDomu`) + 1) where `reffed` = 0 and `nrDomu` rlike '^[[:digit:]]+.*/[[:digit:]]+.*$' and `nrLokalu` is null";
|
|
|
|
|
|
$queries[] = "set @var = (select round(coalesce(max(`ID`), '0.5'), 1) from `BI_audit_ALL_ref_RELATIONS`)";
|
|
|
$queries[] = "insert into `BI_audit_ALL_ref_RELATIONS` (`ID`, `RELATION`, `BASE`) select @var:=@var*2, `a`.`RELATION`, `a`.`BASE` from (select `a`.`REMOTE_TABLE` as `RELATION`, `a`.`BASE` as `BASE` from `BI_audit_ALL` `a` where `a`.`REMOTE_TABLE` not in ('BI_audit_ENERGA_RUM_KONTRAHENCI', 'BI_audit_KW_requested_person') group by `a`.`REMOTE_TABLE` order by `a`.`BASE` desc) as `a` left join `BI_audit_ALL_ref_RELATIONS` `r` on `a`.`RELATION` = `r`.`RELATION` where `r`.`RELATION` is null";
|
|
|
@@ -2077,7 +2039,6 @@ class BiAuditRelations {
|
|
|
'regon' => ['regon'],
|
|
|
'krs' => ['krs'],
|
|
|
'pesel' => ['pesel'],
|
|
|
- 'adres' => ['TERYT_SYM', 'TERYT_SYM_UL', 'nrDomu', 'nrLokalu'],
|
|
|
];
|
|
|
|
|
|
private $destTables = ['BI_audit_ENERGA_RUM_KONTRAHENCI', 'BI_audit_KW_requested_person'];
|