| | |
| | | //MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"` |
| | | Model constvar.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"` //最小库存 |
| | | MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最大库存" json:"maxInventory"` //最大库存 |
| | | Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"` //数量 |
| | | 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"` //最小库存 |
| | | MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最大库存" json:"maxInventory"` //最大库存 |
| | | 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"` |
| | | 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:"templateID"` //模板ID |
| | | //FSource string `gorm:"type:varchar(191);comment:生产车间" json:"-"` |
| | | //Status constvar.MaterialStatus `gorm:"type:int(11);comment:状态" json:"status"` |
| | |
| | | PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:采购价格" json:"purchasePrice"` //采购价格 |
| | | //PurchaseAheadDay int `gorm:"type:int(11);comment:采购提前期(天)" json:"purchaseAheadDay"` |
| | | //ProduceAheadDay int `gorm:"type:int(11);comment:制造提前期(天)" json:"produceAheadDay"` |
| | | MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:最小采购量" json:"minPurchaseAmount"` //最小采购量 |
| | | //PurchaseType constvar.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:"-"` |
| | | MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:最小采购量" json:"minPurchaseAmount"` //最小采购量 |
| | | PurchaseType constvar.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"` |
| | | //wms添加字段 |
| | | ProductType constvar.ProductType `gorm:"type:int(11);comment:产品类型" json:"productType"` //产品类型 |
| | | InvoicingStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:开票策略" json:"invoicingStrategy"` //开票策略 |
| | |
| | | ControlStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:控制策略" json:"controlStrategy"` //控制策略 |
| | | BuyExplain string `gorm:"type:varchar(512);comment:采购说明" json:"buyExplain"` //采购说明 |
| | | Principal string `gorm:"type:varchar(255);comment:负责人" json:"principal"` //负责人 |
| | | Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:重量" json:"weight"` //重量 |
| | | Weight decimal.Decimal `gorm:"type:decimal(20,3);comment:重量" json:"weight"` //重量 |
| | | Volume decimal.Decimal `gorm:"type:decimal(20,2);comment:体积" json:"volume"` //体积 |
| | | MakeAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:制造前置时间" json:"makeAdvanceTime"` //制造前置时间(天) |
| | | OrderAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:订单准备天数" json:"orderAdvanceTime"` //订单准备天数(天) |
| | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | 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 { |
| | |
| | | // return fileName, nil |
| | | //} |
| | | |
| | | func (slf *MaterialSearch) MaxAutoIncr() (int64, error) { |
| | | func (slf *MaterialSearch) MaxAutoIncr() (int, error) { |
| | | type Result struct { |
| | | Max int64 |
| | | Max int |
| | | } |
| | | |
| | | var ( |