1
0
forked from dyf/APP

完成008A功能开发

This commit is contained in:
liub
2026-05-19 17:38:56 +08:00
parent 6d9df4c945
commit 8f53a45280
63 changed files with 4162 additions and 766 deletions

View File

@ -11,12 +11,15 @@ import {
MsgClear,
MsgInfo
} from '@/utils/MsgPops.js';
import MqPlus from '@/utils/MqPlus.js';
var mqcommon = null;
const homePath = 'pages/common/index'
class BleReceive {
constructor(_ref) {
if(_ref && !this.ref){
this.ref = _ref;
}
if (_ref && !this.ref) {
this.ref = _ref;
}
this.StorageKey = "linkedDevices";
this.HandlerMap = {
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
@ -30,10 +33,10 @@ class BleReceive {
'/pages/6170/deviceControl/index': this.Receive_6170.bind(this),
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
'/pages/6075J/BJQ6075J': this.Receive_6075.bind(this),
'/pages/210/HBY210':this.Receive_210.bind(this),
'/pages/018A/HBY018A':this.Receive_018A.bind(this)
'/pages/210/HBY210': this.Receive_210.bind(this),
'/pages/018A/HBY018A': this.Receive_018A.bind(this)
};
mqcommon = MqPlus.getMqPlus();
}
@ -213,7 +216,7 @@ class BleReceive {
msg.push("设备'" + f.device.deviceName + "'环境存在漏电电源");
}
if (this.ref && msg.length>0) {
if (this.ref && msg.length > 0) {
if (msg.length > 0) {
msg = msg.join(',');
MsgError("'" + f.device.deviceName + "'环境存在漏电电源", '', this.ref, () => {
@ -222,8 +225,6 @@ class BleReceive {
}
}
}
}
return formData;
} catch (error) {
@ -289,6 +290,13 @@ class BleReceive {
let data = parseData(receive.bytes);
console.log("data=", data);
if (f && f.device && mqcommon && path == homePath) {
if (data.battary) {
mqcommon.sendCharge(f.device.id, 1, data.battary);
}
}
return data;
}
@ -373,7 +381,7 @@ class BleReceive {
msgs.push("静止报警中");
}
if (receiveData.battary <= 20) {
msg.push("设备'" + f.device.deviceName + "'电量低");
msgs.push("设备'" + f.device.deviceName + "'电量低");
}
if (msgs.length > 0) {
msgs = msgs.join(";");
@ -461,7 +469,9 @@ class BleReceive {
let data = todo(receive.bytes);
if (f && f.device && mqcommon && path == homePath) {
mqcommon.sendCharge(f.device.id, 1);
}
return data;
}
@ -503,11 +513,18 @@ class BleReceive {
//充电状态
let chargeType = 1;
let warn = bytes[5];
if (warn == 0x00) {
warn = '未充电';
chargeType = 1;
} else if (warn == 0x01) {
warn = '充电中';
chargeType = 0;
}
if (f && f.device && mqcommon && path == homePath) {
mqcommon.sendCharge(f.device.id, chargeType);
}
// 解析剩余照明时间(第三和第四字节,小端序)
@ -604,13 +621,17 @@ class BleReceive {
//充电状态
let chargeType = 1;
let warn = bytes[5];
if (warn == 0x00) {
warn = '未充电';
} else if (warn == 0x01) {
warn = '充电中';
chargeType = 0;
}
if (f && f.device && mqcommon && path == homePath) {
mqcommon.sendCharge(f.device.id, chargeType);
}
// 解析剩余照明时间(第三和第四字节,小端序)
let lightingTime = "";
let HH = Math.max(0, Math.min(100, bytes[6]));
@ -633,7 +654,7 @@ class BleReceive {
});
console.log("formData=",formData)
console.log("formData=", formData)
if (!recCnt) {
console.log("11111");
if (formData.battary <= 20 && bytes[5] == 0x00) {
@ -682,6 +703,10 @@ class BleReceive {
} catch (error) {
receiveData = {};
console.log("文本解析失败", error)
} finally {
if (f && f.device && mqcommon && receiveData.sta_PowerPercent && path == homePath) {
mqcommon.sendCharge(f.device.id, 1, receiveData.sta_PowerPercent);
}
}
return receiveData;
@ -699,6 +724,14 @@ class BleReceive {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
let chargeType = 1;
if (receiveData.sta_system == '1' || receiveData.sta_system == '3') {
chargeType = 0;
}
if (f && f.device && mqcommon && path == homePath) {
mqcommon.sendCharge(f.device.id, chargeType);
}
if (!recCnt) {
if (receiveData.sta_battery <= 20 && (receiveData.sta_system != '1' || receiveData.sta_system !=
'3')) {
@ -748,14 +781,16 @@ class BleReceive {
// console.log("设备收到消息:", f);
// console.log("消息内容:", receive);
receiveData = JSON.parse(receive.str);
let deviceState = receiveData.state;
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
let deviceState = receiveData.state;
if (deviceState && deviceState instanceof Array) {
if (deviceState && deviceState instanceof Array) {
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (deviceState[0] == 12 && deviceState[3] <= 20 && deviceState[4] == 0) {
if (this.ref) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
@ -764,14 +799,34 @@ class BleReceive {
}
}
}
if (f && f.device && mqcommon && path == homePath) {
if (deviceState[0] == 12) {
let chargeType = 1;
if (deviceState[4] == 0) {
chargeType = 1;
} else {
chargeType = 0;
}
mqcommon.sendCharge(f.device.id, chargeType);
} else {
mqcommon.sendCharge(f.device.id, 1);
}
}
}
} catch (error) {
receiveData = {};
console.error("文本解析失败", error)
console.error("错误数据:",receive);
console.error("错误数据:", receive);
}
return receiveData;
@ -790,6 +845,19 @@ class BleReceive {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (f && f.device && mqcommon && path == homePath) {
let chargeType = 1;
if (receiveData.sta_charge == 0) {
chargeType = 1;
} else {
chargeType = 0;
}
mqcommon.sendCharge(f.device.id, chargeType);
}
if (!recCnt) {
let msgs = [];
@ -800,9 +868,9 @@ class BleReceive {
if (receiveData.sta_Intrusion === 1) {
msgs.push("设备'" + f.device.deviceName + "'闯入报警中");
}
if (this.ref && msg.length>0) {
if (this.ref && msgs.length > 0) {
msgs = msgs.join(",");
MsgError(msgs, '', this.ref, () => {
MsgClear(this.ref);
@ -814,7 +882,6 @@ class BleReceive {
if (f.device && path === "pages/common/index") { //仅在首页订阅此操作
console.error("1111111111");
let linkKey = "102_" + f.device.id + "_linked";
let warnKey = "102_" + f.device.id + "_warning";
let time = new Date(); //Common.DateFormat(new Date(),'yyyy-MM-dd HH:mmss');
@ -954,17 +1021,29 @@ class BleReceive {
receiveData = JSON.parse(receive.str);
if (f && f.device && mqcommon && path == homePath) {
let chargeType = 1;
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
chargeType = 1;
} else {
chargeType = 0;
}
mqcommon.sendCharge(f.device.id, chargeType);
}
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt && this.ref) {
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
}
}
@ -977,33 +1056,47 @@ class BleReceive {
}
Receive_018A(receive, f, path, recArr) {
let receiveData = {};
try {
receiveData = JSON.parse(receive.str);
if (f && f.device && mqcommon && path == homePath) {
let chargeType = 1;
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
chargeType = 1;
} else {
chargeType = 0;
}
mqcommon.sendCharge(f.device.id, chargeType);
}
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt && this.ref) {
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
}
}
} catch (error) {
receiveData = {};
console.log("文本解析失败", error)
}
return receiveData;
}
Receive_210(receive, f, path, recArr) {
let receiveData = {};
@ -1011,17 +1104,27 @@ class BleReceive {
receiveData = JSON.parse(receive.str);
if (f && f.device && mqcommon && path == homePath) {
let chargeType = 1;
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
chargeType = 1;
} else {
chargeType = 0;
}
mqcommon.sendCharge(f.device.id, chargeType);
}
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt && this.ref) {
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
1)) {
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
MsgClear(this.ref);
});
}
}