Files
bj_power/bj_power_mes/schema/workpiece_process.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

52 lines
1.7 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"
)
// WorkpieceProcess 工件-工艺实绩(某工件在某工位完成某道工艺的一次记录,构成工艺时间线)。
// 执行顺序=工位号升序(工单工艺组合),可跳过未选工位、不可倒序。
type WorkpieceProcess struct {
ent.Schema
}
func (WorkpieceProcess) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}}
}
func (WorkpieceProcess) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").MaxLen(64).Comment("工件SN"),
field.Int("flowId").Comment("完成的工艺ID"),
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
field.String("orderNo").Default("").MaxLen(64),
field.String("processName").Default("").MaxLen(64),
// PENDING / DOING / DONE / NG / REPAIRED
field.String("status").Default("DONE").MaxLen(20),
field.String("operator").Default("").MaxLen(64),
field.String("result").Default("OK").MaxLen(10).Comment("总判定 OK/NG"),
field.Time("startedAt").Optional().Nillable(),
field.Time("endedAt").Optional().Nillable(),
field.Int("durationSec").Default(0).Comment("作业时长(秒)=endedAt-startedAt"),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (WorkpieceProcess) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn"),
index.Fields("sn", "flowId"),
index.Fields("sn", "stationNo"),
index.Fields("orderNo"),
index.Fields("stationNo"),
}
}