fix:修改粒度解析
This commit is contained in:
parent
8fd2ccd7e8
commit
bfee93d7bb
@ -140,6 +140,19 @@ func (dao *SensorDAO) GetAggregatedData(start, end time.Time, interval string) (
|
|||||||
// 对于雨量,使用时间桶内最后一个(最新的)数据点的值
|
// 对于雨量,使用时间桶内最后一个(最新的)数据点的值
|
||||||
aggregated.Rainfall = bucketData[len(bucketData)-1].Rainfall
|
aggregated.Rainfall = bucketData[len(bucketData)-1].Rainfall
|
||||||
|
|
||||||
|
// 计算新增雨量(相对于前一个时间桶)
|
||||||
|
if i > 0 && len(result) > 0 {
|
||||||
|
prevRainfall := result[len(result)-1].Rainfall
|
||||||
|
// 如果当前雨量大于前一个时间桶的雨量,计算差值作为新增雨量
|
||||||
|
if aggregated.Rainfall > prevRainfall {
|
||||||
|
aggregated.Rainfall = aggregated.Rainfall - prevRainfall
|
||||||
|
} else if aggregated.Rainfall == prevRainfall {
|
||||||
|
// 如果雨量没有变化,表示没有新增雨量
|
||||||
|
aggregated.Rainfall = 0
|
||||||
|
}
|
||||||
|
// 如果当前雨量小于前一个时间桶的雨量(可能是雨量计重置),保留当前值作为新增雨量
|
||||||
|
}
|
||||||
|
|
||||||
result = append(result, aggregated)
|
result = append(result, aggregated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user