|
@@ -16,7 +16,29 @@
|
|
<p>智能控制</p>
|
|
<p>智能控制</p>
|
|
</div>
|
|
</div>
|
|
<div class="content-controls-for-box scrollbar-box" :class="!controlsList[0]?'content-null-box':''">
|
|
<div class="content-controls-for-box scrollbar-box" :class="!controlsList[0]?'content-null-box':''">
|
|
- <div class="controls-for-box" v-for="(item,index) in controlsList" :key="index">
|
|
|
|
|
|
+ <!--非空调-->
|
|
|
|
+ <div class="controls-for-box" v-for="(item,index) in controlsList" :key="index" v-if="item.hardwareTypeKey != 'airConditioner'">
|
|
|
|
+ <div class="for-title-box">
|
|
|
|
+ <div class="for-title-img-box">
|
|
|
|
+ <svg-icon v-if="item.exceptionIcon" class="svg-img" :icon-class="item.exceptionIcon"/>
|
|
|
|
+ </div>
|
|
|
|
+ <p class="for-title-name-box">{{item.hardwareName}}</p>
|
|
|
|
+ <div class="for-title-button-box">
|
|
|
|
+ <el-switch
|
|
|
|
+ class="switch"
|
|
|
|
+ @click.native="changeIsNeedCaptcha(item)"
|
|
|
|
+ v-model="item.operatingState"
|
|
|
|
+ :active-value="false"
|
|
|
|
+ :inactive-value="true"
|
|
|
|
+ active-text="关闭"
|
|
|
|
+ inactive-text="开启"
|
|
|
|
+ disabled>
|
|
|
|
+ </el-switch>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <!--空调-->
|
|
|
|
+ <div class="controls-for-box" v-for="(item,index) in controlsList" :key="index" v-if="item.hardwareTypeKey == 'airConditioner'">
|
|
<div class="for-title-box">
|
|
<div class="for-title-box">
|
|
<div class="for-title-img-box">
|
|
<div class="for-title-img-box">
|
|
<svg-icon v-if="item.exceptionIcon" class="svg-img" :icon-class="item.exceptionIcon"/>
|
|
<svg-icon v-if="item.exceptionIcon" class="svg-img" :icon-class="item.exceptionIcon"/>
|
|
@@ -36,7 +58,7 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--空调-->
|
|
<!--空调-->
|
|
- <div class="for-button-box" v-if="item.hardwareTypeKey == 'airConditioner'">
|
|
|
|
|
|
+ <div class="for-button-box">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="null-box" v-if="!controlsList[0]">
|
|
<div class="null-box" v-if="!controlsList[0]">
|
|
@@ -369,6 +391,7 @@
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
|
|
+ import mqtt from 'mqtt'
|
|
import { laboratoryBigViewGetBuildByBigView, laboratoryBigViewGetFloorByBigView,
|
|
import { laboratoryBigViewGetBuildByBigView, laboratoryBigViewGetFloorByBigView,
|
|
laboratoryExitLineGetRedisEvacuation,laboratoryExitLineExecuteEvacuation,
|
|
laboratoryExitLineGetRedisEvacuation,laboratoryExitLineExecuteEvacuation,
|
|
laboratoryExitLineEndEvacuation,laboratoryBigViewOnLineUserList,
|
|
laboratoryExitLineEndEvacuation,laboratoryBigViewOnLineUserList,
|
|
@@ -415,6 +438,8 @@
|
|
controlsList:[],
|
|
controlsList:[],
|
|
//智能监测
|
|
//智能监测
|
|
monitorList:[],
|
|
monitorList:[],
|
|
|
|
+ //传感器报警数据
|
|
|
|
+ planSensorList:[],
|
|
//危险源
|
|
//危险源
|
|
dangerList:{
|
|
dangerList:{
|
|
nameList: [],
|
|
nameList: [],
|
|
@@ -447,6 +472,19 @@
|
|
shadeType:0,
|
|
shadeType:0,
|
|
shadeText:'',
|
|
shadeText:'',
|
|
shadeData:{},
|
|
shadeData:{},
|
|
|
|
+ /****************** MQTT相关 ******************/
|
|
|
|
+ //硬件MQTT
|
|
|
|
+ hardwareOpic:"iot/hardware/all/sub/",
|
|
|
|
+ hardwareClient:{},
|
|
|
|
+ //传感器
|
|
|
|
+ sensorOpic:"iot/device/sensor/sub/",
|
|
|
|
+ sensorClient:{},
|
|
|
|
+ //疏散灯
|
|
|
|
+ lightOpic:"iot/hardware/evacuationLight/floor/",
|
|
|
|
+ lightClient:{},
|
|
|
|
+ //疏散
|
|
|
|
+ evacuateOpic:"lab/floor/exit/line",
|
|
|
|
+ evacuateClient:{},
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created () {
|
|
created () {
|
|
@@ -519,6 +557,13 @@
|
|
this.iotBigViewDeviceFindByType();
|
|
this.iotBigViewDeviceFindByType();
|
|
//查询实验室危险源
|
|
//查询实验室危险源
|
|
this.laboratoryBigViewHazardCensus();
|
|
this.laboratoryBigViewHazardCensus();
|
|
|
|
+ //MQTT相关
|
|
|
|
+ this.offHardwareMQTT('on')
|
|
|
|
+ this.offSensorMQTT('on')
|
|
|
|
+ //判断是否已有链接
|
|
|
|
+ if(!this.evacuateClient.unsubscribe){
|
|
|
|
+ this.offEvacuateMQTT('on');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
//楼栋选中方法
|
|
//楼栋选中方法
|
|
@@ -532,11 +577,15 @@
|
|
},
|
|
},
|
|
//获取楼栋数据
|
|
//获取楼栋数据
|
|
getBuild(){
|
|
getBuild(){
|
|
|
|
+ let self = this;
|
|
laboratoryBigViewGetBuildByBigView({type:2}).then(response => {
|
|
laboratoryBigViewGetBuildByBigView({type:2}).then(response => {
|
|
if(response.data[0]){
|
|
if(response.data[0]){
|
|
this.$set(this,'buildOptions',response.data);
|
|
this.$set(this,'buildOptions',response.data);
|
|
//获取楼层数据
|
|
//获取楼层数据
|
|
this.getFloor();
|
|
this.getFloor();
|
|
|
|
+ // setTimeout(function (){
|
|
|
|
+ // self.offEvacuateMQTT('on');
|
|
|
|
+ // },5000)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -761,6 +810,15 @@
|
|
self.$set(self.shadeMapList[o],'planType',num != 0);
|
|
self.$set(self.shadeMapList[o],'planType',num != 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //传感器
|
|
|
|
+ let planSensorList = [];
|
|
|
|
+ response.data.forEach((item)=>{
|
|
|
|
+ let list = JSON.parse(item.triggerUploadData)
|
|
|
|
+ list.forEach((minItem)=>{
|
|
|
|
+ planSensorList.push(minItem.deviceNo)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.$set(this,'planSensorList',planSensorList);
|
|
this.buttonSubject();
|
|
this.buttonSubject();
|
|
this.$forceUpdate();
|
|
this.$forceUpdate();
|
|
})
|
|
})
|
|
@@ -885,9 +943,16 @@
|
|
},
|
|
},
|
|
//查询实验室传感器
|
|
//查询实验室传感器
|
|
iotBigViewDeviceFindBySubId(){
|
|
iotBigViewDeviceFindBySubId(){
|
|
|
|
+ let self = this;
|
|
iotBigViewDeviceFindBySubId({subId:this.checkSubId}).then(response => {
|
|
iotBigViewDeviceFindBySubId({subId:this.checkSubId}).then(response => {
|
|
response.data.forEach((item)=>{
|
|
response.data.forEach((item)=>{
|
|
- item.type = false;
|
|
|
|
|
|
+ let num = 0;
|
|
|
|
+ self.planSensorList.forEach((minItem)=>{
|
|
|
|
+ if(item.deviceNo == minItem){
|
|
|
|
+ num++
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ item.type = num != 0;
|
|
})
|
|
})
|
|
this.$set(this,'monitorList',response.data);
|
|
this.$set(this,'monitorList',response.data);
|
|
})
|
|
})
|
|
@@ -1334,7 +1399,7 @@
|
|
//应急疏散时-开灯
|
|
//应急疏散时-开灯
|
|
laboratoryExitRelayOpenLight(){
|
|
laboratoryExitRelayOpenLight(){
|
|
let obj = {
|
|
let obj = {
|
|
- buildId:this.buildingId,
|
|
|
|
|
|
+ buildId:this.buildId,
|
|
floorId:this.floorId,
|
|
floorId:this.floorId,
|
|
pointName:this.shadeData.key
|
|
pointName:this.shadeData.key
|
|
};
|
|
};
|
|
@@ -1348,7 +1413,7 @@
|
|
//应急疏散时-关灯
|
|
//应急疏散时-关灯
|
|
laboratoryExitRelayCloseLight(){
|
|
laboratoryExitRelayCloseLight(){
|
|
let obj = {
|
|
let obj = {
|
|
- buildId:this.buildingId,
|
|
|
|
|
|
+ buildId:this.buildId,
|
|
floorId:this.floorId,
|
|
floorId:this.floorId,
|
|
pointName:this.shadeData.key
|
|
pointName:this.shadeData.key
|
|
};
|
|
};
|
|
@@ -1359,6 +1424,161 @@
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ /*********************************** MQTT相关 *********************************/
|
|
|
|
+ //智能控制-MQTT连接
|
|
|
|
+ offHardwareMQTT(type){
|
|
|
|
+ let self = this;
|
|
|
|
+ if(self.hardwareClient.unsubscribe){
|
|
|
|
+ self.hardwareClient.unsubscribe(self.hardwareOpic+self.checkSubId, error => {
|
|
|
|
+ if (error) {
|
|
|
|
+ // console.log('mqtt关闭连接错误:', error)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ self.hardwareClient.end();
|
|
|
|
+ this.$set(this,'hardwareClient',{});
|
|
|
|
+ }
|
|
|
|
+ //判断传入参数如果存在 发起一次新的连接
|
|
|
|
+ if(type){
|
|
|
|
+ this.hardwareMQTT();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //智能控制-MQTT订阅
|
|
|
|
+ hardwareMQTT(){
|
|
|
|
+ let self = this;
|
|
|
|
+ this.hardwareClient = mqtt.connect(localStorage.getItem('mqttUrl'), {
|
|
|
|
+ username: localStorage.getItem('mqttUser'),
|
|
|
|
+ password:localStorage.getItem('mqttPassword')
|
|
|
|
+ });
|
|
|
|
+ this.hardwareClient.on("connect", e =>{
|
|
|
|
+ this.hardwareClient.subscribe(self.hardwareOpic+self.checkSubId, (err) => {
|
|
|
|
+ if (!err) {
|
|
|
|
+ // console.log("智能控制-订阅成功:" + self.hardwareOpic+self.checkSubId);
|
|
|
|
+ }else{
|
|
|
|
+ // console.log("智能控制-连接错误:" + err);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ this.hardwareClient.on("message", (topic, message) => {
|
|
|
|
+ if (message){
|
|
|
|
+ let data = JSON.parse(message)
|
|
|
|
+ let list = JSON.parse(JSON.stringify(this.controlsList))
|
|
|
|
+ list.forEach((item)=>{
|
|
|
|
+ if(item.hardwareNo == data.hardwareNo){
|
|
|
|
+ item.operatingState = data.operatingState;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.$set(this,'controlsList',list);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ //智能监测-MQTT连接
|
|
|
|
+ offSensorMQTT(type){
|
|
|
|
+ let self = this;
|
|
|
|
+ if(self.sensorClient.unsubscribe){
|
|
|
|
+ self.sensorClient.unsubscribe(self.sensorOpic+self.checkSubId, error => {
|
|
|
|
+ if (error) {
|
|
|
|
+ // console.log('mqtt关闭连接错误:', error)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ self.sensorClient.end();
|
|
|
|
+ this.$set(this,'sensorClient',{});
|
|
|
|
+ }
|
|
|
|
+ //判断传入参数如果存在 发起一次新的连接
|
|
|
|
+ if(type){
|
|
|
|
+ this.sensorMQTT();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //智能监测-MQTT订阅
|
|
|
|
+ sensorMQTT(){
|
|
|
|
+ let self = this;
|
|
|
|
+ this.sensorClient = mqtt.connect(localStorage.getItem('mqttUrl'), {
|
|
|
|
+ username: localStorage.getItem('mqttUser'),
|
|
|
|
+ password:localStorage.getItem('mqttPassword')
|
|
|
|
+ });
|
|
|
|
+ this.sensorClient.on("connect", e =>{
|
|
|
|
+ this.sensorClient.subscribe(self.sensorOpic+self.checkSubId, (err) => {
|
|
|
|
+ if (!err) {
|
|
|
|
+ // console.log("智能监测-订阅成功:" + self.sensorOpic+self.checkSubId);
|
|
|
|
+ }else{
|
|
|
|
+ // console.log("智能监测-连接错误:" + err);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ this.sensorClient.on("message", (topic, message) => {
|
|
|
|
+ if (message){
|
|
|
|
+ let data = JSON.parse(message)
|
|
|
|
+ let list = JSON.parse(JSON.stringify(this.monitorList))
|
|
|
|
+ list.forEach((item)=>{
|
|
|
|
+ data.forEach((minItem)=>{
|
|
|
|
+ if(item.deviceNo == minItem.deviceNo){
|
|
|
|
+ item.deviceValue = minItem.deviceValue;
|
|
|
|
+ item.online = minItem.online;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.$set(this,'monitorList',list);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ //智能监测-MQTT连接
|
|
|
|
+ offEvacuateMQTT(type){
|
|
|
|
+ let self = this;
|
|
|
|
+ if(self.evacuateClient.unsubscribe){
|
|
|
|
+ self.evacuateClient.unsubscribe(self.evacuateOpic, error => {
|
|
|
|
+ if (error) {
|
|
|
|
+ // console.log('mqtt关闭连接错误:', error)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ self.evacuateClient.end();
|
|
|
|
+ this.$set(this,'evacuateClient',{});
|
|
|
|
+ }
|
|
|
|
+ //判断传入参数如果存在 发起一次新的连接
|
|
|
|
+ if(type){
|
|
|
|
+ this.evacuateMQTT();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //智能监测-MQTT订阅
|
|
|
|
+ evacuateMQTT(){
|
|
|
|
+ let self = this;
|
|
|
|
+ this.evacuateClient = mqtt.connect(localStorage.getItem('mqttUrl'), {
|
|
|
|
+ username: localStorage.getItem('mqttUser'),
|
|
|
|
+ password:localStorage.getItem('mqttPassword')
|
|
|
|
+ });
|
|
|
|
+ this.evacuateClient.on("connect", e =>{
|
|
|
|
+ this.evacuateClient.subscribe(self.evacuateOpic, (err) => {
|
|
|
|
+ if (!err) {
|
|
|
|
+ console.log("疏散-订阅成功:" + self.evacuateOpic);
|
|
|
|
+ }else{
|
|
|
|
+ console.log("疏散-连接错误:" + err);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ this.evacuateClient.on("message", (topic, message) => {
|
|
|
|
+ if (message){
|
|
|
|
+ console.log('message')
|
|
|
|
+ let data = JSON.parse(message)
|
|
|
|
+ console.log('data',data)
|
|
|
|
+ // let data = JSON.parse(message)
|
|
|
|
+ // let list = JSON.parse(JSON.stringify(this.monitorList))
|
|
|
|
+ // list.forEach((item)=>{
|
|
|
|
+ // data.forEach((minItem)=>{
|
|
|
|
+ // if(item.deviceNo == minItem.deviceNo){
|
|
|
|
+ // item.deviceValue = minItem.deviceValue;
|
|
|
|
+ // item.online = minItem.online;
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
|
|
+ // this.$set(this,'monitorList',list);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ beforeDestroy() {
|
|
|
|
+ //清除定时器
|
|
|
|
+ let self = this;
|
|
|
|
+ self.hardwareMQTT();
|
|
|
|
+ self.sensorMQTT();
|
|
|
|
+ self.offEvacuateMQTT();
|
|
},
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|