Files
bj_power/bj_power_mes/schema/call_pool.go
T
SunYF f65a52d9e1 feat: 多系统新增扫码中间件与 AGV 对接,优化拧紧与退库流程
新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
2026-10-14 17:24:59 +08:00

60 lines
3.0 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/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),
// 按 工位+物料 聚合;需求量 = Σ 该工位排产量 × 单台用量 ×(1+损耗率),逐排产行向上取整后求和
// (与旧备料单 reqQty 口径一致,避免拆单合计与整体取整不一致)。
//
// 四数(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"),
}
}