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 |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/service/report_work.go b/service/report_work.go
index ea25a57..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)

--
Gitblit v1.8.0