Browse Source

HeiDongBimTest

kely 10 months ago
parent
commit
02353b9660
2 changed files with 65 additions and 23 deletions
  1. 21 22
      app/Http/Controllers/API/BimController.php
  2. 44 1
      app/Services/BimView/BimViewService.php

+ 21 - 22
app/Http/Controllers/API/BimController.php

@@ -8,33 +8,32 @@
 
 namespace App\Http\Controllers\API;
 use App\Http\Controllers\Controller;
+use App\Services\BimView\BimViewService;
 use GuzzleHttp\Client;
 use Illuminate\Support\Facades\Http;
 
 class BimController extends Controller
 {
-    public function bimView(){
-
-        $http=Http::accept('application/json')->withHeaders([
-            // 其他必要的头部信息
-            'ClientId' => 'test',
-            'SecretKey' => 'tROsEGDQ9zp7qEGJCtb5tQ==',
-            'UserId' => '3a095fd2-4134-8db1-5527-f950a48174b7',
-            // 注意:对于 GET 请求,通常不需要 Content-Type,除非你发送请求体
-        ]);
-        $getProjectResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/list',[
-            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
-        ]);
-
-        $getTreeByIdResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/modelTree/getTreeById',[
-            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
-        ]);
-
-        $getTreeByIdResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/modelFile/create',[
-            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
-        ]);
-
-        dd($getTreeByIdResponse->json());
+    public function bimView(BimViewService $service){
+
+//        $http=Http::accept('application/json')->withHeaders([
+//            // 其他必要的头部信息
+//            'ClientId' => 'test',
+//            'SecretKey' => 'tROsEGDQ9zp7qEGJCtb5tQ==',
+//            'UserId' => '3a095fd2-4134-8db1-5527-f950a48174b7',
+//            // 注意:对于 GET 请求,通常不需要 Content-Type,除非你发送请求体
+//        ]);
+//
+//        $getTreeByIdResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/modelTree/getTreeById',[
+//            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
+//        ]);
+//
+//        $getTreeByIdResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/modelFile/create',[
+//            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
+//        ]);
+
+        $response=$service->bimView();
+        dd($response->json());
 
         return ;
 

+ 44 - 1
app/Services/BimView/BimViewService.php

@@ -9,9 +9,52 @@
 namespace App\Services\BimView;
 
 
+use Illuminate\Support\Facades\Http;
+
 class BimViewService
 {
-    protected function getHttp(){
+    public function bimView(){
+        $http=$this->getHttp('application/json');
+        $getTreeByIdResponse=$http->post('http://106.52.199.205:9012/blackHole3D/project/modelTree/getTreeById',[
+            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1'
+        ]);
+        $getTree=$getTreeByIdResponse->json();
+        $nodeId=$getTree['data']['subNodes'][0]['nodeId'];
 
+        $filehttp=$this->getFileHttp('multipart/form-data');
+        $getModelFileResponse=$filehttp->post('http://106.52.199.205:9012/blackHole3D/project/modelFile/create',[ 'multipart' => [
+            "projId"=>'3a126eb4-979a-842c-70e6-3813f002cca1',
+            "DataSetId"=>$nodeId,
+            "FileName"=>"WDGC-Q-PL-B01-ASS_v2.rvt",
+            "FileSize"=>"32",
+            "Scheme"=>"file",
+            "BlobCount"=>1,
+            "BlobSize"=>32,
+            "UploadWay"=>0
+        ]]);
+        dd($getModelFileResponse->json());
+        return $getTreeByIdResponse;
+    }
+    protected function getHttp(string $accpt){
+        $http=Http::accept($accpt)->withHeaders([
+            // 其他必要的头部信息
+            'ClientId' => 'test',
+            'SecretKey' => 'tROsEGDQ9zp7qEGJCtb5tQ==',
+            'UserId' => '3a095fd2-4134-8db1-5527-f950a48174b7',
+        ]);
+        return $http;
     }
+
+    protected function getFileHttp(string $accpt){
+        $http=Http::accept($accpt)->withHeaders([
+            // 其他必要的头部信息
+            'ClientId' => 'test',
+            'SecretKey' => 'tROsEGDQ9zp7qEGJCtb5tQ==',
+            'UserId' => '3a095fd2-4134-8db1-5527-f950a48174b7',
+            'fileUploadScheme'=>"Bim",
+            'fileUploadMode'=>"ResumableCreate"
+        ]);
+        return $http;
+    }
+
 }