修复定时任务的bug

This commit is contained in:
lmk
2026-07-21 10:28:54 +08:00
parent 4cc52da4f0
commit 3cee24c114
18 changed files with 930 additions and 48 deletions
+10 -5
View File
@@ -50,12 +50,13 @@ func TaskTable(r *ghttp.Request) {
return
}
// 从调度器获取下次执行时间
// 计算各任务的下次执行时间(基于 cron 表达式)
nextTimeMap := make(map[int]string)
for _, entry := range scheduler.Scheduler.GetEntries() {
var tid int
if _, err := fmt.Sscanf(entry.Name, "task_%d", &tid); err == nil && tid > 0 {
nextTimeMap[tid] = entry.RegisterTime.Format("2006-01-02 15:04:05")
for _, t := range list {
if t.Status == 1 && t.CronSpec != "" {
if nt := scheduler.GetTaskNextTime(t.CronSpec); nt != "" {
nextTimeMap[t.Id] = nt
}
}
}
@@ -503,10 +504,14 @@ func TaskLogTable(r *ghttp.Request) {
page := r.Get("page", 1).Int()
limit := r.Get("limit", 20).Int()
taskId := r.Get("task_id", 0).Int()
status := r.Get("status", 9).Int()
var filters []interface{}
if taskId > 0 {
filters = append(filters, "task_id", taskId)
}
if status != 9 {
filters = append(filters, "status", status)
}
if sortStr := parseSort(r); sortStr != "" {
filters = append(filters, "@order", sortStr)
}