Files
SunYF 46fcb59079 feat: 退料闭环定稿(损耗台账/备料清单/退料AGV自动派车/剩余量参考)+ 工位托盘守卫
- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集)
- 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList
- 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损)
- 新增 AGV 车辆状态表 agv_vehicle_state 及查询
- 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
2026-11-04 19:06:03 +08:00

60 lines
3.0 KiB
Go
Raw Permalink 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/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// CallPool 叫料池(B5 定稿 2026-10-13):工位级物料行四数账,一行 = 一个工位 + 一个物料。
//
// 池子来源 = 启用状态(CONFIRMED)的日排产 × 工单工艺组合(flow_combination) × 工艺物料清单(flow_material),
// 按 工位+物料 聚合;需求量 = Σ 该工位排产量 × 单台用量(R7 2026-11-03 拍板:不预放折损率,
// 损耗走补料审批 shortage),逐排产行向上取整后求和。
//
// 四数(B5 数量账):
// - req_qty 需求(启用排产派生重算;人工调整见 adj_qty)
// - adj_qty 人工调整量(可正可负,默认 0;改动留痕 event_log 谁/何时/原值→新值)
// - sent_qty 已发净额(完成备料实发量累加;退库收回时扣减,额度回补)
// - reserved_qty 占用中(待备料(PENDING)叫料单请求量合计;完成/取消/驳回时释放)
// 可用 = req_qty + adj_qty − sent_qty − reserved_qty;叫料时对行 FOR UPDATE 防护,可用 < 请求量即拒(耗尽即止)。
// 工位只能叫自己工位的行;无工艺 → 无行 → 不能叫。
type CallPool struct {
ent.Schema
}
func (CallPool) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "call_pool"}, entsql.WithComments(true), schema.Comment("CallPool 叫料池:工位级物料行四数账(需求/调整/已发/占用),来源=启用状态日排产")}
}
func (CallPool) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("stationNo").Comment("工位号"),
field.String("materialCode").MaxLen(64).Comment("物料编码(图号)"),
field.String("materialName").Default("").MaxLen(128),
field.String("unit").Default("").MaxLen(16),
// 是否逐件SN管理(冗余自物料档案 sn_mode,出库口径唯一依据):1 序列号=是(逐件SN) / 2 序列号=否
field.Int("snMode").Default(2),
field.Int("reqQty").Default(0).Comment("需求量(启用排产派生,逐行向上取整后合计)"),
field.Int("adjQty").Default(0).Comment("人工调整量(可正可负;改动留痕 event_log)"),
field.Int("sentQty").Default(0).Comment("已发净额(完成备料实发累加;退库收回扣减回补)"),
field.Int("reservedQty").Default(0).Comment("占用中(待备料叫料单请求量合计)"),
field.Bool("crossDay").Default(false).Comment("是否含非今日排产(跨日叫料预警/仓库驳回异常标记)"),
field.String("planDates").Default("").MaxLen(255).Comment("派生快照:贡献需求的排产日期(逗号分隔,可空)"),
field.Time("createdAt").Default(time.Now).Immutable(),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now),
}
}
func (CallPool) Indexes() []ent.Index {
return []ent.Index{
index.Fields("stationNo", "materialCode").Unique(),
index.Fields("stationNo"),
}
}