批量报警、批量发送消息,多个供应商的协议作区分
This commit is contained in:
@ -72,8 +72,10 @@
|
||||
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
|
||||
|
||||
import MqTool from '@/utils/MqHelper.js';
|
||||
var timeout = null;
|
||||
var these = null;
|
||||
var mq=null;
|
||||
export default {
|
||||
components: {
|
||||
CustomPopup,
|
||||
@ -94,13 +96,28 @@
|
||||
alarmApiMapping: [{
|
||||
type: ['HBY100-J'],
|
||||
sendApi: deviceForceAlarmActivation,
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ100J'
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ100J',
|
||||
sendType: 'FYSSend'
|
||||
},
|
||||
{
|
||||
type: ['BJQ6170'],
|
||||
sendApi: deviceSendAlarmMessage,
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ200J'
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_BJQ200J',
|
||||
sendType: 'FYSSend'
|
||||
},
|
||||
|
||||
{
|
||||
type: ['BJQ6075J'],
|
||||
sendApi: deviceSendAlarmMessage,
|
||||
statusTypeName: '',
|
||||
sendType: 'CommonSend'
|
||||
},
|
||||
{
|
||||
type: ['HBY670'],
|
||||
sendApi: deviceSendAlarmMessage,
|
||||
statusTypeName: '',
|
||||
sendType: 'XSSend'
|
||||
}
|
||||
]
|
||||
},
|
||||
loading: false,
|
||||
@ -132,19 +149,20 @@
|
||||
currentApiConfig() {
|
||||
const currentTypeName = this.sendInfo.typeName || '';
|
||||
// 匹配到则用对应配置,匹配不到用默认配置
|
||||
let f= this.dic.alarmApiMapping.find(v=>{
|
||||
return v.type.indexOf(currentTypeName)>-1;
|
||||
let f = this.dic.alarmApiMapping.find(v => {
|
||||
return v.type.indexOf(currentTypeName) > -1;
|
||||
});
|
||||
if(f){
|
||||
if (f) {
|
||||
return f;
|
||||
}else{
|
||||
} else {
|
||||
return {
|
||||
sendApi: deviceDefaultAlarm,
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_Default'
|
||||
statusTypeName: 'FunctionAccessBatchStatusRule_Default',
|
||||
sendType:'FYSSend'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -189,12 +207,12 @@
|
||||
selectAll() {
|
||||
console.log('123');
|
||||
// 仅对在线设备进行全选/取消
|
||||
const allSelected = this.deviceList.every(item => item.checked);
|
||||
const allSelected = this.deviceList.every(item => item.checked);
|
||||
this.deviceList.forEach(item => {
|
||||
// 离线设备不修改checked状态
|
||||
|
||||
item.checked = !allSelected;
|
||||
|
||||
|
||||
item.checked = !allSelected;
|
||||
|
||||
});
|
||||
this.$forceUpdate();
|
||||
},
|
||||
@ -205,7 +223,7 @@
|
||||
console.log(deviceType, 'deviceTypedeviceType');
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: 1,
|
||||
pageNum: this.mescroll?this.mescroll.num:1,
|
||||
pageSize: 50,
|
||||
deviceType: deviceType
|
||||
}
|
||||
@ -217,11 +235,16 @@
|
||||
checked: false
|
||||
}));
|
||||
this.total = res.total;
|
||||
this.deviceList = newDevices;
|
||||
|
||||
|
||||
if(data.pageNum===1){
|
||||
this.deviceList = newDevices;
|
||||
}else{
|
||||
this.deviceList =this.deviceList.concat(newDevices);
|
||||
}
|
||||
|
||||
|
||||
let hasNext = true;
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this
|
||||
.total) {
|
||||
if (res.rows.length < data.pageSize || this.deviceList.length >= this.total) {
|
||||
hasNext = false;
|
||||
} else {
|
||||
hasNext = true;
|
||||
@ -271,7 +294,7 @@
|
||||
this.pendingAlarmAction = 0
|
||||
},
|
||||
//动态调用对应接口
|
||||
async sendAlarmCommand() {
|
||||
sendAlarmCommand() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked);
|
||||
const deviceIds = selectedDevices.map(item => item.id);
|
||||
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
|
||||
@ -291,34 +314,78 @@
|
||||
// 获取当前typeName对应的接口和参数配置
|
||||
const {
|
||||
sendApi,
|
||||
statusTypeName
|
||||
statusTypeName,
|
||||
sendType
|
||||
} = this.currentApiConfig;
|
||||
// 准备请求数据
|
||||
// const batchId = generateShortId();
|
||||
const requestData = {
|
||||
deviceIds: deviceIds,
|
||||
typeName: this.sendInfo.typeName,
|
||||
deviceImeiList: deviceImeiList,
|
||||
// batchId: batchId,
|
||||
voiceStrobeAlarm: this.pendingAlarmAction == 1 ? '1' : '0'
|
||||
};
|
||||
// 动态调用匹配的接口
|
||||
const registerRes = await sendApi(requestData);
|
||||
if (registerRes.code == 200) {
|
||||
|
||||
//FYS的方法
|
||||
let FYSSend = async () => {
|
||||
const requestData = {
|
||||
deviceIds: deviceIds,
|
||||
typeName: this.sendInfo.typeName,
|
||||
deviceImeiList: deviceImeiList,
|
||||
// batchId: batchId,
|
||||
voiceStrobeAlarm: this.pendingAlarmAction == 1 ? '1' : '0'
|
||||
};
|
||||
// 动态调用匹配的接口
|
||||
const registerRes = await sendApi(requestData);
|
||||
if (registerRes.code == 200) {
|
||||
uni.showToast({
|
||||
title: isAlarming ? '强制报警开启成功' : '报警已解除',
|
||||
icon: 'success'
|
||||
});
|
||||
this.showPopupFlag = false
|
||||
uni.$emit('deviceStatusUpdate', {});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: registerRes.msg || '状态查询失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
//XS的方法
|
||||
let XSSend = () => {
|
||||
let json=JSON.stringify({ins_SOSGrade:[1]});
|
||||
for (let i = 0; i < deviceImeiList.length; i++) {
|
||||
let imei = deviceImeiList[i];
|
||||
|
||||
mq.sendData("B/"+imei,json,false);
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: isAlarming ? '强制报警开启成功' : '报警已解除',
|
||||
icon: 'success'
|
||||
});
|
||||
this.showPopupFlag = false
|
||||
uni.$emit('deviceStatusUpdate', {});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
} else {
|
||||
}
|
||||
//统一通信协议方法
|
||||
let CommonSend = () => {
|
||||
let json=JSON.stringify({ins_ShakeBit:1});
|
||||
for (let i = 0; i < deviceImeiList.length; i++) {
|
||||
let imei = deviceImeiList[i];
|
||||
mq.sendData("B/"+imei,json,false);
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: registerRes.msg || '状态查询失败',
|
||||
icon: 'none'
|
||||
title: isAlarming ? '强制报警开启成功' : '报警已解除',
|
||||
icon: 'success'
|
||||
});
|
||||
this.showPopupFlag = false
|
||||
}
|
||||
|
||||
switch (sendType) {
|
||||
case "FYSSend":
|
||||
FYSSend();
|
||||
break;
|
||||
case "XSSend":
|
||||
XSSend();
|
||||
break;
|
||||
case "CommonSend":
|
||||
CommonSend();
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@ -336,8 +403,18 @@
|
||||
this.sendAlarmCommand(this.popupType);
|
||||
},
|
||||
},
|
||||
onUnload() {
|
||||
if(mq){
|
||||
mq.disconnect();
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
these = this;
|
||||
mq=MqTool.getMqTool();
|
||||
if(mq){
|
||||
mq.init();
|
||||
|
||||
}
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||
eventChannel.on('devicePolice', (data) => {
|
||||
|
||||
Reference in New Issue
Block a user