Files
bj_power/bj_power_wms/schema/inbound_order.go
T
2026-10-26 16:32:35 +08:00

68 lines
3.8 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 (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// InboundOrder 入库单
type InboundOrder struct {
ent.Schema
}
func (InboundOrder) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Table("inbound_orders"), entsql.WithComments(true), schema.Comment("InboundOrder 入库单")}
}
func (InboundOrder) Fields() []ent.Field {
return []ent.Field{
field.String("inbound_no").Unique().Comment("入库单号"),
// 类型:purchase(采购/结构件) semi(半成品) finished(成品) return(退货) other(其他入库)
field.String("inbound_type").Default("purchase").Comment("入库类型 purchase/semi/finished/return/other"),
field.String("material_code").Comment("物料编码"),
field.String("material_name").Optional().Comment("物料名称(冗余)"),
// 类型(分类语境,冗余自物料档案):1结构件/2电气件/3其他
field.Int("manage_mode").Default(1).Comment("类型 1结构件/2电气件/3其他"),
// 序列号(sn_mode,2026-09-30 解耦定稿,冗余自物料档案,便于单单据直接判断):1=序列号是(逐件SN)/2=序列号否(按批次数量)
field.Int("sn_mode").Default(0).Comment("序列号 1=是(逐件SN)/2=否(按批次数量)/0未选择"),
field.String("batch_no").Optional().Comment("批次号(结构件)"),
field.String("zone_code").Optional().Comment("入库区域(大区)"),
// 库位四级贯通(客户诉求 问题记录 L32/L169 + D5):区域→货架号→第几层→位置号。
// 与 zones 表 shelf_no/layer_no/position_no 对齐,落位到具体货架/层/位置。
field.String("shelf_no").Optional().Comment("货架号(如 A)"),
field.String("layer_no").Optional().Comment("第几层(如 3)"),
field.String("position_no").Optional().Comment("位置号(如 12)"),
field.Int("quantity").Default(0).Comment("本次入库总数量(批次合计或SN条数)"),
field.String("operator").Optional().Comment("操作人"),
field.String("remark").Optional().Comment("备注"),
// 检测单号:入库检报告单号,必填以闭环质量追溯
field.String("inspection_no").Comment("检测单号(入库检报告单号)"),
// 归属(客户诉求 问题记录 L54:入库记录增加 工单号/科技项目号/无)
// ownership_type: workorder(工单号) / project(科技项目号) / other(其他)
field.String("ownership_type").Default("other").Comment("归属类型 workorder/project/other"),
field.String("ownership_no").Optional().Comment("归属编号(合同号/科技项目号)"),
// 产品工号(新问题1 2026-09-28):归属之下手填的二级编号
field.String("product_work_no").Optional().Comment("产品工号(手填)"),
// 质量状态(客户诉求 问题记录 L129:入库记录增加 合格/不合格 列,提交检验后跳转入库自动关联)
// 空=未关联检验记录;合格/不合格/部分(部分入库)。入库时按检测单号自动带出最近一次检验结论。
field.String("quality_status").Optional().Comment("质量状态 合格/不合格/部分(空=未关联检验)"),
// 作废(客户诉求 2026-09-19):入库单可作废,填写作废原因并回滚对应库存
// (结构件回滚批次数量;电气件按 SN 精确回滚本单的 SN,不与其它单混)。
field.Bool("voided").Default(false).Comment("是否已作废"),
field.String("void_reason").Optional().Comment("作废原因"),
field.String("voided_by").Optional().Comment("作废人"),
field.Int64("voided_at").Optional().Comment("作废时间(unix秒)"),
field.Int64("created_at").DefaultFunc(nowUnix).Comment("创建时间"),
}
}
func (InboundOrder) Indexes() []ent.Index {
return []ent.Index{
index.Fields("material_code"),
index.Fields("inbound_type"),
index.Fields("operator"),
}
}