Files
bj_power/bj_power_mes/schema/material_request.go
T
SunYF d609ff8a9e refactor: 重构工艺工序相关命名与数据模型
1.  全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2.  重构工单与工件工艺数据模型:
    - 新增工艺组合表flow_material作为备料/齐套唯一源头
    - 新增工位状态表station_state支持自主停单/恢复接单
    - 移除station_process派工表,改用工单工艺组合作为路线唯一源头
    - 替换processCode为flowId作为工艺关联标识
    - 重构工件当前进度字段为currentStationNo
3.  删除冗余的静态备份资源文件
4.  调整物料选择组件默认启用仅显示激活物料
5.  优化工单创建/编辑逻辑,新增工艺组合校验与保存
2026-09-22 11:32:29 +08:00

69 lines
3.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 (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// MaterialRequest 备料单:按日排产自动算料生成
type MaterialRequest struct {
ent.Schema
}
func (MaterialRequest) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "material_request"}}
}
func (MaterialRequest) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("requestNo").MaxLen(64).Comment("备料单号"),
field.String("orderNo").MaxLen(64).Comment("工单号"),
field.String("planDate").MaxLen(10).Comment("对应排产日"),
field.String("materialCode").MaxLen(64).Comment("物料编码"),
field.String("materialName").Default("").MaxLen(128),
field.String("unit").Default("").MaxLen(16),
field.String("manageMode").Default("2").MaxLen(10),
field.Float("reqQty").Default(0).Comment("需备数量"),
// PENDING / LOCKED / DELIVERING / DONE
field.String("status").Default("PENDING").MaxLen(20),
field.String("targetDock").Default("").MaxLen(20).Comment("目标接驳台 DOCK01..20"),
// 工位级备料:物料送达的工位号(由 工单工艺组合+日排产分产量 派生)
field.Int("stationNo").Default(0).Comment("目标工位号(0=未指定)"),
field.Int("flowId").Default(0).Comment("该物料所属工艺ID(0=整线共用)"),
// 字段口径(2026-09-19 定稿,一个字段只有一个写者):
// sentQty 已发出量 [写者:自动出库/WMS 回写],同时是「还需发多少 = reqQty − sentQty」的幂等基准
// receivedQty 已接料量 [写者:工位扫码接料]
// 派生:在途 = sentQty receivedQty
field.Float("sentQty").Default(0).Comment("已发出量(分批出库累加;幂等基准,勿与已接料混用)"),
field.Float("receivedQty").Default(0).Comment("已接料量(工位扫码接料累加)"),
field.Int64("receivedAt").Default(0).Comment("最近接料时间(unix 秒)"),
field.String("receiveBy").Default("").MaxLen(64).Comment("接料人"),
// 来源:PLAN=日排产备料(默认) / REFILL=工位叫料·数量不符补发(优先级高于 PLAN)
field.String("source").Default("PLAN").MaxLen(16).Comment("来源 PLAN/REFILL"),
// 补料/超领:超出 BOM 需求的量与原因为必填(超领不硬卡,但必须留痕可统计)
field.Float("overQty").Default(0).Comment("超出 BOM 需求的数量"),
field.String("overReason").Default("").MaxLen(64).Comment("超领原因 损耗/报废/返修/其他"),
// 补发来源:关联的数量不符单号(source=REFILL 且有值时填写)
field.String("refReportNo").Default("").MaxLen(64).Comment("关联数量不符单号"),
field.Bool("needAgv").Default(false).Comment("是否需要AGV配送到接驳台"),
field.String("batchNo").Default("").MaxLen(64).Comment("发料批次号(分批出库时填写)"),
field.String("operator").Default("").MaxLen(64),
field.Time("createdAt").Default(time.Now).Immutable(),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
}
}
func (MaterialRequest) Indexes() []ent.Index {
return []ent.Index{
index.Fields("orderNo"),
index.Fields("materialCode"),
index.Fields("status"),
}
}