fix: 延长数据统计时间
This commit is contained in:
parent
7ca0198b33
commit
9e1c4979c0
@ -61,9 +61,9 @@ func (e *Exporter) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().In(e.loc)
|
now := time.Now().In(e.loc)
|
||||||
// 下一个10分钟边界 + 1分钟(改为60秒延迟)
|
// 下一个10分钟边界 + 1分30秒
|
||||||
next := alignToNextBucketEnd(now, 10).Add(1 * time.Minute)
|
next := alignToNextBucketEnd(now, 10).Add(60 * time.Second)
|
||||||
e.logger.Printf("调度: 当前=%s, 下次执行=%s (延迟1分钟)", now.Format("2006-01-02 15:04:05"), next.Format("2006-01-02 15:04:05"))
|
e.logger.Printf("调度: 当前=%s, 下次执行=%s (延迟1分)", now.Format("2006-01-02 15:04:05"), next.Format("2006-01-02 15:04:05"))
|
||||||
delay := time.Until(next)
|
delay := time.Until(next)
|
||||||
if delay > 0 {
|
if delay > 0 {
|
||||||
timer := time.NewTimer(delay)
|
timer := time.NewTimer(delay)
|
||||||
@ -75,13 +75,14 @@ func (e *Exporter) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前时间是桶末,需要导出的是刚结束的上一个桶
|
// 修正:当前时间是21:11:30,应该导出的是21:00:00桶(表示21:00-21:10的数据)
|
||||||
// 例如:现在是21:01:00,应该导出的是20:50桶(表示20:50-21:00的数据)
|
|
||||||
currentTime := time.Now().In(e.loc)
|
currentTime := time.Now().In(e.loc)
|
||||||
bucketEnd := alignToPrevBucketEnd(currentTime, 10) // 上一个桶末,如21:00
|
// 先找到前一个桶末(如21:10:00)
|
||||||
bucketStart := bucketEnd.Add(-10 * time.Minute) // 上一个桶开始,如20:50
|
bucketEnd := alignToPrevBucketEnd(currentTime, 10)
|
||||||
|
// 再找到对应的桶开始(如21:00:00)
|
||||||
|
bucketStart := bucketEnd.Add(-10 * time.Minute)
|
||||||
|
|
||||||
e.logger.Printf("当前时间=%s, 导出桶=%s-%s",
|
e.logger.Printf("当前时间=%s, 导出桶开始时间=%s, 桶结束时间=%s",
|
||||||
currentTime.Format("2006-01-02 15:04:05"),
|
currentTime.Format("2006-01-02 15:04:05"),
|
||||||
bucketStart.Format("2006-01-02 15:04:05"),
|
bucketStart.Format("2006-01-02 15:04:05"),
|
||||||
bucketEnd.Format("2006-01-02 15:04:05"))
|
bucketEnd.Format("2006-01-02 15:04:05"))
|
||||||
@ -101,7 +102,10 @@ func (e *Exporter) exportBucket(ctx context.Context, bucketStart, bucketEnd time
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
activePath := filepath.Join(outDir, fmt.Sprintf("weather_data_%s.csv", utcDay))
|
activePath := filepath.Join(outDir, fmt.Sprintf("weather_data_%s.csv", utcDay))
|
||||||
e.logger.Printf("开始导出: 桶=%s-%s, 文件=%s", bucketStart.Format("2006-01-02 15:04:05"), bucketEnd.Format("2006-01-02 15:04:05"), activePath)
|
e.logger.Printf("开始导出: 桶开始时间=%s, 桶结束时间=%s, 文件=%s",
|
||||||
|
bucketStart.Format("2006-01-02 15:04:05"),
|
||||||
|
bucketEnd.Format("2006-01-02 15:04:05"),
|
||||||
|
activePath)
|
||||||
|
|
||||||
// 先查询所有符合条件的站点,用于后续比对缺失
|
// 先查询所有符合条件的站点,用于后续比对缺失
|
||||||
var eligibleStations []struct {
|
var eligibleStations []struct {
|
||||||
@ -278,7 +282,7 @@ func (e *Exporter) exportBucket(ctx context.Context, bucketStart, bucketEnd time
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.logger.Printf("导出完成: 桶=%s-%s, 总行数=%d, ZTD命中=%d, ZTD未命中=%d, 缺失站点数=%d",
|
e.logger.Printf("导出完成: 桶开始时间=%s, 桶结束时间=%s, 总行数=%d, ZTD命中=%d, ZTD未命中=%d, 缺失站点数=%d",
|
||||||
bucketStart.Format("2006-01-02 15:04:05"),
|
bucketStart.Format("2006-01-02 15:04:05"),
|
||||||
bucketEnd.Format("2006-01-02 15:04:05"),
|
bucketEnd.Format("2006-01-02 15:04:05"),
|
||||||
total, ztdHit, ztdMiss, missingCount)
|
total, ztdHit, ztdMiss, missingCount)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user