Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
| | |
| | | return |
| | | } |
| | | |
| | | //更新在库的产品类型 |
| | | if params.CategoryId > 0 { |
| | | find, _ := models.NewLocationProductAmountSearch().SetProductId(params.ID).Find() |
| | | if len(find) > 0 { |
| | | var ids []int |
| | | for _, f := range find { |
| | | if f.ProductCategoryID != params.CategoryId { |
| | | ids = append(ids, f.Id) |
| | | } |
| | | } |
| | | m := make(map[string]interface{}) |
| | | m["productCategoryId"] = params.CategoryId |
| | | _ = models.NewLocationProductAmountSearch().SetIds(ids).UpdateByMap(m) |
| | | } |
| | | } |
| | | |
| | | materialAttachmentList := []*models.MaterialAttachment{} |
| | | for _, v := range params.AttachmentIDs { |
| | | ma := &models.MaterialAttachment{MaterialID: params.ID, AttachmentID: v} |
| | |
| | | return |
| | | } |
| | | |
| | | first, err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).First() |
| | | first, err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "产品类型名称不能为空") |
| | | return |
| | | } |
| | | err := models.NewProductCategorySearch().SetID(params.ID).Save(¶ms) |
| | | err := models.NewProductCategorySearch().SetID(params.Id).Save(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品类型信息更新失败") |
| | | return |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "无效id") |
| | | return |
| | | } |
| | | err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).Delete() |
| | | err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | return |
| | |
| | | ids = append(ids, params.LocationId) |
| | | } else { |
| | | //查询位置 |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll() |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).SetType(3).FindAll() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询位置失败") |
| | | return |
| | |
| | | LocationId int `json:"locationId" gorm:"type:int;not null;comment:位置id"` //位置id |
| | | Location Location `json:"location" gorm:"foreignKey:LocationId;references:id"` |
| | | ProductCategoryID int `json:"productCategoryId" gorm:"type:int;not null;comment:产品种类id"` //产品种类id |
| | | ProductCategory ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:ID"` |
| | | ProductCategory ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:Id"` |
| | | ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id |
| | | Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:库存数量"` //库存数量 |
| | |
| | | //LocationProductIds []int |
| | | LocationIds []int |
| | | ProductIds []string |
| | | Ids []int |
| | | } |
| | | |
| | | LocationProductAmountWithOperation struct { |
| | |
| | | |
| | | func (slf *LocationProductAmountSearch) SetID(id int) *LocationProductAmountSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) SetIds(ids []int) *LocationProductAmountSearch { |
| | | slf.Ids = ids |
| | | return slf |
| | | } |
| | | |
| | |
| | | |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | if len(slf.Ids) > 0 { |
| | | db = db.Where("id in (?)", slf.Ids) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | return record, db.First(&record) |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) Count() (int64, error) { |
| | | var ( |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) 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 |
| | | } |
| | |
| | | type ( |
| | | // ProductCategory 产品分类 |
| | | ProductCategory struct { |
| | | BaseModelInt |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:分类名称"` //分类名称 |
| | | ParentId int `json:"parentId" gorm:"type:int;comment:上级分类id"` //上级id |
| | | RouteId int `json:"routeId" gorm:"type:int;comment:路线id"` //路线id |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ProductCategorySearch) SetID(id uint) *ProductCategorySearch { |
| | | slf.ID = id |
| | | func (slf *ProductCategorySearch) SetID(id int) *ProductCategorySearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | |
| | | func (slf *ProductCategorySearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ProductCategory{}) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if slf.Order != "" { |