refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据

- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
This commit is contained in:
SunYF
2026-10-08 13:09:53 +08:00
parent 7c7c16ee6d
commit 1f7a42fc38
132 changed files with 2799 additions and 1090 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ type Alert struct {
}
func (Alert) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "alert"}}
return []schema.Annotation{entsql.Annotation{Table: "alert"}, entsql.WithComments(true), schema.Comment("Alert 预警消息:规则命中或手动触发后写入,供前端预警中心收件箱展示")}
}
func (Alert) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type AlertRule struct {
}
func (AlertRule) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "alert_rule"}}
return []schema.Annotation{entsql.Annotation{Table: "alert_rule"}, entsql.WithComments(true), schema.Comment("AlertRule 预警规则:按类型 + 阈值触发,命中后写入 alert 消息表")}
}
func (AlertRule) Fields() []ent.Field {
+2 -2
View File
@@ -17,7 +17,7 @@ type AssociationTrace struct {
}
func (AssociationTrace) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "association_trace"}}
return []schema.Annotation{entsql.Annotation{Table: "association_trace"}, entsql.WithComments(true), schema.Comment("AssociationTrace 成品追溯关联:成品SN ↔ 结构件批次 + 电气件SN")}
}
func (AssociationTrace) Fields() []ent.Field {
@@ -39,4 +39,4 @@ func (AssociationTrace) Fields() []ent.Field {
func (AssociationTrace) Indexes() []ent.Index {
return []ent.Index{index.Fields("finishedSn").Unique()}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ type Attachment struct {
}
func (Attachment) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "attachment"}}
return []schema.Annotation{entsql.Annotation{Table: "attachment"}, entsql.WithComments(true), schema.Comment("Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据。")}
}
func (Attachment) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type DailyPlan struct {
}
func (DailyPlan) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "daily_plan"}}
return []schema.Annotation{entsql.Annotation{Table: "daily_plan"}, entsql.WithComments(true), schema.Comment("DailyPlan 日排产:仅预告,不触发出库/领料")}
}
func (DailyPlan) Fields() []ent.Field {
+1 -1
View File
@@ -18,7 +18,7 @@ type Dock struct {
}
func (Dock) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "dock"}}
return []schema.Annotation{entsql.Annotation{Table: "dock"}, entsql.WithComments(true), schema.Comment("Dock 接驳台主数据:DOCK01~DOCK20(产线,DOCKn↔工位n)+ DOCK21(库房收货)。")}
}
func (Dock) Fields() []ent.Field {
+2 -2
View File
@@ -17,7 +17,7 @@ type EventLog struct {
}
func (EventLog) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "event_log"}}
return []schema.Annotation{entsql.Annotation{Table: "event_log"}, entsql.WithComments(true), schema.Comment("EventLog 操作日志:必须含 workOrderNo(工单号)、operator(操作人)")}
}
func (EventLog) Fields() []ent.Field {
@@ -43,4 +43,4 @@ func (EventLog) Indexes() []ent.Index {
index.Fields("operator"),
index.Fields("createdAt"),
}
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ type FlowMaterial struct {
}
func (FlowMaterial) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "flow_material"}}
return []schema.Annotation{entsql.Annotation{Table: "flow_material"}, entsql.WithComments(true), schema.Comment("FlowMaterial 工艺物料清单:一道工艺装什么料、单台用多少(备料/齐套校验的唯一源头)。")}
}
func (FlowMaterial) Fields() []ent.Field {
+1 -1
View File
@@ -20,7 +20,7 @@ type InspectionRecord struct {
}
func (InspectionRecord) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "inspection_record"}}
return []schema.Annotation{entsql.Annotation{Table: "inspection_record"}, entsql.WithComments(true), schema.Comment("InspectionRecord 巡检与质量检验记录(PAD 巡检终端 + MES 质量检验录入共用):")}
}
func (InspectionRecord) Fields() []ent.Field {
+1 -1
View File
@@ -19,7 +19,7 @@ type LinePoint struct {
}
func (LinePoint) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "line_point"}}
return []schema.Annotation{entsql.Annotation{Table: "line_point"}, entsql.WithComments(true), schema.Comment("LinePoint 产线点位台账:记录每个点位当前存放的工件(唯一事实源)。")}
}
func (LinePoint) Fields() []ent.Field {
+1 -1
View File
@@ -27,7 +27,7 @@ type Material struct {
}
func (Material) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "materials"}}
return []schema.Annotation{entsql.Annotation{Table: "materials"}, entsql.WithComments(true), schema.Comment("Material 物料主数据 MES 本地副本(两库对等双向同步,2026-09-29 定稿 M1)。")}
}
func (Material) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type MaterialQtyReport struct {
}
func (MaterialQtyReport) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "material_qty_report"}}
return []schema.Annotation{entsql.Annotation{Table: "material_qty_report"}, entsql.WithComments(true), schema.Comment("MaterialQtyReport 工位数量不符上报(客户诉求 问题记录 L482/L486):")}
}
func (MaterialQtyReport) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type MaterialRequest struct {
}
func (MaterialRequest) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "material_request"}}
return []schema.Annotation{entsql.Annotation{Table: "material_request"}, entsql.WithComments(true), schema.Comment("MaterialRequest 备料单:按日排产自动算料生成")}
}
func (MaterialRequest) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type Permission struct {
}
func (Permission) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "permission"}}
return []schema.Annotation{entsql.Annotation{Table: "permission"}, entsql.WithComments(true), schema.Comment("Permission 权限/菜单")}
}
func (Permission) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type PlcSendLog struct {
}
func (PlcSendLog) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "plc_send_log"}}
return []schema.Annotation{entsql.Annotation{Table: "plc_send_log"}, entsql.WithComments(true), schema.Comment("PlcSendLog PLC 工序码下发日志")}
}
func (PlcSendLog) Fields() []ent.Field {
+1 -1
View File
@@ -18,7 +18,7 @@ type ProcessFlow struct {
}
func (ProcessFlow) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "process_flow"}}
return []schema.Annotation{entsql.Annotation{Table: "process_flow"}, entsql.WithComments(true), schema.Comment("ProcessFlow 工艺流程图(菜谱):描述“这个工位怎么干”,承载工艺图纸 PDF + 工序步骤模板。")}
}
func (ProcessFlow) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type ProcessStep struct {
}
func (ProcessStep) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "process_step"}}
return []schema.Annotation{entsql.Annotation{Table: "process_step"}, entsql.WithComments(true), schema.Comment("ProcessStep 工序步骤模板:一份工艺流程包含多个采集/考核步骤(按 seq 顺序执行)")}
}
func (ProcessStep) Fields() []ent.Field {
+2 -2
View File
@@ -17,7 +17,7 @@ type Role struct {
}
func (Role) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "role"}}
return []schema.Annotation{entsql.Annotation{Table: "role"}, entsql.WithComments(true), schema.Comment("Role 角色:承载菜单/按钮权限")}
}
func (Role) Fields() []ent.Field {
@@ -35,4 +35,4 @@ func (Role) Fields() []ent.Field {
func (Role) Indexes() []ent.Index {
return []ent.Index{index.Fields("code").Unique()}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ type SemiFlow struct {
}
func (SemiFlow) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "semi_flow"}}
return []schema.Annotation{entsql.Annotation{Table: "semi_flow"}, entsql.WithComments(true), schema.Comment("SemiFlow 半成品流转记录:进度快照(完成至工位N),调用 WMS /api/internal/semi/*")}
}
func (SemiFlow) Fields() []ent.Field {
+1 -6
View File
@@ -16,7 +16,7 @@ type Station struct {
}
func (Station) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "station"}}
return []schema.Annotation{entsql.Annotation{Table: "station"}, entsql.WithComments(true), schema.Comment("Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)")}
}
func (Station) Fields() []ent.Field {
@@ -33,11 +33,6 @@ func (Station) Fields() []ent.Field {
// 需与 PLC 通讯、必须按工位号顺序流转;内置工位不允许改工位类型、不允许删除。
// 页面「新增工位」创建的是非内置工位(可改类型、可删除)。
field.Bool("isBuiltin").Default(false).Comment("内置工位:不可改类型/不可删除"),
// 是否有接驳台:对应实体位置(1~10 号工位各 2 个接驳台;0/11/12/13 无),
// 由内置数据给定,页面不可手动更改。
field.Bool("hasDock").Default(false).Comment("是否有接驳台(实体位置,内置不可改)"),
// 引用接驳台编码(与 WMS dock.dock_code 对应,1:1):产线工位 DOCKn↔工位n,无接驳台则空
field.String("dockCode").Default("").MaxLen(20).Comment("接驳台编码 DOCK01..21"),
// 终端可见页签(按工位配置,2026-09-23):空=全部显示(兼容存量工位);
// 可选值 online(上线建档)/work(作业)/material(物料叫料)/move(产线点位:上料/下料,历史 key 沿用)/pdf(工艺文件)/inspect(巡检异常)/offline(下线完工)
field.JSON("visibleTabs", []string{}).Optional(),
+1 -1
View File
@@ -18,7 +18,7 @@ type StationState struct {
}
func (StationState) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "station_state"}}
return []schema.Annotation{entsql.Annotation{Table: "station_state"}, entsql.WithComments(true), schema.Comment("StationState 工位运行状态(当日有效):工人自主 停止接单/恢复接单。")}
}
func (StationState) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type StepCriterion struct {
}
func (StepCriterion) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "step_criterion"}}
return []schema.Annotation{entsql.Annotation{Table: "step_criterion"}, entsql.WithComments(true), schema.Comment("StepCriterion 工序步骤考核标准:如 扭矩在RANGE[35,45] 自动判定 OK")}
}
func (StepCriterion) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type StepData struct {
}
func (StepData) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "step_data"}}
return []schema.Annotation{entsql.Annotation{Table: "step_data"}, entsql.WithComments(true), schema.Comment("StepData 步骤考核数据:某工件某工序步骤采集/手填实际值,按考核标准判定 OK/NG")}
}
func (StepData) Fields() []ent.Field {
+1 -1
View File
@@ -18,7 +18,7 @@ type StepSignRecord struct {
}
func (StepSignRecord) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "step_sign_record"}}
return []schema.Annotation{entsql.Annotation{Table: "step_sign_record"}, entsql.WithComments(true), schema.Comment("StepSignRecord 步骤签字记录:工艺步骤配置 need_operator_sign/need_inspector_sign 后,")}
}
func (StepSignRecord) Fields() []ent.Field {
+1 -1
View File
@@ -15,7 +15,7 @@ type SysConfig struct {
}
func (SysConfig) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "sys_config"}}
return []schema.Annotation{entsql.Annotation{Table: "sys_config"}, entsql.WithComments(true), schema.Comment("SysConfig 系统基础设置(key/value)。")}
}
func (SysConfig) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type TorqueRecord struct {
}
func (TorqueRecord) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "torque_record"}}
return []schema.Annotation{entsql.Annotation{Table: "torque_record"}, entsql.WithComments(true), schema.Comment("TorqueRecord 拧紧数据(工位终端上报,sn,strain扭矩,angle角度,result,operator,workOrder,time)")}
}
func (TorqueRecord) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type User struct {
}
func (User) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "user"}}
return []schema.Annotation{entsql.Annotation{Table: "user"}, entsql.WithComments(true), schema.Comment("User 用户")}
}
func (User) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type UserStation struct {
}
func (UserStation) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "user_station"}}
return []schema.Annotation{entsql.Annotation{Table: "user_station"}, entsql.WithComments(true), schema.Comment("UserStation 用户-工位 关联(一个操作员可绑定多个工位)")}
}
func (UserStation) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type WorkOrder struct {
}
func (WorkOrder) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "work_order"}}
return []schema.Annotation{entsql.Annotation{Table: "work_order"}, entsql.WithComments(true), schema.Comment("WorkOrder 工单:一个合同 = 一个工单")}
}
func (WorkOrder) Fields() []ent.Field {
+1 -1
View File
@@ -16,7 +16,7 @@ type Workpiece struct {
}
func (Workpiece) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece"}}
return []schema.Annotation{entsql.Annotation{Table: "workpiece"}, entsql.WithComments(true), schema.Comment("Workpiece 工件(SN):序列号管理的成品/主件")}
}
func (Workpiece) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type WorkpieceBind struct {
}
func (WorkpieceBind) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_bind"}}
return []schema.Annotation{entsql.Annotation{Table: "workpiece_bind"}, entsql.WithComments(true), schema.Comment("WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)")}
}
func (WorkpieceBind) Fields() []ent.Field {
+1 -1
View File
@@ -17,7 +17,7 @@ type WorkpieceProcess struct {
}
func (WorkpieceProcess) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}}
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}, entsql.WithComments(true), schema.Comment("WorkpieceProcess 工件-工艺实绩(某工件在某工位完成某道工艺的一次记录,构成工艺时间线)。")}
}
func (WorkpieceProcess) Fields() []ent.Field {