| | |
| | | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/model/request" |
| | | "errors" |
| | |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | if procedure.Status != model.ProcedureStatusProcessing { |
| | | return errors.New("当前工序未开始或已结束,不允许报工") |
| | | } |
| | | |
| | | nowTs := time.Now().Unix() |
| | | var startTs int64 |
| | | var workerName string |
| | |
| | | Channel: procedure.Channel, |
| | | StartTime: startTs, |
| | | EndTime: nowTs, |
| | | ReportAmount: params.ReportAmount, |
| | | WorkerID: params.WorkerID, |
| | | WorkerName: workerName, |
| | | } |
| | | return model.NewReportWorkSearch(nil).Create(record) |
| | | |
| | | err = model.NewReportWorkSearch(nil).Create(record) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | PlcCacheSet(conf.Conf.CurrentDeviceID, procedure.Channel, constvar.PlcCacheKeyFinishNumber, params.ReportAmount) |
| | | return nil |
| | | } |
| | | |
| | | // GetLastReportWork 获取最后一个报工 |
| | | func GetLastReportWork(procedureId uint) (reportWork *model.ReportWork, err error) { |
| | | return model.NewReportWorkSearch(nil).SetProceduresId(procedureId).SetDeviceId(conf.Conf.CurrentDeviceID).SetOrder("id desc").First() |
| | | } |