|
@@ -1949,6 +1949,8 @@ SQL;
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ $BiAuditPowiazania = new BiAuditPowiazania($ID, $tasksDirLocation);
|
|
|
|
|
+
|
|
|
$query = "select count(*) from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA` where `FILE_STATUS` = 'IN_PROGRESS' and `BI_analiza_reloadCache` = 'Part' and ID != ${ID}";
|
|
$query = "select count(*) from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA` where `FILE_STATUS` = 'IN_PROGRESS' and `BI_analiza_reloadCache` = 'Part' and ID != ${ID}";
|
|
|
$sqlArr = [
|
|
$sqlArr = [
|
|
|
'BI_analiza_reloadCache' => 'Part',
|
|
'BI_analiza_reloadCache' => 'Part',
|
|
@@ -1966,7 +1968,7 @@ SQL;
|
|
|
} while ($activeReloadingCache);
|
|
} while ($activeReloadingCache);
|
|
|
|
|
|
|
|
BiAuditPowiazania::saveToLog("Uruchamiam częściowe odświeżenie cache");
|
|
BiAuditPowiazania::saveToLog("Uruchamiam częściowe odświeżenie cache");
|
|
|
- $this->doReloadCache();
|
|
|
|
|
|
|
+// $this->doReloadCache();
|
|
|
BiAuditPowiazania::saveToLog("Odświeżono częściowo cache");
|
|
BiAuditPowiazania::saveToLog("Odświeżono częściowo cache");
|
|
|
|
|
|
|
|
$sqlArr = [
|
|
$sqlArr = [
|
|
@@ -1975,7 +1977,7 @@ SQL;
|
|
|
];
|
|
];
|
|
|
DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', "ID", $ID, $sqlArr);
|
|
DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', "ID", $ID, $sqlArr);
|
|
|
|
|
|
|
|
- $BiAuditPowiazania = new BiAuditPowiazania($ID, $tasksDirLocation);
|
|
|
|
|
|
|
+ $BiAuditPowiazania->run();
|
|
|
if (!$BiAuditPowiazania->powiazaniaFound()) throw new Exception("Nie znaleziono żadnych powiązań");
|
|
if (!$BiAuditPowiazania->powiazaniaFound()) throw new Exception("Nie znaleziono żadnych powiązań");
|
|
|
//file_put_contents($xmlFile, $BiAuditPowiazania->asXml());
|
|
//file_put_contents($xmlFile, $BiAuditPowiazania->asXml());
|
|
|
|
|
|
|
@@ -2184,11 +2186,12 @@ class BiAuditPowiazania {
|
|
|
private $progressFile;
|
|
private $progressFile;
|
|
|
private $progress = [
|
|
private $progress = [
|
|
|
'summary' => [
|
|
'summary' => [
|
|
|
- 'count' => null,
|
|
|
|
|
|
|
+ 'count' => 0,
|
|
|
'message' => 'Inicjacja',
|
|
'message' => 'Inicjacja',
|
|
|
'ts' => null,
|
|
'ts' => null,
|
|
|
'step' => 'initialize',
|
|
'step' => 'initialize',
|
|
|
- 'created' => 0,
|
|
|
|
|
|
|
+ 'reportsCount' => 0,
|
|
|
|
|
+ 'reportsCreated' => 0,
|
|
|
],
|
|
],
|
|
|
'details' => [],
|
|
'details' => [],
|
|
|
];
|
|
];
|
|
@@ -2248,14 +2251,16 @@ class BiAuditPowiazania {
|
|
|
public function __construct($ID = 0, $tasksDirLocation = null) {
|
|
public function __construct($ID = 0, $tasksDirLocation = null) {
|
|
|
if (!$ID) self::throwException("Wrong ID parameter");
|
|
if (!$ID) self::throwException("Wrong ID parameter");
|
|
|
if (!$tasksDirLocation) self::throwException("Wrong directory of tasks location");
|
|
if (!$tasksDirLocation) self::throwException("Wrong directory of tasks location");
|
|
|
|
|
+ $this->ID = $ID;
|
|
|
$this->tasksDirLocation = $tasksDirLocation;
|
|
$this->tasksDirLocation = $tasksDirLocation;
|
|
|
-
|
|
|
|
|
|
|
+ $this->progressFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.progress";
|
|
|
$this->saveProgress();
|
|
$this->saveProgress();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $query = "select BI_analiza_minDepth, BI_analiza_maxDepth, BI_analiza_onlyTargets from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full')";
|
|
|
|
|
|
|
+ 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')";
|
|
|
$result = DB::getPDO()->fetchAll($query);
|
|
$result = DB::getPDO()->fetchAll($query);
|
|
|
if (!$result) self::throwException("Błąd danych");
|
|
if (!$result) self::throwException("Błąd danych");
|
|
|
- $this->ID = $ID;
|
|
|
|
|
|
|
|
|
|
if ($this->loadResults()) {
|
|
if ($this->loadResults()) {
|
|
|
$this->splitResults();
|
|
$this->splitResults();
|
|
@@ -2282,7 +2287,6 @@ class BiAuditPowiazania {
|
|
|
|
|
|
|
|
self::saveToLog("Rozpoczynam wyszukiwanie powiązań");
|
|
self::saveToLog("Rozpoczynam wyszukiwanie powiązań");
|
|
|
|
|
|
|
|
- $this->progressFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.progress";
|
|
|
|
|
$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`
|
|
|
on `all`.`REMOTE_TABLE` = 'BI_audit_ENERGA_PRACOWNICY' and `all`.`REMOTE_ID` = `ref`.`REMOTE_PRIMARY_KEY` and `ref`.`PRIMARY_KEY` = '{$this->ID}' order by `all`.`ID` asc";
|
|
on `all`.`REMOTE_TABLE` = 'BI_audit_ENERGA_PRACOWNICY' and `all`.`REMOTE_ID` = `ref`.`REMOTE_PRIMARY_KEY` and `ref`.`PRIMARY_KEY` = '{$this->ID}' order by `all`.`ID` asc";
|
|
@@ -2449,10 +2453,7 @@ class BiAuditPowiazania {
|
|
|
$_keys = array_keys($this->results[$resultKey]);
|
|
$_keys = array_keys($this->results[$resultKey]);
|
|
|
$countByDest[end($_keys)][] = $resultKey;
|
|
$countByDest[end($_keys)][] = $resultKey;
|
|
|
}
|
|
}
|
|
|
- foreach ($countByDest as $resultKeys2) {
|
|
|
|
|
- while (count($resultKeys2) > $MAX) $resultsKeys[] = array_splice($resultKeys2, 0, $MAX);
|
|
|
|
|
- $resultsKeys[] = $resultKeys2;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ foreach ($countByDest as $resultKeys2) $resultsKeys = array_merge($resultsKeys, array_chunk($resultKeys2, $MAX));
|
|
|
} else $resultsKeys[] = $resultKeys;
|
|
} else $resultsKeys[] = $resultKeys;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2463,9 +2464,12 @@ class BiAuditPowiazania {
|
|
|
if (count($resultKeys) + count($next) <= $MAX) {
|
|
if (count($resultKeys) + count($next) <= $MAX) {
|
|
|
$resultKeys = array_merge($resultKeys, $next);
|
|
$resultKeys = array_merge($resultKeys, $next);
|
|
|
unset($resultsKeys[key($resultsKeys)]);
|
|
unset($resultsKeys[key($resultsKeys)]);
|
|
|
- } else next($resultsKeys);
|
|
|
|
|
|
|
+ } else break; //next($resultsKeys);
|
|
|
}
|
|
}
|
|
|
- $results[] = array_map(function ($resultKey) {return $this->results[$resultKey];}, $resultKeys);
|
|
|
|
|
|
|
+ $_results = [];
|
|
|
|
|
+ foreach ($resultKeys as $key) $_results[$key] = $this->results[$key];
|
|
|
|
|
+ $results[] = $_results;
|
|
|
|
|
+// $results[] = array_map(function ($resultKey) {return $this->results[$resultKey];}, $resultKeys);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->splittedResults = $results;
|
|
$this->splittedResults = $results;
|
|
@@ -2507,7 +2511,9 @@ class BiAuditPowiazania {
|
|
|
$query = "select * from `{$row['REMOTE_TABLE']}` where ID = '{$row['REMOTE_ID']}'";
|
|
$query = "select * from `{$row['REMOTE_TABLE']}` where ID = '{$row['REMOTE_ID']}'";
|
|
|
$obj = DB::fetch(DB::query($query));
|
|
$obj = DB::fetch(DB::query($query));
|
|
|
$item_result = [];
|
|
$item_result = [];
|
|
|
- if ($this->fidRow) $item_result['@attributes'] = ['fid' => "{$xmlObject}.{$this->fidRow[$key]['obj'][$ID]}"];
|
|
|
|
|
|
|
+ if ($this->fidRow) {
|
|
|
|
|
+ $item_result['@attributes'] = ['fid' => "{$xmlObject}.{$this->fidRow[$key]['obj'][$ID]}"];
|
|
|
|
|
+ }
|
|
|
$item_result[$row['REMOTE_TABLE']] = array_merge(['@attributes' => ['fid' => "{$row['REMOTE_TABLE']}.{$row['REMOTE_ID']}"]], (array) $obj);
|
|
$item_result[$row['REMOTE_TABLE']] = array_merge(['@attributes' => ['fid' => "{$row['REMOTE_TABLE']}.{$row['REMOTE_ID']}"]], (array) $obj);
|
|
|
|
|
|
|
|
if ($refTable = BiAuditRefTables::getRefTable('BI_audit_operational_raport_note', $row['REMOTE_TABLE'], false)) {
|
|
if ($refTable = BiAuditRefTables::getRefTable('BI_audit_operational_raport_note', $row['REMOTE_TABLE'], false)) {
|