dedsudiyu лет назад: 2
Родитель
Сommit
ed87cb186d
3 измененных файлов с 179 добавлено и 42 удалено
  1. 18 0
      src/api/evacuationBigData/index.js
  2. 8 8
      src/utils/request.js
  3. 153 34
      src/views/newEvacuationBigData.vue

+ 18 - 0
src/api/evacuationBigData/index.js

@@ -146,3 +146,21 @@ export function closeLight(data) {
   })
 }
 
+//执行一键灭火 subjectId=85&deviceCode=28613608F0CA1
+
+export function outfirepc(query) {
+  return request({
+    url: '/algorithm/firedevice/outfirepc',
+    method: 'get',
+    params: query
+  })
+}
+
+//取消一键灭火
+export function isCancelOutFile(query) {
+  return request({
+    url: '/algorithm/firedevice/isCancelOutFile',
+    method: 'get',
+    params: query
+  })
+}

+ 8 - 8
src/utils/request.js

@@ -86,14 +86,14 @@ service.interceptors.response.use(res => {
             type: 'warning'
           }
         ).then(() => {
-          // store.dispatch('LogOut').then(() => {
-          //   localStorage.removeItem('serviceType');
-          //   router.replace({
-          //     path: '/login'
-          //   })
-          //   // location.href = '/index';
-          // })
-          // return
+          store.dispatch('LogOut').then(() => {
+            localStorage.removeItem('serviceType');
+            router.replace({
+              path: '/login'
+            })
+            // location.href = '/index';
+          })
+          return
         }).catch(() => {});
       }
       // return Promise.reject('令牌验证失败')

+ 153 - 34
src/views/newEvacuationBigData.vue

@@ -219,7 +219,8 @@
                   <p class="img-p" :class="!fireData.flameType?'img-p-3-one':'img-p-3-two'"></p>
                 </div>
               </div>
-              <p class="fire-button" v-if="fireListType" @click="shadeButton(1)">一键灭火</p>
+              <p class="fire-button" v-if="fireListType&&!fireStartType" @click="shadeButton(1)">一键灭火</p>
+              <p class="fire-text" v-if="fireListType&&fireStartType">{{fireStartText}},灭火程序将于{{fireStartTime}}秒后结束</p>
               <div class="null-fire-box" v-if="!fireListType">
                 <img src="@/assets/ZDimages/bigData3_2/icon_sblx.png">
                 <p>设备已离线,请及时处理</p>
@@ -296,6 +297,7 @@
           </div>
         </div>
       </div>
+      <!--确认弹层-->
       <div class="shade-max-big-box" v-if="shadeType != 0">
         <div class="shade-big-box">
           <p class="off-button el-icon-close" @click="shadeButton(4)"></p>
@@ -319,6 +321,7 @@
           </div>
         </div>
       </div>
+      <!--疏散选择-->
       <div class="evacuation-shade-max-big-box" v-if="evacuationShadeType">
         <div class="evacuation-shade-big-box">
           <p class="position-title-p">请确定疏散出口</p>
@@ -370,6 +373,7 @@
           <p class="evacuation-button-p" @click="executeEvacuation(1)">已确定疏散出口,立即执行疏散</p>
         </div>
       </div>
+      <!--灭火倒计时-->
       <div class="fire-shade-max-big-box" v-if="fireShadeType">
         <div class="fire-shade-big-box">
           <img src="@/assets/ZDimages/bigData3_2/img_mhz.png">
