fix: 修正导出的时间含义

This commit is contained in:
yarnom 2025-08-23 00:08:44 +08:00
parent 0444df3b4c
commit 7f4b8bb18b

View File

@ -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分30秒 // 下一个10分钟边界 + 10秒
next := alignToNextBucketEnd(now, 10).Add(90 * time.Second) next := alignToNextBucketEnd(now, 10).Add(10 * time.Second)
e.logger.Printf("调度: 当前=%s, 下次执行=%s (延迟1分30秒)", now.Format("2006-01-02 15:04:05"), next.Format("2006-01-02 15:04:05")) e.logger.Printf("调度: 当前=%s, 下次执行=%s (延迟10秒)", 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)
@ -204,9 +204,9 @@ func (e *Exporter) exportBucket(ctx context.Context, bucketStart, bucketEnd time
processedStationIDs[stationID] = true processedStationIDs[stationID] = true
e.logger.Printf("处理站点: station_id=%s, device_id=%s, 经度=%.6f, 纬度=%.6f", stationID, deviceID, lon.Float64, lat.Float64) e.logger.Printf("处理站点: station_id=%s, device_id=%s, 经度=%.6f, 纬度=%.6f", stationID, deviceID, lon.Float64, lat.Float64)
// 使用桶开始时间作为date_time // CSV 使用桶末时间作为 date_time用于表意 10 分钟区间的右端点)
dateTimeStr := bucketStartTS.In(e.loc).Format("2006-01-02 15:04:05") dateTimeStr := bucketEnd.In(e.loc).Format("2006-01-02 15:04:05")
e.logger.Printf("站点 %s: 使用时间=%s", stationID, dateTimeStr) e.logger.Printf("站点 %s: 写出时间(桶末)=%s用于 ZTD 对齐参考", stationID, dateTimeStr)
var pressureStr, tempStr, wsStr, wdStr, rhStr string var pressureStr, tempStr, wsStr, wdStr, rhStr string
if pX100.Valid { if pX100.Valid {