| | |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` //仓库id |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` //仓库 |
| | | Prefix string `json:"prefix" gorm:"type:varchar(255);comment:前缀"` //前缀 |
| | | |
| | | DefaultLocationSrcId int `json:"defaultLocationSrcId" gorm:"type:int;not null;comment:默认源位置id"` //默认源位置id |
| | | DefaultLocationSrc Location `json:"defaultLocationSrc" gorm:"foreignKey:DefaultLocationSrcId"` //默认源位置 |
| | |
| | | ReservationDaysBefore int `json:"reservationDaysBefore" gorm:"type:int;"` //收货前几天 |
| | | ReservationDaysBeforePriority int `json:"ReservationDaysBeforePriority" gorm:"type:int;"` //在优先级的前几天 |
| | | ShowOperations bool `json:"showOperations" gorm:"column:show_operations;type:int"` //显示作业详情 |
| | | EarlyOperations bool `json:"earlyOperations" gorm:"type:int;comment:预填写作业详情"` //预填写作业详情 |
| | | CreateBackorder constvar.WhetherType `json:"createBackorder" gorm:"column:create_backorder"` //创建欠单 |
| | | ReturnOperationTypeID int `json:"returnOperationTypeID" gorm:"column:return_job_type_id"` //退货类型ID |
| | | ReturnOperationType string `json:"returnOperationType" gorm:"-"` //退货类型名称 |
| | | ReadyCount int `json:"readyCount" gorm:"-"` //就绪数量 |
| | | FinishCount int `json:"finishCount" gorm:"-"` //完成数量 |
| | | } |
| | | |
| | | OperationTypeSearch struct { |
| | |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | } |
| | | |
| | | OperationTypeByStatus struct { |
| | | Id int `gorm:"column:id"` |
| | | Status constvar.OperationStatus `gorm:"column:status"` |
| | | Count int `gorm:"column:count"` |
| | | } |
| | | ) |
| | | |
| | | func (slf *OperationType) TableName() string { |
| | | return "job_type" |
| | | return "wms_job_type" |
| | | } |
| | | |
| | | func NewOperationTypeSearch() *OperationTypeSearch { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) SetBaseOperationType(baseOperationType constvar.BaseOperationType) *OperationTypeSearch { |
| | | slf.BaseOperationType = baseOperationType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) SetWarehouseId(warehouseId int) *OperationTypeSearch { |
| | | slf.WarehouseId = warehouseId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&OperationType{}) |
| | | |
| | |
| | | |
| | | if slf.Preload { |
| | | db = db.Preload("Company").Preload("Warehouse").Preload("DefaultLocationSrc").Preload("DefaultLocationDest") |
| | | } |
| | | |
| | | if slf.WarehouseId > 0 { |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) ListByStatusAndCount(idList []int) ([]*OperationTypeByStatus, error) { |
| | | var ( |
| | | records = make([]*OperationTypeByStatus, 0) |
| | | db = slf.Orm |
| | | ) |
| | | db = db.Table("wms_job_type").Select("wms_job_type.id,wms_operation.status,count(wms_operation.id) as count").InnerJoins("inner join wms_operation on wms_operation.operation_type_id=wms_job_type.id").Where("wms_operation.deleted_at is null"). |
| | | Group("wms_job_type.id,wms_operation.status") |
| | | if len(idList) > 0 { |
| | | db = db.Where("wms_job_type.id IN ?", idList) |
| | | } |
| | | |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("func ListByStatusAndCount err: %v, ", err) |
| | | } |
| | | |
| | | return records, nil |
| | | } |