From 2d6875c93b25d0b7336c7fa11e066d213259fe2e Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 25 四月 2024 10:02:01 +0800 Subject: [PATCH] 更改定时任务时区设置 --- service/report_work.go | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/service/report_work.go b/service/report_work.go index a89ae40..99d7a82 100644 --- a/service/report_work.go +++ b/service/report_work.go @@ -10,6 +10,7 @@ "encoding/json" "errors" "github.com/jinzhu/gorm" + "github.com/spf13/cast" "time" ) @@ -30,13 +31,12 @@ nowTs := time.Now().Unix() var startTs int64 var workerName string - for _, worker := range procedure.ProceduresInfo.Workers { - if params.WorkerID == worker.WorkerID { - workerName = worker.WorkerName + if params.WorkerID != "" { + for _, worker := range procedure.ProceduresInfo.Workers { + if params.WorkerID == worker.WorkerID { + workerName = worker.WorkerName + } } - } - if workerName == "" { - return errors.New("娌℃湁鎵惧埌褰撳墠鍊肩彮浜哄憳") } finishAmount := params.ReportAmount @@ -65,7 +65,7 @@ WorkerID: params.WorkerID, WorkerName: workerName, WorkerTime: nowTs - startTs, - BarCode: snowflake.GenerateIdStr(), + BarCode: cast.ToString(snowflake.GenerateID()), } err = model.WithTransaction(func(db *gorm.DB) error { err = model.NewReportWorkSearch(db).Create(record) @@ -92,7 +92,7 @@ return err } - err = NewProgressService().UpdateProgressByProceduresId(procedure.ID, int64(params.ReportAmount)) + err = NewProgressService().UpdateProgressByProceduresId(procedure.ID, params.ReportAmount) return nil } -- Gitblit v1.8.0