Pārlūkot izejas kodu

文件列表增加返回model浏览链接

waymen 6 mēneši atpakaļ
vecāks
revīzija
5bf19ebaa5

+ 1 - 0
app/Http/Controllers/API/FolderController.php

@@ -286,6 +286,7 @@ class FolderController extends Controller
 
 
         $files = File::query()->where($objectWhere)
+            ->with('bimFile')
             ->where("folder_id", $folderId)
             ->where("is_latest_version", 1)
             ->orderBy('updated_at', $orderBy)

+ 11 - 2
app/Http/Resources/API/FileByObjectResource.php

@@ -2,10 +2,13 @@
 
 namespace App\Http\Resources\API;
 
+use App\Libraries\BIM\BIMFactory;
+use App\Models\Enums\BimFileConvertStatus;
 use Illuminate\Http\Request;
 use Illuminate\Http\Resources\Json\JsonResource;
 use Illuminate\Support\Facades\Storage;
 
+
 class FileByObjectResource extends JsonResource
 {
     /**
@@ -20,9 +23,15 @@ class FileByObjectResource extends JsonResource
             'title' => $this->title,
             'extension' => $this->extension,
             'download_url' => Storage::url($this->pathname),
+            $this->mergeWhen(
+                $this->is_bim == 1 && $this->bimFile && $this->bimFile->convert_status == BimFileConvertStatus::DONE,
+                [
+                    'model_view_url' => BIMFactory::make($this->bimFile->bim_driver)->getModelViewLink($this->bimFile->bim_data_set_id),
+                ]
+            ),
             'size' => $this->size,
-            'created_by' => $this->createdBy?new UserProfileResource($this->createdBy):null,
-            'created_at' => (string)$this->created_at,
+            'created_by' => $this->createdBy ? new UserProfileResource($this->createdBy) : null,
+            'created_at' => (string) $this->created_at,
             'version' => $this->version,
         ];
     }

+ 5 - 0
app/Libraries/BIM/BlackHole/BlackHole.php

@@ -106,6 +106,11 @@ class BlackHole extends BIMAbstract
         return $result['data'] ?? [];
     }
 
+    public function getModelViewLink(string $dataSetId): string
+    {
+        return '';
+    }
+
 
     /**
      * 模型文件上传准备

+ 2 - 0
app/Libraries/BIM/Contacts/BIMContact.php

@@ -15,4 +15,6 @@ interface BIMContact {
     public function viewDataSetModel(array $dataSetIDS);
 
     public function addToConvertQueue(string $dataSetId): array;
+
+    public function getModelViewLink(string $dataSetId): string;
 }

+ 12 - 2
app/Libraries/BIM/Glendale/Glendale.php

@@ -15,7 +15,7 @@ class Glendale extends BIMAbstract
     public function uploadFile(UploadedFile $file, array $params = [])
     {
         $uploadFormData = [
-            ['name' => 'file', 'contents' =>  fopen($file, 'r+'), 'filename' => $file->getClientOriginalName()]
+            ['name' => 'file', 'contents' => fopen($file, 'r+'), 'filename' => $file->getClientOriginalName()]
         ];
 
         $result = Client::getInstance()->post('/api/app/model/upload-file', [
@@ -53,7 +53,7 @@ class Glendale extends BIMAbstract
             ]
         ]);
 
-        $getStatus = function($status) {
+        $getStatus = function ($status) {
             if ($status >= 1 && $status <= 99) {
                 return BimFileConvertStatus::CONVERTING->value;
             }
@@ -89,4 +89,14 @@ class Glendale extends BIMAbstract
     {
         return [];
     }
+
+    /**
+     * 获取model的浏览链接
+     * @param string $dataSetId
+     * @return string
+     */
+    public function getModelViewLink(string $dataSetId): string
+    {
+        return config('bim.glendale.view_url') . '/#/webgl?id=' . $dataSetId;
+    }
 }

+ 1 - 1
app/Tools/ApiAnonymousResourceCollection.php

@@ -13,7 +13,7 @@ class ApiAnonymousResourceCollection extends AnonymousResourceCollection
                 'current_page' => $paginated['current_page'],
                 'from' => $paginated['from'],
                 'last_page' => $paginated['last_page'],
-                'path' => $paginated['path'],
+                // 'path' => $paginated['path'],
                 'per_page' => $paginated['per_page'],
                 'to' => $paginated['to'],
                 'total' => $paginated['total'],

+ 5 - 2
config/bim.php

@@ -3,7 +3,9 @@
 return [
     'default' => env('BIM_DRIVER', 'black_hole'),
 
-    'extensions' => ['rvt', 'ifc', 'fbx', '3dxml', 'gim', 'igms', 'stp', 'gltf', '3dm', 'skp', 'glb', 'dgn', 'nwd', 'nwc'],
+    'gis_extensions' => ['las', 'ply', 'pnts', 'czml', 'kml', 'wms', 'geojson', 'shp', 'bgltf', 'glb', 'glbf', 'b3dm', 'osgb'],
+
+    'extensions' => ['rvt', 'ifc', 'fbx', '3dxml', 'gim', 'igms', 'stp', 'gltf', '3dm', 'skp', 'glb', 'dgn', 'nwd', 'nwc', 'dwg', 'rfa', 'stl', 'iges'],
 
     'black_hole' => [
         'host' => env("BLACK_HOLE_HOST", "http://175.178.242.215:9012/"),
@@ -14,7 +16,8 @@ return [
     ],
 
     'glendale' => [
-        'host' => env("GLENDALE_HOST", "http://101.33.225.105:18086/"),
+        'host' => env("GLENDALE_HOST", "http://159.75.168.101:18086/"),
+        'view_url' => env("GLENDALE_VIEW_URL", "http://159.75.168.101:18083"),
         'token' => env("GLENDALE_TOKEN"),
         'project_id' => env("GLENDALE_PROJECT_ID"),
     ]