|
@@ -1354,7 +1354,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
'nrLokalu' => 'Numer_mieszkania_lokalu',
|
|
'nrLokalu' => 'Numer_mieszkania_lokalu',
|
|
|
],
|
|
],
|
|
|
'base' => '0',
|
|
'base' => '0',
|
|
|
- 'where' => "ownCompany != 'Y'",
|
|
|
|
|
|
|
+ 'where' => "and ownCompany != 'Y'",
|
|
|
],
|
|
],
|
|
|
'BI_audit_KRS' => [
|
|
'BI_audit_KRS' => [
|
|
|
'fields' => [
|
|
'fields' => [
|
|
@@ -1421,16 +1421,16 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
'base' => '1',
|
|
'base' => '1',
|
|
|
],
|
|
],
|
|
|
|
|
|
|
|
- 'BI_audit_KW_requested_person' => [
|
|
|
|
|
- 'fields' => [
|
|
|
|
|
- 'pesel' => 'Seller_person_pesel',
|
|
|
|
|
- 'krs' => 'Seller_person_KRS',
|
|
|
|
|
- 'nip' => 'Seller_person_NIP',
|
|
|
|
|
- 'regon' => 'Seller_person_REGON',
|
|
|
|
|
- ],
|
|
|
|
|
- 'base' => '0',
|
|
|
|
|
- //'where' => '',
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+// 'BI_audit_KW_requested_person' => [
|
|
|
|
|
+// 'fields' => [
|
|
|
|
|
+// 'pesel' => 'Seller_person_pesel',
|
|
|
|
|
+// 'krs' => 'Seller_person_KRS',
|
|
|
|
|
+// 'nip' => 'Seller_person_NIP',
|
|
|
|
|
+// 'regon' => 'Seller_person_REGON',
|
|
|
|
|
+// ],
|
|
|
|
|
+// 'base' => '0',
|
|
|
|
|
+// //'where' => '',
|
|
|
|
|
+// ],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$refTablesConf = [
|
|
$refTablesConf = [
|
|
@@ -1471,10 +1471,10 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$queries[] = "delete from BI_audit_ALL_ref where BASE = 0";
|
|
$queries[] = "delete from BI_audit_ALL_ref where BASE = 0";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- foreach ($refTablesConf as $refTrableFrom => $refTableConf) {
|
|
|
|
|
|
|
+ foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
if ($refTableConf['base']) continue;
|
|
if ($refTableConf['base']) continue;
|
|
|
foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
- $refTable = ACL::getRefTable("default_db/{$refTrableFrom}/{$refTrableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
|
|
|
|
+ $refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
$queries[] = "update `{$refTable}` set `A_STATUS` = 'WAITNG' where `A_STATUS` = 'NORMAL'";
|
|
$queries[] = "update `{$refTable}` set `A_STATUS` = 'WAITNG' where `A_STATUS` = 'NORMAL'";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1482,11 +1482,11 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
foreach ($tablesConf as $table => $tableConf) {
|
|
foreach ($tablesConf as $table => $tableConf) {
|
|
|
$where = "where `cached` = 0";
|
|
$where = "where `cached` = 0";
|
|
|
if (!empty($tableConf['where'])) $where .= " {$tableConf['where']}";
|
|
if (!empty($tableConf['where'])) $where .= " {$tableConf['where']}";
|
|
|
- $queries[] = "lock tables `{$table}` write";
|
|
|
|
|
|
|
+// $queries[] = "lock tables `{$table}` write";
|
|
|
$queries[] = "insert into `BI_audit_ALL` (`REMOTE_TABLE`, `REMOTE_ID`, `BASE`, " . implode(", ", array_keys($tableConf['fields'])) .
|
|
$queries[] = "insert into `BI_audit_ALL` (`REMOTE_TABLE`, `REMOTE_ID`, `BASE`, " . implode(", ", array_keys($tableConf['fields'])) .
|
|
|
") select '{$table}', ID, '{$tableConf['base']}', " . implode(", ", $tableConf['fields']) . " from `{$table}` {$where}";
|
|
") select '{$table}', ID, '{$tableConf['base']}', " . implode(", ", $tableConf['fields']) . " from `{$table}` {$where}";
|
|
|
$queries[] = "update `{$table}` set `cached` = 1 {$where}";
|
|
$queries[] = "update `{$table}` set `cached` = 1 {$where}";
|
|
|
- $queries[] = "unlock tables";
|
|
|
|
|
|
|
+// $queries[] = "unlock tables";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$queries[] = "update `BI_audit_ALL` set `nip` = null where `nip` = 0";
|
|
$queries[] = "update `BI_audit_ALL` set `nip` = null where `nip` = 0";
|
|
@@ -1503,27 +1503,27 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$queries[] = "set @var = (select round(coalesce(max(`ID`), '0.5'), 1) from `BI_audit_ALL_ref_RELATIONS`)";
|
|
$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";
|
|
$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";
|
|
|
|
|
|
|
|
- foreach ($refTablesConf as $refTrableFrom => $refTableConf) {
|
|
|
|
|
|
|
+ foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
- $refTable = ACL::getRefTable("default_db/{$refTrableFrom}/{$refTrableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
|
|
- $queries[] = "lock tables `{$refTable}` write";
|
|
|
|
|
|
|
+ $refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
|
|
+// $queries[] = "lock tables `{$refTable}` write";
|
|
|
$joins = "`BI_audit_ALL` as `all1` join `{$refTable}` as `ref` on `all1`.`REMOTE_TABLE` = '{$refTableFrom}' and `all1`.`REMOTE_ID` = `ref`.`PRIMARY_KEY` and `ref`.`A_STATUS` = 'WAITING' join `BI_audit_ALL` as `all2` on `all2`.`REMOTE_TABLE` = '{$refTableTo}' and `ref`.`REMOTE_PRIMARY_KEY` = `all2`.`REMOTE_ID` join `BI_audit_ALL_ref_RELATIONS` `rel` on `all1`.`REMOTE_TABLE` = `rel`.`RELATION`";
|
|
$joins = "`BI_audit_ALL` as `all1` join `{$refTable}` as `ref` on `all1`.`REMOTE_TABLE` = '{$refTableFrom}' and `all1`.`REMOTE_ID` = `ref`.`PRIMARY_KEY` and `ref`.`A_STATUS` = 'WAITING' join `BI_audit_ALL` as `all2` on `all2`.`REMOTE_TABLE` = '{$refTableTo}' and `ref`.`REMOTE_PRIMARY_KEY` = `all2`.`REMOTE_ID` join `BI_audit_ALL_ref_RELATIONS` `rel` on `all1`.`REMOTE_TABLE` = `rel`.`RELATION`";
|
|
|
|
|
|
|
|
$queries[] = "insert ignore into `BI_audit_ALL_ref` (`ID1`, `ID2`, `RELATION_ID`, `BASE`) select `all1`.`ID`, `all2`.`ID`, `rel`.`ID`, {$refTableConf['base']} from {$joins}";
|
|
$queries[] = "insert ignore into `BI_audit_ALL_ref` (`ID1`, `ID2`, `RELATION_ID`, `BASE`) select `all1`.`ID`, `all2`.`ID`, `rel`.`ID`, {$refTableConf['base']} from {$joins}";
|
|
|
$queries[] = "insert ignore into `BI_audit_ALL_ref` (`ID1`, `ID2`, `RELATION_ID`, `BASE`) select `all2`.`ID`, `all1`.`ID`, `rel`.`ID`, {$refTableConf['base']} from {$joins}";
|
|
$queries[] = "insert ignore into `BI_audit_ALL_ref` (`ID1`, `ID2`, `RELATION_ID`, `BASE`) select `all2`.`ID`, `all1`.`ID`, `rel`.`ID`, {$refTableConf['base']} from {$joins}";
|
|
|
- $queries[] = "update `ref` using {$joins} set `ref`.`A_STATUS` = 'NORMAL'";
|
|
|
|
|
- $queries[] = "unlock tables";
|
|
|
|
|
|
|
+ $queries[] = "update {$joins} set `ref`.`A_STATUS` = 'NORMAL'";
|
|
|
|
|
+// $queries[] = "unlock tables";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ echo implode(";\n", $queries) . ";\n";
|
|
|
foreach ($queries as $query) DB::getPDO()->query($query);
|
|
foreach ($queries as $query) DB::getPDO()->query($query);
|
|
|
|
|
|
|
|
$BiAuditRelations = new BiAuditRelations($full);
|
|
$BiAuditRelations = new BiAuditRelations($full);
|
|
|
- DB::getPDO()->query("locktables `BI_audit_ALL` write");
|
|
|
|
|
|
|
+// DB::getPDO()->query("lock tables `BI_audit_ALL` write");
|
|
|
$result = DB::getPDO()->query("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
$result = DB::getPDO()->query("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
|
while ($row = $result->fetch()) $BiAuditRelations->findRelations($row['ID']);
|
|
while ($row = $result->fetch()) $BiAuditRelations->findRelations($row['ID']);
|
|
|
DB::getPDO()->query("update `BI_audit_ALL` set `reffed` = 1");
|
|
DB::getPDO()->query("update `BI_audit_ALL` set `reffed` = 1");
|
|
|
- DB::getPDO()->query("unlock tables");
|
|
|
|
|
|
|
+// DB::getPDO()->query("unlock tables");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function doReloadCache($full = false) {
|
|
public function doReloadCache($full = false) {
|