zhangqian
2024-03-28 c7e82fd1d76b9fb25497d5aba4372bbfe13a8468
model/test/material.go
@@ -10,8 +10,6 @@
   Name              string          `gorm:"type:varchar(191);not null;comment:物料名称" json:"name"`
   MaterialType      MaterialType    `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"`
   Model             MaterialMode    `gorm:"type:varchar(191);not null;comment:物料类型(字符串)" json:"model"`
   Explain           string          `gorm:"type:varchar(512);comment:编号说明" json:"explain"`
   CodeStandardID    string          `gorm:"type:varchar(191);comment:编码规范ID" json:"codeStandardID"`
   Specs             string          `gorm:"type:varchar(191);comment:物料规格" json:"specs"`
   Type              string          `gorm:"type:varchar(191);comment:物料型号" json:"type"`
   MinInventory      decimal.Decimal `gorm:"type:decimal(35,18);comment:最小库存" json:"minInventory"`
@@ -19,9 +17,7 @@
   Amount            decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"`
   LockAmount        decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:锁定数量" json:"lockAmount"`
   Unit              string          `gorm:"type:varchar(100);comment:单位" json:"unit"`
   Note              string          `gorm:"type:varchar(1024);comment:备注" json:"note"`
   TemplateID        string          `gorm:"type:varchar(191);comment:模板ID" json:"-"`
   FSource           string          `gorm:"type:varchar(191);comment:生产车间" json:"-"`
   Status            MaterialStatus  `gorm:"type:int(11);comment:状态" json:"status"`
   Supplier          string          `gorm:"type:varchar(191);comment:供应商" json:"supplier"`
   PurchasePrice     decimal.Decimal `gorm:"type:decimal(35,18);comment:采购价格" json:"purchasePrice"`
@@ -29,10 +25,10 @@
   ProduceAheadDay   int             `gorm:"type:int(11);comment:制造提前期(天)" json:"produceAheadDay"`
   MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:最小采购量" json:"minPurchaseAmount"`
   PurchaseType      PurchaseType    `gorm:"type:int(11);comment:采购类型" json:"purchaseType"`
   IsSale            *bool           `gorm:"type:tinyint(1);comment:是否销售" json:"isSale"`
   SalePrice         decimal.Decimal `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"`
   AutoIncr          uint            `gorm:"type:int(11);comment:自增ID;default:0;" json:"autoIncr"`
   AttachmentList    []*Attachment   `json:"attachmentList" gorm:"many2many:material_attachment"`
   CategoryName      string          `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"`            //产品类别名称
   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计算时跳过该层级直接领用下级物料,虚拟物料不生成工单
}
// PurchaseType 采购类型
@@ -59,9 +55,10 @@
   MaterialModeRaw         MaterialMode = "原材料"
   MaterialModeSemi        MaterialMode = "半成品"
   MaterialModeFinished    MaterialMode = "成品"
   MaterialModeAuxiliary   MaterialMode = "辅料" //辅料
   MaterialModeConsumables MaterialMode = "耗材" //耗材
   MaterialModeOther       MaterialMode = "其他" //其他
   MaterialModeAuxiliary   MaterialMode = "辅料"  //辅料
   MaterialModeConsumables MaterialMode = "耗材"  //耗材
   MaterialModeOther       MaterialMode = "其他"  //其他
   MaterialModeVirtual     MaterialMode = "虚拟件" //虚拟件, 不能销售,不能出入库,不能采购
)
func (t MaterialMode) Valid() bool {
@@ -70,7 +67,8 @@
      t != MaterialModeAuxiliary &&
      t != MaterialModeConsumables &&
      t != MaterialModeOther &&
      t != MaterialModeFinished {
      t != MaterialModeFinished &&
      t != MaterialModeVirtual {
      return false
   }
   return true
@@ -84,6 +82,14 @@
      return MaterialTypeSemi
   case MaterialModeFinished:
      return MaterialTypeFinished
   case MaterialModeAuxiliary:
      return MaterialTypeAuxiliary
   case MaterialModeConsumables:
      return MaterialTypeConsumables
   case MaterialModeOther:
      return MaterialTypeOther
   case MaterialModeVirtual:
      return MaterialTypeVirtual
   }
   return MaterialType(0)
}
@@ -98,11 +104,12 @@
   MaterialTypeAuxiliary              //辅料
   MaterialTypeConsumables            //耗材
   MaterialTypeOther                  //其他
   MaterialTypeVirtual                //虚拟件
)
func (t MaterialType) Valid() bool {
   if t < MaterialTypeRaw ||
      t > MaterialTypeFinished {
      t > MaterialTypeVirtual {
      return false
   }
   return true