zhangqian
2024-06-12 3efb723b393ef6f516dbe1644697f0ba5536c48c
models/material.go
@@ -79,7 +79,7 @@
      IsStorage               int             `gorm:"type:tinyint(1);default:1;comment:是否存库(1是2否)" json:"isStorage"`   //无库存的在wms以及srm中需要过滤掉
      IsVirtual               int             `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:是否虚拟物料(1是2否)"` //虚拟物料在MRP计算时跳过该层级直接领用下级物料,虚拟物料不生成工单
      ReorderRuleNum          int64           `json:"reorderRuleNum"`
      MoreUnit                bool            `json:"moreUnit" gorm:"type:tinyint(1);default:false;comment:启动多单位"`
      MoreUnit                *bool           `json:"moreUnit" gorm:"type:tinyint(1);default:false;comment:启动多单位"`
      MoreUnitList            []UnitItems     `json:"moreUnitList" gorm:"-"`
      MoreUnitValue           string          `json:"-" gorm:"type:varchar(255);comment:多单位值"`
      GrossWeight             decimal.Decimal `json:"grossWeight" gorm:"type:decimal(20,3);comment:毛重"`
@@ -109,6 +109,7 @@
      Orm         *gorm.DB
      CategoryIds []int
      Preload     bool
      Fields      string
   }
   IdAndName struct {
@@ -258,6 +259,11 @@
   return slf
}
func (slf *MaterialSearch) SetFields(fields string) *MaterialSearch {
   slf.Fields = fields
   return slf
}
func (slf *MaterialSearch) build() *gorm.DB {
   var db = slf.Orm.Table(slf.TableName())
@@ -322,6 +328,10 @@
   }
   if len(slf.CategoryIds) > 0 {
      db = db.Where("category_id in ?", slf.CategoryIds)
   }
   if slf.Fields != "" {
      db = db.Select(slf.Fields)
   }
   if slf.Preload {
@@ -592,7 +602,7 @@
   OperationDate     string                     `json:"operationDate" gorm:"type:varchar(31);comment:安排日期"`
   ContacterID       int                        `json:"contacterID" gorm:"type:int;comment:联系人ID"`
   ContacterName     string                     `json:"contacterName" gorm:"type:varchar(63);comment:联系人姓名"`
   CompanyID         int                        `json:"companyID" gorm:"type:int;comment:公司ID-客户"`
   CompanyID         string                     `json:"companyID"` //公司ID-客户
   CompanyName       string                     `json:"companyName" gorm:"type:varchar(127);comment:公司名称-客户"`
   Comment           string                     `json:"comment" gorm:"type:text;comment:备注"`
   ProductId         string                     `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"`   //产品id
@@ -611,3 +621,11 @@
   return nil
}
func MaterialMap(records []*Material) (m map[string]*Material) {
   m = make(map[string]*Material, len(records))
   for _, record := range records {
      m[record.ID] = record
   }
   return m
}