From 28addaa46cb97c20ad37e13eb10535de7b75e71c Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 29 十一月 2023 19:29:43 +0800 Subject: [PATCH] 首次报工开始时间为工序开始时间 --- model/production_progress.go | 78 ++++++++++++++++++++++++++------------ 1 files changed, 53 insertions(+), 25 deletions(-) diff --git a/model/production_progress.go b/model/production_progress.go index 8305442..58bc036 100644 --- a/model/production_progress.go +++ b/model/production_progress.go @@ -3,27 +3,30 @@ import ( "apsClient/pkg/sqlitex" "fmt" - "gorm.io/gorm" + "github.com/jinzhu/gorm" ) type ( ProductionProgress struct { - gorm.Model `json:"-"` - ID int `gorm:"primarykey"` - WorkOrderID string `gorm:"index;type:varchar(191);not null;comment:宸ュ崟ID" json:"workOrderID"` - OrderID string `gorm:"index;type:varchar(191);not null;comment:璁㈠崟ID" json:"orderID"` - ProcedureID string `gorm:"uniqueIndex:idx_product_procedure;type:varchar(191);comment:宸ュ簭ID" json:"procedureId"` - DeviceID string `gorm:"type:varchar(191);not null;comment:璁惧ID" json:"deviceId"` - FinishedQuantity int64 `gorm:"type:int;not null;comment:瀹屾垚鏁伴噺" json:"finishedQuantity"` - TotalQuantity int64 `gorm:"type:int;not null;comment:鎬婚噺" json:"totalQuantity"` + gorm.Model + ProceduresID uint `gorm:"index;type:varchar(191)" json:"proceduresId"` //procedures琛ㄧ殑id + WorkOrderID string `gorm:"index;type:varchar(191);not null" json:"workOrderID"` + OrderID string `gorm:"index;type:varchar(191);not null" json:"orderID"` + ProcedureID string `gorm:"type:varchar(191)" json:"procedureId"` + ProductProcedureID string `gorm:"type:varchar(191);" json:"productProcedureID"` //浜у搧宸ュ簭id + DeviceID string `gorm:"type:varchar(191);not null" json:"deviceId"` + FinishedQuantity int64 `gorm:"type:int;not null" json:"finishedQuantity"` + Channel int32 `gorm:"type:int" json:"channel"` //閫氶亾 + TotalQuantity int64 `gorm:"type:int;not null" json:"totalQuantity"` } ProductionProgressSearch struct { ProductionProgress - Order string - PageNum int - PageSize int - Orm *gorm.DB + Order string + PageNum int + PageSize int + Orm *gorm.DB + UnFinished bool } ) @@ -63,13 +66,33 @@ return slf } +func (slf *ProductionProgressSearch) SetProceduresId(proceduresId uint) *ProductionProgressSearch { + slf.ProceduresID = proceduresId + return slf +} + func (slf *ProductionProgressSearch) SetDeviceId(id string) *ProductionProgressSearch { slf.DeviceID = id return slf } -func (slf *ProductionProgressSearch) SetId(id int) *ProductionProgressSearch { +func (slf *ProductionProgressSearch) SetProductProcedureId(productProcedureId string) *ProductionProgressSearch { + slf.ProductProcedureID = productProcedureId + return slf +} + +func (slf *ProductionProgressSearch) SetId(id uint) *ProductionProgressSearch { slf.ID = id + return slf +} + +func (slf *ProductionProgressSearch) SetChannel(channel int32) *ProductionProgressSearch { + slf.Channel = channel + return slf +} + +func (slf *ProductionProgressSearch) SetUnFinished() *ProductionProgressSearch { + slf.UnFinished = true return slf } @@ -96,8 +119,24 @@ db = db.Where("procedure_id = ?", slf.ProcedureID) } + if slf.ProceduresID != 0 { + db = db.Where("procedures_id = ?", slf.ProceduresID) + } + if slf.DeviceID != "" { db = db.Where("device_id = ?", slf.DeviceID) + } + + if slf.Channel != 0 { + db = db.Where("channel = ?", slf.Channel) + } + + if slf.UnFinished { + db = db.Where("finished_quantity < total_quantity") + } + + if slf.ProductProcedureID != "" { + db = db.Where("product_procedure_id = ?", slf.ProductProcedureID) } return db @@ -109,17 +148,6 @@ if err := db.Create(record).Error; err != nil { return fmt.Errorf("create err: %v, record: %+v", err, record) - } - - return nil -} - -// CreateBatch 鎵归噺鎻掑叆 -func (slf *ProductionProgressSearch) CreateBatch(records []*ProductionProgress) error { - var db = slf.build() - - if err := db.Create(&records).Error; err != nil { - return fmt.Errorf("create batch err: %v, records: %+v", err, records) } return nil -- Gitblit v1.8.0