| | |
| | | RecentlyCount string `json:"recentlyCount" gorm:"type:varchar(255);comment:最近盘点"` //最近盘点 |
| | | NextCount string `json:"nextCount" gorm:"type:varchar(255);comment:下次盘点"` //下次盘点 |
| | | JointName string `json:"jointName" gorm:"type:varchar(255);comment:拼接名称"` //拼接名称 |
| | | Children []*Location `json:"children" gorm:"-"` |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库ID"` //仓库ID |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` //仓库 |
| | | } |
| | | |
| | | LocationSearch struct { |
| | |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | JointNames []string |
| | | Ids []int |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *LocationSearch) SetID(ID int) *LocationSearch { |
| | | slf.Id = ID |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetIds(ids []int) *LocationSearch { |
| | | slf.Ids = ids |
| | | return slf |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetIsScrapLocation(isScrapLocation bool) *LocationSearch { |
| | | slf.IsScrapLocation = isScrapLocation |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if len(slf.Ids) > 0 { |
| | | db = db.Where("id in (?)", slf.Ids) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | } |
| | | if len(slf.JointNames) != 0 { |
| | | db = db.Where("joint_name in (?)", slf.JointNames) |
| | | } |
| | | |
| | | if slf.IsScrapLocation { |
| | | db = db.Where("is_scrap_location = ?", slf.IsScrapLocation) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Preload("Warehouse") |
| | | } |
| | | |
| | | return db |
| | |
| | | locations = append(locations, &Location{Name: "库存损失", Type: 5, JointName: "库存损失"}) |
| | | locations = append(locations, &Location{Name: "生产", Type: 6, JointName: "生产"}) |
| | | locations = append(locations, &Location{Name: "中转位置", Type: 7, JointName: "中转位置"}) |
| | | locations = append(locations, &Location{Name: "报废位置", Type: 8, JointName: "报废位置"}) |
| | | locations = append(locations, &Location{Name: "报废位置", Type: 8, JointName: "报废位置", IsScrapLocation: true}) |
| | | locations = append(locations, &Location{Name: "库存盘点", Type: 9, JointName: "库存盘点"}) |
| | | return slf.CreateBatch(locations) |
| | | } |