refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -31,8 +31,6 @@ func (BomItem) Fields() []ent.Field {
|
||||
field.String("unit").Default("").MaxLen(16),
|
||||
// 1 批次(结构件) / 2 序列号(电气件)
|
||||
field.String("manageMode").Default("2").MaxLen(10),
|
||||
// 装配工序 1..12:该料在第几道工序被装配(装机绑定/齐套校验按此过滤);0=未指定,不参与工位绑定校验
|
||||
field.Int("processCode").Default(0).Comment("装配工序 1~12,0=不参与工位绑定"),
|
||||
field.Float("unitQty").Default(0).Comment("单台用量"),
|
||||
field.Float("lossRate").Default(0).Comment("损耗率%"),
|
||||
field.String("relatedStandard").Default("").MaxLen(255).Comment("相关标准(检验细则)"),
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// FlowMaterial 工艺物料清单:一道工艺装什么料、单台用多少(备料/齐套校验的唯一源头)。
|
||||
// 约束:物料必须属于产品物料清单(BOM)子集(写入时校验)。
|
||||
type FlowMaterial struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (FlowMaterial) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "flow_material"}}
|
||||
}
|
||||
|
||||
func (FlowMaterial) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.Int("flowId").Comment("所属工艺ID"),
|
||||
field.String("materialCode").MaxLen(64).Comment("物料编码"),
|
||||
field.String("materialName").Default("").MaxLen(128),
|
||||
field.String("spec").Default("").MaxLen(128),
|
||||
field.String("unit").Default("").MaxLen(16),
|
||||
// 1 批次(结构件) / 2 序列号(电气件)
|
||||
field.String("manageMode").Default("2").MaxLen(10),
|
||||
field.Float("unitQty").Default(0).Comment("单台用量"),
|
||||
field.Float("lossRate").Default(0).Comment("损耗率%"),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (FlowMaterial) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("flowId"),
|
||||
index.Fields("flowId", "materialCode").Unique(),
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,9 @@ func (MaterialRequest) Fields() []ent.Field {
|
||||
// PENDING / LOCKED / DELIVERING / DONE
|
||||
field.String("status").Default("PENDING").MaxLen(20),
|
||||
field.String("targetDock").Default("").MaxLen(20).Comment("目标接驳台 DOCK01..20"),
|
||||
// 工位级备料:物料送达的工位号(由 station_process 派工 + 日排产分配派生)
|
||||
// 工位级备料:物料送达的工位号(由 工单工艺组合+日排产分产量 派生)
|
||||
field.Int("stationNo").Default(0).Comment("目标工位号(0=未指定)"),
|
||||
field.Int("processCode").Default(0).Comment("该物料所属装配工序(1~12)"),
|
||||
field.Int("flowId").Default(0).Comment("该物料所属工艺ID(0=整线共用)"),
|
||||
// 字段口径(2026-09-19 定稿,一个字段只有一个写者):
|
||||
// sentQty 已发出量 [写者:自动出库/WMS 回写],同时是「还需发多少 = reqQty − sentQty」的幂等基准
|
||||
// receivedQty 已接料量 [写者:工位扫码接料]
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// StationProcess 工位↔工序 派工(当日/班次可换)
|
||||
type StationProcess struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (StationProcess) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "station_process"}}
|
||||
}
|
||||
|
||||
func (StationProcess) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.Int("stationNo").Comment("工位号 1..12"),
|
||||
field.Int("processCode").Comment("工序代码"),
|
||||
field.String("effectDate").Default("").MaxLen(10).Comment("生效日期"),
|
||||
field.String("shift").Default("").MaxLen(20).Comment("班次"),
|
||||
field.String("operator").Default("").MaxLen(64),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (StationProcess) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("stationNo"),
|
||||
index.Fields("effectDate"),
|
||||
index.Fields("stationNo", "effectDate"),
|
||||
// 同工位同天同班次唯一(派工覆盖式写入),防止备料算料翻倍
|
||||
index.Fields("stationNo", "effectDate", "shift").Unique(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// StationState 工位运行状态(当日有效):工人自主 停止接单/恢复接单。
|
||||
// 停单后上位机不再向该工位下发工件流转指令;某工艺全部工位停单=工件目的地不可达,报警。
|
||||
// 跨天自动失效(只认当天记录),次日默认全部恢复接单。
|
||||
type StationState struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (StationState) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{entsql.Annotation{Table: "station_state"}}
|
||||
}
|
||||
|
||||
func (StationState) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.Int("stationNo").Comment("工位号"),
|
||||
field.String("date").MaxLen(10).Comment("生效日期 yyyy-MM-dd(只认当天)"),
|
||||
field.Bool("paused").Default(false).Comment("是否停止接单"),
|
||||
field.String("reason").Default("").MaxLen(255).Comment("停单原因(缺料/故障/其他)"),
|
||||
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
|
||||
field.Time("createdAt").Default(time.Now).Immutable(),
|
||||
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (StationState) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("stationNo", "date").Unique(),
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,11 @@ func (WorkOrder) Fields() []ent.Field {
|
||||
// 创建人(取当前登录用户)+ 完成日期(必填)
|
||||
field.String("createdBy").Default("").MaxLen(64).Comment("创建人"),
|
||||
field.Time("dueDate").Optional().Nillable().Comment("完成日期(必填)"),
|
||||
// 工艺组合:本工单经过的 工艺→工位 清单(按工位号升序即执行顺序,可跳位、不可倒序)。
|
||||
// 由建单/编辑时人工勾选(绑定工位默认全选);自动排产/备料/报工/PLC 全部以它为唯一路线源头。
|
||||
field.JSON("flowCombination", []map[string]int{}).Optional().SchemaType(map[string]string{
|
||||
dialect.Postgres: "jsonb",
|
||||
}).Comment("工艺组合 [{flowId,stationNo}] 按工位号升序"),
|
||||
// CREATED / RELEASED / IN_PROGRESS / COMPLETED / CLOSED
|
||||
field.String("status").Default("CREATED").MaxLen(20),
|
||||
field.Time("planStart").Optional().Nillable().Comment("计划开始"),
|
||||
|
||||
@@ -25,7 +25,7 @@ func (Workpiece) Fields() []ent.Field {
|
||||
field.String("sn").Unique().MaxLen(64).Comment("工件唯一SN"),
|
||||
field.String("orderNo").Default("").MaxLen(64).Comment("所属工单"),
|
||||
field.Int("workOrderId").Optional().Comment("工单ID"),
|
||||
field.Int("currentProcess").Optional().Comment("当前进行到的工序码"),
|
||||
field.Int("currentStationNo").Optional().Comment("最后完成报工的工位号(0=未报任何工艺;下一道=工艺组合中工位号更大的下一条)"),
|
||||
// ONLINE(已进线) / PROCESSING(在工位) / DONE(完工) / REPAIR / SCRAPPED
|
||||
field.String("status").Default("ONLINE").MaxLen(20),
|
||||
field.Time("onlineAt").Optional().Nillable().Comment("进线时间"),
|
||||
|
||||
@@ -25,7 +25,7 @@ func (WorkpieceBind) Fields() []ent.Field {
|
||||
field.Int("id").Positive(),
|
||||
field.String("sn").MaxLen(64).Comment("工件SN"),
|
||||
field.String("orderNo").Default("").MaxLen(64).Comment("工单号"),
|
||||
field.Int("processCode").Comment("装配工序 1~12"),
|
||||
field.Int("flowId").Comment("装配工艺ID"),
|
||||
field.String("stationNo").Default("").MaxLen(32).Comment("绑定工位"),
|
||||
field.String("materialCode").MaxLen(64).Comment("物料编码"),
|
||||
field.String("materialName").Default("").MaxLen(128).Comment("物料名称"),
|
||||
@@ -45,7 +45,7 @@ func (WorkpieceBind) Fields() []ent.Field {
|
||||
func (WorkpieceBind) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("sn"),
|
||||
index.Fields("sn", "processCode"),
|
||||
index.Fields("sn", "flowId"),
|
||||
index.Fields("sn", "materialCode"),
|
||||
index.Fields("orderNo"),
|
||||
index.Fields("materialCode", "bindValue"),
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// WorkpieceProcess 工件-工序实绩(某工件在某工位完成某道工序的一次记录,构成工序时间线)
|
||||
// WorkpieceProcess 工件-工艺实绩(某工件在某工位完成某道工艺的一次记录,构成工艺时间线)。
|
||||
// 执行顺序=工位号升序(工单工艺组合),可跳过未选工位、不可倒序。
|
||||
type WorkpieceProcess struct {
|
||||
ent.Schema
|
||||
}
|
||||
@@ -23,7 +24,7 @@ func (WorkpieceProcess) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("id").Positive(),
|
||||
field.String("sn").MaxLen(64).Comment("工件SN"),
|
||||
field.Int("processCode").Comment("工序代码"),
|
||||
field.Int("flowId").Comment("完成的工艺ID"),
|
||||
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
|
||||
field.String("orderNo").Default("").MaxLen(64),
|
||||
field.String("processName").Default("").MaxLen(64),
|
||||
@@ -42,7 +43,8 @@ func (WorkpieceProcess) Fields() []ent.Field {
|
||||
func (WorkpieceProcess) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("sn"),
|
||||
index.Fields("sn", "processCode"),
|
||||
index.Fields("sn", "flowId"),
|
||||
index.Fields("sn", "stationNo"),
|
||||
index.Fields("orderNo"),
|
||||
index.Fields("stationNo"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user