Browse Source

add import data outline

haojianlong 5 years ago
parent
commit
98fdb0c91c
2 changed files with 289 additions and 0 deletions
  1. 5 0
      src/router/system.js
  2. 284 0
      src/views/business_space/dataUtil/index.vue

+ 5 - 0
src/router/system.js

@@ -71,6 +71,9 @@ import overView from '@/views/relation/overview'
 /**  厂家库 */
 import supplier from '@/views/manufactor/supplier'
 
+/**  业务空间数据导入工具 */
+import dataUtil from '@/views/business_space/dataUtil'
+
 /**市场及商务 */
 const OwnerManage = () =>
     import('@/views/market/owner/manage')
@@ -80,6 +83,8 @@ export default [
     //{ path: '/login', name: 'Login', component: Login },
     { path: '/auth', name: 'auth', component: auth },
     { path: '/noUser', name: 'noUser', component: noUser },
+    // 业务空间数据导入工具
+    { path: '/dataUtil', name: 'dataUtil', component: LayoutMain,children:[{path:'index',component: dataUtil}] },
     // 平台管理
     {
         path: '/platform',

+ 284 - 0
src/views/business_space/dataUtil/index.vue

@@ -0,0 +1,284 @@
+<template>
+  <div class="main-box">
+    <div class="saga-build-mess">
+      <span style="padding-right:12px;color:#999999;">建筑楼层</span>
+      <el-cascader :options="options" v-model="buildFloorSelectd" :props="props" @change="changeCascader"></el-cascader>
+      <el-button @click="importOutline">导入业务空间轮廓线</el-button>
+    </div>
+  </div>
+</template>
+<script>
+import {
+  getDataDictionary,
+  getAllbusiness,
+  getSpaceFloor,
+  queryDictionaryHead,
+  buildingQuery, //数据中心-建筑查询
+  queryZone,
+  updateZone,
+  getGraphyId, // 物理世界获取图实例关系
+  getRelation, // 物理世界获取业务空间与元空间关系
+  getBussines2, //
+} from "@/api/scan/request";
+import { mapGetters } from "vuex";
+export default {
+  data() {
+    return {
+      buildFloorSelectd: [],
+      props: { //自定义字段
+        value: "BuildID",
+        label: "BuildLocalName",
+        children: "Floor"
+      },
+      options: [],
+      tabsList: [
+        {
+          "Code": "GeneralZone",
+          "Name": "默认分区",
+          "Rel_type": "99"
+        },
+        {
+          "Name": "供电分区",
+          "Rel_type": "1",
+          "Code": "PowerSupplyZone"
+        },
+        {
+          "Name": "照明分区",
+          "Rel_type": "2",
+          "Code": "LightingZone"
+        },
+        {
+          "Name": "空调分区",
+          "Rel_type": "4",
+          "Code": "AirConditioningZone"
+        }, {
+          "Name": '租赁分区',
+          'Rel_type': '10',
+          "Code": 'TenantZone'
+        }
+      ],
+      allSiListMap: {}, //Si id 与轮廓线的对应关系
+      graphyId: '',
+    }
+  },
+  computed: {
+    ...mapGetters('layout', ['projectId', 'userId', 'secret'])
+  },
+  methods: {
+    // 初始化
+    init() {
+      this.getBuilding();
+      // this.getTypes()
+    },
+    // 获取图实例关系
+    getGraphy() {
+      getGraphyId({
+        type: "ElementSptoSpace",
+        ProjId: this.projectId,
+        secret: this.secret
+      }).then(res => {
+        if (res.data.Result == "success") {
+          this.graphyId = res.data.graph_id;
+          this.tabsList.map(t => {
+            this.getHasSpace(t.Code, t.Rel_type);
+          })
+        }
+      })
+    },
+    // 查询元空间
+    querySi() {
+      let pa = {
+        data: {
+          Filters: `FloorId='${this.buildFloorSelectd[1]}'`,
+          PageSize: 1000
+        },
+        zone: 'Ispace'
+      }
+      queryZone(pa, res => {
+        res.Content.map(t => {
+          let arr = t.BIMID.split(":");
+          //arr[1] sourceid
+          this.allSiListMap[t.RoomID] = arr[1];
+        })
+      })
+    },
+    // 获取业务空间与元空间的关系
+    getRelationInSpSi(Code, Reltype, list) {
+      let pa = {
+        criterias: { criterias: [] },
+        ProjId: this.projectId,
+        secret: this.secret
+      }
+      list.map(t => {
+        pa.criterias.criterias.push({
+          to_id: t,
+          graph_id: this.graphyId,
+          rel_type: Reltype
+        })
+      })
+      getRelation(pa).then(res => {
+        let relList = []
+        list.map((item, index) => {
+          let children = res.data.Content[index].Content.map(i => {
+            if (!!i) {
+              return i.from_id;
+            } else {
+              return undefined;
+            }
+          });
+          relList.push({
+            id: item,
+            children: children
+          });
+        });
+        this.importOutline(Code, relList)
+      })
+    },
+    // 获取项目下建筑
+    getBuilding() {
+      let pa = {
+        Cascade: [{ name: 'floor', Orders: 'SequenceId desc' }],
+        Orders: "BuildLocalName asc",
+      }
+      buildingQuery(pa, res => {
+        this.options = res.Content.map(t => {
+          if (t.Floor) {
+            t.Floor = t.Floor.map(item => {
+              item.BuildID = item.FloorID;
+              item.BuildLocalName = item.FloorLocalName;
+              return item;
+            })
+          } else {
+            t.Floor = []
+          }
+          return t;
+        })
+      })
+    },
+    // 切换楼层
+    changeCascader() {
+      this.getGraphy();
+      this.querySi();
+    },
+    // 获取tabs的列表
+    getTypes() {
+      let pa = {
+        Filters: `parentId = 'Space'`
+      }
+      queryDictionaryHead(pa, res => {
+        this.tabsList = res.Content.map(t => {
+          if (t.Name == "元空间") {
+            return undefined;
+          }
+          return t;
+        }).filter(item => item);
+      })
+    },
+    // 更新业务空间的轮廓线
+    importOutline(Code, relList) {
+      let pa = {
+        data: {
+          Content: [],
+          Projection: ['Outline']
+        },
+        zone: Code
+      }
+      relList.map(t => {
+        let obj = {
+          RoomID: t.id,
+          Outline: []
+        }
+        t.children.map(item => {
+          obj.Outline.push(this.allSiListMap[item]);
+        })
+        pa.data.Content.push(obj);
+      })
+      console.log(pa)
+      // return
+      updateZone(pa, res => { console.log(res) })
+    },
+    // 查询绑定了元空间的业务空间
+    getHasSpace(Code, Reltype) {
+      let param = {
+        data: {
+          criteria: {
+            id: this.buildFloorSelectd[1],
+            type: [Code],
+            "include": [ // 可选, 只查询指定图/关系中的对象
+              {
+                "graphId": this.graphyId,
+                "graphType": Code,
+                "relType": Reltype,
+                "side": "toId",
+              }
+            ]
+          },
+        },
+        ProjId: this.projectId,
+        secret: this.secret
+      }
+      getBussines2(param).then(res => {
+        if (res.data.Result == "success") {
+          if (res.data.Content && res.data.Content.length) {
+            let relationList = res.data.Content.map(item => {
+              return item.id;
+            });
+            this.getRelationInSpSi(Code, Reltype, relationList);
+          }
+        }
+      })
+    },
+    // 获取底图
+    getJson(jsonId) {
+      axios({
+        method: 'get',
+        url: "/image-service/common/file_get/" + jsonId + "?systemId=revit",
+        data: {},
+        responseType: 'blob',
+      }).then(res => {
+        let data = null
+        var blob = res.data;
+        var reader = new FileReader();
+        reader.readAsBinaryString(blob)
+        let _this = this
+        reader.onload = function (readerEvt) {
+          var binaryString = readerEvt.target.result;
+          let base64Data = btoa(binaryString)
+          let unGzipData = pako.unzip(base64Data)
+          data = unGzipData
+          _this.exportJsonData = JSON.stringify(data);
+          _this.jsonId = jsonId.split('.')[0];
+          _this.dataMax = tools.getPoint(data);
+          if (data.SpaceList && data.SpaceList.length) {
+            tools.changeMap(data.SpaceList, -1, "Paths");
+          }
+          let ids = [];
+          if (data.SpaceList && data.SpaceList.length) {
+            data.SpaceList.map(items => {
+              items.BimId = _this.buildMess.code + ":" + items.BimId;
+              ids.push(items.BimId);
+            });
+          } else {
+            _this.$message("没有元空间数据")
+          }
+          if (!!ids && ids.length) {
+            _this.bimIdToId(ids, data);
+          } else {
+            //没有id没有map
+            _this.hasMap = false
+          }
+          _this.myLoading = true;
+        };
+      });
+    },
+  },
+  created() {
+    this.init()
+  },
+  watch: {
+    projectId() {
+      this.init()
+    }
+  }
+}
+</script>