From d4243f398b84a8b8cdcd27c35ace72f6a30a6452 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期日, 08 十月 2023 10:45:09 +0800 Subject: [PATCH] 是否可以开始增加开始时间判断,考虑进程退出和断电情况 --- service/task.go | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-) diff --git a/service/task.go b/service/task.go index 446ae6d..f9413cc 100644 --- a/service/task.go +++ b/service/task.go @@ -10,7 +10,6 @@ "apsClient/pkg/ecode" "apsClient/pkg/logx" "apsClient/pkg/structx" - "encoding/json" "fmt" "gorm.io/gorm" "time" @@ -35,7 +34,6 @@ Workers: slf.WorkerDistinct(workers), } - nowTs := time.Now().Unix() var ( err error orders []*model.Order @@ -48,14 +46,10 @@ if mode == constvar.TaskModeUnStarted { search.SetStatus(model.ProcedureStatusWaitProcess). - SetStartTimeMax(nowTs). - SetEndTimeMin(nowTs). SetOrder("start_time asc") } else if mode == constvar.TaskModeCurrent { search.SetStatus(model.ProcedureStatusProcessing). - SetStartTimeMax(nowTs). - SetEndTimeMin(nowTs). - SetOrder("status desc, start_time asc") + SetOrder("start_time asc") } else if mode == constvar.TaskModeLastFinished { search.SetStatus(model.ProcedureStatusFinished).SetOrder("updated_at desc") if len(channels) > 0 { @@ -113,8 +107,7 @@ return taskResp, ecode.OK } func (slf TaskService) NewTaskCount() (count int64) { - nowTs := time.Now().Unix() - count, _ = model.NewProceduresSearch(nil).SetDeviceId(conf.Conf.System.DeviceId).SetStatus(model.ProcedureStatusWaitProcess).SetStartTimeMax(nowTs).SetEndTimeMin(nowTs).Count() + count, _ = model.NewProceduresSearch(nil).SetDeviceId(conf.Conf.System.DeviceId).SetStatus(model.ProcedureStatusWaitProcess).Count() return count } @@ -177,11 +170,6 @@ return nil, err } if err == nil { - err = json.Unmarshal([]byte(data.Params), &data.ParamsMap) - if err != nil { - logx.Errorf("process model json.Unmarshal:%v", err) - return - } return data, nil } -- Gitblit v1.8.0