|
|
@ -118,13 +118,13 @@ class EnvironmentService { |
|
|
|
h2sTotal += parseInt(i.h2s); |
|
|
|
}); |
|
|
|
dataObj.push({ |
|
|
|
temperature: tempTotal / len, |
|
|
|
humidity: humidityTotal / len, |
|
|
|
co2: co2Total / len, |
|
|
|
nh3: nh3Total / len, |
|
|
|
illumination: illuminationTotal / len, |
|
|
|
wind_speed: windSpeedTotal / len, |
|
|
|
h2s: h2sTotal / len, |
|
|
|
temperature: (tempTotal / len).toFixed(2), |
|
|
|
humidity: (humidityTotal / len).toFixed(2), |
|
|
|
co2: (co2Total / len).toFixed(2), |
|
|
|
nh3: (nh3Total / len).toFixed(2), |
|
|
|
illumination: (illuminationTotal / len).toFixed(2), |
|
|
|
wind_speed: (windSpeedTotal / len).toFixed(2), |
|
|
|
h2s: (h2sTotal / len).toFixed(2), |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
@ -138,6 +138,54 @@ class EnvironmentService { |
|
|
|
} else { |
|
|
|
// 7天和全部的按照 每天进行汇总,计算出每天的平均并返回 默认展示7条 前端可以滚动展示
|
|
|
|
// TODO
|
|
|
|
let obj = {}; |
|
|
|
arr.map((item) => { |
|
|
|
const hour = moment(item.log_time).format("YYYY-MM-DD"); |
|
|
|
if (obj[hour]) { |
|
|
|
obj[hour] = [...obj[hour], item]; |
|
|
|
} else { |
|
|
|
obj[hour] = [item]; |
|
|
|
} |
|
|
|
}); |
|
|
|
timeList = Object.keys(obj); |
|
|
|
let dataObj = []; |
|
|
|
Object.values(obj)?.map((item) => { |
|
|
|
const len = item.length; |
|
|
|
if (len != 0) { |
|
|
|
let tempTotal = 0; |
|
|
|
let humidityTotal = 0; |
|
|
|
let co2Total = 0; |
|
|
|
let nh3Total = 0; |
|
|
|
let illuminationTotal = 0; |
|
|
|
let windSpeedTotal = 0; |
|
|
|
let h2sTotal = 0; |
|
|
|
item.map((i) => { |
|
|
|
tempTotal += parseInt(i.temperature); |
|
|
|
humidityTotal += parseInt(i.humidity); |
|
|
|
co2Total += parseInt(i.co2); |
|
|
|
nh3Total += parseInt(i.nh3); |
|
|
|
illuminationTotal += parseInt(i.illumination); |
|
|
|
windSpeedTotal += parseInt(i.wind_speed); |
|
|
|
h2sTotal += parseInt(i.h2s); |
|
|
|
}); |
|
|
|
dataObj.push({ |
|
|
|
temperature: (tempTotal / len).toFixed(2), |
|
|
|
humidity: (humidityTotal / len).toFixed(2), |
|
|
|
co2: (co2Total / len).toFixed(2), |
|
|
|
nh3: (nh3Total / len).toFixed(2), |
|
|
|
illumination: (illuminationTotal / len).toFixed(2), |
|
|
|
wind_speed: (windSpeedTotal / len).toFixed(2), |
|
|
|
h2s: (h2sTotal / len).toFixed(2), |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
temperatureList = dataObj.map((item) => item.temperature); |
|
|
|
humidityList = dataObj.map((item) => item.humidity); |
|
|
|
co2List = dataObj.map((item) => item.co2); |
|
|
|
nh3List = dataObj.map((item) => item.nh3); |
|
|
|
illuminationList = dataObj.map((item) => item.illumination); |
|
|
|
windSpeedList = dataObj.map((item) => item.wind_speed); |
|
|
|
h2sList = dataObj.map((item) => item.h2s); |
|
|
|
} |
|
|
|
// 根据所选监测数据进行筛选
|
|
|
|
if (indicator_id == "1") { |
|
|
|