newEvacuationBigDataHome.vue 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  1. <template>
  2. <div class="newEvacuationBigDataHome" ref="maxBox">
  3. <div class="evacuation-title-position-box">风险应急处置指挥平台</div>
  4. <div class="evacuation-out-button-position-box">
  5. <i class="el-icon-switch-button"></i>
  6. <p @click="goRoute">{{routeType?'退出全屏':'全屏'}}</p>
  7. </div>
  8. <div class="left-max-big-box">
  9. <div class="left-top-big-box">
  10. <div class="big-title-box">
  11. <img src="@/assets/ZDimages/bigData3_2/icon_znjc_tb.png">
  12. <p>智能监测</p>
  13. </div>
  14. <div class="left-top-for-big-box scrollbar-box">
  15. <div class="left-top-for-box" v-for="(item,index) in lotStaticList" :key="index">
  16. <p>{{item.sensorTotal}}</p>
  17. <p>{{item.sensorName}}</p>
  18. <img v-if="item.sensorType == 1" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_zcbg.png">
  19. <img v-if="item.sensorType == 2" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_hyjc.png">
  20. <img v-if="item.sensorType == 3" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_qtjc.png">
  21. <img v-if="item.sensorType == 4" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_wsd.png">
  22. <img v-if="item.sensorType == 5" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_wsd(1).png">
  23. <img v-if="item.sensorType == 6" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_fcjc.png">
  24. <img v-if="item.sensorType == 7" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_znjk.png">
  25. <img v-if="item.sensorType == 8" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_znmj.png">
  26. <img v-if="item.sensorType == 9" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_ytj.png">
  27. <img v-if="item.sensorType == 10" src="@/assets/ZDimages/bigData3_2/home/icon_dqkz.png">
  28. <img v-if="item.sensorType == 11" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_zntf.png">
  29. <img v-if="item.sensorType == 12" src="@/assets/ZDimages/bigData3_2/home/img_zdmh_znmh.png">
  30. <img src="@/assets/ZDimages/bigData3_2/home/icon_znjc_bg.png">
  31. </div>
  32. </div>
  33. <p class="hazardSum-p" v-if="lotStaticSum">总数:{{lotStaticSum}}</p>
  34. </div>
  35. <div class="left-bottom-big-box">
  36. <div class="big-title-box">
  37. <img src="@/assets/ZDimages/bigData3_2/icon_znjc_tb.png">
  38. <p>危险源</p>
  39. </div>
  40. <div id="eCharts"></div>
  41. <p class="hazardSum-p" v-if="hazardSum">总数:{{hazardSum}}</p>
  42. <p class="eCharts-null-p" v-if="!eChartsData.nameList[0]">暂无数据</p>
  43. </div>
  44. </div>
  45. <div class="center-max-big-box">
  46. <div class="top-button-box">
  47. <div class="top-button-left-select-box">
  48. <el-select v-model="buildingId" placeholder="请选择"
  49. :popper-append-to-body="false"
  50. @change="buildingChange"
  51. class="building-select-box">
  52. <el-option
  53. v-for="item in buildingOptions"
  54. :key="item.id"
  55. :label="item.name"
  56. :value="item.id">
  57. </el-option>
  58. </el-select>
  59. </div>
  60. <div class="top-button-right-num-box">
  61. </div>
  62. </div>
  63. <div id="container" ref="container" @mousedown="getMouseXY($event)">
  64. </div>
  65. <div class="position-floor-user-box">
  66. <img src="@/assets/ZDimages/bigData3_2/icon_zhpt_rs.png">
  67. <p>实时人数:</p>
  68. <p>{{userNum}}人</p>
  69. </div>
  70. <div class="position-floor-button-box" v-if="mapList[0]">
  71. <p class="position-floor-for-button-p" :class="item.checkType?'check-button-box':''"
  72. @click="dataDispose(item.index)"
  73. v-for="(item,index) in maxMapButtonList" :key="index">
  74. {{item.indexName}}
  75. </p>
  76. </div>
  77. </div>
  78. <div class="right-max-big-box scrollbar-box">
  79. <p class="null-p" v-if="!monitorNumList[0]">暂无数据</p>
  80. <div class="monitor-max-for-box" v-for="(item,index) in monitorNumList" :key="index">
  81. <div class="monitor-title-box">
  82. <p>{{item.name}}</p>
  83. <i :class="index == monitorType?'el-icon-arrow-up':'el-icon-arrow-down'" @click="getMonitorUrl(index)"></i>
  84. </div>
  85. <div class="video-mx-big-box" v-show="index == monitorType"
  86. v-for="(videoItem,videoIndex) in item.hardwareList" :key="videoIndex">
  87. <video class="video-box" :id="videoItem" ref="videoRef" :poster="videoCover"
  88. autoplay controls muted width="366px" height="210px"></video>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import mqtt from 'mqtt'
  96. import flvjs from 'flv.js'
  97. import { subjectInfo,startUrl } from "@/api/laboratory/subject";
  98. import { getBuildOrFloorList,exitHazardTotalByBuildId,getLotStatis,
  99. getBuildOrFloorDetailList,getBuildOrFloorInfo,selectTriggerInfo } from '@/api/evacuationBigData/index.js'
  100. import * as Three from 'three'
  101. import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
  102. import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
  103. import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
  104. import { SceneUtils } from 'three/examples/jsm/utils/SceneUtils.js'
  105. export default {
  106. name: 'newEvacuationBigDataHome',
  107. computed:{
  108. Obj(){
  109. return this.$store.state.settings.planData
  110. }
  111. },
  112. watch:{
  113. Obj(newVal,oldVal){
  114. //可以对数据执行相应的操作
  115. console.log(newVal,oldVal)
  116. this.selectTriggerInfo();
  117. }
  118. },
  119. data() {
  120. return {
  121. videoCover:window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + localStorage.getItem('videoCover'),
  122. //当前路由状态
  123. routeType:false,
  124. containerType:false,
  125. buttonIndex:null,
  126. mapData:[{"x":1,"y":160,"w":797,"h":100,"type":"2","lightList":[{"type":"light","state":"4","w":40,"h":40,"x":520,"y":30,"relayType":2,"configName":"2","configStatus":"2","key":"light0","openType":false},{"type":"light","state":"3","w":40,"h":40,"x":266,"y":30,"relayType":2,"configName":"1","configStatus":"1","key":"light1","openType":false}],"key":"corridor0"},{"x":1,"y":1,"w":398,"h":159,"type":"1","doorList":[{"type":"door","toward":"bottom","w":34,"h":34,"x":193,"y":123}],"roomType":1,"roomNum":"1-1","roomName":null,"subId":160,"subName":"管理员测试实验室1","key":"lab0","id":486,"buildId":48,"floorId":49,"online":0,"loginAdmin":true,"planType":false},{"x":399,"y":1,"w":398,"h":159,"type":"1","doorList":[{"type":"door","toward":"bottom","w":34,"h":34,"x":181,"y":123}],"roomType":-99,"roomNum":"1-2","roomName":"其他房间","subId":-1,"subName":null,"key":"lab1","id":487,"buildId":48,"floorId":49,"online":null,"loginAdmin":false,"planType":false},{"x":1,"y":260,"w":301,"h":139,"type":"1","doorList":[{"type":"door","toward":"top","w":34,"h":34,"x":131,"y":2}],"roomType":-99,"roomNum":"1-3","roomName":"其他房间","subId":-1,"subName":null,"key":"lab2","id":488,"buildId":48,"floorId":49,"online":null,"loginAdmin":false,"planType":false},{"x":302,"y":260,"w":316,"h":139,"type":"1","doorList":[{"type":"door","toward":"top","w":34,"h":34,"x":153,"y":2}],"roomType":-99,"roomNum":"1-4","roomName":"其他房间","subId":-1,"subName":null,"key":"lab3","id":489,"buildId":48,"floorId":49,"online":null,"loginAdmin":false,"planType":false},{"x":618,"y":260,"w":181,"h":139,"type":"3","doorList":[{"type":"door","toward":"top","w":34,"h":34,"x":80,"y":2}],"key":"escape0","roomCheckType":false}],
  127. maxMapButtonList:[],
  128. maxMapList:[],
  129. mapList:[],
  130. // 地基数据
  131. foundation:{
  132. bgColor:'#999',
  133. bgOpacity:1,
  134. x:null,//镜头位置
  135. y:null,//镜头位置
  136. spacing:300,
  137. visualDistance:null,
  138. planColor:'#f15b6c'
  139. },
  140. //数据类型1.实验室
  141. roomData_1:{
  142. bgColor:'#2a5caa',
  143. bgOpacity:0.4,
  144. },
  145. //数据类型 2.走廊
  146. roomData_2:{
  147. bgColor:'#84bf96',
  148. bgOpacity:1,
  149. },
  150. //数据类型 3.逃生通道
  151. roomData_3:{
  152. bgColor:'#007d65',
  153. bgOpacity:0.4,
  154. },
  155. //dom
  156. container:null,
  157. //场景
  158. scene: null,
  159. camera:null,
  160. controls:null,
  161. renderer:null,
  162. //楼栋数据
  163. buildingId:null,
  164. buildingOptions:[],
  165. //楼栋下传感器数据
  166. lotStaticSum:null,
  167. lotStaticList:[],
  168. //楼栋下危险源数量
  169. hazardSum:null,
  170. //实时人数
  171. userNum:null,
  172. //eCharts
  173. eChartsData:{
  174. nameList: [],
  175. numList: [],
  176. maxNumList: [],
  177. },
  178. //mqtt
  179. //全局MQTT相关
  180. allClient:{},
  181. planTopic:"lab/newexit/line",//预案
  182. //楼栋MQTT相关
  183. buildingClient:{},
  184. userTopic:"lab/horn",//消息
  185. //摄像头数据
  186. monitorNumList:[],
  187. monitorType:null,
  188. videoList:[],
  189. videoPlayList:[],
  190. //动画数据
  191. animateData:null,
  192. }
  193. },
  194. created() {
  195. if(this.$route.path == '/newEvacuationBigData'){
  196. this.$set(this,'routeType',true);
  197. }else{
  198. this.$set(this,'routeType',false);
  199. }
  200. },
  201. mounted(){
  202. // this.offAllMQTT('on');
  203. //获取楼栋数据
  204. this.getBuilding();
  205. },
  206. methods: {
  207. //数据处理
  208. dataDispose(num){
  209. let self = this;
  210. if(this.maxMapList[num]){
  211. let list = [];
  212. let index = 0;
  213. if(num-2<=0 && num+2>=(self.maxMapList.length-1)){
  214. index = 0;
  215. }else if (num > (self.maxMapList.length-6) && (num-2) > 0){
  216. if(num + 2 > (self.maxMapList.length-1)){
  217. index = self.maxMapList.length-5;
  218. }else{
  219. index = num - 2;
  220. }
  221. }else{
  222. if(num - 2 > 0){
  223. index = num - 2;
  224. }else{
  225. index = 0;
  226. }
  227. }
  228. let pushNum = 0
  229. for (let i=0 ;i < self.maxMapList.length;i++){
  230. if(index == i && pushNum < 5){
  231. list.push(self.maxMapList[i])
  232. self.maxMapList[i].checkType = true;
  233. pushNum ++
  234. index ++
  235. }else{
  236. self.maxMapList[i].checkType = false;
  237. }
  238. }
  239. this.$set(this,'mapList',list);
  240. if(this.mapList[0]){
  241. let newList = [];
  242. for(let i=0;i<self.maxMapList.length;i++){
  243. let obj = JSON.parse(JSON.stringify(self.maxMapList[i]))
  244. obj.index = i;
  245. newList.unshift(obj);
  246. }
  247. this.$set(this,'maxMapButtonList',newList);
  248. this.$set(this,'buttonIndex',num);
  249. this.selectTriggerInfo();
  250. }
  251. }
  252. },
  253. //初始化
  254. initAdd(){
  255. let self = this;
  256. let maxWidth = 0;
  257. let maxHeight = 0;
  258. let minWidth = 0;
  259. let minHeight = 0;
  260. //数据初始化
  261. for(let i=0;i<self.mapList.length;i++){
  262. self.mapList[i].maxWidth = 0;
  263. self.mapList[i].maxHeight = 0;
  264. for(let o=0;o<self.mapList[i].relationalData.length;o++){
  265. if ((self.mapList[i].relationalData[o].x + self.mapList[i].relationalData[o].w) > self.mapList[i].maxWidth) {
  266. self.mapList[i].maxWidth = self.mapList[i].relationalData[o].x + self.mapList[i].relationalData[o].w
  267. }
  268. if ((self.mapList[i].relationalData[o].y + self.mapList[i].relationalData[o].h) > self.mapList[i].maxHeight) {
  269. self.mapList[i].maxHeight = self.mapList[i].relationalData[o].y + self.mapList[i].relationalData[o].h
  270. }
  271. }
  272. //找出最大高度
  273. if(self.mapList[i].maxHeight > maxHeight){
  274. maxHeight = self.mapList[i].maxHeight;
  275. }
  276. //找出最大宽度
  277. if(self.mapList[i].maxWidth > maxWidth){
  278. maxWidth = self.mapList[i].maxWidth;
  279. }
  280. //找出最小高度
  281. if(minHeight == 0){
  282. minHeight = self.mapList[i].maxHeight;
  283. }else if(self.mapList[i].maxHeight < minHeight){
  284. minHeight = self.mapList[i].maxHeight;
  285. }
  286. //找出最小宽度
  287. if(minWidth == 0){
  288. minWidth = self.mapList[i].maxWidth;
  289. }else if(self.mapList[i].maxWidth < minWidth){
  290. minWidth = self.mapList[i].maxWidth;
  291. }
  292. }
  293. this.$set(this.foundation,'x',maxHeight);
  294. this.$set(this.foundation,'y',maxWidth);
  295. //根据楼层宽度或高度来设定每层之间的间距
  296. // this.$set(this.foundation,'spacing',minWidth>minHeight?minHeight:minWidth);
  297. if(maxWidth>maxHeight){
  298. if(maxWidth>1120){
  299. maxWidth/1120
  300. }else{
  301. }
  302. }else{
  303. if(maxHeight>1120){
  304. }else{
  305. }
  306. }
  307. this.$set(this.foundation,'spacing',maxWidth>maxHeight?maxHeight*0.6:maxWidth*0.6);
  308. this.$set(this.foundation,'visualDistance',maxWidth>maxHeight?maxWidth:maxHeight);
  309. /*
  310. * 创建场景对象Scene
  311. */
  312. // this.scene = new Three.Scene()
  313. //创建层数据
  314. let maxList = [];
  315. for(let i=0;i<self.mapList.length;i++){
  316. /*
  317. * 创建楼层地基
  318. */
  319. let geometryList = [];
  320. let materialList = [];
  321. let geometry = new Three.BoxGeometry(self.mapList[i].maxWidth, 4, self.mapList[i].maxHeight);
  322. //位置偏移
  323. geometry.translate((self.mapList[i].maxWidth/2)-self.mapList[i].maxWidth/2,
  324. (i*self.foundation.spacing),
  325. (self.mapList[i].maxHeight/2)-self.mapList[i].maxHeight/2)
  326. //材质
  327. let material = new Three.MeshLambertMaterial()
  328. //透明度开启关闭
  329. material.transparent = true;
  330. //透明度
  331. material.opacity = self.foundation.bgOpacity;
  332. material.emissive.setStyle(self.foundation.bgColor);
  333. //添加
  334. geometryList.push(geometry)
  335. materialList.push(material)
  336. /*
  337. * 创建楼层房间
  338. */
  339. for(let o=0;o<self.mapList[i].relationalData.length;o++){
  340. let geometry = new Three.BoxGeometry(self.mapList[i].relationalData[o].w, self.mapList[i].relationalData[o].type == 2?4:1, self.mapList[i].relationalData[o].h);
  341. //位置偏移
  342. geometry.translate((self.mapList[i].relationalData[o].x+(self.mapList[i].relationalData[o].w/2))-self.mapList[i].maxWidth/2,
  343. ((i*self.foundation.spacing)+(self.mapList[i].relationalData[o].type == 2?4:20)),
  344. (self.mapList[i].relationalData[o].y+(self.mapList[i].relationalData[o].h/2))-self.mapList[i].maxHeight/2)
  345. //材质
  346. let material = new Three.MeshPhongMaterial()
  347. //区分房间类型 生成文字
  348. //透明度开启关闭
  349. material.transparent = true;
  350. //透明度
  351. material.opacity = self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgOpacity:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgOpacity:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgOpacity:''))
  352. if(self.mapList[i].relationalData[o].planType){
  353. material.emissive.setStyle(self.foundation.planColor);
  354. }else{
  355. material.emissive.setStyle(self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgColor:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgColor:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgColor:'')));
  356. }
  357. //添加
  358. geometryList.push(geometry)
  359. materialList.push(material)
  360. if(self.mapList[i].relationalData[o].type != 2){
  361. //生成墙体
  362. let qt_1 = new Three.BoxGeometry(self.mapList[i].relationalData[o].w, 20, 2);
  363. qt_1.translate((self.mapList[i].relationalData[o].x+(self.mapList[i].relationalData[o].w/2))-self.mapList[i].maxWidth/2,
  364. ((i*self.foundation.spacing)+10),
  365. self.mapList[i].relationalData[o].y-self.mapList[i].maxHeight/2)
  366. let cz_1 = new Three.MeshLambertMaterial()
  367. cz_1.opacity = 1
  368. if(self.mapList[i].relationalData[o].planType){
  369. cz_1.emissive.setStyle(self.foundation.planColor);
  370. }else{
  371. cz_1.emissive.setStyle(self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgColor:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgColor:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgColor:'')));
  372. }
  373. geometryList.push(qt_1)
  374. materialList.push(cz_1)
  375. let qt_2 = new Three.BoxGeometry(self.mapList[i].relationalData[o].w, 20, 2);
  376. qt_2.translate(self.mapList[i].relationalData[o].x+(self.mapList[i].relationalData[o].w/2)-self.mapList[i].maxWidth/2,
  377. ((i*self.foundation.spacing)+10),
  378. self.mapList[i].relationalData[o].y+self.mapList[i].relationalData[o].h-self.mapList[i].maxHeight/2)
  379. let cz_2 = new Three.MeshLambertMaterial()
  380. cz_2.opacity = 1
  381. if(self.mapList[i].relationalData[o].planType){
  382. cz_2.emissive.setStyle(self.foundation.planColor);
  383. }else{
  384. cz_2.emissive.setStyle(self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgColor:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgColor:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgColor:'')));
  385. }
  386. geometryList.push(qt_2)
  387. materialList.push(cz_2)
  388. let qt_3 = new Three.BoxGeometry(2, 20, self.mapList[i].relationalData[o].h);
  389. qt_3.translate(self.mapList[i].relationalData[o].x-self.mapList[i].maxWidth/2,
  390. ((i*self.foundation.spacing)+10),
  391. self.mapList[i].relationalData[o].y+(self.mapList[i].relationalData[o].h/2)-self.mapList[i].maxHeight/2)
  392. let cz_3 = new Three.MeshLambertMaterial()
  393. cz_3.opacity = 1
  394. if(self.mapList[i].relationalData[o].planType){
  395. cz_3.emissive.setStyle(self.foundation.planColor);
  396. }else{
  397. cz_3.emissive.setStyle(self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgColor:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgColor:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgColor:'')));
  398. }
  399. geometryList.push(qt_3)
  400. materialList.push(cz_3)
  401. let qt_4 = new Three.BoxGeometry(2, 20, self.mapList[i].relationalData[o].h);
  402. qt_4.translate(self.mapList[i].relationalData[o].x+self.mapList[i].relationalData[o].w-self.mapList[i].maxWidth/2,
  403. ((i*self.foundation.spacing)+10),
  404. self.mapList[i].relationalData[o].y+(self.mapList[i].relationalData[o].h/2)-self.mapList[i].maxHeight/2)
  405. let cz_4 = new Three.MeshLambertMaterial()
  406. cz_4.opacity = 1
  407. if(self.mapList[i].relationalData[o].planType){
  408. cz_4.emissive.setStyle(self.foundation.planColor);
  409. }else{
  410. cz_4.emissive.setStyle(self.mapList[i].relationalData[o].type == 1?self.roomData_1.bgColor:(self.mapList[i].relationalData[o].type == 2?self.roomData_2.bgColor:(self.mapList[i].relationalData[o].type == 3?self.roomData_3.bgColor:'')));
  411. }
  412. geometryList.push(qt_4)
  413. materialList.push(cz_4)
  414. //生成文字图片
  415. let canvas = document.createElement("canvas");
  416. let ctx = canvas.getContext('2d')
  417. canvas.width = self.mapList[i].relationalData[o].w/2
  418. canvas.height = self.mapList[i].relationalData[o].h/2
  419. //制作矩形
  420. ctx.fillStyle = "gray";
  421. ctx.fillRect(0, 0, 0, 0)
  422. //设置文字
  423. ctx.fillStyle = "white";
  424. ctx.font = 'normal 14px "楷体"'
  425. ctx.fillText(self.mapList[i].relationalData[o].type==3?'紧急出口':(self.mapList[i].relationalData[o].roomName?self.mapList[i].relationalData[o].roomName:self.mapList[i].relationalData[o].subName),0, 20)
  426. //生成图片
  427. let url = canvas.toDataURL('image/png');
  428. let geometry1 = new Three.PlaneGeometry(self.mapList[i].relationalData[o].w/2, 60)
  429. geometry1.translate(self.mapList[i].relationalData[o].x+(self.mapList[i].relationalData[o].w/2)-self.mapList[i].maxWidth/2,
  430. ((i*self.foundation.spacing)+10),
  431. self.mapList[i].relationalData[o].y+(self.mapList[i].relationalData[o].h/2)-self.mapList[i].maxHeight/2)
  432. let material1 = new Three.MeshBasicMaterial({
  433. map: new Three.TextureLoader().load(url),
  434. side: Three.DoubleSide,
  435. opacity: 1,
  436. transparent: true, // 设为透明
  437. })
  438. geometryList.push(geometry1)
  439. materialList.push(material1)
  440. }
  441. }
  442. maxList.push({
  443. geometryList:geometryList,
  444. materialList:materialList,
  445. name:self.mapList[i].name,
  446. floorId:self.mapList[i].id,
  447. subNum:self.mapList[i].subNum,
  448. })
  449. // //合并数据
  450. // let merged = mergeBufferGeometries(geometryList, true)
  451. // let mergeMesh = new Three.Mesh(merged, materialList)
  452. // //给合并项增加名称
  453. // mergeMesh.name = self.mapList[i].name;
  454. // mergeMesh.floorId = self.mapList[i].id;
  455. // mergeMesh.subNum = self.mapList[i].subNum;
  456. // //插入合并数据
  457. // self.scene.add(mergeMesh);
  458. }
  459. //清除动画数据
  460. if(this.renderer){
  461. cancelAnimationFrame(this.animateData);
  462. this.scene.traverse((child) => {
  463. if (child.material) {
  464. for(let i=0;i<child.material.length;i++){
  465. child.material[i].dispose();
  466. }
  467. }
  468. if (child.geometry) {
  469. child.geometry.dispose();
  470. }
  471. child = null;
  472. });
  473. this.container.innerHTML = '';
  474. this.renderer.forceContextLoss();
  475. this.renderer.dispose();
  476. this.scene.clear();
  477. this.$set(this,'scene',null);
  478. this.$set(this,'camera',null);
  479. this.$set(this,'controls',null);
  480. this.$set(this.renderer,'domElement',null);
  481. this.$set(this,'renderer',null);
  482. this.$set(this,'animateData',null);
  483. this.$set(this,'container',null);
  484. }
  485. this.scene = new Three.Scene()
  486. for(let i=0;i<maxList.length;i++){
  487. //合并数据
  488. let merged = mergeBufferGeometries(maxList[i].geometryList, true)
  489. let mergeMesh = new Three.Mesh(merged, maxList[i].materialList)
  490. //给合并项增加名称
  491. mergeMesh.name = maxList[i].name;
  492. mergeMesh.floorId = maxList[i].floorId;
  493. mergeMesh.subNum = maxList[i].subNum;
  494. //插入合并数据
  495. self.scene.add(mergeMesh);
  496. }
  497. this.lens();
  498. },
  499. //镜头
  500. lens(){
  501. this.container = document.getElementById('container')
  502. /*
  503. * 创建相机对象
  504. */
  505. this.camera = new Three.PerspectiveCamera(75, this.container.clientWidth / this.container.clientHeight, 0.1, 3000)
  506. //根据楼层间距与显示层数设定相机距离
  507. this.camera.position.set(0,
  508. this.foundation.visualDistance+(this.foundation.spacing*this.maxMapButtonList.length)*0.2,
  509. this.foundation.visualDistance+(this.foundation.spacing*this.maxMapButtonList.length)*0.2)
  510. /*
  511. * 创建渲染器对象
  512. */
  513. this.renderer = new Three.WebGLRenderer({antialias: true})
  514. this.renderer.setClearColor(0xf4f4f4, 0)
  515. //设置渲染区域尺寸
  516. this.renderer.setSize(this.container.clientWidth, this.container.clientHeight)
  517. //设置背景颜色
  518. //body元素中插入canvas对象
  519. this.container.appendChild(this.renderer.domElement)
  520. //执行渲染操作 指定场景、相机作为参数
  521. this.renderer.render(this.scene, this.camera)
  522. //镜头控制器
  523. this.createControls();
  524. //执行渲染
  525. // this.render();
  526. },
  527. //渲染
  528. render() {
  529. this.renderer.render(this.scene,this.camera);//执行渲染操作
  530. },
  531. // 创建控件对象
  532. createControls() {
  533. this.controls = new OrbitControls(this.camera, this.renderer.domElement)
  534. this.controls.enablePan = false // 是否开启右键拖拽
  535. this.controls.maxPolarAngle = 1 // 上下翻转的最大角度
  536. this.controls.minPolarAngle = 1 // 上下翻转的最小角度
  537. this.controls.autoRotate = true // 是否自动旋转
  538. this.controls.enableZoom = true // 是否可以缩放 默认是true
  539. this.controls.dampingFactor = 0.5 // 动态阻尼系数 就是鼠标拖拽旋转灵敏度,阻尼越小越灵敏
  540. // this.controls.addEventListener('change', this.render)
  541. this.animate();
  542. },
  543. //旋转动画
  544. animate() {
  545. let t0 = new Date()
  546. this.controls.update();
  547. let t1 = new Date(); //本次时间
  548. let t = t1 - t0; // 时间差
  549. this.camera.rotateY(0.0001 * t / 3); //物体的均匀从左到又平移可以用相机旋转Y轴来实现
  550. this.controls.target = new Three.Vector3(0,((this.foundation.visualDistance/40)*(this.maxMapButtonList.length*4)),0);
  551. this.renderer.render(this.scene, this.camera);
  552. this.animateData = requestAnimationFrame(this.animate);
  553. },
  554. // 点击事件
  555. getMouseXY(event){
  556. let self = this;
  557. let dom = document.getElementById('container');
  558. var mouse=new Three.Vector3();
  559. var raycaster=new Three.Raycaster();
  560. if(this.routeType){
  561. mouse.x = ((event.clientX - dom.offsetParent.offsetLeft) / dom.clientWidth) * 2 - 1;//因为布局原因获取父级的offsetLeft
  562. mouse.y = -((event.clientY - dom.offsetTop) / dom.clientHeight) * 2 + 1;
  563. }else{
  564. let borderLeft = Math.round(this.$refs.maxBox.getBoundingClientRect().left);
  565. let borderTop = Math.round(this.$refs.maxBox.getBoundingClientRect().top);
  566. let str = this.$refs.maxBox.style.transform + '';
  567. let index1=str.indexOf('(')
  568. let index2=str.indexOf(')')
  569. str = this.accMul(parseFloat(str.substring(index1+1,index2)),100)
  570. let x = event.clientX - borderLeft;
  571. x = x/str
  572. x = this.accMul(x,100)
  573. x = x - dom.offsetParent.offsetLeft
  574. let y = event.clientY - borderTop;
  575. y = y/str
  576. y = this.accMul(y,100)
  577. y = y - dom.offsetTop
  578. mouse.x = (x / dom.clientWidth) * 2 - 1
  579. mouse.y = -(y / dom.clientHeight) * 2 + 1;
  580. }
  581. raycaster.setFromCamera(mouse, this.camera);
  582. const intersects = raycaster.intersectObjects(this.scene.children);
  583. if(intersects[0]){
  584. if(intersects[0].object.subNum > 0){
  585. for(let i=0;i<self.mapList.length;i++){
  586. if(self.mapList[i].id == intersects[0].object.floorId){
  587. for(let o=0;o<self.mapList[i].relationalData.length;o++){
  588. if(self.mapList[i].relationalData[o].type == '1'){
  589. if(self.mapList[i].relationalData[o].roomType != '-99'){
  590. if(self.mapList[i].relationalData[o].planType){
  591. for(let x=0;x<self.mapList[i].buildFloorLayoutVoList.length;x++){
  592. if(self.mapList[i].buildFloorLayoutVoList[x].loginAdmin){
  593. if(self.mapList[i].buildFloorLayoutVoList[x].subId == self.mapList[i].relationalData[o].subId){
  594. if(self.$route.query.buildId){
  595. delete self.$route.query.buildId;
  596. }
  597. if(self.$route.query.subId){
  598. delete self.$route.query.subId;
  599. }
  600. if(self.$route.query.floorId){
  601. delete self.$route.query.floorId;
  602. }
  603. if(self.$route.query.groupId){
  604. delete self.$route.query.groupId;
  605. }
  606. let obj = {
  607. buildId:self.buildingId,
  608. floorId:self.mapList[i].id,
  609. subId:self.mapList[i].buildFloorLayoutVoList[x].subId,
  610. planType:true
  611. }
  612. self.$parent.goPage(2,obj);
  613. return
  614. }
  615. }
  616. }
  617. }
  618. }
  619. }
  620. }
  621. for(let o=0;o<self.mapList[i].buildFloorLayoutVoList.length;o++){
  622. if(self.mapList[i].buildFloorLayoutVoList[o].loginAdmin){
  623. if(self.$route.query.buildId){
  624. delete self.$route.query.buildId;
  625. }
  626. if(self.$route.query.subId){
  627. delete self.$route.query.subId;
  628. }
  629. if(self.$route.query.floorId){
  630. delete self.$route.query.floorId;
  631. }
  632. if(self.$route.query.groupId){
  633. delete self.$route.query.groupId;
  634. }
  635. let obj = {
  636. buildId:self.buildingId,
  637. floorId:self.mapList[i].id,
  638. subId:self.mapList[i].buildFloorLayoutVoList[o].subId,
  639. planType:false
  640. }
  641. self.$parent.goPage(2,obj);
  642. return
  643. }
  644. }
  645. }
  646. }
  647. }
  648. }
  649. },
  650. //获取楼栋数据
  651. getBuilding(){
  652. getBuildOrFloorList({type:2,parentId:''}).then(response => {
  653. if(response.data[0]){
  654. this.$set(this,'buildingOptions',response.data);
  655. this.$set(this,'buildingId',response.data[0].id);
  656. //获取楼层数据
  657. this.getFloor();
  658. //获取楼栋人数
  659. this.getBuildOrFloorInfo();
  660. //获取eCharts数据
  661. this.exitHazardTotalByBuildId();
  662. //获取楼栋传感器数据接口
  663. this.getLotStatis();
  664. //楼栋MQTT
  665. this.offBuildingMQTT('on');
  666. }
  667. })
  668. },
  669. //楼栋数据选择
  670. buildingChange(){
  671. this.$set(this,'monitorType',null);
  672. //获取楼层数据
  673. this.getFloor();
  674. //获取楼栋人数
  675. this.getBuildOrFloorInfo();
  676. //获取eCharts数据
  677. this.exitHazardTotalByBuildId();
  678. //获取楼栋传感器数据接口
  679. this.getLotStatis();
  680. //楼栋MQTT
  681. this.offBuildingMQTT('on');
  682. },
  683. //获取楼栋人数
  684. getBuildOrFloorInfo(){
  685. let obj = {
  686. type:2,
  687. id:this.buildingId
  688. }
  689. getBuildOrFloorInfo(obj).then(response => {
  690. this.$set(this,'userNum',response.data.online);
  691. })
  692. },
  693. //获取楼层数据
  694. getFloor(){
  695. getBuildOrFloorDetailList({parentId : this.buildingId}).then(response => {
  696. let list = [];
  697. let monitorList = [];
  698. for(let i=0;i<response.data.length;i++){
  699. let obj = {
  700. id:response.data[i].id,
  701. name:response.data[i].name,
  702. parentId:response.data[i].parentId,
  703. subNum:response.data[i].subNum,
  704. buildFloorLayoutVoList:response.data[i].buildFloorLayoutVoList,
  705. relationalData:JSON.parse(response.data[i].exitLineVertexList[0].layoutJoinData),
  706. checkType:false,
  707. indexName:i+1,
  708. }
  709. list.push(obj);
  710. //处理楼层摄像头
  711. if(response.data[i].sparseHardwareList[0]){
  712. let newObj = {
  713. name:response.data[i].name,
  714. type:i==0?true:false,
  715. hardwareList:[],
  716. urlList:[],
  717. }
  718. for(let o=0;o<response.data[i].sparseHardwareList.length;o++){
  719. newObj.hardwareList.push(response.data[i].sparseHardwareList[o].hardwareNum)
  720. }
  721. monitorList.push(newObj)
  722. }
  723. }
  724. this.$set(this,'maxMapList',list);
  725. //处理楼层摄像头
  726. this.$set(this,'monitorNumList',monitorList);
  727. if(monitorList[0]){
  728. this.getMonitorUrl(0);
  729. }
  730. //初始化
  731. this.dataDispose(0);
  732. })
  733. },
  734. //获取楼栋摄像头
  735. async getMonitorUrl(index){
  736. let self = this;
  737. if(index !== this.monitorType){
  738. this.videoOff()
  739. let obj = {
  740. page:"1",
  741. count:"100",
  742. deviceIds:this.monitorNumList[index].hardwareList+'',
  743. };
  744. const { data } = await startUrl(obj);
  745. if(data){
  746. let newData = data;
  747. let urlText = window.location.href;
  748. let videoList = [];
  749. if(urlText.indexOf(localStorage.getItem('ipIdentify')) != -1){
  750. for(let i=0;i<newData.length;i++){
  751. let obj = {
  752. divId:newData[i].deviceID,
  753. hasAudio:false,
  754. height:false,
  755. videoUrl:newData[i].ws_flv,
  756. }
  757. videoList.push(obj)
  758. }
  759. }else{
  760. for(let i=0;i<newData.length;i++){
  761. let text = localStorage.getItem('cameraUrl');
  762. let url = newData[i].ws_flv;
  763. url = url.split("rtp/");
  764. let newUrl = text+'rtp/'+url[1];
  765. let obj = {
  766. divId:newData[i].deviceID,
  767. hasAudio:false,
  768. height:false,
  769. videoUrl:newUrl,
  770. }
  771. videoList.push(obj)
  772. }
  773. }
  774. this.$set(this,'videoList',videoList);
  775. this.$set(this,'monitorType',index);
  776. setTimeout(function(){
  777. self.videoPlay();
  778. },300);
  779. }
  780. }
  781. },
  782. //播放视频流
  783. videoPlay(){
  784. let self = this;
  785. this.loading = false;
  786. let videoList = JSON.parse(JSON.stringify(this.videoList))
  787. for(let i=0;i<videoList.length;i++){
  788. let obj = {
  789. player :{},
  790. flvPlayer:{}
  791. };
  792. obj.player = document.getElementById(videoList[i].divId);
  793. obj.flvPlayer = flvjs.createPlayer(
  794. {
  795. // isLive: true, //=> 是否为直播流
  796. // hasAudio: false, //=> 是否开启声音
  797. type: 'flv', //媒体类型 flv 或 mp4
  798. url: videoList[i].videoUrl //视频流地址
  799. },
  800. {
  801. enableStashBuffer: true,//启用 IO 存储缓冲区。 如果您需要实时流播放(最小延迟),请设置为 false,但如果存在网络抖动,则可能会停止。
  802. stashInitialSize: 128,//IO 存储缓冲区初始大小。 默认值为 384KB。 指示合适的大小可以改善视频加载/搜索时间。
  803. isLive: true,//是否是直播
  804. lazyLoadRecoverDuration: 30,//指示以秒为单位的lazyLoad 恢复时间边界。
  805. autoCleanupSourceBuffer: true,//进行自动清理
  806. autoCleanupMaxBackwardDuration: 3 * 60,//3 * 60 当向后缓冲持续时间超过这个值(以秒为单位)时,对 SourceBuffer 进行自动清理
  807. autoCleanupMinBackwardDuration: 2 * 60,//2 * 60 指示在执行自动清理时为后向缓冲区保留的持续时间(以秒为单位)。
  808. }
  809. );
  810. self.videoPlayList.push(obj);
  811. }
  812. for(let i=0;i<self.videoPlayList.length;i++){
  813. self.videoPlayList[i].flvPlayer.attachMediaElement(self.videoPlayList[i].player);
  814. self.videoPlayList[i].flvPlayer.load(); //加载
  815. self.videoPlayList[i].flvPlayer.play(); //加载
  816. }
  817. },
  818. //断开视频流
  819. videoOff(){
  820. let self = this;
  821. if(self.videoPlayList[0]){
  822. for(let i=0;i<self.videoPlayList.length;i++){
  823. if(self.videoPlayList[i].flvPlayer){
  824. self.videoPlayList[i].flvPlayer.pause();
  825. self.videoPlayList[i].flvPlayer.unload();
  826. self.videoPlayList[i].flvPlayer.detachMediaElement();
  827. self.videoPlayList[i].flvPlayer.destroy();
  828. self.videoPlayList[i].flvPlayer = null;
  829. }
  830. }
  831. self.$set(self,'videoList',[]);
  832. self.$set(self,'videoPlayList',[]);
  833. }
  834. },
  835. //获取楼栋下传感器数据
  836. getLotStatis(){
  837. getLotStatis({buildId:this.buildingId}).then(response => {
  838. this.$set(this,'lotStaticList',response.data.lotStaticList);
  839. this.$set(this,'lotStaticSum',response.data.lotStaticSum);
  840. })
  841. },
  842. //获取eCharts数据
  843. exitHazardTotalByBuildId(){
  844. exitHazardTotalByBuildId({buildId:this.buildingId}).then(response => {
  845. if(response.data.hazardTotal[0]){
  846. this.$set(this,'hazardSum',response.data.hazardSum);
  847. let obj = {
  848. nameList: [],
  849. numList: [],
  850. maxNumList: [],
  851. }
  852. for(let i=0;i<response.data.hazardTotal.length;i++){
  853. obj.nameList.push(response.data.hazardTotal[i].name)
  854. obj.numList.push(response.data.hazardTotal[i].percentage)
  855. obj.maxNumList.push(100)
  856. }
  857. this.$set(this,'eChartsData',obj);
  858. this.eChartsFunction(this.eChartsData);
  859. }else{
  860. this.$set(this,'hazardSum',0);
  861. let obj = {
  862. nameList: [],
  863. numList: [],
  864. maxNumList: [],
  865. }
  866. this.$set(this,'eChartsData',obj);
  867. this.eChartsFunction(this.eChartsData);
  868. }
  869. });
  870. },
  871. //eCharts表格
  872. eChartsFunction(obj){
  873. let self = this;
  874. // document.getElementById('eCharts').innerHTML = '';
  875. this.myChart = this.$echarts.init(document.getElementById('eCharts'));
  876. let option = {
  877. backgroundColor: 'rgba(0,0,0,0)',
  878. grid: {
  879. left: '10%',
  880. right: '10%',
  881. bottom: '10%',
  882. top: '10%',
  883. containLabel: true,
  884. },
  885. legend: [{
  886. show: false,
  887. }],
  888. xAxis: [
  889. {
  890. type: 'category',
  891. data: obj.nameList,
  892. axisLine: {
  893. lineStyle: {
  894. color: 'rgba(5, 80, 93, 1)',
  895. },
  896. },
  897. axisLabel: {
  898. fontSize: 12,
  899. // color: 'black',
  900. color: '#fff',
  901. fontFamily: 'DIN-Medium',
  902. padding: [3, 0, 0, 0]
  903. },
  904. axisTick: {
  905. show: false,
  906. },
  907. },
  908. {
  909. type: 'category',
  910. data: obj.nameList,
  911. show: false,
  912. },],
  913. yAxis: [{
  914. type: 'value',
  915. name: "",
  916. nameTextStyle: {
  917. fontSize: 14,
  918. fontFamily: 'Source Han Sans CN',
  919. fontWeight: '400',
  920. color: 'rgba(255, 255, 255, 1)',
  921. padding: [0, 75, -8, 0]
  922. },
  923. nameGap: 24,
  924. axisLine: {
  925. show: true,
  926. lineStyle: {
  927. color: 'rgba(5, 80, 93, 1)',
  928. }
  929. },
  930. axisTick: {
  931. show: false,
  932. },
  933. splitLine: {
  934. show: false,
  935. lineStyle: {
  936. color: 'rgba(5, 80, 93, 1)',
  937. type: "dashed",
  938. },
  939. },
  940. alignTicks: true,
  941. axisLabel: {
  942. fontSize: 12,
  943. color: 'rgba(255, 255, 255, 1)',
  944. fontFamily: 'DIN-Medium',
  945. padding: [0, 7, 0, 0]
  946. },
  947. splitArea: {
  948. show: false,
  949. },
  950. }],
  951. series: [
  952. {
  953. type: 'bar',
  954. label: {
  955. normal: {
  956. show: true,
  957. position: 'top',
  958. fontSize: 12,
  959. color: 'rgba(16, 213, 223, 1)',
  960. formatter: function (params) {
  961. return params.value + '%'
  962. },
  963. offset: [0, -10],
  964. },
  965. },
  966. tooltip: {
  967. show: false
  968. },
  969. barWidth: 14,
  970. itemStyle: {
  971. color: {
  972. type: 'linear',
  973. x: 0, x2: 0, y: 0, y2: 1,
  974. colorStops: [
  975. { offset: 0, color: '#00FCFC' },
  976. { offset: 1, color: '#016FCC' }
  977. ]
  978. },
  979. },
  980. name: '',
  981. data: obj.numList
  982. },
  983. {
  984. // 分隔
  985. type: 'pictorialBar',
  986. itemStyle: {
  987. normal: {
  988. color: 'rgba(3, 72, 84, 0.5)',
  989. },
  990. },
  991. symbolRepeat: 'fixed',//重复
  992. symbolMargin: 2,//上下间隔
  993. symbol: 'rect',//图形类型
  994. symbolClip: true,//是否裁剪
  995. symbolSize: [20, 2],//图形的大小,可以用数组分开表示宽和高
  996. symbolPosition: 'center',//图形的定位位置
  997. symbolOffset: [0, 2],//图形相对于原本位置的偏移
  998. data: obj.numList,
  999. z: 0,
  1000. zlevel: 1,
  1001. },
  1002. {
  1003. type: 'bar',
  1004. barWidth: 40,
  1005. xAxisIndex: 1,
  1006. itemStyle: {
  1007. color: 'rgba(0, 0, 0, 0)'
  1008. },
  1009. name: '',
  1010. data: obj.maxNumList
  1011. },
  1012. ],
  1013. }
  1014. this.myChart.setOption(option);
  1015. },
  1016. //查询预案发生
  1017. selectTriggerInfo(){
  1018. let self = this;
  1019. selectTriggerInfo().then(response => {
  1020. if(response.data[0]){
  1021. for(let i=0;i<response.data.length;i++){
  1022. for(let o=0;o<self.mapList.length;o++){
  1023. for(let x=0;x<self.mapList[o].relationalData.length;x++){
  1024. if (self.mapList[o].relationalData[x].type == '1' && self.mapList[o].relationalData[x].roomType!='-99'){
  1025. if(response.data[i].subId == self.mapList[o].relationalData[x].subId){
  1026. self.mapList[o].relationalData[x].planType = true;
  1027. //判断预案是否进入过
  1028. for(let s=0;s<response.data.length;s++){
  1029. if(response.data[s].riskAttribute != '1'&&response.data[s].ifCheck != '1'){
  1030. setTimeout(function (){
  1031. if(self.$route.query.buildId){
  1032. delete self.$route.query.buildId;
  1033. }
  1034. if(self.$route.query.subId){
  1035. delete self.$route.query.subId;
  1036. }
  1037. if(self.$route.query.floorId){
  1038. delete self.$route.query.floorId;
  1039. }
  1040. if(self.$route.query.groupId){
  1041. delete self.$route.query.groupId;
  1042. }
  1043. let obj = {
  1044. buildId:response.data[s].buildId,
  1045. floorId:response.data[s].floorId,
  1046. subId:response.data[s].subId,
  1047. groupId:response.data[s].groupId,
  1048. planType:true
  1049. }
  1050. self.$parent.goPage(2,obj);
  1051. },5000)
  1052. break
  1053. }
  1054. }
  1055. }else{
  1056. self.mapList[o].relationalData[x].planType = false;
  1057. }
  1058. }
  1059. }
  1060. }
  1061. }
  1062. }else{
  1063. for(let o=0;o<self.mapList.length;o++){
  1064. for(let x=0;x<self.mapList[o].relationalData.length;x++){
  1065. if (self.mapList[o].relationalData[x].type == '1' && self.mapList[o].relationalData[x].roomType!='-99'){
  1066. self.mapList[o].relationalData[x].planType = false;
  1067. }
  1068. }
  1069. }
  1070. }
  1071. this.initAdd();
  1072. })
  1073. },
  1074. //全局-MQTT订阅
  1075. onAllMQTT(){
  1076. let self = this;
  1077. this.allClient = mqtt.connect(localStorage.getItem('mqttUrl'), {
  1078. username: localStorage.getItem('mqttUser'),
  1079. password: localStorage.getItem('mqttPassword')
  1080. });
  1081. this.allClient.on("connect", e =>{
  1082. console.log("连接成功");
  1083. this.allClient.subscribe(self.planTopic, (err) => {
  1084. if (!err) {
  1085. console.log("预案-订阅成功:" + self.planTopic);
  1086. }
  1087. });
  1088. });
  1089. this.allClient.on("message", (topic, message) => {
  1090. if (message){
  1091. let data = JSON.parse(message)
  1092. if(data){
  1093. console.log('data',data);
  1094. if(topic == self.planTopic){
  1095. //传感器状态
  1096. console.log('预案-状态');
  1097. self.selectTriggerInfo();
  1098. }
  1099. }
  1100. }
  1101. });
  1102. },
  1103. //楼层-MQTT订阅
  1104. onBuildingMQTT(){
  1105. let self = this;
  1106. this.buildingClient = mqtt.connect(localStorage.getItem('mqttUrl'), {
  1107. username: localStorage.getItem('mqttUser'),
  1108. password: localStorage.getItem('mqttPassword')
  1109. });
  1110. this.buildingClient.subscribe(self.userTopic+self.buildingId, (err) => {
  1111. if (!err) {
  1112. console.log("实验室人数-订阅成功:" + self.userTopic+self.buildingId);
  1113. }
  1114. });
  1115. this.buildingClient.on("message", (topic, message) => {
  1116. if (message){
  1117. let data = JSON.parse(message)
  1118. if(data){
  1119. console.log('data',data);
  1120. if(topic == (self.userTopic+self.buildingId)){
  1121. console.log('实验室人数-状态');
  1122. //实验室人数
  1123. self.getBuildOrFloorInfo();
  1124. }
  1125. }
  1126. }
  1127. });
  1128. },
  1129. //取消订阅-全局-关闭MQTT连接
  1130. offAllMQTT(type){
  1131. console.log('type',type)
  1132. let self = this;
  1133. //判断是否已有连接如果有责断开
  1134. if(this.allClient.unsubscribe){
  1135. this.allClient.unsubscribe(self.planTopic, error => {
  1136. if (error) {
  1137. console.log('预案-MQTT断开报错=>', error)
  1138. }
  1139. })
  1140. this.allClient.end();
  1141. this.$set(this,'allClient',{});
  1142. }
  1143. //判断传入参数如果存在 发起一次新的连接
  1144. if(type){
  1145. this.onAllMQTT();
  1146. }
  1147. },
  1148. //取消订阅-楼层-关闭MQTT连接
  1149. offBuildingMQTT(type){
  1150. let self = this;
  1151. //判断是否已有连接如果有责断开
  1152. if(this.buildingClient.unsubscribe){
  1153. this.buildingClient.unsubscribe(self.userTopic+self.buildingId, error => {
  1154. if (error) {
  1155. console.log('实验室人数-MQTT断开报错=>', error)
  1156. }
  1157. })
  1158. this.buildingClient.end();
  1159. this.$set(this,'buildingClient',{});
  1160. }
  1161. //判断传入参数如果存在 发起一次新的连接
  1162. if(type){
  1163. this.onBuildingMQTT();
  1164. }
  1165. },
  1166. //跳转
  1167. goRoute(){
  1168. if(this.routeType){
  1169. this.$router.push({
  1170. path: "/emergencyManagement/newPerformEvacuation"
  1171. })
  1172. }else{
  1173. this.$router.push({
  1174. path: "/newEvacuationBigData"
  1175. })
  1176. }
  1177. },
  1178. accMul(arg1,arg2){
  1179. var m=0,s1=arg1.toString(),s2=arg2.toString();
  1180. try{m+=s1.split(".")[1].length}catch(e){}
  1181. try{m+=s2.split(".")[1].length}catch(e){}
  1182. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
  1183. },
  1184. },
  1185. beforeDestroy() {
  1186. //清除定时器
  1187. let self = this;
  1188. self.videoOff();
  1189. // self.offAllMQTT();
  1190. self.offBuildingMQTT();
  1191. cancelAnimationFrame(self.animateData);
  1192. self.scene.traverse((child) => {
  1193. if (child.material) {
  1194. for(let i=0;i<child.material.length;i++){
  1195. child.material[i].dispose();
  1196. }
  1197. }
  1198. if (child.geometry) {
  1199. child.geometry.dispose();
  1200. }
  1201. child = null;
  1202. });
  1203. self.container.innerHTML = '';
  1204. self.renderer.forceContextLoss();
  1205. self.renderer.dispose();
  1206. self.scene.clear();
  1207. self.$set(self,'scene',null);
  1208. self.$set(self,'camera',null);
  1209. self.$set(self,'controls',null);
  1210. self.$set(self.renderer,'domElement',null);
  1211. self.$set(self,'renderer',null);
  1212. self.$set(self,'animateData',null);
  1213. self.$set(self,'container',null);
  1214. console.log("beforeDestroy");
  1215. },
  1216. }
  1217. </script>
  1218. <style scoped lang="scss">
  1219. .newEvacuationBigDataHome{
  1220. flex:1;
  1221. position: relative;
  1222. display: flex;
  1223. width:1920px;
  1224. height:1080px;
  1225. background: url("../assets/ZDimages/bigData3_2/img_bg.png") repeat;
  1226. background-size: 100% 100%;
  1227. p{
  1228. margin:0;
  1229. }
  1230. .evacuation-title-position-box{
  1231. position: absolute;
  1232. top:0;
  1233. height:92px;
  1234. left:41px;
  1235. width: 1837px;
  1236. background: url("../assets/ZDimages/bigData3_2/sy_db_bg.png");
  1237. background-size: 100% 100%;
  1238. text-align: center;
  1239. font-size:40px;
  1240. line-height:82px;
  1241. color:#24d1f9;
  1242. font-weight:900;
  1243. letter-spacing:10px
  1244. }
  1245. .evacuation-out-button-position-box{
  1246. display: flex;
  1247. position: absolute;
  1248. top:0;
  1249. right:0;
  1250. width:110px;
  1251. cursor: pointer;
  1252. i{
  1253. margin:0 10px;
  1254. line-height:40px;
  1255. color:#24D1F9;
  1256. font-size:18px;
  1257. }
  1258. p{
  1259. line-height:40px;
  1260. color:#24D1F9;
  1261. font-size:14px;
  1262. }
  1263. }
  1264. .left-max-big-box{
  1265. width:400px;
  1266. .left-top-big-box{
  1267. height:688px;
  1268. margin-top:71px;
  1269. position: relative;
  1270. .left-top-for-big-box{
  1271. .left-top-for-box{
  1272. display: inline-block;
  1273. width:78px;
  1274. height:118px;
  1275. position: relative;
  1276. margin:30px 0 0 43px;
  1277. p:nth-child(1){
  1278. line-height: 32px;
  1279. font-size:20px;
  1280. font-weight:700;
  1281. text-align: center;
  1282. color:#24d1f9;
  1283. }
  1284. p:nth-child(2){
  1285. line-height: 18px;
  1286. font-size:16px;
  1287. font-weight:500;
  1288. text-align: center;
  1289. color:#fff;
  1290. }
  1291. img:nth-child(3){
  1292. position: absolute;
  1293. bottom:14px;
  1294. left:19px;
  1295. width:40px;
  1296. height:40px;
  1297. }
  1298. img:nth-child(4){
  1299. position: absolute;
  1300. bottom:0;
  1301. left:0;
  1302. width:78px;
  1303. height:86px;
  1304. }
  1305. }
  1306. }
  1307. .hazardSum-p{
  1308. position: absolute;
  1309. top:26px;
  1310. right:60px;
  1311. color:#fff;
  1312. font-size:14px;
  1313. text-align: right;
  1314. }
  1315. }
  1316. .left-bottom-big-box{
  1317. height:321px;
  1318. position: relative;
  1319. #eCharts{
  1320. height:262px;
  1321. }
  1322. .eCharts-null-p{
  1323. position: absolute;
  1324. top:180px;
  1325. left:165px;
  1326. color:#fff;
  1327. font-size:14px;
  1328. }
  1329. .hazardSum-p{
  1330. position: absolute;
  1331. top:26px;
  1332. right:60px;
  1333. color:#fff;
  1334. font-size:14px;
  1335. text-align: right;
  1336. }
  1337. }
  1338. .big-title-box{
  1339. margin:0 0 0 29px;
  1340. width:181px;
  1341. height:59px;
  1342. background: url("../assets/ZDimages/bigData3_2/img_zjdp_bg.png");
  1343. background-size: 100%;
  1344. display: flex;
  1345. img{
  1346. width:18px;
  1347. height:18px;
  1348. margin:27px 16px 0 20px;
  1349. }
  1350. p{
  1351. margin-top:16px;
  1352. line-height:40px;
  1353. color:#fff;
  1354. font-size:16px;
  1355. }
  1356. }
  1357. }
  1358. .center-max-big-box{
  1359. flex:1;
  1360. display: flex;
  1361. flex-direction: column;
  1362. overflow: hidden;
  1363. position: relative;
  1364. .top-button-box{
  1365. height:226px;
  1366. position: relative;
  1367. .top-button-left-select-box{
  1368. position: absolute;
  1369. top:146px;
  1370. left:69px;
  1371. }
  1372. .top-button-right-num-box{
  1373. }
  1374. }
  1375. #container{
  1376. flex:1;
  1377. background: rgba(0,0,0,0)!important;
  1378. }
  1379. .position-floor-user-box{
  1380. position: absolute;
  1381. right:120px;
  1382. top:146px;
  1383. height:40px;
  1384. display: flex;
  1385. img{
  1386. width:26px;
  1387. height:24px;
  1388. margin:8px 16px 0 0;
  1389. }
  1390. p:nth-child(2){
  1391. font-size:16px;
  1392. color:#24D1F9;
  1393. line-height: 40px;
  1394. }
  1395. p:nth-child(3){
  1396. margin-left:10px;
  1397. font-size:20px;
  1398. color:#24D1F9;
  1399. line-height: 40px;
  1400. font-weight:900;
  1401. }
  1402. }
  1403. .position-floor-button-box{
  1404. position: absolute;
  1405. right:90px;
  1406. top:300px;
  1407. .position-floor-for-button-p:first-child{
  1408. border-top:2px solid #1e7790;
  1409. border-top-left-radius: 4px;
  1410. border-top-right-radius: 4px;
  1411. }
  1412. .position-floor-for-button-p:last-child{
  1413. border-bottom:2px solid #1e7790;
  1414. border-bottom-left-radius: 4px;
  1415. border-bottom-right-radius: 4px;
  1416. }
  1417. .check-button-box:first-child{
  1418. border-top:2px solid #24d1f9;
  1419. border-top-left-radius: 4px;
  1420. border-top-right-radius: 4px;
  1421. }
  1422. .check-button-box:last-child{
  1423. border-bottom:2px solid #24d1f9;
  1424. border-bottom-left-radius: 4px;
  1425. border-bottom-right-radius: 4px;
  1426. }
  1427. .position-floor-for-button-p{
  1428. width:38px;
  1429. height:36px;
  1430. text-align: center;
  1431. line-height:36px;
  1432. color:#1e7790;
  1433. border-left:2px solid #1e7790;
  1434. border-right:2px solid #1e7790;
  1435. border-bottom:1px solid #1e7790;
  1436. border-top:1px solid #1e7790;
  1437. font-size:12px;
  1438. cursor: pointer;
  1439. }
  1440. .check-button-box{
  1441. border-left:2px solid #24d1f9;
  1442. border-right:2px solid #24d1f9;
  1443. border-bottom:1px solid #24d1f9;
  1444. border-top:1px solid #24d1f9;
  1445. color:#fff;
  1446. box-shadow:0 0 6px 1px #24D1F9 inset;
  1447. }
  1448. }
  1449. }
  1450. .right-max-big-box{
  1451. width:400px;
  1452. margin-top:71px;
  1453. .null-p{
  1454. text-align: center;
  1455. line-height:500px;
  1456. color:#fff;
  1457. }
  1458. .monitor-max-for-box:nth-child(1){
  1459. .monitor-title-box{
  1460. border-top:none;
  1461. }
  1462. }
  1463. .monitor-max-for-box{
  1464. width:366px;
  1465. .monitor-title-box{
  1466. display: flex;
  1467. border-top:1px dashed #24D1F9;
  1468. border-bottom:1px dashed #24D1F9;
  1469. p{
  1470. color:#24D1F9;
  1471. font-size:16px;
  1472. line-height:54px;
  1473. flex:1;
  1474. margin-left:7px;
  1475. }
  1476. i{
  1477. color:#24D1F9;
  1478. font-size:18px;
  1479. line-height:54px;
  1480. text-align: center;
  1481. width:20px;
  1482. cursor: pointer;
  1483. margin-right:32px;
  1484. }
  1485. }
  1486. .video-mx-big-box:nth-child(2){
  1487. margin-top:20px;
  1488. }
  1489. .video-mx-big-box{
  1490. margin-bottom:20px;
  1491. }
  1492. }
  1493. }
  1494. }
  1495. </style>
  1496. <style lang="scss">
  1497. .newEvacuationBigDataHome{
  1498. .building-select-box{
  1499. .el-input__inner{
  1500. background:rgba(0,0,0,0);
  1501. border:1px solid #24D1F9;
  1502. box-shadow:0 0 5px 1px #24D1F9 inset;
  1503. color:#fff;
  1504. }
  1505. .el-input__inner:hover{
  1506. border:1px solid #24D1F9;
  1507. box-shadow:0 0 5px 1px #24D1F9 inset;
  1508. }
  1509. }
  1510. .floor-select-box{
  1511. width:100px;
  1512. .el-input__inner{
  1513. background:rgba(0,0,0,0);
  1514. border:1px solid #24D1F9;
  1515. box-shadow:0 0 5px 1px #24D1F9 inset;
  1516. color:#fff;
  1517. }
  1518. .el-input__inner:hover{
  1519. border:1px solid #24D1F9;
  1520. box-shadow:0 0 5px 1px #24D1F9 inset;
  1521. }
  1522. }
  1523. .el-select-dropdown{
  1524. background:#01294d;
  1525. border:1px solid #24D1F9;
  1526. .el-select-dropdown__item{
  1527. background: rgba(0,0,0,0);
  1528. color:#fff;
  1529. }
  1530. .el-select-dropdown__item:hover{
  1531. background: #24D1F9;
  1532. }
  1533. }
  1534. .popper__arrow{
  1535. top:-7px;
  1536. border-bottom-color:#24D1F9!important;
  1537. }
  1538. ::after{
  1539. border-bottom-color:#24D1F9!important;
  1540. }
  1541. ::placeholder{
  1542. color: #fff;
  1543. }
  1544. .scrollbar-box::-webkit-scrollbar{
  1545. width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
  1546. height: 4px;
  1547. }
  1548. .scrollbar-box::-webkit-scrollbar-thumb{
  1549. border-radius: 5px;
  1550. -webkit-box-shadow: inset 0 0 5px #116e8e;
  1551. background: #116e8e;
  1552. }
  1553. .scrollbar-box::-webkit-scrollbar-track{
  1554. -webkit-box-shadow: inset 0 0 5px rgba(255,255,255,0);
  1555. border-radius: 0;
  1556. background: rgba(255,255,255,0);
  1557. }
  1558. }
  1559. </style>