Files
bj_power/bj_power_wms/schema/outbound_order.go
T
SunYF 76c9b6a7e2 feat: 两库对等物料管理及产品工号贯通全流程
- 新增 MES 本地物料表及双向同步接口,WMS 物料变更自动同步
- 全流程新增产品工号字段,贯通入库/库存/出库/检验环节
- 工单管理支持多工单混产,移除单工单互斥限制
- 新增批次号/SN 字段支持质量检验联动 WMS 库存处置
- 修复权限规则,仅内置管理员账号不允许修改删除
- 工位终端新增 SN 扫码自动切换所属工单功能
2026-09-29 14:55:03 +08:00

72 lines
4.3 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/schema/field"
"entgo.io/ent/schema/index"
)
// OutboundOrder 出库统一主表
// 所有出库(备料出库 workorder / 补料出库 refill / 通用出库 general)都落在这一张表,
// 用 outbound_type 区分;装箱属性(箱号/SN清单/合同号)直接存本表,不再单独建装箱表。
// 备料出库强约束:净领用(out_qty − returned_qty) ≤ 工单 BOM 需求量,由 WMS 侧台账校验。
//
// 注:报工反冲不再生成出库单(2026-09-19 起反冲只核销台账 consumed_qty,不做物理位移)。
type OutboundOrder struct {
ent.Schema
}
func (OutboundOrder) Fields() []ent.Field {
return []ent.Field{
field.String("outbound_no").Unique().Comment("出库单号"),
// 类型:workorder(备料出库/MES) refill(工位叫料补料) general(通用出库,不依赖工单)
field.String("outbound_type").Default("workorder").Comment("出库类型"),
// 出库单状态:出库即扣库存,故创建即为「已出库」;叫 AGV 配送到位后置「已送达」。
// 「已接料」不在本表(归备料单 material_request.received_qty),避免三处状态互斗。
field.String("status").Default("已出库").Comment("出库单状态 已出库/已送达"),
field.Bool("need_agv").Default(false).Comment("是否需要AGV配送到接驳台"),
// 出库类别(客户诉求 问题记录 L96-108):通用出库先点选类别——
// return(退料)/sample(样品)/scrap(报废)/deliver(发货)/other(其他,手输原因)
field.String("outbound_category").Optional().Comment("出库类别 return/sample/scrap/deliver/other"),
// 归属(客户诉求 L96-108):工单号/科技项目号/其他;与入库 ownership_type 口径一致
field.String("ownership_type").Optional().Comment("归属类型 workorder/project/other"),
field.String("ownership_no").Optional().Comment("归属编号(工单号/科技项目号)"),
// 目标工位(客户诉求 L96-108):出库送到哪个装配工位
field.String("target_station").Optional().Comment("目标工位(装配工位号)"),
field.String("order_no").Optional().Comment("关联工单号(工单为唯一挂靠载体)"),
field.String("material_code").Comment("物料编码"),
field.String("material_name").Optional().Comment("物料名称(冗余)"),
field.Int("manage_mode").Default(1).Comment("管理粒度 1批次/2序列号"),
field.String("batch_no").Optional().Comment("批次号(结构件)"),
// 出库库位四级(客户诉求:出库与入库同口径,2026-09-19 补齐)
field.String("zone_code").Optional().Comment("出库区域(大区)"),
field.String("shelf_no").Optional().Comment("货架号(与入库同口径)"),
field.String("layer_no").Optional().Comment("第几层(与入库同口径)"),
field.String("position_no").Optional().Comment("位置号(与入库同口径)"),
field.Int("quantity").Default(0).Comment("本次出库总数量"),
field.String("operator").Optional().Comment("操作人"),
field.String("reviewer").Optional().Comment("复核人"),
field.String("target_dock").Optional().Comment("目标接驳台(AGV配送)"),
field.String("remark").Optional().Comment("备注"),
// 装箱属性:出库时一并记录箱号/SN清单/合同号,统一落在出库主表,不再单独建装箱表
field.String("box_no").Optional().Comment("箱号(装箱出库时填写,用于整箱发货追溯)"),
field.String("box_sn_list").Optional().Comment("装箱 SN 清单(JSON 数组字符串)"),
field.String("contract_no").Optional().Comment("合同号(装箱选填)"),
// 检测单号(2026-09-21 对齐入库单字段):退货/报废等需要溯源检验单据的出库场景可选填写
field.String("inspection_no").Optional().Comment("检测单号(溯源关联检验单据)"),
// 产品工号(随库存带入,出库记录展示/筛选,2026-09-29 五页带出)
field.String("product_work_no").Optional().Comment("产品工号(随库存带入,出库记录展示/筛选)"),
field.Int64("created_at").DefaultFunc(nowUnix).Comment("创建时间"),
}
}
func (OutboundOrder) Indexes() []ent.Index {
return []ent.Index{
index.Fields("order_no"),
index.Fields("material_code"),
index.Fields("outbound_type"),
index.Fields("box_no"),
index.Fields("inspection_no"),
}
}