diff --git a/internal/dao/sensor.go b/internal/dao/sensor.go index b5067c5..77a299f 100644 --- a/internal/dao/sensor.go +++ b/internal/dao/sensor.go @@ -64,12 +64,7 @@ func (dao *SensorDAO) GetAggregatedData(start, end time.Time, interval string) ( // 构建通用查询 query := ` SELECT - DATE_FORMAT( - FROM_UNIXTIME( - FLOOR(UNIX_TIMESTAMP(timestamp)/?)*? - ), - ? - ) as ts, + MIN(timestamp) as ts, ROUND(AVG(temperature)/10, 1) as avg_temp, MAX(rainfall) - MIN(rainfall) as rainfall, ROUND(AVG(humidity)/10, 1) as avg_humidity, @@ -83,8 +78,6 @@ func (dao *SensorDAO) GetAggregatedData(start, end time.Time, interval string) ( // 执行查询 rows, err := dao.db.Query( query, - intervalSeconds, intervalSeconds, // 用于FROM_UNIXTIME参数 - timeFormat, // DATE_FORMAT格式 start, end, // 时间范围 intervalSeconds, // GROUP BY参数 )