liujiandao
2024-01-22 dec7039530a66297fd3800fec4742824c3a9a2c1
models/material.go
@@ -71,7 +71,18 @@
      OutStorageExplain       string        `gorm:"type:varchar(512);comment:出库说明" json:"outStorageExplain"`         //出库说明
      InternalTransferExplain string        `gorm:"type:varchar(512);comment:内部调拨说明" json:"internalTransferExplain"` //内部调拨说明
      AttachmentList          []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
      AttachmentIDs           []uint        `json:"attachmentIDs" gorm:"-"`
      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"`
      //以下为不存库的字段
      AttachmentIDs    []uint          `json:"attachmentIDs" gorm:"-"`
      PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"`
      InputAmount      decimal.Decimal `json:"inputAmount" gorm:"-"`
      OutputAmount     decimal.Decimal `json:"outputAmount" gorm:"-"`
      MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存
      MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存
   }
   MaterialSearch struct {
@@ -99,7 +110,7 @@
}
func NewMaterialSearch() *MaterialSearch {
   return &MaterialSearch{Orm: mysqlx.GetDB()}
   return &MaterialSearch{Orm: mysqlx.GetDB().Where("is_storage = ", 1)} //只查询有库存的
}
func (slf *MaterialSearch) SetOrm(tx *gorm.DB) *MaterialSearch {
@@ -122,10 +133,10 @@
   return slf
}
func (slf *MaterialSearch) SetIsSale(isSale bool) *MaterialSearch {
   slf.IsSale = isSale
   return slf
}
//func (slf *MaterialSearch) SetIsSale(isSale bool) *MaterialSearch {
//   slf.IsSale = isSale
//   return slf
//}
func (slf *MaterialSearch) SetIDs(ids []string) *MaterialSearch {
   slf.Ids = ids
@@ -238,9 +249,9 @@
   if len(slf.Ids) > 0 {
      db = db.Where("id in ?", slf.Ids)
   }
   if slf.IsSale {
      db = db.Where("is_sale = ?", 1)
   }
   //if slf.IsSale {
   //   db = db.Where("is_sale = ?", 1)
   //}
   if slf.CategoryId > 0 {
      db = db.Where("category_id = ?", slf.CategoryId)
   }