明树Git Lab

Commit e358edfe authored by zengfanpei's avatar zengfanpei

小数处理 暂无精度要求 avg可用

parent de2ca538
......@@ -54,6 +54,13 @@ async function getSMCChangeTrend(req, res, next) {
// soilPH: { $avg: "$soilPH" },
}
},
{$project: {
soilTemperature: {$round: ["$soilTemperature", 2]},
soilMoisture: {$round: ["$soilMoisture", 2]},
nitrogen: {$round: ["$nitrogen", 2]},
phosphorus: {$round: ["$phosphorus", 2]},
potassium: {$round: ["$potassium", 2]},
}},
{ $sort: { _id: 1 } }
];
......@@ -79,6 +86,10 @@ async function getSMCChangeTrend(req, res, next) {
soilConductivity: { $avg: "$soilConductivity" },
}
},
{$project: {
soilPH: {$round: ["$soilPH", 2]},
soilConductivity: {$round: ["$soilConductivity", 2]},
}},
{ $sort: { _id: 1 } }
];
......@@ -281,7 +292,12 @@ async function getAreaDistribution(req, res, next) {
latestYield: { $sum: "$latestYield" },
latestYieldValue: { $sum: "$latestYieldValue" },
}
}
},
{$project: {
area: {$round: ["$area", 2]},
latestYield: {$round: ["$latestYield", 2]},
latestYieldValue: {$round: ["$latestYieldValue", 2]},
}},
]);
let totalArea = _.sumBy(lands, 'area');
let totalYield = _.sumBy(lands, 'latestYield');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment