123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Services\File\BIM\BlackHole;
- use App\Services\File\BIM\Contacts\BIMContact;
- use Illuminate\Http\UploadedFile;
- 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);
- dump($modelFile);
- //$this->modelFileCreate(config("bim.black_hole.project_id"), $file);
- }
- public function downloadSourceFile()
- {
- }
- protected function modelFileCreate(string $projectId, string $nodeId, UploadedFile $file)
- {
- $formData = [
- 'ProjId' => $projectId,
- 'DataSetId' => $nodeId,
- 'FileName' => $file->getClientOriginalName(),
- 'FileSize' => $file->getSize(),
- 'FileType' => $file->getExtension() ? $file->getExtension() : pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION),
- 'Scheme' => 'Bim',
- 'BlobCount' => 1,
- 'BlobSize' => $file->getSize(),
- 'UploadWay' => 0
- ];
- $result = Client::getInstance()->request("POST", "/blackHole3D/project/modelFile/create", [
- 'form_params' => $formData,
- 'headers' => [
- 'fileUploadScheme' => 'Bim',
- 'fileUploadMode' => 'ResumableCreate'
- ]
- ]);
- return $result['data'] ?? [];
- }
- protected function getTreeById(string $projectId)
- {
- $result = Client::getInstance()->request("POST", "/blackHole3D/project/modelTree/getTreeById", [
- 'json' => [
- 'projId' => $projectId
- ]
- ]);
- return $result['data'] ?? [];
- }
- protected function addLeafNodes(array $nodes, string $parentId = "")
- {
- $items = [];
- foreach ($nodes as $node) {
- $items[]['dataSetName'] = $node;
- }
- $result = Client::getInstance()->request("POST", "/blackHole3D/project/modelTree/addLevelNodes", [
- 'json' => [
- 'parentId' => $parentId,
- 'dataSets' => $items
- ]
- ]);
- dump([
- 'parentId' => $parentId,
- 'dataSets' => $items
- ]);
- dump($result);
- }
- }
|