| | |
| | | "encoding/json" |
| | | "errors" |
| | | "github.com/jinzhu/gorm" |
| | | "github.com/spf13/cast" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | 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 |
| | |
| | | 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) |