- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
60 lines
3.0 KiB
Go
60 lines
3.0 KiB
Go
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)的日排产 × 工单来源产品工艺的工艺分账(product_process_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"),
|
||
}
|
||
}
|