From 56b07ac5ed6d823841f8ff6aa9cadf4a2961d0be Mon Sep 17 00:00:00 2001 From: hzz Date: Wed, 12 Feb 2025 08:08:41 +0800 Subject: [PATCH] update --- src/store/modules/r_d_environment.js | 12 +- src/utils/websocket.js | 4 +- .../screen/R_D_Environment1/component/Lr4.vue | 19 +- src/views/screen/R_D_Environment1/index.vue | 337 ++++++++---------- 4 files changed, 166 insertions(+), 206 deletions(-) diff --git a/src/store/modules/r_d_environment.js b/src/store/modules/r_d_environment.js index 71be220..c26ebb5 100644 --- a/src/store/modules/r_d_environment.js +++ b/src/store/modules/r_d_environment.js @@ -74,6 +74,16 @@ const useR_D_EnvironmentStore = defineStore( "deptId": "113", "deptName": "4楼", "status": false + }, + { + "deviceId": "1111", + "humidity": "0", + "name": "温湿度监测2", + "label": "temp_humi_2", + "temp": "0", + "deptId": "114", + "deptName": "5楼", + "status": false } ], "TVOC_CH2O": [ @@ -126,10 +136,8 @@ const useR_D_EnvironmentStore = defineStore( }, } let sensorData = state.sensorData - console.log(sensorData, '123'); if (sensorData['temp_humi'] && sensorData['temp_humi'].length > 0) { - console.log(sensorData['temp_humi'], '12113'); let fourTemp = 0 let fourHumi = 0 let fourCount = 0 diff --git a/src/utils/websocket.js b/src/utils/websocket.js index d0f2278..76d0e5e 100644 --- a/src/utils/websocket.js +++ b/src/utils/websocket.js @@ -27,14 +27,14 @@ export const connectWebsocket = (url = null, agentData, successCallback, errCall if (import.meta.env.VITE_APP_ENV == "production") { wsUrl = `ws://${window.document.location.hostname}:9018/` } else { - console.log(import.meta.env,'11111111'); + //console.log(import.meta.env,'11111111'); wsUrl = import.meta.env.VITE_APP_WS_API } } else { wsUrl = url } - console.log('socket地址:',wsUrl); + //console.log('socket地址:',wsUrl); createWebSoket() messageCallback = successCallback errorCallback = errCallback diff --git a/src/views/screen/R_D_Environment1/component/Lr4.vue b/src/views/screen/R_D_Environment1/component/Lr4.vue index 1de9c2e..7f72a38 100644 --- a/src/views/screen/R_D_Environment1/component/Lr4.vue +++ b/src/views/screen/R_D_Environment1/component/Lr4.vue @@ -15,12 +15,12 @@ import u918 from './../image/u918.png'; import { computed } from 'vue'; const prop = defineProps({ - option: { + data: { type: Object, default: () => { return { - xData: [], - seriesData: [], + ch2o: [], + tvoc: [] } } } @@ -31,9 +31,9 @@ const options = computed(() => { tooltip: { trigger: 'axis' }, - legend: { - data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'] - }, + // legend: { + // data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'] + // }, grid: { left: '3%', right: '4%', @@ -42,9 +42,8 @@ const options = computed(() => { }, backgroundColor: 'transparent', xAxis: { - type: 'category', + type: 'time', boundaryGap: false, - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' @@ -56,7 +55,7 @@ const options = computed(() => { areaStyle: { opacity: 0.3 }, - data: [120, 132, 101, 134, 90, 230, 210] + data: prop.data.ch2o }, { name: 'TVOC', @@ -64,7 +63,7 @@ const options = computed(() => { areaStyle: { opacity: 0.3 }, - data: [220, 182, 191, 234, 290, 330, 310] + data: prop.data.tvoc } ] }; diff --git a/src/views/screen/R_D_Environment1/index.vue b/src/views/screen/R_D_Environment1/index.vue index afc742c..01c88f6 100644 --- a/src/views/screen/R_D_Environment1/index.vue +++ b/src/views/screen/R_D_Environment1/index.vue @@ -12,13 +12,13 @@ - +
- +
@@ -45,6 +45,7 @@ import Lr4 from './component/Lr4.vue'; import ZdScrollBoard from "@/components/ZdScrollBoard/index.vue"; import SensorNumLoop from './component/SensorNumLoop.vue'; import useR_D_EnvironmentStore from '@/store/modules/r_d_environment' +import { connectWebsocket, closeWebsocket} from "@/utils/websocket"; import { getSensorByDept } from '@/api/screen/R_D_Environment'; @@ -53,203 +54,136 @@ let deltaY = ref(0) let avg_temp_humi = computed(() => { return R_D_EnvironmentStore.getLayerData }) -let noiseDataList = computed(()=>{ +let noiseDataList = computed(() => { return R_D_EnvironmentStore.getNoiseData }) -let humi = ref({ - "Humiture": [ - { - "devId": "eb98cb70-158f-11ee-b4df-a9653aef169c", - "name": "服装军团", - "temp": "15.4", - "humidity": "14.6", - "status": true - }, - { - "devId": "50633690-158f-11ee-b4df-a9653aef169c", - "name": "家纺军团", - "temp": "16.3", - "humidity": "54.1", - "status": false - }, - { - "devId": "e07dee00-158f-11ee-b4df-a9653aef169c", - "name": "医防军团", - "temp": "15.2", - "humidity": "12.3", - "status": true - }, - { - "devId": "5b01df20-158f-11ee-b4df-a9653aef169c", - "name": "配套中心", - "temp": "11.4", - "humidity": "20", - "status": true - }, - { - "devId": "c524cfd0-4bb2-11ee-864d-e941de71fb47", - "name": "东气泵房", - "temp": "26.9", - "humidity": "10", - "status": true - }, - { - "devId": "e7868a00-4bb2-11ee-864d-e941de71fb47", - "name": "西气泵房", - "temp": "34.4", - "humidity": "6", - "status": true - }, - { - "devId": "7cd36740-158f-11ee-b4df-a9653aef169c", - "name": "东莞分公司", - "temp": "27.7", - "humidity": "38.9", - "status": false - }, - { - "devId": "c502b660-158f-11ee-b4df-a9653aef169c", - "name": "东莞分公司", - "temp": "29.5", - "humidity": "56.3", - "status": false - }, - { - "devId": "57d4bbc0-1bc9-11ee-93b4-8d0afc6a8fe9", - "name": "微工厂", - "temp": "14.7", - "humidity": "17.1", - "status": false - } - ], - "top": { - "temp": 45, - "humidity": 75, - "name": "温湿度上限值" +let TVOC_CH2O = reactive({ + '4f': { + ch2o: [], + tvoc: [] }, - "bottom": { - "temp": -15, - "humidity": 15, - "name": "温湿度下限值" + '5f': { + ch2o: [], + tvoc: [] } }) -let sensor_list = computed(()=>{ +let sensor_list = computed(() => { let sensorData = R_D_EnvironmentStore.sensorData - return [ - { + return [ + { - component: 'SvgWendu', - unit: '℃', - type: 'AirTemp_Reg', - limit: 40, - list: sensorData['temp_humi']?.map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.temp, - status: sensor.status - } - }) - }, - { - component: 'SvgShidu', - unit: '%RH', - type: 'AirHumi_Reg', - limit: 90, - list: sensorData['temp_humi']?.map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.humidity, - status: sensor.status - } - }) - }, - { - component: 'SvgJiaquan', - unit: 'mg/m³', - type: 'CH2O', - limit: 0.08, - list: sensorData['TVOC_CH2O']?.filter(sensor => sensor.type === 'CH2O').map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - }, - { - component: 'SvgTVOC', - unit: 'mg/m³', - type: 'TVOC', - limit: 0.5, - list: sensorData['TVOC_CH2O']?.filter(sensor => sensor.type === 'TVOC').map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - }, - { - component: 'SvgPm25', - unit: 'mg/m³', - type: 'HIGH_PM25_Reg', - limit: 30, - list: sensorData['dust']?.filter(sensor => sensor.type === 'HIGH_PM25_Reg').map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - }, - { - component: 'SvgPm10', - unit: 'mg/m³', - type: 'HIGH_PM10_Reg', - limit: 30, - list: sensorData['dust']?.filter(sensor => sensor.type === 'HIGH_PM10_Reg').map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - }, - { - component: 'SvgZaosheng', - unit: 'dB', - type: 'Noise_Reg', - limit: 85, - list: sensorData['noise']?.map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - }, - { - component: 'SvgYanwu', - unit: 'mg/m³', - type: 'Smoke_Reg', - limit: 100, - list: sensorData['Smoke']?.map(sensor => { - return { - id: sensor.deviceId, - name: sensor.name, - value: sensor.data, - status: sensor.status - } - }) - } -] + component: 'SvgWendu', + unit: '℃', + type: 'AirTemp_Reg', + limit: 40, + list: sensorData['temp_humi']?.map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.temp, + status: sensor.status + } + }) + }, + { + component: 'SvgShidu', + unit: '%RH', + type: 'AirHumi_Reg', + limit: 90, + list: sensorData['temp_humi']?.map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.humidity, + status: sensor.status + } + }) + }, + { + component: 'SvgJiaquan', + unit: 'mg/m³', + type: 'CH2O', + limit: 0.08, + list: sensorData['TVOC_CH2O']?.filter(sensor => sensor.type === 'CH2O').map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + }, + { + component: 'SvgTVOC', + unit: 'mg/m³', + type: 'TVOC', + limit: 0.5, + list: sensorData['TVOC_CH2O']?.filter(sensor => sensor.type === 'TVOC').map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + }, + { + component: 'SvgPm25', + unit: 'mg/m³', + type: 'HIGH_PM25_Reg', + limit: 30, + list: sensorData['dust']?.filter(sensor => sensor.type === 'HIGH_PM25_Reg').map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + }, + { + component: 'SvgPm10', + unit: 'mg/m³', + type: 'HIGH_PM10_Reg', + limit: 30, + list: sensorData['dust']?.filter(sensor => sensor.type === 'HIGH_PM10_Reg').map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + }, + { + component: 'SvgZaosheng', + unit: 'dB', + type: 'Noise_Reg', + limit: 85, + list: sensorData['noise']?.map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + }, + { + component: 'SvgYanwu', + unit: 'mg/m³', + type: 'Smoke_Reg', + limit: 100, + list: sensorData['Smoke']?.map(sensor => { + return { + id: sensor.deviceId, + name: sensor.name, + value: sensor.data, + status: sensor.status + } + }) + } + ] }) const radioGroup1 = ref('四层') let zd_config = ref({ @@ -272,6 +206,7 @@ function reqSensorByDept() { if (res.code === 200) { let sensorData = res.data let temp_humi = sensorData.temp_humi + let TVOC_CH2O = sensorData.TVOC_CH2O let temp = [] temp_humi.map(item => { let index = temp.find(item2 => { return item2.deviceId == item.deviceId }) @@ -308,6 +243,23 @@ function reqSensorByDept() { } } }) + let now = +new Date() + TVOC_CH2O.map(item => { + if (item.deptId == '113') { + if (item.type === 'CH2O') { + TVOC_CH2O['4f'].ch2o.push([now,item.data]) + } else if (item.type === 'TVOC') { + TVOC_CH2O['4f'].tvoc.push([now,item.data]) + } + + } else if(item.deptId == '114') { + if (item.type === 'CH2O') { + TVOC_CH2O['5f'].ch2o.push([now,item.data]) + } else if (item.type === 'TVOC') { + TVOC_CH2O['5f'].tvoc.push([now,item.data]) + } + } + }) sensorData.temp_humi = temp R_D_EnvironmentStore.sensorData = sensorData // noiseDataList.value = res.data @@ -426,6 +378,7 @@ onMounted(() => { // deltaY.value = 0 // } }, { passive: false }); + //connectWebsocket('','',getWebsocket, errWebsocket) });