| | |
| | | package models |
| | | |
| | | import ( |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "github.com/spf13/cast" |
| | |
| | | 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:启动多单位"` |
| | | MoreUnitValue string `json:"moreUnitValue" gorm:"type:varchar(255);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:毛重"` |
| | | NetWeight decimal.Decimal `json:"netWeight" gorm:"type:decimal(20,3);comment:净重"` |
| | | GrossUnit string `json:"grossUnit" gorm:"type:varchar(255);comment:毛重单位"` |
| | |
| | | Id string `json:"id"` |
| | | Name string `json:"name"` |
| | | } |
| | | |
| | | UnitItems struct { |
| | | Amount decimal.Decimal `json:"amount"` |
| | | Unit string `json:"unit"` |
| | | Floating bool `json:"floating"` |
| | | } |
| | | ) |
| | | |
| | | func (slf Material) TableName() string { |
| | |
| | | } |
| | | } else if slf.PurchaseType != 0 { //兼容旧数据 |
| | | slf.PurchaseTypeList = append(slf.PurchaseTypeList, int(slf.PurchaseType)) |
| | | } |
| | | if slf.MoreUnitValue != "" { |
| | | var arr []UnitItems |
| | | err := json.Unmarshal([]byte(slf.MoreUnitValue), &arr) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.MoreUnitList = arr |
| | | } |
| | | return |
| | | } |
| | |
| | | slf.PurchaseType = constvar.PurchaseType(slf.PurchaseTypeList[0]) |
| | | } |
| | | } |
| | | if len(slf.MoreUnitList) != 0 { |
| | | str, err := json.Marshal(slf.MoreUnitList) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.MoreUnitValue = string(str) |
| | | } |
| | | return |
| | | } |
| | | |