Browse Source

黑洞接口调用和调试

moell 10 months ago
parent
commit
5cef9f34d5

+ 12 - 10
app/Services/File/BIM/BlackHole/BlackHole.php

@@ -9,31 +9,33 @@ class BlackHole implements BIMContact
 {
     public function uploadFile(UploadedFile $file, array $params = [])
     {
-        //$this->addLeafNodes(['Node1', 'Node2'], config("bim.black_hole.project_id"));
-
         $projectId = config("bim.black_hole.project_id");
         $treeInfo = $this->getTreeById($projectId);
 
         $modelFile = $this->modelFileCreate($projectId, $treeInfo['subNodes'][0]['nodeId'], $file);
+        $dataSetId = $modelFile['dataSetId'];
 
         $uploadFormData = [
             ['name' => 'FileId', 'contents' => $modelFile['fileId']],
-            ['name' => 'FileInfo', 'contents' => $file],
+            ['name' => 'FileInfo', 'contents' => fopen($file, 'r'), 'filename' => $file->getClientOriginalName()],
             ['name' => 'FileDataId', 'contents' => $modelFile['fileDataId']],
-            ['name' => 'Key', 'contents' => uniqid()],
+            ['name' => 'Key', 'contents' => $modelFile['extraProperties']['ResumableKey']],
             ['name' => 'BlobIndex', 'contents' => 0],
         ];
 
-        $result = Client::getInstance()->post("/blackHole3D/project/modelFile/append", [
+        Client::getInstance()->post("/blackHole3D/project/modelFile/append", [
             'multipart' => $uploadFormData,
             'headers' => [
                 'fileUploadScheme' => 'Bim',
-                'fileUploadMode' => 'ResumableCreate'
-            ]
+                'fileUploadMode' => 'ResumableAppend',
+            ],
         ]);
 
-        dump($result);
-
+        return [
+            'bim_data_set_id' => $dataSetId,
+            'bim_file_id' => $modelFile['fileId'],
+            'bim_convert_status' => 0,
+        ];
     }
 
     public function downloadSourceFile()
@@ -74,7 +76,7 @@ class BlackHole implements BIMContact
         ];
 
         $result = Client::getInstance()->post("/blackHole3D/project/modelFile/addToConvertQueue", [
-            'json' => $formData
+            'json' => $formData,
         ]);
 
         return $result['data'] ?? [];

+ 1 - 0
app/Services/File/BIM/BlackHole/Client.php

@@ -18,6 +18,7 @@ class Client {
         $this->client = new \GuzzleHttp\Client([
             'base_uri' => config("bim.black_hole.host"),
             'http_errors' => false,
+            'debug' => false,
             'headers' => [
                 'Accept' => "application/json",
                 'ClientId' => config("bim.black_hole.client_id"),

+ 28 - 0
database/migrations/2024_05_11_130202_add_bim_fields_to_files_table.php

@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('files', function (Blueprint $table) {
+            $table->boolean("is_bim")->default(false);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('files', function (Blueprint $table) {
+            $table->dropColumn(['is_bim']);
+        });
+    }
+};

+ 32 - 0
database/migrations/2024_05_11_171639_create_bim_files_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('bim_files', function (Blueprint $table) {
+            $table->id();
+            $table->index("file_id");
+            $table->string("bim_driver")->nullable();
+            $table->string("bim_data_set_id", 40)->nullable();
+            $table->string("bim_file_id", 40)->nullable();
+            $table->tinyInteger("convert_status")->default(0);
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('bim_files');
+    }
+};