From c388c4c824749cb6d7a0295027bf9d9bf92385e3 Mon Sep 17 00:00:00 2001 From: sunmeng <1162067978@qq.com> Date: Wed, 21 Aug 2024 14:58:11 +0800 Subject: [PATCH] 1 --- api/driverapi.js | 18 +--- .../fertilizer_machine_new.vue | 28 +++++-- .../target_water_fertilizer_PH.vue | 82 +++++++++++++------ pages/timeEnvironment/timeEnvironment.vue | 64 ++++++++++++++- 4 files changed, 141 insertions(+), 51 deletions(-) diff --git a/api/driverapi.js b/api/driverapi.js index 49df90a..1ed9e83 100644 --- a/api/driverapi.js +++ b/api/driverapi.js @@ -57,23 +57,9 @@ let api = { readFs_byid:'/readFs/byid',//查看用户施肥机名称信息 getFiState:"/getFI/getState",//智能灌溉控制器读取. - irrigate1:"/readFi/irrigate1",//智能灌溉组 - irrigate2:"/readFi/irrigate2",//智能灌溉组 - irrigate3:"/readFi/irrigate3",//智能灌溉组 - irrigate4:"/readFi/irrigate4",//智能灌溉组 - irrigate5:"/readFi/irrigate5",//智能灌溉组 - irrigate6:"/readFi/irrigate6",//智能灌溉组 - irrigate7:"/readFi/irrigate7",//智能灌溉组 - irrigate8:"/readFi/irrigate8",//智能灌溉组 - irrigate9:"/readFi/irrigate9",//智能灌溉组 - irrigate10:"/readFi/irrigate10",//智能灌溉组 - irrigate11:"/readFi/irrigate11",//智能灌溉组 - irrigate12:"/readFi/irrigate12",//智能灌溉组 - irrigate13:"/readFi/irrigate13",//智能灌溉组 - irrigate14:"/readFi/irrigate14",//智能灌溉组 - irrigate15:"/readFi/irrigate15",//智能灌溉组 - irrigate16:"/readFi/irrigate16",//智能灌溉组 + getFi_rtdata:"/getFi/rtdata",//首页智能灌溉 writeFi_write:"/writeFi/write",//智能灌溉组写入 + chart_fidata:'/chart/fidata',//智能灌溉的折线图 getcontrol_geteqetdata:'/getcontrol/geteqetdata',//小程序气象站显示 getcontrol_rtDatastation:'/getcontrol/rtDatastation',//主页查看控制器气象站实时数据 diff --git a/pages/fertilizer_machine_new/fertilizer_machine_new.vue b/pages/fertilizer_machine_new/fertilizer_machine_new.vue index 945e14a..b86ef41 100644 --- a/pages/fertilizer_machine_new/fertilizer_machine_new.vue +++ b/pages/fertilizer_machine_new/fertilizer_machine_new.vue @@ -371,9 +371,10 @@ uni.stopPullDownRefresh(); this.inputData = res.data; this.getData30() //数据30/进水出水泵 - this.getData29() //数据29 启动方式/信号 + this.getDataInfo2() this.getcenterBottom() //获取电磁阀 + this.getData29() //数据29 启动方式/信号 } else { that.$refs.uToast.show({ title: res.msg, @@ -547,8 +548,10 @@ typeNumber = i } } + this.openType = this.getType29(typeNumber) - this.dataInfo2_list[3].timer = this.getType29(typeNumber) + console.log(typeNumber,111); + this.dataInfo2_list[2].timer = this.getType29(typeNumber) var statusIndex = 8 let list=[] for (var j = 0; j < statusIndex; j++) { @@ -645,12 +648,15 @@ }); }, getcenterBottom() { + // 96个电磁阀 this.centerBottom = [] var inputData = this.inputData - var list1 = this.padString(inputData['32'].toString(2), 16) - var list2 = this.padString(inputData['33'].toString(2), 16) - var list3 = this.padString(inputData['34'].toString(2), 16) - var list4 = this.padString(inputData['35'].toString(2), 16) + var list1 = this.padString(inputData['3016'].toString(2), 16) + var list2 = this.padString(inputData['3017'].toString(2), 16) + var list3 = this.padString(inputData['3018'].toString(2), 16) + var list4 = this.padString(inputData['3019'].toString(2), 16) + var list5 = this.padString(inputData['3020'].toString(2), 16) + var list6 = this.padString(inputData['3021'].toString(2), 16) var number = 16 for (var i = 0; i < number; i++) { if (Number(list1[list1.length - 1 - i])) { @@ -672,6 +678,16 @@ this.centerBottom.push(l + 48) } } + for (var m = 0; m < number; m++) { + if (Number(list5[list5.length - 1 - m])) { + this.centerBottom.push(m + 64) + } + } + for (var n = 0; n < number; n++) { + if (Number(list6[list6.length - 1 - n])) { + this.centerBottom.push(n + 80) + } + } }, countData(data) { if (data) { diff --git a/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue b/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue index 7c31f56..42980ba 100644 --- a/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue +++ b/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue @@ -125,9 +125,10 @@ } this.titleName = this.getStatus(option.equipmentNumber, option.targetValue) + this.getEchartsData() }, mounted() { - this.getEchartsData() + }, methods: { getServerData() { @@ -148,7 +149,60 @@ // 获取折线图数据 getEchartsData() { - if(this.flag != 1){ + if(this.flag == 1){ + + this.$http({ + url:this.api.equip_chartdata + '?equipmentId=' + this.equipmentId, + method: 'POST' + }).then(res=>{ + // console.log(res,'气象站折线图数据'); + res.data.forEach((i, index) => { + this.categoriesList.push(i.time); + this.valuePHList.push(i.value) + }) + this.getServerData(); + + this.categoriesList = this.categoriesList.map(item => { + return item.split(' ')[1] + }) + for(let k=0;k{ + if(item.name == this.echartName){ + this.newValuePHList.push(item.value==undefined?'':item.value) + } + }) + } + }) + }else if(this.flag == 2){ + this.$http({ + url: this.api.chart_fidata+ '?equipmentId=' + this.equipmentId, + method: 'POST' + }).then(res => { + // console.log(res, '获取折线图数据'); + res.data.forEach((i, index) => { + this.categoriesList.push(i.time); + this.valuePHList.push(i.value) + }) + this.getServerData(); + + this.categoriesList = this.categoriesList.map(item => { + return item.split(' ')[1] + }) + // console.log(this.categoriesList,'this.categoriesList'); + // console.log(this.valuePHList,'this.valuePHList'); + for(let k=0;k{ + if(item.name == this.titleName + this.echartName){ + this.newValuePHList.push(item.value==undefined?'':item.value) + } + }) + } + // console.log(this.newValuePHList, '121212212121211111111'); + }) + + }else{ this.$http({ url: (this.equipmentName == 1 ? this.api.chart_fsdata : this.api.getcontrol_fsdata) + '?equipmentId=' + this.equipmentId, method: 'POST' @@ -175,30 +229,6 @@ } // console.log(this.newValuePHList, '121212212121211111111'); }) - }else{ - this.$http({ - url:this.api.equip_chartdata + '?equipmentId=' + this.equipmentId, - method: 'POST' - }).then(res=>{ - // console.log(res,'气象站折线图数据'); - res.data.forEach((i, index) => { - this.categoriesList.push(i.time); - this.valuePHList.push(i.value) - }) - this.getServerData(); - - this.categoriesList = this.categoriesList.map(item => { - return item.split(' ')[1] - }) - for(let k=0;k{ - if(item.name == this.echartName){ - this.newValuePHList.push(item.value==undefined?'':item.value) - } - }) - } - }) } }, diff --git a/pages/timeEnvironment/timeEnvironment.vue b/pages/timeEnvironment/timeEnvironment.vue index 57e288b..247e00d 100644 --- a/pages/timeEnvironment/timeEnvironment.vue +++ b/pages/timeEnvironment/timeEnvironment.vue @@ -75,7 +75,31 @@ - + + @@ -402,7 +426,10 @@ equipmentName30List:[], equipmentName30ListChild:[], + equipmentName20List:[], + equipmentName20ListChild:[], updateTime30:[], + updateTime20:[], } }, onLoad() { @@ -489,15 +516,21 @@ // console.log(res, '根据用户id查询对应的设备数据'); if (res.code == 200) { this.equipmentName30List = []; + this.equipmentName20List = []; res.data.forEach(el=>{ if(el.equipmentName == 30){ this.equipmentName30List.push(el) } + if(el.equipmentName == 20){ + this.equipmentName20List.push(el) + } }) if(this.equipmentName30List.length != 0){ this.getcontrol_rtDatastation1() } - + if(this.equipmentName20List.length != 0){ + this.getFi_rtdata() + } this.waterAndFertilizerParamsList = res.data.map((item, index) => { return { ...item, @@ -677,7 +710,32 @@ getcontrol_rtDatastation(equipmentId){ }, - + // 获取deviceName为20的智能灌溉实时数据 + getFi_rtdata(){ + this.equipmentName20List = this.equipmentName20List.map((item,index)=>{ + return { + ...item, + equipmentName20ListChild:[] + } + }) + + this.updateTime20 = [] + this.equipmentName20List.forEach(el=>{ + this.$http({ + url:this.api.getFi_rtdata + '?equipmentId=' + el.deviceId, + method: 'GET' + }).then(res=>{ + if(res.code == 200){ + el.equipmentName20ListChild = res.data; + this.updateTime20.push(res.data[0]) + + } + + }) + }) + console.log(this.equipmentName20List); + + }, // 获取deviceName为30的气象站实时数据 getcontrol_rtDatastation1(){ this.equipmentName30List = this.equipmentName30List.map((item,index)=>{