| | |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/model/request" |
| | | "apsClient/pkg/logx" |
| | | "apsClient/pkg/snowflake" |
| | | "encoding/json" |
| | | "errors" |
| | | "github.com/jinzhu/gorm" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | WorkerTime: nowTs - startTs, |
| | | BarCode: snowflake.GenerateIdStr(), |
| | | } |
| | | err = model.WithTransaction(func(db *gorm.DB) error { |
| | | err = model.NewReportWorkSearch(nil).Create(record) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | err = model.NewReportWorkSearch(nil).Create(record) |
| | | content, err := json.Marshal(record) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | err = model.NewReportsToCloudSearch(nil).Create(&model.ReportsToCloud{ |
| | | ReportType: constvar.ReportTypeReportWork, |
| | | Content: string(content), |
| | | }) |
| | | return err |
| | | }) |
| | | if err != nil { |
| | | logx.Errorf("save report work transaction error: %v", err) |
| | | return err |
| | | } |
| | | |
| | | PlcCacheSet(conf.Conf.CurrentDeviceID, procedure.Channel, constvar.PlcCacheKeyFinishNumber, params.ReportAmount) |
| | | return nil |
| | | } |