48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package model
|
|
|
|
import "fmt"
|
|
|
|
type MaterialCategory struct {
|
|
ID int64 `json:"id"`
|
|
OrganizationID int64 `json:"organization_id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
ParentID *int64 `json:"parent_id,omitempty"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type Unit struct {
|
|
ID int64 `json:"id"`
|
|
OrganizationID int64 `json:"organization_id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
PrecisionScale int `json:"precision_scale"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type CodeRule struct {
|
|
ID int64 `json:"id"`
|
|
OrganizationID int64 `json:"organization_id"`
|
|
CategoryID int64 `json:"category_id"`
|
|
CategoryCode string `json:"category_code"`
|
|
CategoryName string `json:"category_name"`
|
|
Prefix string `json:"prefix"`
|
|
SequenceLength int `json:"sequence_length"`
|
|
NextSequence int64 `json:"next_sequence"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
// FormatCode 按「前缀 + 左侧补零的流水号」拼出物料编码。流水号位数超过
|
|
// sequence_length 时不截断而是按实际长度输出,否则号段涨过位数后会算出重复编码。
|
|
func (r *CodeRule) FormatCode(sequence int64) string {
|
|
return fmt.Sprintf("%s%0*d", r.Prefix, r.SequenceLength, sequence)
|
|
}
|
|
|
|
// NextMaterialCode 是新增物料时按小类编码规则预览出的编码。Available 为 false
|
|
// 表示该小类没有启用中的规则,需要用户手工填写编码。
|
|
type NextMaterialCode struct {
|
|
Available bool `json:"available"`
|
|
Code string `json:"code"`
|
|
}
|