@@ -387,7 +391,8 @@
   import { getCameraByFloor } from '@/api/executeThePlan.js'
   import { getDeviceList,addHxpChemical,getHornLastMess, subOnlineUser,
            exitHazardTotal,getFireStatus,getFloorData,getBuildOrFloorList,
-           executeEvacuation,endEvacuation,openLight,closeLight,getRedisEvacuation } from '@/api/evacuationBigData/index.js'
+           executeEvacuation,endEvacuation,openLight,closeLight,getRedisEvacuation,
+           outfirepc,isCancelOutFile} from '@/api/evacuationBigData/index.js'
   export default {
     name: 'newEvacuationBigData',
     props:{
@@ -408,8 +413,9 @@
         switchTopic:"lab/hardware/data",//硬件
         //灭火设备MQTT相关
         fireClient:{},
-        fireTopic:"alarm/fireDevice/Warn/",//火灾
-        fireTypeTopic:"lab/fireDevice/isOnline/",//火灾
+        fireTopic:"lab/fireDevice/Warn/",//传感器状态异常
+        fireOnlineTopic:"lab/fireDevice/isOnline/",//设备是否在线
+        firePerformTopic:"lab/fireDevice/executing/",//是否正在执行灭火操作
         //当前实验室/楼栋/楼层
         subText:"",
         floorText:"",
@@ -456,6 +462,10 @@
         },
         //灭火设备code
         fireCode:null,
+        //灭火启动状态
+        fireStartType:false,
+        //灭火描述
+        fireStartText:null,
         /***********一键灭火相关数据***********/
         //一件灭火遮罩
         fireShadeType:false,
@@ -463,6 +473,10 @@
         fireTime:null,
         //灭火倒计时方法数据
         fireTimeData:null,
+        //灭火中倒计时
+        fireStartTime:null,
+        //灭火中倒计时方法数据
+        fireStartTimeData:null,
         //一键灭火倒计时开启状态
         putOutTheFireType:false,
         //实验室人员数据
@@ -724,21 +738,58 @@
       //执行灭火
       putOutTheFireButton(){
         let self = this;
-        if(!this.putOutTheFireType){
-          this.$set(this,'fireTime',5);
-          this.fireTimeData = window.setInterval(refreshCount, 1000);
-          this.$set(this,'putOutTheFireType',true);
-          function refreshCount() {
-            if(self.fireTime<=0){
+        if(!self.putOutTheFireType){
+          let obj = {
+            subjectId:self.subId,
+            deviceCode:self.fireCode,
+          }
+          outfirepc(obj).then(response => {
+            if(response.data.waitTime){
+              self.$set(self,'fireTime',response.data.waitTime);
+              self.fireTimeData = window.setInterval(refreshCount, 1000);
+              self.$set(self,'shadeType',0);
+              self.$set(self,'fireShadeType',true);
+              self.$set(self,'putOutTheFireType',true);
+              function refreshCount() {
+                if(self.fireTime<=1){
+                  window.clearInterval(self.fireTimeData);
+                  self.$set(self,'putOutTheFireType',false);
+                  self.$set(self,'fireShadeType',false);
+                }else{
+                  self.fireTime--
+                }
+              }
+            }else{
+              self.msgError('一键灭火启动失败')
+            }
+          })
+        }else{
+          let obj = {
+            subjectId:this.subId
+          };
+          isCancelOutFile(obj).then(response => {
+            if(response.code == 200){
               window.clearInterval(self.fireTimeData);
+              self.$set(self,'putOutTheFireType',false);
+              self.$set(self,'fireShadeType',false);
             }else{
-              self.fireTime--
+              self.msgError('放弃一键灭火失败')
             }
+          })
+        }
+      },
+      //灭火中倒计时
+      fireStartTimeFunction(time){
+        let self = this;
+        self.$set(self,'fireStartTime',time);
+        self.fireStartTimeData = window.setInterval(refreshCount, 1000);
+        function refreshCount() {
+          if(self.fireStartTime<=1){
+            window.clearInterval(self.fireStartTimeData);
+            self.$set(self,'fireStartType',false);
+          }else{
+            self.fireStartTime--
           }
-        }else{
-          window.clearInterval(self.fireTimeData);
-          this.$set(this,'putOutTheFireType',false);
-          this.$set(this,'fireShadeType',false);
         }
       },
       //获取相关实验室数据
@@ -1272,6 +1323,13 @@
               this.$set(this.fireData,'flameType',response.data.fire);
               this.$set(this,'fireCode',response.data.fireDevice.deviceCode);
               this.offFireMQTT('on');
+              if(response.data.temperature && response.data.smoke){
+                if(!this.fireStartType){
+                  this.$set(this,'fireStartType',true);
+                  this.$set(this,'fireStartText','自动灭火中');
+                  this.fireStartTimeFunction(response.data.timeDifference);
+                }
+              }
             }else{
               this.$set(this,'fireListType',false);
               this.$set(this.fireData,'temperatureType',false);
@@ -1457,9 +1515,12 @@
         this.allClient.on("message", (topic, message) => {
           if (message){
             let data = JSON.parse(message)
-            console.log('全局-mqtt消息data',data);
             if(data){
-
+              console.log('data',data);
+              if(topic == self.planTopic){
+                //传感器状态
+                console.log('预案-状态');
+              }
             }
           }
         });
@@ -1487,13 +1548,21 @@
         this.floorClient.on("message", (topic, message) => {
           if (message){
             let data = JSON.parse(message)
-            console.log('楼层-mqtt消息data',data);
             if(data){
-              if(data.data == 'FLOOR_EXITLINE'){
-                //疏散消息
-                self.getRedisEvacuation();
-              }else if(data.data == 'FLOOR_HORN'){
-                self.getHornLastMess();
+              console.log('data',data);
+              if(topic == (self.messageTopic+self.floorId)){
+                //传感器状态
+                console.log('消息-状态');
+                if(data.data == 'FLOOR_HORN'){
+                  self.getHornLastMess();
+                }
+              }else if(topic == (self.evacuationTopic+self.floorId)){
+                //设备在线状态
+                console.log('疏散-状态');
+                if(data.data == 'FLOOR_EXITLINE'){
+                  //疏散消息
+                  self.getRedisEvacuation();
+                }
               }
             }
           }
@@ -1522,9 +1591,15 @@
         this.subClient.on("message", (topic, message) => {
           if (message){
             let data = JSON.parse(message)
-            console.log('实验室-mqtt消息data',data);
             if(data){
-
+              console.log('data',data);
+              if(topic == (self.sensorTopic+self.subId)){
+                //传感器状态
+                console.log('实验室传感器-状态');
+              }else if(topic == (self.switchTopic+self.subId)){
+                //设备在线状态
+                console.log('实验室设备-状态');
+              }
             }
           }
         });
@@ -1541,16 +1616,44 @@
             console.log("连接成功");
             this.fireClient.subscribe(self.fireTopic+self.fireCode, (err) => {
               if (!err) {
-                console.log("火灾-订阅成功:" + self.fireTopic+self.fireCode);
+                console.log("火灾传感器状态-订阅成功:" + self.fireTopic+self.fireCode);
+              }
+            });
+            this.fireClient.subscribe(self.fireOnlineTopic+self.fireCode, (err) => {
+              if (!err) {
+                console.log("火灾设备是否在线-订阅成功:" + self.fireOnlineTopic+self.fireCode);
+              }
+            });
+            this.fireClient.subscribe(self.firePerformTopic+self.fireCode, (err) => {
+              if (!err) {
+                console.log("火灾是否正在执行灭火操作-订阅成功:" + self.firePerformTopic+self.fireCode);
               }
             });
           });
           this.fireClient.on("message", (topic, message) => {
             if (message){
               let data = JSON.parse(message)
-              console.log('实验室-mqtt消息data',data);
               if(data){
-
+                console.log('data',data);
+                if(topic == (self.fireTopic + self.fireCode)){
+                  //传感器状态
+                  console.log('传感器状态');
+                  self.getFireStatus();
+                }else if(topic == (self.fireOnlineTopic + self.fireCode)){
+                  //设备在线状态
+                  console.log('设备在线状态');
+                }else if(topic == (self.firePerformTopic + self.fireCode)){
+                  //灭火执行操作
+                  if(data.fireStatus == 1){
+                    if(!self.fireStartType){
+                      self.$set(self,'fireStartType',true);
+                      self.$set(self,'fireStartText','灭火中');
+                      self.fireStartTimeFunction(data.direTime);
+                    }else if(data.fireStatus == 0){
+                      self.msgError('一键灭火启动失败')
+                    }
+                  }
+                }
               }
             }
           });
@@ -1561,11 +1664,6 @@
         let self = this;
         //判断是否已有连接如果有责断开
         if(this.allClient.unsubscribe){
-          this.allClient.unsubscribe(self.evacuationTopic, error => {
-            if (error) {
-              console.log('疏散-MQTT断开报错=>', error)
-            }
-          })
           this.allClient.unsubscribe(self.planTopic, error => {
             if (error) {
               console.log('预案-MQTT断开报错=>', error)
@@ -1584,6 +1682,11 @@
         let self = this;
         //判断是否已有连接如果有责断开
         if(this.floorClient.unsubscribe){
+          this.floorClient.unsubscribe(self.evacuationTopic+self.floorId, error => {
+            if (error) {
+              console.log('疏散-MQTT断开报错=>', error)
+            }
+          })
           this.floorClient.unsubscribe(self.messageTopic+self.floorId, error => {
             if (error) {
               console.log('消息-MQTT断开报错=>', error)
@@ -1627,7 +1730,17 @@
         if(this.fireClient.unsubscribe){
           this.fireClient.unsubscribe(self.fireTopic+self.fireCode, error => {
             if (error) {
-              console.log('火灾-MQTT断开报错=>', error)
+              console.log('火灾传感器状态-MQTT断开报错=>', error)
+            }
+          })
+          this.fireClient.unsubscribe(self.fireOnlineTopic+self.fireCode, error => {
+            if (error) {
+              console.log('火灾设备是否在线-MQTT断开报错=>', error)
+            }
+          })
+          this.fireClient.unsubscribe(self.firePerformTopic+self.fireCode, error => {
+            if (error) {
+              console.log('火灾是否正在执行灭火操作-MQTT断开报错=>', error)
             }
           })
           this.fireClient.end();
@@ -2349,6 +2462,12 @@
               background:#FF2333;
               color:#fff;
             }
+            .fire-text{
+              color:#FF2333;
+              font-size:14px;
+              text-align: center;
+              margin-top:25px;
+            }
             .null-fire-box{
               img{
                 width:60px;