|
@@ -2284,7 +2284,7 @@ class BiAuditPowiazania {
|
|
|
}
|
|
}
|
|
|
$query = implode(" union ", $subQueries);
|
|
$query = implode(" union ", $subQueries);
|
|
|
$resultDst = DB::getPDO()->fetchAll($query);
|
|
$resultDst = DB::getPDO()->fetchAll($query);
|
|
|
- if (!$resultDst) self::throwException("Błąd danych - nie zdefinowano żadnego końcowego obiektu");
|
|
|
|
|
|
|
+ if ((!$resultDst) && $this->onlyTargets) self::throwException("Błąd danych - nie zdefinowano żadnego końcowego obiektu");
|
|
|
|
|
|
|
|
$refPowiazaniaToPracownicy = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'BI_audit_ENERGA_PRACOWNICY', true);
|
|
$refPowiazaniaToPracownicy = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'BI_audit_ENERGA_PRACOWNICY', true);
|
|
|
$query = "select `all`.`ID` from `BI_audit_ALL` `all` join `{$refPowiazaniaToPracownicy}` `ref`
|
|
$query = "select `all`.`ID` from `BI_audit_ALL` `all` join `{$refPowiazaniaToPracownicy}` `ref`
|
|
@@ -2292,7 +2292,7 @@ class BiAuditPowiazania {
|
|
|
$resultSrc = DB::getPDO()->fetchAll($query);
|
|
$resultSrc = DB::getPDO()->fetchAll($query);
|
|
|
if (!$resultSrc) self::throwException("Błąd danych - nie zdefinowano żadnego początkowego obiektu");
|
|
if (!$resultSrc) self::throwException("Błąd danych - nie zdefinowano żadnego początkowego obiektu");
|
|
|
|
|
|
|
|
- if (count($resultSrc) <= count($resultDst)) {
|
|
|
|
|
|
|
+ if (count($resultSrc) <= count($resultDst) || (!$this->onlyTargets)) {
|
|
|
$result = $resultSrc;
|
|
$result = $resultSrc;
|
|
|
$this->endNodes = array_map('reset', $resultDst);
|
|
$this->endNodes = array_map('reset', $resultDst);
|
|
|
$this->query = "select ref.ID2 as ID, RELATION_ID from BI_audit_ALL_ref ref where ref.ID1";
|
|
$this->query = "select ref.ID2 as ID, RELATION_ID from BI_audit_ALL_ref ref where ref.ID1";
|
|
@@ -2338,6 +2338,7 @@ class BiAuditPowiazania {
|
|
|
|
|
|
|
|
$this->nodes = [];
|
|
$this->nodes = [];
|
|
|
self::saveToLog("Zakończono wyszukiwanie powiązań");
|
|
self::saveToLog("Zakończono wyszukiwanie powiązań");
|
|
|
|
|
+ $this->sortResults();
|
|
|
$this->saveResults();
|
|
$this->saveResults();
|
|
|
//$this->saveToDb(); 2017-12-14 - przerobiono na zapisywanie danych do bazy w locie
|
|
//$this->saveToDb(); 2017-12-14 - przerobiono na zapisywanie danych do bazy w locie
|
|
|
$this->splitResults();
|
|
$this->splitResults();
|
|
@@ -2418,6 +2419,24 @@ class BiAuditPowiazania {
|
|
|
array_pop($this->path);
|
|
array_pop($this->path);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function sortResults() {
|
|
|
|
|
+ if (!$this->results) return;
|
|
|
|
|
+ uasort($this->results, function ($a, $b) {
|
|
|
|
|
+ $ca = count($a);
|
|
|
|
|
+ $cb = count($b);
|
|
|
|
|
+ $c = min($ca, $cb);
|
|
|
|
|
+ $ka = array_keys($a);
|
|
|
|
|
+ $kb = array_keys($b);
|
|
|
|
|
+ for ($i = 0; $i < $c; $i++) {
|
|
|
|
|
+ if ($ka[$i] < $kb[$i]) return -1;
|
|
|
|
|
+ if ($ka[$i] > $kb[$i]) return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($ca < $cb) return -1;
|
|
|
|
|
+ if ($ca > $cb) return 1;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function saveResults() {
|
|
private function saveResults() {
|
|
|
self::saveToLog("Zapisuję wyliczone dane do pliku");
|
|
self::saveToLog("Zapisuję wyliczone dane do pliku");
|
|
|
if (!$this->results) {
|
|
if (!$this->results) {
|