Przeglądaj źródła

提交优化版本

wangming 1 miesiąc temu
rodzic
commit
d67e9b39da

+ 2 - 137
src/components/component/alarModel.vue

@@ -449,22 +449,14 @@ export default {
             let selectedService = uni.getStorageSync("sercviceChoice");
             if (!selectedService || selectedService == "aloneServe") {
                 if (__wxConfig.envVersion == "develop") {
-                    // client = mqtt.connect(
-                    //     "wxs://cmd.radar-power.com:8084/mqtt",
-                    //     params
-                    // );
                     client = mqtt.connect(
-                        "wxs://radar-power.cn:8084/mqtt",
+                        "wxs://cmd.radar-power.com:8084/mqtt",
                         params
                     );
                 }
                 if (__wxConfig.envVersion == "trial") {
-                    // client = mqtt.connect(
-                    //     "wxs://cmd.radar-power.com:8084/mqtt",
-                    //     params
-                    // );
                     client = mqtt.connect(
-                        "wxs://radar-power.cn:8084/mqtt",
+                        "wxs://cmd.radar-power.com:8084/mqtt",
                         params
                     );
                 }
@@ -517,10 +509,6 @@ export default {
             client.on("message", (topic, message) => {
                 console.log(JSON.parse(message.toString()), "8870");
                 // 处理点位消息
-                if (this.clientIdProp !== null) {
-                    this.handleMessage(topic, message, this.clientIdProp);
-                }
-
                 let userId = uni.getStorageSync("userId");
                 const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
                 const match = topic.match(noticeMatch);
@@ -615,132 +603,9 @@ export default {
                     }
                 });
         },
-
-        // 处理点位消息
-        handleMessage(topic, message, clientId) {
-            // 清除不活动定时器
-            clearTimeout(this.inactivityTimer);
-            this.inactivityTimer = setTimeout(() => {
-                this.targetPoints = {};
-                console.log("长时间没有点位,清除数据");
-                this.sendChange();
-                this.$emit("sendHealth", 0);
-            }, 1500);
-
-            // 验证topic格式
-            const match = topic.match(/^\/dev\/(.+)\/dsp_data$/);
-            if (!match || match[1] !== clientId) return;
-
-            try {
-                const data = JSON.parse(message.toString());
-                if (data.health) {
-                    if (
-                        data.health.breath_rpm ||
-                        data.health.breath_rpm === 0
-                    ) {
-                        this.$emit(
-                            "sendHealth",
-                            Math.floor(data.health.breath_rpm)
-                        );
-                    } else {
-                        this.$emit("sendHealth", 0);
-                    }
-                }
-                this.processTrackerData(data.tracker_targets);
-            } catch (e) {
-                console.error("MQTT消息解析失败", e);
-            }
-        },
-
-        processTrackerData(arr) {
-            if (Array.isArray(arr) && arr.length > 0 && Array.isArray(arr[0])) {
-                this.targetPoints = {};
-                const currentIds = new Set();
-                const newTargetPoints = {};
-                // 处理每个追踪目标
-                arr.forEach((item) => {
-                    if (!Array.isArray(item) || item.length < 4) return;
-
-                    const [x, y, z, id] = item;
-                    currentIds.add(id.toString());
-
-                    // 处理新点或更新现有点
-                    if (!this.targetPoints[id]) {
-                        newTargetPoints[id] = this.createNewTargetPoint(
-                            x,
-                            y,
-                            z,
-                            id
-                        );
-                    } else {
-                        newTargetPoints[id] = this.updateExistingTargetPoint(
-                            this.targetPoints[id],
-                            x,
-                            y,
-                            z,
-                            2
-                        );
-                    }
-                });
-
-                // 移除不存在的点
-                Object.keys(this.targetPoints).forEach((id) => {
-                    if (!currentIds.has(id)) {
-                        delete this.targetPoints[id];
-                    }
-                });
-
-                // 更新目标点
-                this.targetPoints = {
-                    ...this.targetPoints,
-                    ...newTargetPoints,
-                };
-                if (Array.isArray(this.targetPoints)) {
-                    this.targetPoints = this.targetPoints.filter(
-                        (item) => item !== null && item !== undefined
-                    );
-                }
-                console.log("当前目标点11111", this.targetPoints);
-                this.sendChange();
-            }
-        },
         sendChange() {
             this.$emit("sendChange", this.targetPoints);
         },
-        // 创建新目标点
-        createNewTargetPoint(x, y, z, id) {
-            return {
-                x,
-                y,
-                z,
-                id,
-                displayX: x,
-                displayY: y,
-                lastX: x,
-                lastY: y,
-            };
-        },
-        // 更新现有目标点
-        updateExistingTargetPoint(existingPoint, x, y, z, THRESHOLD) {
-            const dx = x - existingPoint.lastX;
-            const dy = y - existingPoint.lastY;
-            const distance = Math.sqrt(dx * dx + dy * dy);
-
-            if (distance > THRESHOLD) {
-                return {
-                    ...existingPoint,
-                    x,
-                    y,
-                    z,
-                    lastX: x,
-                    lastY: y,
-                    displayX: x,
-                    displayY: y,
-                };
-            }
-
-            return existingPoint;
-        },
     },
     mounted() {
         this.connectMQTTwo();

+ 16 - 14
src/pages/home/home.vue

@@ -122,11 +122,15 @@
                     </view>
                 </view>
                 <view class="shareTitleTwo" v-else>
-                    <view class="shareTitle">
-                        {{ alarmRetentionLists[0].devName }}检测到有{{
-                            getEventTypeName(item.eventType)
-                        }}
-                    </view>
+                    <template v-if="alarmRetentionLists.length == 1">
+                        <view class="shareTitle">
+                            {{ alarmRetentionLists[0].devName }}检测到有{{
+                                getEventTypeName(
+                                    alarmRetentionLists[0].eventType
+                                )
+                            }}
+                        </view>
+                    </template>
                 </view>
             </view>
             <image src="../../static/arrFour.png" class="warmImage"></image>
@@ -283,18 +287,16 @@ export default {
                 });
         },
         getwarmType() {
-            this.$http
-                .get("pub/dic/query", { dicType: "alarm_event_type" })
-                .then((res) => {
-                    if (res.data.data) {
-                        this.warmTypeList = res.data.data;
-                    }
-                });
+            this.$http.get("wap/stats/queryEventType").then((res) => {
+                if (res.data.data) {
+                    this.warmTypeList = res.data.data;
+                }
+            });
         },
         getEventTypeName(eventType) {
             return (
-                this.warmTypeList.find((item) => item.itemCode == eventType)
-                    ?.itemName || "未知"
+                this.warmTypeList.find((item) => item.eventVal == eventType)
+                    ?.eventDesc || "未知"
             );
         },
         gotoSurvey(path) {

+ 8 - 9
src/pagesA/abnormalInfo/abnormalInfo.vue

@@ -88,6 +88,7 @@
             </view>
         </template>
         <view style="height: 20rpx"></view>
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
 
@@ -162,18 +163,16 @@ export default {
                 });
         },
         getwarmType() {
-            this.$http
-                .get("pub/dic/query", { dicType: "alarm_event_type" })
-                .then((res) => {
-                    if (res.data.data) {
-                        this.warmTypeList = res.data.data;
-                    }
-                });
+            this.$http.get("wap/stats/queryEventType").then((res) => {
+                if (res.data.data) {
+                    this.warmTypeList = res.data.data;
+                }
+            });
         },
         getEventTypeName(eventType) {
             return (
-                this.warmTypeList.find((item) => item.itemCode == eventType)
-                    ?.itemName || "未知"
+                this.warmTypeList.find((item) => item.eventVal == eventType)
+                    ?.eventDesc || "未知"
             );
         },
         getDate(type) {

+ 5 - 5
src/pagesA/deviceDetail/deviceDetail.vue

@@ -912,14 +912,14 @@ export default {
             let selectedService = uni.getStorageSync("sercviceChoice");
             if (!selectedService || selectedService == "aloneServe") {
                 if (__wxConfig.envVersion == "develop") {
-                    // clientTwo = mqtt.connect(
-                    //     "wxs://data.radar-power.com:8084/mqtt",
-                    //     params
-                    // );
                     clientTwo = mqtt.connect(
-                        "wxs://radar-power.cn:8084/mqtt",
+                        "wxs://data.radar-power.com:8084/mqtt",
                         params
                     );
+                    // clientTwo = mqtt.connect(
+                    //     "wxs://radar-power.cn:8084/mqtt",
+                    //     params
+                    // );
                 }
                 if (__wxConfig.envVersion == "trial") {
                     // clientTwo = mqtt.connect(

+ 8 - 2
src/pagesA/devices/devices.vue

@@ -60,6 +60,8 @@
                 </view>
             </view>
         </view>
+
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
 
@@ -71,6 +73,7 @@ export default {
             option: ["全部", "离线", "在线", "报警"],
             selectValue: 0,
             devs: [],
+            isInitAlarm: false,
         };
     },
     methods: {
@@ -178,11 +181,14 @@ export default {
     },
     onLoad() {},
     onShow() {
+        this.isInitAlarm = true;
         this.queryList();
     },
-    onHide() {},
+    onHide() {
+        this.isInitAlarm = false;
+    },
     onUnload() {
-        // this.isInitAlarm = false;
+        this.isInitAlarm = false;
     },
 
     onPullDownRefresh() {