fix: 修正cma预报时间的错误
This commit is contained in:
parent
93533aa76c
commit
d2a73a7dc3
@ -253,8 +253,7 @@ func RunCMAFetch(ctx context.Context) error {
|
|||||||
loc = time.FixedZone("CST", 8*3600)
|
loc = time.FixedZone("CST", 8*3600)
|
||||||
}
|
}
|
||||||
issuedAt := time.Now().In(loc)
|
issuedAt := time.Now().In(loc)
|
||||||
startHour := issuedAt.Truncate(time.Hour)
|
base := issuedAt.Truncate(time.Hour)
|
||||||
targets := []time.Time{startHour.Add(1 * time.Hour), startHour.Add(2 * time.Hour), startHour.Add(3 * time.Hour)}
|
|
||||||
|
|
||||||
// 请求CMA
|
// 请求CMA
|
||||||
form := url.Values{}
|
form := url.Values{}
|
||||||
@ -323,6 +322,28 @@ func RunCMAFetch(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从可用数据中选择“接下来可用的三个未来时次”(按接口实际返回)
|
||||||
|
timeSet := map[time.Time]struct{}{}
|
||||||
|
for i := range tables {
|
||||||
|
for t := range tables[i] {
|
||||||
|
if t.After(base) {
|
||||||
|
timeSet[t] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var targets []time.Time
|
||||||
|
for t := range timeSet {
|
||||||
|
targets = append(targets, t)
|
||||||
|
}
|
||||||
|
targets = sortTimesAsc(targets)
|
||||||
|
if len(targets) > 3 {
|
||||||
|
targets = targets[:3]
|
||||||
|
}
|
||||||
|
if len(targets) == 0 {
|
||||||
|
// 无未来时次则不写库,避免写入“假想整点”。
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// 读取站点列表(全部)
|
// 读取站点列表(全部)
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
stationIDs, err := loadAllStationIDs(ctx, db)
|
stationIDs, err := loadAllStationIDs(ctx, db)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user