| | |
| | | // FinenessRegister 纤度登记 |
| | | FinenessRegister struct { |
| | | gorm.Model |
| | | Number string `gorm:"type:varchar(255);not null;comment:编号" json:"number"` //编号 |
| | | FinishDate string `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"` //落丝时间 |
| | | Workshop string `gorm:"type:varchar(255);not null;comment:车间" json:"name"` //车间 |
| | | WorkshopGroup int `gorm:"type:int(11);not null;default:0;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | Spec string `gorm:"type:varchar(255);not null;comment:规格" json:"spec"` //规格 |
| | | Circle uint8 `gorm:"not null;default:0;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;default:0;comment:总回数" json:"totalCircle"` //总回数 |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"` |
| | | SumFineness decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"` |
| | | SumQuantity decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"` |
| | | Position int `gorm:"not null;default:0;comment:车号" json:"position"` //最后一个车号 |
| | | Number string `gorm:"type:varchar(255);not null;comment:编号" json:"number"` //编号 |
| | | FinenessCheckID uint `gorm:"not null;comment:纤度检验表ID" json:"finenessCheckID"` //纤度检验表ID |
| | | FinishDate string `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"` //落丝时间 |
| | | Workshop string `gorm:"type:varchar(255);not null;comment:车间" json:"name"` //车间 |
| | | WorkshopGroup int `gorm:"type:int(11);not null;default:0;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | Spec string `gorm:"type:varchar(255);not null;comment:规格" json:"spec"` //规格 |
| | | Circle uint8 `gorm:"not null;default:0;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;default:0;comment:总回数" json:"totalCircle"` //总回数 |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"` |
| | | SumFineness decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"` |
| | | SumQuantity decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"` |
| | | Position int `gorm:"not null;default:0;comment:车号" json:"position"` //最后一个车号 |
| | | } |
| | | FinenessRegisterSearch struct { |
| | | FinenessRegister |
| | |
| | | ) |
| | | |
| | | func (slf *FinenessRegister) TableName() string { |
| | | return "fineness_register" |
| | | return "silk_fineness_register" |
| | | } |
| | | |
| | | func NewFinenessRegisterSearch() *FinenessRegisterSearch { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetWorkshop(workshop string) *FinenessRegisterSearch { |
| | | slf.Workshop = workshop |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetMarket(market string) *FinenessRegisterSearch { |
| | | slf.Market = market |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetWorkshopGroup(group int) *FinenessRegisterSearch { |
| | | slf.WorkshopGroup = group |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Where("number like ?", fmt.Sprintf("%%%s%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.Workshop != "" { |
| | | db = db.Where("workshop = ?", slf.Workshop) |
| | | } |
| | | |
| | | if slf.Market != "" { |
| | | db = db.Where("market = ?", slf.Market) |
| | | } |
| | | |
| | | if slf.WorkshopGroup > 0 { |
| | | db = db.Where("workshop_group = ?", slf.WorkshopGroup) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |