<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="updateSpOutline">导入业务空间Outline</el-button>
      <el-button @click="updateSiOutline" v-show="0">更新元空间Outline,Height</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";
import pako from '@/assets/pako/pako'
import axios from "axios";
export default {
  data() {
    return {
      buildFloorSelectd: [],
      props: { //自定义字段
        value: "BuildID",
        label: "BuildLocalName",
        children: "Floor"
      },
      floorIdToMap: {}, //楼层id->楼层图
      options: [],
      tabsList: [
        {
          "Code": "GeneralZone",
          "Name": "默认分区",
          "Rel_type": "99"
        },
        {
          "Name": "供电分区",
          "Rel_type": "1",
          "Code": "PowerSupplyZone"
        },
        {
          "Name": "照明分区",
          "Rel_type": "2",
          "Code": "LightingZone"
        },
        {
          "Name": "网络分区",
          "Rel_type": "3",
          "Code": "NetworkZone"
        },
        {
          "Code": "AirConditioningZone",
          "Name": "空调分区",
          "Rel_type": "4"
        },
        {
          "Name": "采暖分区",
          "Rel_type": "5",
          "Code": "HeatingZone"
        },
        {
          "Name": "洁净分区",
          "Rel_type": "6",
          "Code": "CleanZone"
        },
        {
          "Name": "生活给水分区",
          "Rel_type": "7",
          "Code": "DomesticWaterSupplyZone"
        },
        {
          "Code": "FireZone",
          "Name": "防火分区",
          "Rel_type": "8"
        },
        {
          "Name": "安防分区",
          "Rel_type": "9",
          "Code": "SecurityZone"
        },
        {
          "Name": "租户分区",
          "Rel_type": "10",
          "Code": "TenantZone"
        },
        {
          "Name": '功能分区',
          'Rel_type': '11',
          "Code": 'FunctionZone'
        }
      ],
      allSiListMap: {}, //Si id ->sourceid
      sourceIdToOutline: {}, //sourceid -> outline
      sourceIdToHeight: {}, //sourceid -> height
      graphyId: '',
      allABC: [
        'Fl11010500011b85b9eeff8211e8b8b087ac5144d0ef20191010145313bim.jsonz',
        'Fl110105000181b22b1608b911e9acbca78c1b4e10a620191011181833bim.jsonz',
        'Fl1101050001072a8b6cff8211e8b8b0015f957e8c7f20191010145327bim.jsonz',
        'Fl11010500011007d4edff8211e8b8b0ab7044c4281120191010145320bim.jsonz',
        'Fl11010500012a0741ffff8211e8b8b057c9c998394220191010152132bim.jsonz',
        'Fl1101050001fb55faebff8111e8b8b07995537bf28720191011143329bim.jsonz',
        'Fl11010500012c9b2aeb5ffa11e9a618397d1467f28020191011104423bim.jsonz',
        'Fl11010500018aff2ad35ff711e9a6182f2301e72e6020190909174638bim.jsonz',
        'Fl110105000150fa91315ff711e9a618c9724397ed0720191010152112bim.jsonz',
        'Fl1101050001183b6fde5ff711e9a618071bdac223fe20191011143315bim.jsonz',
        'Fl1101050001723c0e525ff711e9a618cbf5042c40d120191010152106bim.jsonz',
        'Fl11010500013e6974505ff711e9a618e15213be8b4820191010161301bim.jsonz',
        'Fl110105000130c1d17f5ff711e9a618c7fff3f2463720190829142855bim.jsonz',
        'Fl11010500019bd7ae53b36611e9989b6b5aa64fce0020191011143304bim.jsonz',
        'Fl110105000107cd29a4b36711e9989b833dd102d9f620190909180620bim.jsonz',
        'Fl1101050001c62588265ff711e9a6180390acf0fbab20191010161242bim.jsonz',
        'Fl1101050001ed4873e85ff711e9a618b9a20cddb21320191010161233bim.jsonz',
        'Fl1101050001fc75cc595ff711e9a6184b0a58d23d4b20191011180342bim.jsonz',
        'Fl1101050001b83236555ff711e9a6187be56804052e20191010161246bim.jsonz',
        'Fl1101050001d8621c675ff711e9a61867e9c4c4e7ed20191010161238bim.jsonz',
        'Fl1101050001a62034845ff711e9a6187d378045931b20191010161256bim.jsonz',
        'Fl1101050001417e9293877811e9ad1f9727a4cb9ff920191008182236bim.jsonz',
        'Fl110105001393a9aafcdf6d11e99e5477f4fe220c4820190929200808bim.jsonz',
        'Fl1101050013866991b5df6f11e99e548f7fb48601bc20190929200729bim.jsonz',
        'Fl1101050013fae74390df6d11e99e54d5561aa01bd520190929200817bim.jsonz',
        'Fl1101050013c3da061adf6f11e99e54c7d23ab4172a20190929200700bim.jsonz',
        'Fl11010500139faa5f21df6e11e99e546bdd7272e66c20190929200825bim.jsonz',
        'Fl1101050013937cbcb6df6f11e99e543d85d7068bdf20190929200724bim.jsonz',
        'Fl1101050013db95d69fdf6d11e99e5429a50115d5a420190929223016bim.jsonz',
        'Fl1101050013e4bae212df6e11e99e54b7ff375e245d20190929200841bim.jsonz',
        'Fl1101050013a075a8f7df6f11e99e54adca7466d03c20190929200719bim.jsonz',
        'Fl1101050013ac0986f8df6f11e99e54fdce5ae59e1e20190929200712bim.jsonz',
        'Fl1101050013b977f159df6f11e99e54b1c8cff9906a20190929200706bim.jsonz',
        'Fl1101050013ce04c90edf6d11e99e54f9e2920216e220190929200752bim.jsonz',
        'Fl110105001359d5d373df6f11e99e54b7e95468964e20190929200740bim.jsonz',
        'Fl110105001374ad7814df6f11e99e545f0fb9fea1c520190929200735bim.jsonz',
        'Fl1101050013c019dbaddf6d11e99e54bd8e15b3817720190929200801bim.jsonz',
        'Fl1101050013a307b155a6e611e9af72f99ee18c8c9320190929200849bim.jsonz',
        'Fl110105001382cc80a2a6e611e9af72f5982a28cf3420190929200858bim.jsonz',
        'Fl11010500135cae0c8fa6e611e9af722bfdfa84dab620190929200911bim.jsonz',
        'Fl1101050013750e96b1a6e611e9af721b1d998988a820190929200902bim.jsonz',
        'Fl11010500134fb34b8ea6e611e9af7283fc80c9cbb120190929200915bim.jsonz',
        'Fl1101050013437068dda6e611e9af72cde0e896ab3d20190929200920bim.jsonz',
        'Fl1101050013af27a2b6a6e611e9af72a3a381eb49f520190929200845bim.jsonz',
        'Fl11010500138ee916a3a6e611e9af7219302358433020190929200854bim.jsonz',
        'Fl1101050013349a582ca6e611e9af72f38a28243be020190929200924bim.jsonz',
        'Fl1101050013ebcbe2daa6e511e9af72535c0db8e49420190929200928bim.jsonz',
        'Fl110105001367b00ad0a6e611e9af72391f1a6981f320190929200907bim.jsonz',
        'Fl11010500135ced8275e0f111e99542a554062b3c7920190929201135bim.jsonz',
        'Fl1101050013619b3967a6cd11e9af727dca2b35db2320190929201149bim.jsonz',
        'Fl110105001392f3f029a6cc11e9af727dda4b57623320190929201048bim.jsonz',
        'Fl1101050013647048c7a6cc11e9af72273d51e4947220190929201101bim.jsonz',
        'Fl1101050013d269353ea6cc11e9af728fc5d00b2f0a20190929201023bim.jsonz',
        'Fl11010500133665f9b5a6cd11e9af726fad221345ff20190929201130bim.jsonz',
        'Fl110105001326ee9ff4a6cd11e9af72c73df1895e7720190929200935bim.jsonz',
        'Fl110105001318587e73a6cd11e9af722f27783c843620190929200943bim.jsonz',
        'Fl11010500134ce29f05a6cc11e9af7279570e0d569620190929201108bim.jsonz',
        'Fl1101050013c6574d9da6cc11e9af72814bd704fa4820190929201033bim.jsonz',
        'Fl1101050013866b03c8a6cc11e9af7267ca9836c13820190929201052bim.jsonz',
        'Fl110105001373245d34cec611e9ba1805fb011b0dfb20190929201056bim.jsonz',
        'Fl1101050013ba5f569ca6cc11e9af729b3a5696c34b20190929201038bim.jsonz',
        'Fl11010500131f8ca234a6cc11e9af726b1c42a58f6d20190929201113bim.jsonz',
        'Fl1101050013fd91c9c1a6cc11e9af7209967911472120190929201009bim.jsonz',
        'Fl1101050013ab47d01ba6cc11e9af72c5020a93d09a20190929201043bim.jsonz',
        'Fl1101050013e5eb8fefa6cc11e9af72f7e04830b73820190929201019bim.jsonz',
        'Fl11010500130b3dd962a6cd11e9af723b4fff1de76c20190929200948bim.jsonz',
        'Fl1101050013f0e5c500a6cc11e9af72ff5f8a3c54ec20190929201013bim.jsonz',
        'Fl1101050027b6b6aeeebffc11e9878df3336d9ea69e20190902174737bim.jsonz',
        'Fl1101050027f0987e4fbffc11e9878d853ef4ec937120190902174729bim.jsonz',
        'Fl11010500276984c300bffd11e9878daf61c33e94da20190902174726bim.jsonz',
        'Fl11010500278764c5a1bffd11e9878dff1cbcff2a8c20190902174719bim.jsonz',
        'Fl11010500270e9c1032cd2a11e980674dea463014f320190902174707bim.jsonz',
        'Fl110105002724295613cd2a11e9806727431a8ae35120190902174701bim.jsonz',
        'Fl11010500279a0795c2bffd11e9878d21f91e2f7f0320190902174656bim.jsonz',
        'Fl11010500272fb9e795ebf811e99ae435ea4d30ba4420191011153552bim.jsonz',
        'Fl1101050027169fd510bfff11e9878d93526a68d7f520190828114146bim.jsonz',
        'Fl1101050027fec855d9c97111e9878db36977c4803420190830162151bim.jsonz',
        'Fl11010500273fc2ba11c00011e9878d8b124890032f20190828114140bim.jsonz',
        'Fl1101050027cff41526cad711e9878d51b041ce6c1420190830160305bim.jsonz',
        'Fl11010500275ca2b1d2c00011e9878df9f6e301bb0020190830160300bim.jsonz',
        'Fl1101050027c941e8f4ebf711e99ae419b18488406120191011153543bim.jsonz',
        'Fl11010500272815663fbffe11e9878db3dfe1b036f620190828114149bim.jsonz',
        'Fl11010500277a169a48c00211e9878d4992c207a3fb20190903115048bim.jsonz',
        'Fl11010500270c2d96ecc00311e9878d3f65b38832eb20190830142026bim.jsonz',
        'Fl1101050027c594c649c00211e9878d4958f9e57f9220190903115038bim.jsonz',
        'Fl1101050027f904cdebc00211e9878d3fc39b79fc7620190903115027bim.jsonz',
        'Fl11010500270d0cbe35c00111e9878d612869b5adf720190903115053bim.jsonz',
        'Fl1101050027a9f1f454c00011e9878d3d62ff2fd7d120190903115104bim.jsonz',
        'Fl1101050027da8704aac00211e9878de504b8a990b820190903115033bim.jsonz',
        'Fl11010500276f8ca7a7c00111e9878df574b1a855ee20190903115126bim.jsonz',
        'Fl11010500274c7f4426c00111e9878d0fcd7948fe4720191011181832bim.jsonz',
        'Fl110106000484c7cba9a1f011e9af72d1172b07188c20190917182902bim.jsonz',
        'Fl11010600043f284548a1ef11e9af724d13fb54915920190906141306bim.jsonz',
        'Fl110106000495c67edba1ef11e9af72ef904d1149c920190815150042bim.jsonz',
        'Fl11010600044ba809e9a1ef11e9af7227433ebfb24b20190806101248bim.jsonz',
        'Fl110106000427e698a6a1ef11e9af7245df9000e89720190906141322bim.jsonz',
        'Fl1101060004a9672c63a1ee11e9af72311fab83533320190906141338bim.jsonz',
        'Fl1101060004edd4f170a1ec11e9af72337886122cde20190917182934bim.jsonz',
        'Fl110106000495197d15a1ec11e9af723104dc167b8b20190918175434bim.jsonz',
        'Fl1101060004770c6551a1ee11e9af7265d7fcda7fec20190805175421bim.jsonz',
        'Fl1101060004eca29690a1ed11e9af72411038923a1620190906102538bim.jsonz',
        'Fl1101060004144a69c2a1ee11e9af72cb8e03b3179120190806101414bim.jsonz',
        'Fl1101060004d6912c8da1ed11e9af721742ebc5a8e720190906102550bim.jsonz',
        'Fl1101060004bd91552ca1ed11e9af7229b5746d0be420190906102601bim.jsonz',
        'Fl11010600049cb9e47aa1ed11e9af72b7f53d9fd31c20190906102613bim.jsonz',
        'Fl1101060004859d9a28a1ed11e9af722795f30acb1e20190906102624bim.jsonz',
        'Fl11010600046b0dfb06a1ed11e9af72095d00257b8320190906102636bim.jsonz',
        'Fl110106000454df4505a1ed11e9af725993924d36af20190906102647bim.jsonz',
        'Fl1101060004a2b8d0d2a1ee11e9af72cf69abe1f44c20190830172626bim.jsonz',
        'Fl11010600049728cdfda1ef11e9af722b0e3c2ead1a20190906141233bim.jsonz',
        'Fl11010600049401dd4ba1ea11e9af7217861d0891ec20190919101549bim.jsonz',
        'Fl1101060004481d2ad5a1ee11e9af7217d19632185220190906102502bim.jsonz',
        'Fl110106000453353e84a1ed11e9af729581dac7689720190918175156bim.jsonz',
        'Fl110106000476457d84a1ec11e9af72615d90b9bace20190905115756bim.jsonz',
        'Fl110106000420829e13a1ee11e9af727b0bba623f7b20190906102514bim.jsonz',
        'Fl110106000427accdd4a1f011e9af726b0152b4b9c620190929194726bim.jsonz',
        'Fl1101060004fc037a2ea1f011e9af728bfeb54243cc20190906114418bim.jsonz',
        'Fl110106000439d43700a1f111e9af72e19a95c6fbb820190909162505bim.jsonz',
        'Fl1101060004d58ad82da1f011e9af72ef37cac520f920190918174923bim.jsonz',
        'Fl1101060004fe4aa030a1ef11e9af72890f877b061520190929194745bim.jsonz',
        'Fl1101060004240b4503a1ed11e9af726774a6bf470620190906102658bim.jsonz',
        'Fl1101060004f9d47331a1f511e9af7289f01e05fb2c20190806101048bim.jsonz',
        'Fl110106000473aaead0a1ee11e9af72ad49804d0c8f20190905163621bim.jsonz',
        'Fl1101060004601ce4c6a1f011e9af72cf69dc1b598a20190918175009bim.jsonz',
        'Fl11010600041747409ca1ec11e9af720fa2b741a00520190918175404bim.jsonz',
        'Fl1101060004df80ec9ea1ed11e9af7277bc2af6e9c020190918175110bim.jsonz',
        'Fl1101060004d6911abea1ef11e9af722b4776bc3d0e20190906141217bim.jsonz',
        'Fl110106000458a53beaa1ef11e9af72fff3e1767ce920190906141250bim.jsonz',
        'Fl11010600041c8a0912a1ed11e9af72c9b7bfceff0d20190909155405bim.jsonz',
        'Fl11010600042b9521b7a1ef11e9af7279797025390a20190806101302bim.jsonz',
        'Fl1101060004d30d8eb5a1ee11e9af72bfe0e47b193920190806101316bim.jsonz',
        'Fl11010600040586cfa1a1ee11e9af722bb32265eadd20190906102527bim.jsonz',
        'Fl110106000431b95b14a1ee11e9af727d00803ef8d620190806180123bim.jsonz',
        'Fl11010600047253dba7a1ed11e9af72ff3602d8e82320190918175134bim.jsonz',
        'Fl110106000448d6812ca2ad11e9af727d118e25aa6e20190806101526bim.jsonz',
        'Fl1101060004e22b615fa1ef11e9af7247e952fac96320190806101219bim.jsonz',
        'Fl11010600043bcc2bd5a1f011e9af72291c81eb8ae020190918175036bim.jsonz',
        'Fl1101060004b4734e76a1ec11e9af722dd03355db1220190918175217bim.jsonz',
        'Fl110106000420b6c57fa1f111e9af72012c927f3f4f20190906141134bim.jsonz',
        'Fl1101060004aea831aba1ed11e9af72dfa8683aa4f720190802175313bim.jsonz',
        'Fl1101060004a6eccafca1f011e9af7267472ea15a9620190918174948bim.jsonz',
        'Fl110108000408a83beea2ee11e9af7259d2f787ab1620190830153737bim.jsonz',
        'Fl11010800043f73a6877cfb11e9b795d3adf149642620191009195306bim.jsonz',
        'Fl1101080004946844cc4ac311e99acc8b6cd31791d320190920154722bim.jsonz',
        'Fl11010800043637f04b70834f2dbe0b82eb39068a0420191009200946bim.jsonz',
        'Fl11010800062954591caec311e99dcfaf5a8be870d220190726122330bim.jsonz',
        'Fl110108000672c3bbfeb1e811e9989bbd47a0e3272e20190729181028bim.jsonz',
        'Fl1101080006d99973bfb1da11e9989b79ad9f9909f120190729170849bim.jsonz',
        'Fl110108000602683ac0b1db11e9989b790e8880072b20190729170815bim.jsonz',
        'Fl11010800069dcb169eb1da11e9989bc5597d8ba85920190729171022bim.jsonz',
        'Fl11010800069fee982cb1a311e98d09d94cc66ae83520190729095659bim.jsonz',
        'Fl1101080006b4019a1db1a311e98d093b33ddef2c3320190729095658bim.jsonz',
        'Fl1101080006b18ac731b0d711e99dcf0f0ecc4ec38320190728095102bim.jsonz',
        'Fl1101080006deb6f4e2b0d711e99dcfaf78f8a28ef720190728095012bim.jsonz',
        'Fl11010800062bd07555b1cb11e9989b9751358f824620190729152437bim.jsonz',
        'Fl11010800063c933ad6b1cb11e9989b1f3944fc1f0320190729152317bim.jsonz',
        'Fl11010800064bdddf47b1cb11e9989b6713fdfea4de20190729152224bim.jsonz',
        'Fl110108000610ea51c4b1cb11e9989be5322a94201220190729152547bim.jsonz',
        'Fl11022900023e5a6bf514b511e9bf82f555b5e8b9ef20190419193227bim.jsonz',
        'Fl110229000227d3f90414b511e9bf82bb63fa6a645a20190628142041bim.jsonz',
        'Fl11022900020feb5e0314b511e9bf82c9cf158b9d1d20190628142043bim.jsonz',
        'Fl110229000251f844f730f011e9b57c69e5186dd31b20190419193222bim.jsonz',
        'Fl1102290002f78b220214b411e9bf82d9c41152624520190628142046bim.jsonz',
        'Fl1102290002c54c958014b411e9bf82990dde33286d20190419193245bim.jsonz',
        'Fl1102290002ae932baf14b411e9bf82d95e5f5d242a20190419193249bim.jsonz',
        'Fl110229000248580efd14b411e9bf82e3a8a0e2a89e20190628120557bim.jsonz',
        'Fl110229000217341a3c14b411e9bf82b76a9822ffb720190612121043bim.jsonz',
        'Fl1102290002415d2275156a11e9bf8299370a1e2bae20190529164411bim.jsonz',
        'Fl11022900027d6114935b7b11e9a5293d97a8a829ec20190612115403bim.jsonz',
        'Fl110229000280f3ab26156a11e9bf82f9931ac7a65e20190529164406bim.jsonz',
        'Fl1102290002e04c6878303e11e98edb07eab392dc6f20190419193209bim.jsonz',
        'Fl11022900027a15c8e15b7511e9a52949dda85af39520190529164353bim.jsonz',
        'Fl11022900023faffc705b7511e9a5298ff666bb187320190529164400bim.jsonz',
        'Fl1102290002994137425b7511e9a529e917c82b6f3b20190419193155bim.jsonz',
        'Fl3202130001f7a87a77e02b11e99542576d04b778bd20190930133829bim.jsonz',
        'Fl3202130001c0c2fb23e02b11e995428577eec7921f20190930133918bim.jsonz',
        'Fl32021300011194d4b9e02c11e99542bd8a4e0763ed20190926170827bim.jsonz',
        'Fl32021300015df8ccdbe02c11e995427d500ee9f7e020190926170802bim.jsonz',
        'Fl32021300016b71be8ce02c11e995426f7774395d0220190930135557bim.jsonz',
        'Fl32021300018565fd6fe02b11e9954225a51157c39520190930133927bim.jsonz',
        'Fl32021300015193bc2ae02c11e995427d46e123456120190926170815bim.jsonz',
        'Fl3202130001e480e9f6e02b11e99542093b12ca666c20190930133841bim.jsonz',
        'Fl3202130001b39cbd52e02b11e99542e108d97173bf20190926160644bim.jsonz',
        'Fl3202130001d795e065e02b11e99542efd320197a1120190930133854bim.jsonz',
        'Fl3202130001cd8e6ec4e02b11e9954285c1898e19ee20190930133904bim.jsonz',
        'Fl3202130001a8e360d1e02b11e995421b39d0ace4ba20190927163237bim.jsonz',
        'Fl320213000102b80d48e02c11e99542a716c237371720190926170838bim.jsonz',
        'Fl32021300017033cfdee02b11e995425b075e3067b920190927163247bim.jsonz',
        'Fl320302000133a87d5fb82d11e9b911b16d2dc3905220191011212048bim.jsonz',
        'Fl32030200012b206aa6b82b11e9b9115d2e5ebb7c5320191011231520bim.jsonz',
        'Fl3203020001412bd428e43d11e995428303078b495420191011194108bim.jsonz',
        'Fl3203020001224834c9b82c11e9b911213bd490e29120191011231238bim.jsonz',
        'Fl32030200014b32730bb82c11e9b911e70ac73db3d520191001021358bim.jsonz',
        'Fl3203020001a29af72ee44211e9954245190612ff2120191011184403bim.jsonz',
        'Fl3203020001110346f8b82c11e9b91193bb5caf414f20191011231407bim.jsonz',
        'Fl32030200011c74da7db82d11e9b911153be4336a1320191011193846bim.jsonz',
        'Fl3203020001ea88d037b82b11e9b91165a8f4d67d7f20191011184556bim.jsonz',
        'Fl3203020001f19ae48be38b11e995427107eaf662ac20191009084145bim.jsonz',
        'Fl32030200010e5874e3e97e11e99ae48398da7062f220191008120205bim.jsonz',
        'Fl321023000111978428ddcc11e99e54178307d0c26720190924114916bim.jsonz',
        'Fl32102300012906d079ddcc11e99e54ed7a9709490320190923170801bim.jsonz',
        'Fl3210230001e2e44147ddcb11e99e54859c4c487f7220190923170824bim.jsonz',
        'Fl330108000103044151bed44f7598d0e442f2f97c2e20181205121637bim.jsonz',
        'Fl3301080001d660e6513bf241efbf0039a38d41959320181205121634bim.jsonz',
        'Fl330108000132de58189884406e87c67054015b8ed020181205121650bim.jsonz',
        'Fl33010800013fbaeba32e3843a48f9483c89f9e92e120181206034333bim.jsonz',
        'Fl33010800013f801891979f4c15becd5eebf5eae9cd20181205121647bim.jsonz',
        'Fl42010500013ed500a0dce811e8a553553e376f6dfe20190803114640bim.jsonz',
        'Fl42010500012ca5c61ddcf511e8a5535bb85ffaee3b20190910175845bim.jsonz',
        'Fl4201050001cb2aa6fbdced11e8a55303170283ca2920190912170100bim.jsonz',
        'Fl4201050001b947f615dcf111e8a553b7cf52cf35af20190912170028bim.jsonz',
        'Fl420105000110be38e9dcf511e8a5532b791a1ee2c420190910175947bim.jsonz',
        'Fl42010500018e478ab3dcd811e88790bdbb92e7fee120190603191648bim.jsonz',
        'Fl4201050001077f36addce111e8a5534ded040d5d7c20190603191658bim.jsonz',
        'Fl420105000152e79b7adce211e8a55337c9cf1e3bdf20190717152852bim.jsonz',
        'Fl42010500010495727bdce311e8a5539d686e463b9120190717152934bim.jsonz',
        'Fl42010500012298db9cdce311e8a5534d128a2b354f20190803114429bim.jsonz',
        'Fl4201050001cf1cad1ddce311e8a553934d1b04c91820190803114512bim.jsonz',
        'Fl4201050001d4f1ea8fdce711e8a55335c5dd75d7b320190803114559bim.jsonz',
        'Fl42010500015ecaeaf1dce811e8a553ab01e573104520190803114726bim.jsonz',
        'Fl420105000189c43312dce811e8a5530301735c51a020190803114808bim.jsonz',
        'Fl4201050001afd0f3e3dce811e8a553f5b22da96b1b20190803114831bim.jsonz',
        'Fl420105000103457586dcf211e8a553531a211276f820190910175633bim.jsonz',
        'Fl42010500017108cf60dcee11e8a55391554ae262a520190912170227bim.jsonz',
        'Fl420105000119b7c08edcee11e8a553abe8a598be9320190912170132bim.jsonz',
        'Fl42010500016dc07b43dcf111e8a553e7c23f5c005c20190803114853bim.jsonz',
        'Fl42010500018b580334dcf111e8a553db1eadfac99320190803114958bim.jsonz',
        'Fl42010500013b806f0fdcee11e8a553edb14706cbae20190912170155bim.jsonz',
        'Fl42010500015f8ce4eddcf411e8a5532f436ae9c16120190910175756bim.jsonz',
        'Fl420105000187b9a94fdcf511e8a553f74f3c6c70e020190910175919bim.jsonz',
        'Fl420105000127246764dcf711e8a55349b04e56bcfc20190715180639bim.jsonz',
        'Fl420105000189701916dda411e8a553593d715bd0c020190726104402bim.jsonz',
        'Fl4201050001b3a83417dda411e8a5536fdeea00e31920190529111322bim.jsonz',
        'Fl4201050001cbec83a8dda411e8a553e9d5e46989b220190708172234bim.jsonz',
        'Fl42010500011ce3d777626a11e9b1b401e6e3ff79df20190529111305bim.jsonz',
        'Fl4201050001d82483b0dcf511e8a553356fcf1dd57720190910175713bim.jsonz',
        'Fl4403040012c38b2d7981b611e9a64d2f8df58163fa20190823180122bim.jsonz',
        'Fl4403040012ef96cffb81b611e9a64d0552bb0a85ab20190924101419bim.jsonz',
        'Fl4403040012d9485cfa81b611e9a64d11ceb052822320190718175437bim.jsonz',
        'Fl4403040012a3c5a1f881b611e9a64d2d7ef600a17b20190823180142bim.jsonz',
        'Fl440304001239f96f4581b611e9a64d43a752acf96c20190905154149bim.jsonz',
        'Fl44030400122e5e48de81b711e9a64dbbdec755c07c20190815142831bim.jsonz',
        'Fl44030400125ba87b4681b611e9a64dbf3a1838393b20190823180229bim.jsonz',
        'Fl44030400124f295d7f81b711e9a64d0314bee18a1720190817152204bim.jsonz',
        'Fl44030400120337881c81b711e9a64d5908c65ec0ab20190823142759bim.jsonz',
        'Fl44030400127b7a466181b711e9a64d558931e17c6e20190712120444bim.jsonz',
        'Fl44030400121842578d81b711e9a64dad63b66e0c2f20190823142746bim.jsonz',
        'Fl440304001261be991081b711e9a64d5f6f04bcc34e20190823142737bim.jsonz',
        'Fl44030400127ab7880781b611e9a64d0d6ad5abbd1520190920162746bim.jsonz',
        'Fl441900000531d1a578b82e48a1b6a4dcfced63bdc020191001101716bim.jsonz',
        'Fl44190000058cf94fefd42648609c305693f88e076620190930175443bim.jsonz',
        'Fl4419000005b98bb7a9d85840b39f56a8fe69e2741620190930175456bim.jsonz',
        'Fl4419000005d99cddf5561e4ffc942e5a7428cad9c120191001101653bim.jsonz',
        'Fl44190000058ed0b0e0964549e4aa9c2f75e71537e820191011145844bim.jsonz',
        'Fl4419000005eef95195db6c4531b410974040cf5f4a20191001101610bim.jsonz',
        'Fl4419000005fcd5559503354eb19b84cbc71187f99c20191001101729bim.jsonz',
        'Fl110108000100100320190228022700bim.jsonz',
        'Fl110108000100100620190228022706bim.jsonz',
        'Fl110108000100100720190228022708bim.jsonz',
        'Fl110108000100100820190228022709bim.jsonz',
        'Fl110108000100100220190228022658bim.jsonz',
        'Fl110108000100100120190228022656bim.jsonz',
        'Fl110108000100100420190228022702bim.jsonz',
        'Fl110108000100100520190301095138bim.jsonz'
      ]
    }
  },
  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 => {
        this.allSiListMap = {}
        res.Content.map(t => {
          let arr = t.BIMID.split(":");
          this.allSiListMap[t.RoomID] = arr[1];
        })
        console.log(this.allSiListMap)
        this.updateSiOutline();
      })
    },
    // 获取业务空间与元空间的关系
    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;
              this.floorIdToMap[item.FloorID] = item.StructureInfo ? item.StructureInfo.FloorMap : ''
              return item;
            })
            console.log(this.floorIdToMap)
          } else {
            t.Floor = []
          }
          return t;
        })
      })
    },
    // 切换楼层
    changeCascader() {
      this.getJson(this.floorIdToMap[this.buildFloorSelectd[1]])
    },
    // 获取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', 'Height']
        },
        zone: Code
      }
      relList.map(t => {
        let obj = {
          RoomID: t.id,
          Height: 0,
          Outline: []
        }
        t.children.map(item => {
          if (this.sourceIdToOutline[this.allSiListMap[item]]) {
            obj.Outline.push(this.sourceIdToOutline[this.allSiListMap[item]]);
            if (this.sourceIdToHeight[this.allSiListMap[item]] && (obj.Height == 0 || this.sourceIdToHeight[this.allSiListMap[item]] < obj.Height)) {
              obj.Height = this.sourceIdToHeight[this.allSiListMap[item]] / 1000;
            }
          }
        })
        pa.data.Content.push(obj);
      })
      updateZone(pa, res => {
        this.$message.success(`success-----${Code}`)
      })
    },
    // 查询绑定了元空间的业务空间
    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?systemId=revit&key=${jsonId}`,
        data: {},
        responseType: 'blob',
      }).then(res => {
        let data = null
        let blob = res.data;
        let reader = new FileReader();
        reader.readAsBinaryString(blob)
        let _this = this
        reader.onload = function (readerEvt) {
          let binaryString = readerEvt.target.result;
          let base64Data = btoa(binaryString)
          let unGzipData = pako.unzip(base64Data)
          // data = unGzipData
          data = unGzipData.entityList ? unGzipData.entityList[0].Elements : unGzipData.EntityList[0].Elements
          if (data.Spaces && data.Spaces.length) {
            data.Spaces.map(t => {
              _this.sourceIdToOutline[t.SourceId] = t.OutLine;
              _this.sourceIdToHeight[t.SourceId] = t.Height;
            })
            // }
            // if (data.SpaceList && data.SpaceList.length) {
            //   data.SpaceList.map(items => {
            //     _this.sourceIdToOutline[items.BimId] = items.Paths;
            //   });
          } else {
            _this.$message("没有元空间数据")
          }
          console.log(_this.sourceIdToOutline)
          _this.querySi();
        };
      });
    },
    updateSpOutline() {
      this.getGraphy();
    },
    updateSiOutline() {
      let pa = {
        data: {
          Content: [],
          Projection: ['Outline', 'Height']
        },
        zone: 'Ispace'
      }
      for (let key in this.allSiListMap) {
        let obj = {
          RoomID: key,
          Outline: []
        }
        if (this.sourceIdToOutline[this.allSiListMap[key]]) {
          obj.Outline = this.sourceIdToOutline[this.allSiListMap[key]];
          obj.Height = this.sourceIdToHeight[this.allSiListMap[key]] / 1000 || 0;
          pa.data.Content.push(obj);
        }
      }
      if (pa.data.Content.length) {
        updateZone(pa, res => {
          this.$message.success(`success-----Ispace`)
        })
      }
    }
  },
  created() {
    this.init()
  },
  watch: {
    projectId() {
      this.init()
    }
  }
}
</script>