|
|
@ -4,13 +4,18 @@ const moment = require("moment"); |
|
|
|
const { Op } = require("sequelize"); |
|
|
|
class EnvironmentService { |
|
|
|
async getEnvironmentByCoopId(house_id, coop_id) { |
|
|
|
const res = await Environment.findOne({ |
|
|
|
const res = await Environment.findAll({ |
|
|
|
where: { |
|
|
|
coop_id, |
|
|
|
house_id, |
|
|
|
}, |
|
|
|
order: [["log_time", "DESC"]], |
|
|
|
}); |
|
|
|
return res ? res.dataValues : null; |
|
|
|
const arr = res.map((item) => item.dataValues); |
|
|
|
if (arr && arr.length > 0) { |
|
|
|
return arr[0]; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
async addNewLog( |
|
|
@ -84,44 +89,44 @@ class EnvironmentService { |
|
|
|
// 根据所选监测数据进行筛选
|
|
|
|
if (indicator_id == "1") { |
|
|
|
return { |
|
|
|
xData: temperatureList, |
|
|
|
yData: timeList, |
|
|
|
yData: temperatureList, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "2") { |
|
|
|
return { |
|
|
|
xData: nh3List, |
|
|
|
yData: timeList, |
|
|
|
yData: nh3List, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "3") { |
|
|
|
return { |
|
|
|
xData: humidityList, |
|
|
|
yData: timeList, |
|
|
|
yData: humidityList, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "4") { |
|
|
|
return { |
|
|
|
xData: co2List, |
|
|
|
yData: timeList, |
|
|
|
yData: co2List, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "5") { |
|
|
|
return { |
|
|
|
xData: illuminationList, |
|
|
|
yData: timeList, |
|
|
|
yData: illuminationList, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "6") { |
|
|
|
return { |
|
|
|
xData: windSpeedList, |
|
|
|
yData: timeList, |
|
|
|
yData: windSpeedList, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
if (indicator_id == "7") { |
|
|
|
return { |
|
|
|
xData: h2sList, |
|
|
|
yData: timeList, |
|
|
|
yData: h2sList, |
|
|
|
xData: timeList, |
|
|
|
}; |
|
|
|
} |
|
|
|
return null; |
|
|
|