package model
|
|
//
|
//import (
|
// "apsClient/pkg/sqlitex"
|
// "fmt"
|
// "github.com/jinzhu/gorm"
|
//)
|
//
|
//type (
|
// ProductionProgress struct {
|
// 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
|
// UnFinished bool
|
// }
|
//)
|
//
|
//func (slf *ProductionProgress) TableName() string {
|
// return "production_progress"
|
//}
|
//
|
//func NewProductionProgressSearch(db *gorm.DB) *ProductionProgressSearch {
|
// if db == nil {
|
// db = sqlitex.GetDB()
|
// }
|
// return &ProductionProgressSearch{Orm: db}
|
//}
|
//
|
//func (slf *ProductionProgressSearch) SetOrm(tx *gorm.DB) *ProductionProgressSearch {
|
// slf.Orm = tx
|
// return slf
|
//}
|
//
|
//func (slf *ProductionProgressSearch) SetPage(page, size int) *ProductionProgressSearch {
|
// slf.PageNum, slf.PageSize = page, size
|
// return slf
|
//}
|
//
|
//func (slf *ProductionProgressSearch) SetOrder(order string) *ProductionProgressSearch {
|
// slf.Order = order
|
// return slf
|
//}
|
//
|
//func (slf *ProductionProgressSearch) SetWorkOrderId(orderId string) *ProductionProgressSearch {
|
// slf.WorkOrderID = orderId
|
// return slf
|
//}
|
//
|
//func (slf *ProductionProgressSearch) SetProcedureId(procedureId string) *ProductionProgressSearch {
|
// slf.ProcedureID = procedureId
|
// 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) 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
|
//}
|
//
|
//func (slf *ProductionProgressSearch) build() *gorm.DB {
|
// var db = slf.Orm.Model(&ProductionProgress{})
|
//
|
// if slf.Order != "" {
|
// db = db.Order(slf.Order)
|
// }
|
//
|
// if slf.ID != 0 {
|
// db = db.Where("id = ?", slf.ID)
|
// }
|
//
|
// if slf.WorkOrderID != "" {
|
// db = db.Where("work_order_id = ?", slf.WorkOrderID)
|
// }
|
//
|
// if slf.OrderID != "" {
|
// db = db.Where("order_id = ?", slf.OrderID)
|
// }
|
//
|
// if slf.ProcedureID != "" {
|
// 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
|
//}
|
//
|
//// Create 单条插入
|
//func (slf *ProductionProgressSearch) Create(record *ProductionProgress) error {
|
// var db = slf.build()
|
//
|
// if err := db.Create(record).Error; err != nil {
|
// return fmt.Errorf("create err: %v, record: %+v", err, record)
|
// }
|
//
|
// return nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) Save(record *ProductionProgress) error {
|
// var db = slf.build()
|
//
|
// if err := db.Save(record).Error; err != nil {
|
// return fmt.Errorf("save err: %v, record: %+v", err, record)
|
// }
|
//
|
// return nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) UpdateByMap(upMap map[string]interface{}) error {
|
// var (
|
// db = slf.build()
|
// )
|
//
|
// if err := db.Updates(upMap).Error; err != nil {
|
// return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap)
|
// }
|
//
|
// return nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error {
|
// var (
|
// db = slf.Orm.Table(slf.TableName()).Where(query, args...)
|
// )
|
//
|
// if err := db.Updates(upMap).Error; err != nil {
|
// return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap)
|
// }
|
//
|
// return nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) Delete() error {
|
// var db = slf.build()
|
//
|
// if err := db.Unscoped().Delete(&ProductionProgress{}).Error; err != nil {
|
// return err
|
// }
|
//
|
// return nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) First() (*ProductionProgress, error) {
|
// var (
|
// record = new(ProductionProgress)
|
// db = slf.build()
|
// )
|
//
|
// if err := db.First(record).Error; err != nil {
|
// return record, err
|
// }
|
//
|
// return record, nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) Find() ([]*ProductionProgress, int64, error) {
|
// var (
|
// records = make([]*ProductionProgress, 0)
|
// total int64
|
// db = slf.build()
|
// )
|
//
|
// if err := db.Count(&total).Error; err != nil {
|
// return records, total, fmt.Errorf("find count err: %v", err)
|
// }
|
// if slf.PageNum*slf.PageSize > 0 {
|
// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
|
// }
|
// if err := db.Find(&records).Error; err != nil {
|
// return records, total, fmt.Errorf("find records err: %v", err)
|
// }
|
//
|
// return records, total, nil
|
//}
|
//
|
//func (slf *ProductionProgressSearch) FindNotTotal() ([]*ProductionProgress, error) {
|
// var (
|
// records = make([]*ProductionProgress, 0)
|
// db = slf.build()
|
// )
|
//
|
// if slf.PageNum*slf.PageSize > 0 {
|
// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
|
// }
|
// if err := db.Find(&records).Error; err != nil {
|
// return records, fmt.Errorf("find records err: %v", err)
|
// }
|
//
|
// return records, nil
|
//}
|
//
|
//// FindByQuery 指定条件查询.
|
//func (slf *ProductionProgressSearch) FindByQuery(query string, args []interface{}) ([]*ProductionProgress, int64, error) {
|
// var (
|
// records = make([]*ProductionProgress, 0)
|
// total int64
|
// db = slf.Orm.Table(slf.TableName()).Where(query, args...)
|
// )
|
//
|
// if err := db.Count(&total).Error; err != nil {
|
// return records, total, fmt.Errorf("find by query count err: %v", err)
|
// }
|
// if slf.PageNum*slf.PageSize > 0 {
|
// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
|
// }
|
// if err := db.Find(&records).Error; err != nil {
|
// return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
|
// }
|
//
|
// return records, total, nil
|
//}
|
//
|
//// FindByQueryNotTotal 指定条件查询&不查询总条数.
|
//func (slf *ProductionProgressSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*ProductionProgress, error) {
|
// var (
|
// records = make([]*ProductionProgress, 0)
|
// db = slf.Orm.Table(slf.TableName()).Where(query, args...)
|
// )
|
//
|
// if slf.PageNum*slf.PageSize > 0 {
|
// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
|
// }
|
// if err := db.Find(&records).Error; err != nil {
|
// return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
|
// }
|
//
|
// return records, nil
|
//}
|