|
|
@@ -2216,6 +2216,8 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
private static function exec($cmd) {
|
|
|
+ $path = 'export PATH=$PATH:/usr/sbin;';
|
|
|
+ $cmd = "{$path} {$cmd}";
|
|
|
echo "CMD :: {$cmd}\n";
|
|
|
shell_exec($cmd);
|
|
|
}
|
|
|
@@ -2225,9 +2227,6 @@ class BiAuditPowiazania {
|
|
|
if (isset($args['progress']) && $this->i) {
|
|
|
$elapsed = $timestamp - $this->startTimestamp;
|
|
|
if ($args['progress']) {
|
|
|
- //$lastElapsed = $timestamp - $this->lastTimestamp;
|
|
|
- //$lastProgress = $progress - $this->lastProgress;
|
|
|
- //$estimated = (($elapsed * (1 - $progress)) / $progress + ($lastElapsed * (1 - $lastProgress)) / $lastProgress) / 2;
|
|
|
$estimated = ($elapsed * (1 - $args['progress'])) / $args['progress'];
|
|
|
} else $estimated = "N/A";
|
|
|
$this->lastProgress = $args['progress'];
|
|
|
@@ -2238,7 +2237,7 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
if (isset($args['message'])) $this->progress['summary']['message'] = $args['message'];
|
|
|
if (isset($args['step'])) $this->progress['summary']['step'] = $args['step'];
|
|
|
- if (isset($args['reportsCreated'])) $this->progress['summary']['reportsCreated'] += $args['reportsCreated'];
|
|
|
+ if (isset($args['reportsCreated'])) $this->progress['summary']['reportsCreated'] = round($this->progress['summary']['reportsCreated'] + $args['reportsCreated'], 2);
|
|
|
$this->progress['summary']['ts'] = $timestamp;
|
|
|
file_put_contents($this->progressFile, json_encode($this->progress));
|
|
|
}
|
|
|
@@ -2481,12 +2480,16 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
private function generateItemsResults($resultsPart = null) {
|
|
|
- self::saveToLog("Generuję dane na potrzeby utworzenia pliku XML ({$resultsPart})");
|
|
|
+ if ($resultsPart === null) self::saveToLog("Generuję dane na potrzeby utworzenia pojedynczego pliku XML");
|
|
|
+ else {
|
|
|
+ self::saveToLog("Generuję dane na potrzeby utworzenia pliku XML ({$resultsPart})");
|
|
|
+ if ($resultsPart >= $this->getPartsCount()) throw new Exception("generateItemsResults() error - bad part number");
|
|
|
+ }
|
|
|
+
|
|
|
$xmlTask = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA";
|
|
|
$xmlRow = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row";
|
|
|
$xmlObject = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object";
|
|
|
|
|
|
- $this->items_results = [];
|
|
|
$items_kontrahenci = [];
|
|
|
$items_kw_person = [];
|
|
|
$kontrahenci = [];
|
|
|
@@ -2496,10 +2499,13 @@ class BiAuditPowiazania {
|
|
|
$refUmowyToKontrahenci = BiAuditRefTables::getRefTable('BI_audit_ENERGA_RUM_UMOWY', 'BI_audit_ENERGA_RUM_KONTRAHENCI', true);
|
|
|
$refKwRequestedToKwRequestedPerson = BiAuditRefTables::getRefTable('BI_audit_KW_requested', 'BI_audit_KW_requested_person', true);
|
|
|
|
|
|
+ $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}"];
|
|
|
- if ($resultsPart === null) $results = $this->results;
|
|
|
- else {
|
|
|
+
|
|
|
+ if ($resultsPart === null) {
|
|
|
+ $results = $this->results;
|
|
|
+ } else {
|
|
|
$results = (!empty($this->splittedResults[$resultsPart])) ? $this->splittedResults[$resultsPart] : [];
|
|
|
$this->items_results[$resultsPart][$xmlTask]['@attributes']['system_cache__dita:part'] = ($resultsPart + 1);
|
|
|
}
|
|
|
@@ -2676,30 +2682,47 @@ class BiAuditPowiazania {
|
|
|
if (!is_dir($antDir)) mkdir($antDir, 0777, true);
|
|
|
$antXmlFilename = "relations-{$id_part}.out_task.dita.final_with_RelatedFeatureLoop.xml";
|
|
|
$antXmlFile = $antDir . "/" . $antXmlFilename;
|
|
|
+ $ditamapFile = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/relations-{$id_part}.ditamap";
|
|
|
$pdfFile = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/pdf/relations-{$id_part}.pdf";
|
|
|
$htmlDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/html";
|
|
|
+
|
|
|
if (!file_exists($antDir)) mkdir($antDir, 0770, true);
|
|
|
if (!is_dir($antDir)) {
|
|
|
$sqlArr['FILE_STATUS_info'] .= ", ale nie udało się utworzyć plików PDF i HTML";
|
|
|
self::saveToLog("Nie wygenerowano plików PDF oraz HTML - problem z utworzeniem katalogu dla ant ({$resultsPart})");
|
|
|
+ $this->saveProgress(['reportsCreated' => 1]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ copy($xmlFile, $antXmlFile);
|
|
|
+ self::saveToLog("Generuję plik przejściowy do wygenerowania plików PDF i HTML ({$resultsPart})");
|
|
|
+ self::exec("cd /Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree && /opt/local/bin/ant -f build_CRM_PROCES_tree.xml default_db:PROCES_INIT:tree:dita -Duuid=relations-{$id_part}");
|
|
|
+ if (file_exists($ditamapFile))
|
|
|
+ {
|
|
|
+ self::saveToLog("Wygenerowano plik przejściowy");
|
|
|
+ $this->saveProgress(['reportsCreated' => 0.3]);
|
|
|
} else {
|
|
|
- copy($xmlFile, $antXmlFile);
|
|
|
- self::exec("cd /Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree && /opt/local/bin/ant -f build_CRM_PROCES_tree.xml default_db:PROCES_INIT:tree:dita -Duuid=relations-{$id_part}");
|
|
|
- self::saveToLog("Generuję plik PDF ({$resultsPart})");
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o pdf -i relations-{$id_part}.ditamap -f pdf");
|
|
|
- if (file_exists($pdfFile)) {
|
|
|
- rename($pdfFile, $pdfDestFile);
|
|
|
- self::saveToLog("Wygenerowano plik PDF ({$resultsPart})");
|
|
|
- } else self::saveToLog("Nie udało się wygenerować pliku PDF ({$resultsPart})");
|
|
|
- self::saveToLog("Generuję pliki HTML ({$resultsPart})");
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o html -i relations-{$id_part}.ditamap -f tocjs");
|
|
|
- if (file_exists($htmlDir) && is_dir($htmlDir)) {
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && zip -r \"{$htmlZipDestFile}\" html");
|
|
|
- if (file_exists($htmlDestDir)) self::exec("rm -rf \"{$htmlDestDir}\"");
|
|
|
- self::exec("mv \"{$htmlDir}\" \"{$htmlDestDir}\"");
|
|
|
- self::saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
|
|
|
- } else self::saveToLog("Nie udało się wygenerować plików HTML {$resultsPart})");
|
|
|
- }
|
|
|
- $this->saveProgress(['reportsCreated' => 1]);
|
|
|
+ self::saveToLog("Nie udało się wygenerować pliku przejściowego, przerywm");
|
|
|
+ $this->saveProgress(['reportsCreated' => 1]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ self::saveToLog("Generuję plik PDF ({$resultsPart})");
|
|
|
+ self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o pdf -i relations-{$id_part}.ditamap -f pdf");
|
|
|
+ if (file_exists($pdfFile)) {
|
|
|
+ rename($pdfFile, $pdfDestFile);
|
|
|
+ self::saveToLog("Wygenerowano plik PDF ({$resultsPart})");
|
|
|
+ } else self::saveToLog("Nie udało się wygenerować pliku PDF ({$resultsPart})");
|
|
|
+ $this->saveProgress(['reportsCreated' => 0.35]);
|
|
|
+
|
|
|
+ self::saveToLog("Generuję pliki HTML ({$resultsPart})");
|
|
|
+ self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o html -i relations-{$id_part}.ditamap -f tocjs");
|
|
|
+ if (file_exists($htmlDir) && is_dir($htmlDir)) {
|
|
|
+ self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && zip -r \"{$htmlZipDestFile}\" html");
|
|
|
+ if (file_exists($htmlDestDir)) self::exec("rm -rf \"{$htmlDestDir}\"");
|
|
|
+ self::exec("mv \"{$htmlDir}\" \"{$htmlDestDir}\"");
|
|
|
+ self::saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
|
|
|
+ } else self::saveToLog("Nie udało się wygenerować plików HTML {$resultsPart})");
|
|
|
+ $this->saveProgress(['reportsCreated' => 0.35]);
|
|
|
}
|
|
|
}
|