123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace App\Services\File\BIM\Glendale;
- use App\Models\Enums\BimFileConvertStatus;
- use App\Services\File\BIM\Contacts\BIMContact;
- use Illuminate\Http\UploadedFile;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Storage;
- use Ramsey\Uuid\Uuid;
- class Glendale implements BIMContact
- {
- public function uploadFile(UploadedFile $file, array $params = [])
- {
- /*dump([
- 'name' => $file->getClientOriginalName(),
- 'initiatingUser' => Auth::user()->name,
- 'uniqueCode' => Uuid::uuid4(),
- 'priority' => 205,
- 'isCAD' => $params['is_cad'],
- 'modelDownloadUrl' => Storage::url($params['pathname'])
- ]);*/
- $uploadFormData = [
- ['name' => 'file', 'contents' => fopen($file, 'r')]
- ];
- $result = Client::getInstance()->post('/api/app/model/transcode-file', [
- 'query_params' => [
- 'input' => json_encode([
- 'name' => $file->getClientOriginalName(),
- 'initiatingUser' => Auth::user()->name,
- 'uniqueCode' => Uuid::uuid4(),
- 'priority' => 205,
- 'isCAD' => $params['is_cad'],
- 'modelDownloadUrl' => $params['pathname'],
- "configJson" => ExtensionModelConfig::getConfigOption($params['extension']),
- ])
- ],
- //'multipart' => $uploadFormData,
- ]);
- dump($result);
- }
- public function downloadSourceFile()
- {
- // TODO: Implement downloadSourceFile() method.
- }
- public function findConvertStatus(string $dataSetId)
- {
- $result = Client::getInstance()->post('/api/app/model/query-model-info', [
- 'query_params' => [
- 'LightweightName' => $dataSetId
- ]
- ]);
- $getStatus = function($status) {
- if ($status >= 1 && $status <= 99) {
- return BimFileConvertStatus::CONVERTING->value;
- }
- if ($status <= 0) {
- return BimFileConvertStatus::FAILED_TO_ADD_QUEUE->value;
- }
- return BimFileConvertStatus::IN_QUEUE->value;
- };
- return match ($result['data']['status']) {
- 0, 1, 101 => BimFileConvertStatus::IN_QUEUE->value,
- 100 => BimFileConvertStatus::DONE->value,
- default => $getStatus($result['data']['status'])
- };
- }
- public function viewDataSetModel(array $dataSetIDS)
- {
- $result = Client::getInstance()->get('/api/app/model/model-SourceFileurl', [
- 'LightweightName' => $dataSetIDS[0]
- ]);
- return [
- 'datas' => $result['datas']
- ];
- }
- public function addToConvertQueue(string $dataSetId): array
- {
- return [];
- }
- }
|