|
|
@@ -1671,7 +1671,7 @@ function toggleCheckSecond(check) {
|
|
|
DB::getPDO()->query($query);
|
|
|
}
|
|
|
|
|
|
- private static function deleteResultsFromDB($ID) {
|
|
|
+ public static function deleteResultsFromDB($ID) {
|
|
|
$refPowiazaniaToPowiazaniaRow = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row', true);
|
|
|
$refPowiazaniaRowToPowiazaniaRowObject = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row', 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object', true);
|
|
|
$refTables = BiAuditRefTables::getRefTables('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object');
|
|
|
@@ -2969,6 +2969,7 @@ class BiAuditRefTables {
|
|
|
public static function getRefTable($tableFrom, $tableTo, $returnException = false) {
|
|
|
static $refTables = [];
|
|
|
static $tempRefTables = [];
|
|
|
+ static $tempRefTablesCount = 0;
|
|
|
|
|
|
if (is_array($tableTo)) {
|
|
|
if (!$tableTo) throw new Exception('BiAuditRefTables::getRefTable - bad parameter $tableTo');
|
|
|
@@ -2983,7 +2984,7 @@ class BiAuditRefTables {
|
|
|
$_tableFrom = $_tableTo;
|
|
|
}
|
|
|
|
|
|
- $name = "TEMP__#REF_TABLE__" . (count($tempRefTables) + 1);
|
|
|
+ $name = "TEMP__#REF_TABLE__" . (++$tempRefTablesCount);
|
|
|
$first = reset($_refTables);
|
|
|
$last = end($_refTables);
|
|
|
$prev = array_shift($_refTables);
|
|
|
@@ -3046,6 +3047,7 @@ class BiAuditRefTables {
|
|
|
|
|
|
class BiAuditPowiazania {
|
|
|
|
|
|
+ private $L_APPOITMENT_INFO;
|
|
|
private $minDepth;
|
|
|
private $maxDepth, $origMaxDepth;
|
|
|
private $onlyTargets;
|
|
|
@@ -3056,21 +3058,24 @@ class BiAuditPowiazania {
|
|
|
private $results = [];
|
|
|
private $items_results = [];
|
|
|
private $relations = [];
|
|
|
- private $srcTables = ['BI_audit_ENERGA_PRACOWNICY',
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_KRS'],
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_KRS_person'],
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_MSIG'],
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_MSIG_person'],
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_CEIDG'],
|
|
|
- ['BI_audit_POWIAZANIA_OD', 'BI_audit_CEIDG_pelnomocnicy'],
|
|
|
+ private $srcTables = [
|
|
|
+ 'BI_audit_ENERGA_PRACOWNICY' => [],
|
|
|
+ 'BI_audit_KRS' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
+ 'BI_audit_KRS_person' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
+ 'BI_audit_MSIG' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
+ 'BI_audit_MSIG_person' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
+ 'BI_audit_CEIDG' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
+ 'BI_audit_CEIDG_pelnomocnicy' => ['BI_audit_POWIAZANIA_OD'],
|
|
|
];
|
|
|
- private $destTables = ['BI_audit_ENERGA_RUM_KONTRAHENCI', 'BI_audit_KW_requested_person',
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_KRS'],
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_KRS_person'],
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_MSIG'],
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_MSIG_person'],
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_CEIDG'],
|
|
|
- ['BI_audit_POWIAZANIA_DO', 'BI_audit_CEIDG_pelnomocnicy'],
|
|
|
+ private $destTables = [
|
|
|
+ 'BI_audit_ENERGA_RUM_KONTRAHENCI' => [],
|
|
|
+ 'BI_audit_KW_requested_person' => [],
|
|
|
+ 'BI_audit_KRS' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
+ 'BI_audit_KRS_person' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
+ 'BI_audit_MSIG' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
+ 'BI_audit_MSIG_person' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
+ 'BI_audit_CEIDG' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
+ 'BI_audit_CEIDG_pelnomocnicy' => ['BI_audit_POWIAZANIA_DO'],
|
|
|
];
|
|
|
private $step = 0;
|
|
|
private $tasksDirLocation;
|
|
|
@@ -3151,7 +3156,7 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
public function run() {
|
|
|
- $query = "select BI_analiza_minDepth, BI_analiza_maxDepth, BI_analiza_onlyTargets from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$this->ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full')";
|
|
|
+ $query = "select L_APPOITMENT_INFO, BI_analiza_minDepth, BI_analiza_maxDepth, BI_analiza_onlyTargets from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$this->ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full')";
|
|
|
$result = DB::getPDO()->fetchAll($query);
|
|
|
if (!$result) self::throwException("Błąd danych");
|
|
|
|
|
|
@@ -3161,6 +3166,8 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
self::saveToLog("Wczytuję parametry wyszukiwania powiązań");
|
|
|
+ Route_UrlAction_BiAuditGenerate::deleteResultsFromDB($this->ID);
|
|
|
+ $this->L_APPOITMENT_INFO = $result[0]['L_APPOITMENT_INFO'];
|
|
|
$this->minDepth = (int) $result[0]['BI_analiza_minDepth'];
|
|
|
$this->maxDepth = (int) $result[0]['BI_analiza_maxDepth'];
|
|
|
$this->onlyTargets = ($result[0]['BI_analiza_onlyTargets'] != 'N');
|
|
|
@@ -3170,8 +3177,9 @@ class BiAuditPowiazania {
|
|
|
|
|
|
$subQueries = [];
|
|
|
$resultDest = [];
|
|
|
- foreach ($this->destTables as $destTable) {
|
|
|
- if ($refTable = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $destTable)) {
|
|
|
+ foreach ($this->destTables as $destTable => $destPath) {
|
|
|
+ $destPath[] = $destTable;
|
|
|
+ if ($refTable = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $destPath)) {
|
|
|
$subQueries[] = "select `all`.`ID`, `all`.`REMOTE_TABLE` from `BI_audit_ALL` `all` join `{$refTable}` `ref` on `all`.`REMOTE_TABLE` = '{$destTable}' and `all`.`REMOTE_ID` = `ref`.`REMOTE_PRIMARY_KEY` and `ref`.`PRIMARY_KEY` = '{$this->ID}'";
|
|
|
}
|
|
|
}
|
|
|
@@ -3183,8 +3191,9 @@ class BiAuditPowiazania {
|
|
|
|
|
|
$subQueries = [];
|
|
|
$resultSrc = [];
|
|
|
- foreach ($this->srcTables as $srcTable) {
|
|
|
- if ($refTable = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $srcTable)) {
|
|
|
+ foreach ($this->srcTables as $srcTable => $srcPath) {
|
|
|
+ $srcPath[] = $srcTable;
|
|
|
+ if ($refTable = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $srcPath)) {
|
|
|
$subQueries[] = "select `all`.`ID`, `all`.`REMOTE_TABLE` from `BI_audit_ALL` `all` join `{$refTable}` `ref` on `all`.`REMOTE_TABLE` = '{$srcTable}' and `all`.`REMOTE_ID` = `ref`.`REMOTE_PRIMARY_KEY` and `ref`.`PRIMARY_KEY` = '{$this->ID}'";
|
|
|
}
|
|
|
}
|
|
|
@@ -3209,7 +3218,7 @@ class BiAuditPowiazania {
|
|
|
|
|
|
self::saveToLog("Rozpoczynam wyszukiwanie powiązań");
|
|
|
|
|
|
- $externalTables = array_filter(array_merge($this->srcTables, $this->destTables), function($x) {if (!is_array($x)) return true;});
|
|
|
+ $externalTables = array_keys(array_filter(array_merge($this->srcTables, $this->destTables), function($x) {return (!count($x));}));
|
|
|
$this->count = count($result);
|
|
|
$this->progress['summary']['count'] = $this->count;
|
|
|
$this->origMaxDepth = $this->maxDepth;
|
|
|
@@ -3227,7 +3236,8 @@ class BiAuditPowiazania {
|
|
|
$this->maxDepth = $this->origMaxDepth;
|
|
|
self::saveToLog("Przywrócono oryginalną maksymalną głębokość przeszukiwania ({$this->origMaxDepth})");
|
|
|
}
|
|
|
- $weight = in_array($row['REMOTE_TABLE'], $externalTables) ? 0 : 1;
|
|
|
+// $weight = in_array($row['REMOTE_TABLE'], $externalTables) ? 0 : 1; // TODO Nie ujmowanie w glebokosci przejscia z bazy wewnetrznej Energi do baz zewnetrznych
|
|
|
+ $weight = 1;
|
|
|
$this->findPowiazania($row['ID'], $weight);
|
|
|
$this->saveProgress(['progress' => 1, 'message' => "Zakończono wyszukiwanie powiązań dla obiektu {$this->i}/{$this->count}"]);
|
|
|
$this->lastResults = count($this->results);
|
|
|
@@ -3480,6 +3490,7 @@ class BiAuditPowiazania {
|
|
|
$this->items_results[$resultsPart] = [];
|
|
|
$this->items_results[$resultsPart]['@attributes'] = ['xmlns:system_cache__dita' => 'http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/dita.xsd'];
|
|
|
$this->items_results[$resultsPart][$xmlTask]['@attributes'] = ['fid' => "{$xmlTask}.{$this->ID}"];
|
|
|
+ $this->items_results[$resultsPart][$xmlTask]['L_APPOITMENT_INFO'] = $this->L_APPOITMENT_INFO;
|
|
|
|
|
|
if ($resultsPart === null) {
|
|
|
$results = $this->results;
|