index2.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="main-box">
  3. <div class="saga-build-mess">
  4. <el-button @click="queryZone">导入业务空间BIMLocation</el-button>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import {
  10. queryZone,
  11. updateZone,
  12. } from "@/api/scan/request";
  13. import { mapGetters } from "vuex";
  14. import pako from '@/assets/pako/pako'
  15. import axios from "axios";
  16. export default {
  17. data() {
  18. return {
  19. options: [],
  20. tabsList: [
  21. {
  22. "Code": "GeneralZone",
  23. "Name": "默认分区",
  24. "Rel_type": "99"
  25. },
  26. {
  27. "Name": "供电分区",
  28. "Rel_type": "1",
  29. "Code": "PowerSupplyZone"
  30. },
  31. {
  32. "Name": "照明分区",
  33. "Rel_type": "2",
  34. "Code": "LightingZone"
  35. },
  36. {
  37. "Name": "网络分区",
  38. "Rel_type": "3",
  39. "Code": "NetworkZone"
  40. },
  41. {
  42. "Code": "AirConditioningZone",
  43. "Name": "空调分区",
  44. "Rel_type": "4"
  45. },
  46. {
  47. "Name": "采暖分区",
  48. "Rel_type": "5",
  49. "Code": "HeatingZone"
  50. },
  51. {
  52. "Name": "洁净分区",
  53. "Rel_type": "6",
  54. "Code": "CleanZone"
  55. },
  56. {
  57. "Name": "生活给水分区",
  58. "Rel_type": "7",
  59. "Code": "DomesticWaterSupplyZone"
  60. },
  61. {
  62. "Code": "FireZone",
  63. "Name": "防火分区",
  64. "Rel_type": "8"
  65. },
  66. {
  67. "Name": "安防分区",
  68. "Rel_type": "9",
  69. "Code": "SecurityZone"
  70. },
  71. {
  72. "Name": "租户分区",
  73. "Rel_type": "10",
  74. "Code": "TenantZone"
  75. },
  76. {
  77. "Name": '功能分区',
  78. 'Rel_type': '11',
  79. "Code": 'FunctionZone'
  80. }
  81. ],
  82. }
  83. },
  84. computed: {
  85. ...mapGetters('layout', ['projectId', 'userId', 'secret'])
  86. },
  87. methods: {
  88. init() { },
  89. // 查询该项目下所有的业务空间
  90. queryZone() {
  91. this.tabsList.map(t => {
  92. this.getZone(t.Code, 1, t.Name);
  93. })
  94. },
  95. getZone(Code, PageNumber, Name) {
  96. let pa = {
  97. data: {
  98. PageNumber: PageNumber,
  99. PageSize: 1000,
  100. Orders: 'RoomID asc'
  101. },
  102. zone: Code
  103. }
  104. queryZone(pa, res => {
  105. if (res.Total > PageNumber * 1000) {
  106. let num = PageNumber + 1
  107. console.log(num)
  108. this.getZone(Code, num, Name)
  109. }
  110. let params = {
  111. data: {
  112. Content: [],
  113. Projection: ["BIMLocation"]
  114. },
  115. zone: Code
  116. }
  117. res.Content.map(t => {
  118. if (t.Outline && t.Outline[0]) {
  119. t.BIMLocation = this.getAverageVal(t.Outline);
  120. let obj = {
  121. RoomID: t.RoomID,
  122. BIMLocation: t.BIMLocation
  123. }
  124. params.data.Content.push(obj);
  125. }
  126. });
  127. if (params.data.Content.length) {
  128. updateZone(params, res => {
  129. console.log(`${this.projectId},${Name},${params.data.Content.length}条更新完成`);
  130. })
  131. }
  132. })
  133. },
  134. getAverageVal(Outline) {
  135. let X = 0, Y = 0, Z = 0, len = 0;
  136. Outline.map(t => {
  137. if (t[0]) {
  138. t[0].map(item => {
  139. X += item.X;
  140. Y += item.Y;
  141. Z += item.Z;
  142. })
  143. len += t[0].length
  144. }
  145. })
  146. X = (X / len).toFixed(2);
  147. Y = (Y / len).toFixed(2);
  148. Z = (Z / len).toFixed(2);
  149. return `${X},${Y},${Z}`
  150. },
  151. },
  152. created() {
  153. this.init()
  154. },
  155. watch: {
  156. projectId() {
  157. this.init()
  158. }
  159. }
  160. }
  161. </script>