|
@@ -1236,6 +1236,50 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static function importPracownicy() { //TODO
|
|
|
|
|
+ $fields = [
|
|
|
|
|
+ 'BI_audit_ENERGA_PRACOWNICY' = [
|
|
|
|
|
+ 'PERNR',
|
|
|
|
|
+ 'imiona',
|
|
|
|
|
+ 'nazwisko',
|
|
|
|
|
+ 'pesel',
|
|
|
|
|
+ 'nr_konta',
|
|
|
|
|
+ 'jednostka_organizacyjna',
|
|
|
|
|
+ 'nip',
|
|
|
|
|
+ 'regon',
|
|
|
|
|
+ 'source',
|
|
|
|
|
+ ],
|
|
|
|
|
+ 'BI_audit_ENERGA_PRACOWNICY_adresy' = [
|
|
|
|
|
+ 'kodPocztowy',
|
|
|
|
|
+ 'miejscowosc',
|
|
|
|
|
+ 'ulica',
|
|
|
|
|
+ 'nrBudynku',
|
|
|
|
|
+ 'nrLokalu',
|
|
|
|
|
+ ],
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ $query = "select * from `BI_audit_ENERGA_PRACOWNICY_import` where `importResult` = 'none'";
|
|
|
|
|
+ $pracownicy = DB::getPDO()->query($query);
|
|
|
|
|
+ while ($pracownik = $pracownicy->fetch()) {
|
|
|
|
|
+ $ID_pracownik = DB::getPDO()->fetchValue("select `ID` from `BI_audit_ENERGA_PRACOWNICY` where `pesel` = '{$pracownik['pesel']}'");
|
|
|
|
|
+ $sqlArr = [];
|
|
|
|
|
+ foreach ($fields['BI_audit_ENERGA_PRACOWNICY'] as $field) $sqlArr[$field] = trim($pracownik[$field]);
|
|
|
|
|
+ if ($ID_pracownik) DB::getPDO()->update('BI_audit_ENERGA_PRACOWNICY', 'ID', $ID, $sqlArr);
|
|
|
|
|
+ else $ID_pracownik = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY', $sqlArr);
|
|
|
|
|
+
|
|
|
|
|
+ $sqlArr = [];
|
|
|
|
|
+ foreach ($fields['BI_audit_ENERGA_PRACOWNICY_adresy'] as $field) {
|
|
|
|
|
+ $sqlArr[$field] = trim($pracownik[$field]);
|
|
|
|
|
+ if (!$sqlArr[$field]) unset $sqlArr[$field];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!$sqlArr) break;
|
|
|
|
|
+ $sql = [];
|
|
|
|
|
+// foreach ($fields['BI_audit_ENERGA_PRACOWNICY_adresy'] as $field) {
|
|
|
|
|
+//// if (isset($sqlArr[$field])) $sql[] = "`{$field}` = " . DUPA;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static function reloadCache_parseUmowy($full = false) {
|
|
private static function reloadCache_parseUmowy($full = false) {
|
|
|
$fields = [
|
|
$fields = [
|
|
|
'BI_audit_ENERGA_RUM_KONTRAHENCI' => [
|
|
'BI_audit_ENERGA_RUM_KONTRAHENCI' => [
|
|
@@ -1776,6 +1820,7 @@ SQL;
|
|
|
$reloadCacheResultFile = $tasksDirLocation . "/reloadCache.result";
|
|
$reloadCacheResultFile = $tasksDirLocation . "/reloadCache.result";
|
|
|
file_put_contents($reloadCachePidFile, getmypid());
|
|
file_put_contents($reloadCachePidFile, getmypid());
|
|
|
try {
|
|
try {
|
|
|
|
|
+ //self::importPracownicy(); //TODO
|
|
|
self::reloadCache_reTeryt($full);
|
|
self::reloadCache_reTeryt($full);
|
|
|
self::reloadCache_parseUmowy($full);
|
|
self::reloadCache_parseUmowy($full);
|
|
|
self::reloadCache_updateAll($full, $onlyBase);
|
|
self::reloadCache_updateAll($full, $onlyBase);
|
|
@@ -1993,7 +2038,7 @@ class BiAuditPowiazania {
|
|
|
private $lowProgressCount = 0;
|
|
private $lowProgressCount = 0;
|
|
|
private $count, $i;
|
|
private $count, $i;
|
|
|
private $splittedResults = [];
|
|
private $splittedResults = [];
|
|
|
- private $maxResults = 200000;
|
|
|
|
|
|
|
+ private $maxResults = 1000000;
|
|
|
|
|
|
|
|
private function getRefTable($tableFrom, $tableTo, $returnException = true) {
|
|
private function getRefTable($tableFrom, $tableTo, $returnException = true) {
|
|
|
if (!isset($this->refTables[$tableFrom][$tableTo])) {
|
|
if (!isset($this->refTables[$tableFrom][$tableTo])) {
|
|
@@ -2024,12 +2069,12 @@ class BiAuditPowiazania {
|
|
|
private function saveProgress($progress, $message = null) {
|
|
private function saveProgress($progress, $message = null) {
|
|
|
$timestamp = microtime(true);
|
|
$timestamp = microtime(true);
|
|
|
if ($progress !== null && $this->i) {
|
|
if ($progress !== null && $this->i) {
|
|
|
- $this->lastProgress = $progress;
|
|
|
|
|
$elapsed = $timestamp - $this->startTimestamp;
|
|
$elapsed = $timestamp - $this->startTimestamp;
|
|
|
if ($progress) {
|
|
if ($progress) {
|
|
|
- $lastElapsed = $timestamp - $this->lastTimestamp;
|
|
|
|
|
- $lastProgress = $progress - $this->lastProgress;
|
|
|
|
|
- $estimated = (($elapsed * (1 - $progress)) / $progress + ($lastElapsed * (1 - $lastProgress)) / $lastProgress) / 2;
|
|
|
|
|
|
|
+ //$lastElapsed = $timestamp - $this->lastTimestamp;
|
|
|
|
|
+ //$lastProgress = $progress - $this->lastProgress;
|
|
|
|
|
+ //$estimated = (($elapsed * (1 - $progress)) / $progress + ($lastElapsed * (1 - $lastProgress)) / $lastProgress) / 2;
|
|
|
|
|
+ $estimated = ($elapsed * (1 - $progress)) / $progress;
|
|
|
} else $estimated = "N/A";
|
|
} else $estimated = "N/A";
|
|
|
$this->lastProgress = $progress;
|
|
$this->lastProgress = $progress;
|
|
|
$this->lastTimestamp = $timestamp;
|
|
$this->lastTimestamp = $timestamp;
|
|
@@ -2042,8 +2087,6 @@ class BiAuditPowiazania {
|
|
|
file_put_contents($this->progressFile, json_encode($this->progress));
|
|
file_put_contents($this->progressFile, json_encode($this->progress));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
private static function throwException($message) {
|
|
private static function throwException($message) {
|
|
|
self::saveToLog($message);
|
|
self::saveToLog($message);
|
|
|
throw new Exception($message);
|
|
throw new Exception($message);
|