Добавлен расширенный отчет по реализации
Добавлен монитор активности
This commit is contained in:
miroman-afk
2023-08-03 11:05:15 +03:00
parent 19ad7d1c8a
commit c4dc6e02a0
93 changed files with 13328 additions and 1122 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Commands;
use App\Component\Models\Base;
use App\Component\Models\Places;
use App\Component\Models\Tables;
use App\Component\Models\Terminal;
@@ -11,6 +12,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Mtownsend\XmlToArray\XmlToArray;
class GETRoomMapFile extends HRCCommand implements HRCCommandInterface
{
@@ -74,19 +76,79 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface
'message' => 'Файлы не найдены'
];
}
$objXmlDocument = simplexml_load_file($places_file);
$objJsonDocument = json_encode($objXmlDocument);
$xmlPlaces = json_decode($objJsonDocument, TRUE);
$xmlPlaces = XmlToArray::convert(file_get_contents($places_file));
Schema::disableForeignKeyConstraints();
DB::table('place_tables')->truncate();
DB::table('places')->truncate();
Schema::enableForeignKeyConstraints();
if (count($xmlPlaces['Place']) > 2) {
foreach ($xmlPlaces['Place'] as $xmlPlace) {
if (count($xmlPlaces['Place']) > 1) {
$places = $xmlPlaces['Place'];
foreach ($places as $place) {
$newPlace = new Places;
$newPlace->name = $xmlPlace['@attributes']['name'];
$newPlace->name = $place['@attributes']['name'];
if ($place['@attributes']['image'] != "false") {
$newPlace->image = base64_encode(Base::customBase64Decode($place['@attributes']['image']));
$newPlace->save();
$image = $newPlace->image;
$imageName = "place-" . $newPlace->id . ".png";
file_put_contents($dirname . $imageName, base64_decode($image));
} else {
$newPlace->save();
}
$tables = $place['Table'];
if (count($tables) > 1) {
foreach ($tables as $table) {
$newTable = new Tables;
$newTable->name = $table['@attributes']['text'];
$newTable->table_id = intval($table['@attributes']['number']);
$newTable->place_id = $newPlace['id'];
$newTable->width = $table['@attributes']['width'];
$newTable->height = $table['@attributes']['height'];
$newTable->x = $table['@attributes']['y'];
$newTable->y = $table['@attributes']['x'];
if (isset($table['@attributes']['type'])) {
$newTable->type = intval($table['@attributes']['type']);
} else {
$newTable->type = 0;
}
$newTable->save();
}
} else {
$table = $place['Table'];
$newTable = new Tables;
$newTable->name = $table['@attributes']['text'];
$newTable->table_id = intval($table['@attributes']['number']);
$newTable->place_id = $newPlace['id'];
$newTable->width = $table['@attributes']['width'];
$newTable->height = $table['@attributes']['height'];
$newTable->x = $table['@attributes']['y'];
$newTable->y = $table['@attributes']['x'];
if (isset($table['@attributes']['type'])) {
$newTable->type = intval($table['@attributes']['type']);
} else {
$newTable->type = 0;
}
$newTable->save();
}
}
} else {
$place = $xmlPlaces['Place'];
$newPlace = new Places;
$newPlace->name = $place['@attributes']['name'];
if ($place['@attributes']['image'] != "false") {
$newPlace->image = $place['@attributes']['image'];
$newPlace->save();
$tables = $xmlPlace['Table'];
$image = $newPlace->image;
$image = str_replace(array('\r\n', '\r', '\n'), '', $image);
$image = str_replace(' ', '', $image);
$imageName = "place-" . $newPlace->id . ".png";
file_put_contents($dirname . $imageName, base64_decode($image));
} else {
$newPlace->save();
}
$tables = $place['Table'];
if (count($tables) > 1) {
foreach ($tables as $table) {
$newTable = new Tables;
$newTable->name = $table['@attributes']['text'];
@@ -103,17 +165,8 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface
}
$newTable->save();
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
} else {
$newPlace = new Places;
$newPlace->name = $xmlPlaces['Place']['@attributes']['name'];
$newPlace->save();
$tables = $xmlPlaces['Place']['Table'];
foreach ($tables as $table) {
} else {
$table = $place['Table'];
$newTable = new Tables;
$newTable->name = $table['@attributes']['text'];
$newTable->table_id = intval($table['@attributes']['number']);
@@ -129,11 +182,10 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface
}
$newTable->save();
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
}