From 39093641d84461cd830c5803ea3e1e2d87ee413a Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Thu, 24 Jul 2025 11:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E8=83=BD=E7=B3=BB=E7=BB=9F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/admin/dict.js | 6 +- .../advancedanalysis/airanalysisstrategy.vue | 58 +++---- .../energy-system/deviceCenter/devicejk.vue | 142 +++++++++--------- src/views/sys/user-boot/dictype/treetable.vue | 2 +- 4 files changed, 108 insertions(+), 100 deletions(-) diff --git a/src/api/admin/dict.js b/src/api/admin/dict.js index 2cad565..ef4cc16 100644 --- a/src/api/admin/dict.js +++ b/src/api/admin/dict.js @@ -72,21 +72,21 @@ export function getDicTree() { } export function getDicTreeAdd(data) { return request({ - url: '/system-boot/dic/add', + url: '/system-boot/dictTree/add', method: 'post', data: data }) } export function getDicTreeUpdate(data) { return request({ - url: '/system-boot/dic/update', + url: '/system-boot/dictTree/update', method: 'put', data: data }) } export function getDicTreeDelete(data) { return request({ - url: '/system-boot/dic/delete', + url: '/system-boot/dictTree/delete', method: 'delete', params: data }) diff --git a/src/views/energy-system/advancedanalysis/airanalysisstrategy.vue b/src/views/energy-system/advancedanalysis/airanalysisstrategy.vue index 0002561..2f3a484 100644 --- a/src/views/energy-system/advancedanalysis/airanalysisstrategy.vue +++ b/src/views/energy-system/advancedanalysis/airanalysisstrategy.vue @@ -202,14 +202,14 @@ type="danger" size="small" v-if="scope.row.type === 1" - style="color: red" + style="color: #008000" >开机策略 关机策略 @@ -256,24 +256,24 @@ }} - - - - + diff --git a/src/views/energy-system/deviceCenter/devicejk.vue b/src/views/energy-system/deviceCenter/devicejk.vue index dc8af8e..3ccfb4e 100644 --- a/src/views/energy-system/deviceCenter/devicejk.vue +++ b/src/views/energy-system/deviceCenter/devicejk.vue @@ -1330,64 +1330,7 @@ export default { this.get_bodyHeight(); this.connectMqtt(); - this.globalMqtt.ws.on("connect", (e) => { - this.$message.success("连接mqtt服务器成功!"); - console.log("mqtt客户端已连接...."); - this.globalMqtt.ws.subscribe("/platform/devack/#"); - }); - this.globalMqtt.ws.on("error", (error) => { - console.log("mqtt连接失败...", error); - this.mqtt.end(); - }); - - this.globalMqtt.ws.on("close", function () { - console.log("mqtt客户端已断开连接....."); - }); - - let index = 0; - this.globalMqtt.ws.on("message", (topic, message) => { - let that = this; - if (message) { - let json = JSON.parse(message); - if (json.code === 200) { - if (json.param.action === "ACInMode") { - this.$message.success("内机模式调节成功!"); - } else if (json.param.action === "ACInSpeed") { - this.$message.success("内机风速调节成功!"); - } else if (json.param.action === "ACInSetTmp") { - this.$message.success("内机温度调节成功!"); - } else if (json.param.action === "ACInStat") { - this.$message.success("内机开关机操作成功!"); - } else { - this.$message.success("操作成功!"); - } - - window.setTimeout(function () { - that.getStatisTemplateById(); - }, 10000); - } else { - this.$message.error(json.msg); - if (this.userIndex === json.userId) { - this.mqttSendCount++; - if (this.mqttSendCount > 2) { - return; - } else { - this.globalMqtt.ws.publish( - "/platform/devcmd/v1/" + this.devInfo.ndid, - JSON.stringify(this.mqttSendMsg) - ); - } - - console.log("错误+++进行重发" + this.mqttSendCount); - } - } - - this.buttonDisable = false; - } - - console.log("收到消息:" + topic + message); - }); //如果别的页面路由过来的进行路由参数处理 }, @@ -1412,10 +1355,11 @@ export default { }, methods: { connectMqtt() { - this.globalMqtt.ws = {}; + let this_ = this + this_.globalMqtt.ws = {}; let mqttWs = null; - let userName = this.$store.state.user.userInfo.loginName; + let userName = this_.$store.state.user.userInfo.loginName; const options = { qos: 2, clean: true, @@ -1424,9 +1368,69 @@ export default { username: "t_user", password: "njcnpqs", }; - const url = "wss://pqmcn.com:8087/mqtt"; + const url = "ws://192.168.1.24:8085/mqtt"; mqttWs = mqtt.connect(url, options); - this.globalMqtt.setWs(mqttWs); + this_.globalMqtt.setWs(mqttWs); + + + this_.globalMqtt.ws.on("connect", (e) => { + this_.$message.success("连接mqtt服务器成功!"); + console.log("mqtt客户端已连接...."); + this_.globalMqtt.ws.subscribe("/platform/devack/#"); + }); + + this_.globalMqtt.ws.on("error", (error) => { + console.log("mqtt连接失败...", error); + this.mqtt.end(); + }); + + this_.globalMqtt.ws.on("close", function () { + console.log("mqtt客户端已断开连接....."); + }); + + + this_.globalMqtt.ws.on("message", (topic, message) => { + let that = this; + if (message) { + let json = JSON.parse(message); + if (json.code === 200) { + if (json.param.action === "ACInMode") { + this_.$message.success("内机模式调节成功!"); + } else if (json.param.action === "ACInSpeed") { + this_.$message.success("内机风速调节成功!"); + } else if (json.param.action === "ACInSetTmp") { + this_.$message.success("内机温度调节成功!"); + } else if (json.param.action === "ACInStat") { + this_.$message.success("内机开关机操作成功!"); + } else { + this_.$message.success("操作成功!"); + } + + window.setTimeout(function () { + that.getStatisTemplateById(); + }, 10000); + } else { + this_.$message.error(json.msg); + if (this_.userIndex === json.userId) { + this_.mqttSendCount++; + if (this_.mqttSendCount > 2) { + return; + } else { + this_.globalMqtt.ws.publish( + "/platform/devcmd/v1/" + this.devInfo.ndid, + JSON.stringify(this.mqttSendMsg) + ); + } + + console.log("错误+++进行重发" + this.mqttSendCount); + } + } + + this_.buttonDisable = false; + } + + console.log("收到消息:" + topic + message); + }); }, //子节点树点击事件 getTreeText(data, level) { @@ -1694,7 +1698,7 @@ export default { }, querfromdata(data, timehbValue, type, interval) { - + this.interval = interval; this.timeRange = data; if (type == 1) { @@ -2009,7 +2013,7 @@ window.echartsArr.push(myChart); switchChange(item, type) { console.log(item); console.log(type); - console.log(this.devInfo.ndid); + let msg = { mid: 1, @@ -2025,10 +2029,14 @@ window.echartsArr.push(myChart); }, }; - this.globalMqtt.ws.publish( - "/platform/devcmd/v1/" + this.devInfo.ndid, - JSON.stringify(msg) - ); + let topic = "/platform/devcmd/v1/" + this.devInfo.ndid; + console.log(topic); + this.globalMqtt.ws.publish(topic, JSON.stringify(msg), { qos: 0 }, (err) => { + if (err) console.error("发送失败:", err); + else console.log("发送成功"); + }) + + this.mqttSendMsg = msg; this.mqttSendCount = 0; diff --git a/src/views/sys/user-boot/dictype/treetable.vue b/src/views/sys/user-boot/dictype/treetable.vue index 23f98fa..8e0ae9e 100644 --- a/src/views/sys/user-boot/dictype/treetable.vue +++ b/src/views/sys/user-boot/dictype/treetable.vue @@ -10,7 +10,7 @@ 查询 --> - 新增字典类型 + 新增字典树类型