Files
bj_power/bj_power_mes/schema/bom_item.go
T
SunYF 6ee131a4bd feat: 新增装机绑定功能与权限、BOM工序配置
1.  新增装机绑定实体与相关CRUD逻辑,支持工件工序物料绑定/解绑
2.  为BOM物料新增装配工序字段,支持按工序校验绑定
3.  扩展权限表,新增父权限码字段支持菜单按钮关联
4.  统一各页面帮助弹窗参数,新增角色管理帮助文档
5.  新增公共格式化工具函数,优化侧边栏菜单展开逻辑
6.  新增工位终端绑定代理接口与MES内部绑定API
7.  修复主入口数据库连接与schema初始化逻辑,新增一键迁移工具
2026-09-07 11:58:19 +08:00

51 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// BomItem 产品 BOM 明细(按产品编码维护,同一型号多个工单共用)
type BomItem struct {
ent.Schema
}
func (BomItem) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "work_order_bom"}}
}
func (BomItem) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("productCode").Default("").MaxLen(64).Comment("产品编码"),
field.String("materialCode").MaxLen(64).Comment("物料编码"),
field.String("materialName").Default("").MaxLen(128),
field.String("spec").Default("").MaxLen(128),
field.String("unit").Default("").MaxLen(16),
// 1 批次(结构件) / 2 序列号(精密件)
field.String("manageMode").Default("2").MaxLen(10),
// 装配工序 1..12:该料在第几道工序被装配(装机绑定/齐套校验按此过滤);0=未指定,不参与工位绑定校验
field.Int("processCode").Default(0).Comment("装配工序 1~120=不参与工位绑定"),
field.Float("unitQty").Default(0).Comment("单台用量"),
field.Float("lossRate").Default(0).Comment("损耗率%"),
field.Float("requiredQty").Default(0).Comment("需求总量=总台数*单台*(1+损耗)"),
field.JSON("serialSns", []string{}).Optional().SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Comment("精密件SN下发列表(可选)"),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (BomItem) Indexes() []ent.Index {
return []ent.Index{
index.Fields("productCode"),
index.Fields("productCode", "materialCode").Unique(),
}
}