diff --git a/App.vue b/App.vue
index eafd4fb..319a02a 100644
--- a/App.vue
+++ b/App.vue
@@ -152,10 +152,10 @@
},
//Mqtt消息回调
mqttMsgHandler(topic, data) {
- // console.error("mqttMsgHandler:", {
- // topic: topic,
- // data: JSON.parse(data),
- // });
+ console.error("mqttMsgHandler:", {
+ topic: topic,
+ data: JSON.parse(data),
+ });
this.dc.handleMessage(topic, JSON.parse(data));
this.sendMsgEvent("mqtt", {
type: "msg",
diff --git a/pages/dev-ops/station.vue b/pages/dev-ops/station.vue
index 469a5de..c87204c 100644
--- a/pages/dev-ops/station.vue
+++ b/pages/dev-ops/station.vue
@@ -26,13 +26,15 @@
软/硬件版本:
- {{ item.softVer}} / {{ item.deviceVersion}}
+ {{ dataObj[item.deviceCode]?.sv || item.softVer}} /
+ {{ dataObj[item.deviceCode]?.dv || item.deviceVersion}}
+
频段:
- {{ item.rolaFrequency}}
+ {{ dataObj[item.deviceCode]?.lf || item.rolaFrequency}}
@@ -90,8 +92,9 @@
return {
landId: null,
dataList: [],
- topics: [],
dc: getApp().dc, // 设备控制公共代码
+ dataObj: {},
+ topics: [],
rolaFrequency: {
item: null,
old: null,
@@ -117,6 +120,32 @@
list.push(lfObj);
}
this.rolaFrequency.range = list;
+ const that = this;
+ getApp().addMsgEvent("mqtt", "mqtt_devOps_station", function(e) {
+ if (e.type == "state") {
+ // that.mqttConnected = e.connected;
+ } else if (e.type == "msg") {
+ if (e.topic.includes("jsy/iot/deviceConfig/1/")) {
+ const arr = e.topic.split("/");
+ const deviceCode = arr[4];
+ let obj = that.dataObj[deviceCode] || {};
+ if (e.data.type == "gsc") {
+ obj = Object.assign(obj, {
+ dv: e.data.data.dv,
+ sv: e.data.data.sv,
+ lf: e.data.data.lf,
+ })
+ }
+ if (e.data.type == "lf") {
+ obj = Object.assign(obj, {
+ lf: e.data.data,
+ })
+ }
+ that.dataObj[deviceCode] = obj;
+ console.error("this.dataObj:", that.dataObj);
+ }
+ }
+ });
},
onShow() {},
mounted() {},
@@ -127,23 +156,15 @@
queryList(pageNo, pageSize) {
DevOpsApi.getStationList(this.landId).then(res => {
console.error("res:", res);
-
- // /${productKey}/${deviceName}/user/postConfig
this.$refs.paging.completeByTotal(res.rows);
this.mqttSubscribes(res.rows);
-
});
},
mqttSubscribes(rows) {
if (rows && rows.length) {
- const shortTopic = [
- "jsy/iot/deviceConfig/", //频段修改上报
- ]
let topic = [];
rows.forEach(item => {
- shortTopic.forEach(i => {
- topic.push(i + `${item.deviceTypeId}/${item.deviceCode}`);
- });
+ topic.push(`jsy/iot/deviceConfig/${item.deviceTypeId}/${item.deviceCode}`);
});
this.topics = topic;
getApp().mqttSubscribes(this.topics);
diff --git a/pages/dev-ops/valve.vue b/pages/dev-ops/valve.vue
index e55a07f..bf5277b 100644
--- a/pages/dev-ops/valve.vue
+++ b/pages/dev-ops/valve.vue
@@ -33,13 +33,17 @@
频段:
- {{ item.device.deviceExtendValve.rolaFrequency }}
+
+ {{ dataObj[item.device.deviceCode]?.lf || item.device.deviceExtendValve.rolaFrequency}}
+
软/硬件版本:
- {{ item.device.softVer || '-'}} / {{ item.device.deviceVersion || '-' }}
+ {{ dataObj[item.device.deviceCode]?.sv || item.device.softVer}} /
+ {{ dataObj[item.device.deviceCode]?.dv || item.device.deviceVersion }}
+
@@ -100,6 +104,8 @@
},
dataList: [],
dc: getApp().dc, // 设备控制公共代码
+ dataObj: {},
+ topics: [],
rolaFrequency: {
item: null,
old: null,
@@ -131,15 +137,64 @@
list.push(lfObj);
}
this.rolaFrequency.range = list;
+ const that = this;
+ getApp().addMsgEvent("mqtt", "mqtt_devOps_valve", function(e) {
+ if (e.type == "state") {
+ // that.mqttConnected = e.connected;
+ } else if (e.type == "msg") {
+ if (e.topic.includes("jsy/iot/deviceConfig/2/") || e.topic.includes(
+ "jsy/iot/deviceConfig/13/")) {
+ const arr = e.topic.split("/");
+ const deviceCode = arr[4];
+ let obj = that.dataObj[deviceCode] || {};
+ if (e.data.type == "gvc") {
+ obj = Object.assign(obj, {
+ dv: e.data.data.dv,
+ sv: e.data.data.sv,
+ lf: e.data.data.lf,
+ })
+ }
+ that.dataObj[deviceCode] = obj;
+ console.error("this.dataObj:", that.dataObj);
+ }
+ if (e.topic.includes("jsy/iot/valveUpdateLoraRes/")) {
+ const arr = e.topic.split("/");
+ const deviceCode = arr[3];
+ let obj = that.dataObj[deviceCode] || {};
+ if (e.data.type == "vlf" && e.data.res == 1) {
+ obj = Object.assign(obj, {
+ lf: e.data.data,
+ })
+ }
+ that.dataObj[deviceCode] = obj;
+ console.error("this.dataObj:", that.dataObj);
+ }
+ }
+ });
},
onShow() {},
mounted() {},
+ onUnload() {
+ getApp().mqttUnsubscribes(this.topics);
+ },
methods: {
queryList(pageNo, pageSize) {
DevOpsApi.getStationValvelist(this.queryParams.landId, this.queryParams.stationId).then(res => {
this.$refs.paging.completeByTotal(res.rows);
+ this.mqttSubscribes(res.rows);
});
},
+ mqttSubscribes(rows) {
+ if (rows && rows.length) {
+ let topic = [];
+ rows.forEach(item => {
+ topic.push(`jsy/iot/deviceConfig/${item.device.deviceTypeId}/${item.device.deviceCode}`);//获取配置
+ topic.push(`jsy/iot/valveUpdateLoraRes/${item.device.deviceCode}`);//修改频段
+ });
+ this.topics = topic;
+ getApp().mqttSubscribes(this.topics);
+ }
+ },
// 重启
restart(item) {
console.error("重启:", item);
diff --git a/utils/indexUtil/dc.js b/utils/indexUtil/dc.js
index d55316f..f5532e7 100644
--- a/utils/indexUtil/dc.js
+++ b/utils/indexUtil/dc.js
@@ -807,6 +807,9 @@ class deviceControl {
* @param {Object} data
*/
handleMessage(topic, data) {
+ if(!topic.includes("jsy/iot/push/")){
+ return;
+ }
const that = this;
if (data.time < that.dataObj[data.deviceCode].time) {
return;