1. Редактор карты зала.
This commit is contained in:
miroman-afk
2022-10-27 15:48:02 +03:00
parent 0e5f2002b1
commit 4d3ad7727d
21 changed files with 625 additions and 192 deletions

View File

@@ -12,10 +12,12 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class GETRoomMapFile extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getroommapfile';
class GETRoomMapFile extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'getroommapfile';
public function command($input, $output = null) {
public function command($input, $output = null)
{
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->first();
$files = [];
@@ -31,10 +33,14 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface {
foreach ($response_files->json()['files'] as $response) {
$filename = $response['filename'];
$basename = $response['basename'];
$files[$response['timestamp']] = array('filename' => $filename, 'basename' => $basename);
$files[$response['timestamp']] = array(
'filename' => $filename,
'basename' => $basename
);
}
if (count($files) == 0) {
return ['status' => 'success',
return [
'status' => 'success',
'message' => 'Файлы не найдены'
];
}
@@ -63,25 +69,51 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface {
}
$places_file = $dirname . $basename;
} else {
return ['status' => 'success',
return [
'status' => 'success',
'message' => 'Файлы не найдены'
];
}
$objXmlDocument = simplexml_load_file($places_file);
$objJsonDocument = json_encode($objXmlDocument);
$xmlPlaces = json_decode($objJsonDocument, TRUE);
Schema::disableForeignKeyConstraints();
DB::table('place_tables')->truncate();
DB::table('places')->truncate();
Schema::enableForeignKeyConstraints();
foreach ($xmlPlaces['Place'] as $xmlPlace) {
$place_name = $xmlPlace['@attributes']['name'];
if (count($xmlPlaces['Place']) > 2) {
foreach ($xmlPlaces['Place'] as $xmlPlace) {
$newPlace = new Places;
$newPlace->name = $xmlPlace['@attributes']['name'];
$newPlace->save();
$tables = $xmlPlace['Table'];
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();
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
} else {
$newPlace = new Places;
$newPlace->name = $place_name;
$newPlace->name = $xmlPlaces['Place']['@attributes']['name'];
$newPlace->save();
foreach ($xmlPlace['Table'] as $table) {
$tables = $xmlPlaces['Place']['Table'];
foreach ($tables as $table) {
$newTable = new Tables;
$newTable->name = $table['@attributes']['text'];
$newTable->table_id = intval($table['@attributes']['number']);
@@ -90,12 +122,18 @@ class GETRoomMapFile extends HRCCommand implements HRCCommandInterface {
$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();
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
return [
'status' => 'success',
'places' => $xmlPlaces
];
}
}
}