Files
bj_power/bj_power_mes/ent/migrate/schema.go
T
SunYF 8be6e03a15 docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
2026-10-10 15:58:59 +08:00

1377 lines
65 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.
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// AlertColumns holds the columns for the "alert" table.
AlertColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "rule_id", Type: field.TypeInt, Comment: "关联规则ID,0=手动触发", Default: 0},
{Name: "type", Type: field.TypeString, Size: 40, Comment: "预警类型"},
{Name: "level", Type: field.TypeString, Size: 20, Comment: "级别:信息/警告/严重(空=历史数据未分级)", Default: ""},
{Name: "target", Type: field.TypeString, Size: 128, Comment: "目标对象(工位/库房/SN 等)", Default: ""},
{Name: "title", Type: field.TypeString, Size: 120, Comment: "标题"},
{Name: "content", Type: field.TypeString, Size: 500, Comment: "内容", Default: ""},
{Name: "ref_type", Type: field.TypeString, Size: 40, Comment: "关联业务类型", Default: ""},
{Name: "ref_id", Type: field.TypeString, Size: 64, Comment: "关联业务ID", Default: ""},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "关联工单号(按工单号查询用)", Default: ""},
{Name: "status", Type: field.TypeString, Size: 10, Comment: "UNREAD/READ", Default: "UNREAD"},
{Name: "receiver", Type: field.TypeString, Size: 255, Comment: "接收人", Default: ""},
{Name: "resolved_at", Type: field.TypeTime, Nullable: true, Comment: "处置时间(resolve 时写入,未处置为空)"},
{Name: "resolved_by", Type: field.TypeString, Size: 64, Comment: "处置人(resolve 时写入)", Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// AlertTable holds the schema information for the "alert" table.
AlertTable = &schema.Table{
Name: "alert",
Comment: "Alert 预警消息:规则命中或手动触发后写入,供前端预警中心收件箱展示",
Columns: AlertColumns,
PrimaryKey: []*schema.Column{AlertColumns[0]},
Indexes: []*schema.Index{
{
Name: "alert_status",
Unique: false,
Columns: []*schema.Column{AlertColumns[10]},
},
{
Name: "alert_type",
Unique: false,
Columns: []*schema.Column{AlertColumns[2]},
},
{
Name: "alert_created_at",
Unique: false,
Columns: []*schema.Column{AlertColumns[14]},
},
},
}
// AlertRuleColumns holds the columns for the "alert_rule" table.
AlertRuleColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString, Size: 80, Comment: "规则名称"},
{Name: "type", Type: field.TypeString, Size: 40, Comment: "预警类型 torque_ng/inspection_ng/inventory_low/task_overdue"},
{Name: "threshold", Type: field.TypeFloat64, Comment: "阈值(不同类含义不同)", Default: 0},
{Name: "enabled", Type: field.TypeBool, Comment: "是否启用", Default: true},
{Name: "notify_channels", Type: field.TypeString, Size: 255, Comment: "通知渠道(BOM 即物料清单无关;本字段为预警通知方式占位,逗号分隔,空=仅预警中心收件箱)", Default: ""},
{Name: "created_by", Type: field.TypeString, Size: 64, Comment: "创建人", Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// AlertRuleTable holds the schema information for the "alert_rule" table.
AlertRuleTable = &schema.Table{
Name: "alert_rule",
Comment: "AlertRule 预警规则:按类型 + 阈值触发,命中后写入 alert 消息表",
Columns: AlertRuleColumns,
PrimaryKey: []*schema.Column{AlertRuleColumns[0]},
Indexes: []*schema.Index{
{
Name: "alertrule_type",
Unique: false,
Columns: []*schema.Column{AlertRuleColumns[2]},
},
{
Name: "alertrule_enabled",
Unique: false,
Columns: []*schema.Column{AlertRuleColumns[4]},
},
},
}
// AssociationTraceColumns holds the columns for the "association_trace" table.
AssociationTraceColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "finished_sn", Type: field.TypeString, Unique: true, Size: 64, Comment: "成品SN(主件)"},
{Name: "order_no", Type: field.TypeString, Size: 64, Default: ""},
{Name: "process_code", Type: field.TypeString, Size: 64, Comment: "成品的工序组合", Default: ""},
{Name: "batch_items", Type: field.TypeJSON, Nullable: true, Comment: "结构件批次号列表", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "serial_items", Type: field.TypeJSON, Nullable: true, Comment: "电气件SN码列表", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "完工关联登记人", Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// AssociationTraceTable holds the schema information for the "association_trace" table.
AssociationTraceTable = &schema.Table{
Name: "association_trace",
Comment: "AssociationTrace 成品追溯关联:成品SN ↔ 结构件批次 + 电气件SN",
Columns: AssociationTraceColumns,
PrimaryKey: []*schema.Column{AssociationTraceColumns[0]},
Indexes: []*schema.Index{
{
Name: "associationtrace_finished_sn",
Unique: true,
Columns: []*schema.Column{AssociationTraceColumns[1]},
},
},
}
// AttachmentColumns holds the columns for the "attachment" table.
AttachmentColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "biz_type", Type: field.TypeString, Size: 40, Comment: "业务类型 work_order/material/process_flow/inspection"},
{Name: "biz_id", Type: field.TypeString, Size: 64, Comment: "业务ID"},
{Name: "file_name", Type: field.TypeString, Size: 255, Comment: "原始文件名"},
{Name: "file_path", Type: field.TypeString, Size: 255, Comment: "上传目录相对路径"},
{Name: "file_size", Type: field.TypeInt, Comment: "字节数", Default: 0},
{Name: "uploader", Type: field.TypeString, Size: 64, Comment: "上传人", Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "file_type", Type: field.TypeString, Size: 32, Comment: "文件类型 大写枚举 PROCESS_PDF/INSPECTION_PHOTO/...", Default: "OTHER"},
{Name: "file_ext", Type: field.TypeString, Size: 16, Comment: "扩展名(小写,不含点)", Default: ""},
{Name: "file_md5", Type: field.TypeString, Size: 64, Comment: "文件MD5(秒传/去重)", Default: ""},
{Name: "mime_type", Type: field.TypeString, Size: 128, Comment: "MIME类型", Default: ""},
{Name: "archived", Type: field.TypeBool, Comment: "是否已归档", Default: false},
{Name: "archived_at", Type: field.TypeInt64, Comment: "归档时间(unix秒)", Default: 0},
{Name: "deleted", Type: field.TypeBool, Comment: "逻辑删除", Default: false},
{Name: "deleted_at", Type: field.TypeInt64, Comment: "删除时间(unix秒)", Default: 0},
{Name: "deleted_by", Type: field.TypeString, Size: 64, Comment: "删除人", Default: ""},
}
// AttachmentTable holds the schema information for the "attachment" table.
AttachmentTable = &schema.Table{
Name: "attachment",
Comment: "Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据。",
Columns: AttachmentColumns,
PrimaryKey: []*schema.Column{AttachmentColumns[0]},
Indexes: []*schema.Index{
{
Name: "attachment_biz_type_biz_id",
Unique: false,
Columns: []*schema.Column{AttachmentColumns[1], AttachmentColumns[2]},
},
{
Name: "attachment_created_at",
Unique: false,
Columns: []*schema.Column{AttachmentColumns[7]},
},
{
Name: "attachment_file_type",
Unique: false,
Columns: []*schema.Column{AttachmentColumns[8]},
},
{
Name: "attachment_file_md5",
Unique: false,
Columns: []*schema.Column{AttachmentColumns[10]},
},
},
}
// DailyPlanColumns holds the columns for the "daily_plan" table.
DailyPlanColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号"},
{Name: "plan_date", Type: field.TypeString, Size: 10, Comment: "排产日期 yyyy-MM-dd"},
{Name: "plan_qty", Type: field.TypeInt, Comment: "计划数量", Default: 0},
{Name: "completed_qty", Type: field.TypeInt, Comment: "已完成数量", Default: 0},
{Name: "station_plan_qty", Type: field.TypeJSON, Nullable: true, Comment: "各工位产量分配 stationNo→计划产量", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "status", Type: field.TypeString, Size: 20, Default: "PENDING"},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// DailyPlanTable holds the schema information for the "daily_plan" table.
DailyPlanTable = &schema.Table{
Name: "daily_plan",
Comment: "DailyPlan 日排产:仅预告,不触发出库/领料",
Columns: DailyPlanColumns,
PrimaryKey: []*schema.Column{DailyPlanColumns[0]},
Indexes: []*schema.Index{
{
Name: "dailyplan_order_no",
Unique: false,
Columns: []*schema.Column{DailyPlanColumns[1]},
},
{
Name: "dailyplan_plan_date",
Unique: false,
Columns: []*schema.Column{DailyPlanColumns[2]},
},
{
Name: "dailyplan_plan_date_order_no",
Unique: true,
Columns: []*schema.Column{DailyPlanColumns[2], DailyPlanColumns[1]},
},
},
}
// DockColumns holds the columns for the "dock" table.
DockColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "dock_code", Type: field.TypeString, Unique: true, Size: 20, Comment: "接驳台编码 DOCK01..21"},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "接驳台名称", Default: ""},
{Name: "dock_type", Type: field.TypeString, Size: 16, Comment: "类型 line产线/store库房/other其他", Default: "line"},
{Name: "station_no", Type: field.TypeInt, Comment: "关联工位号(与工位1:1,非产线为0)", Default: 0},
{Name: "has_pallet", Type: field.TypeBool, Comment: "当前是否有托盘", Default: false},
{Name: "pallet_ref", Type: field.TypeString, Nullable: true, Size: 64, Comment: "托盘关联(出库单号/备料单号)", Default: ""},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ENABLED"},
{Name: "created_at", Type: field.TypeTime},
}
// DockTable holds the schema information for the "dock" table.
DockTable = &schema.Table{
Name: "dock",
Comment: "Dock 接驳台主数据:DOCK01~DOCK20(产线,DOCKn↔工位n)+ DOCK21(库房收货)。",
Columns: DockColumns,
PrimaryKey: []*schema.Column{DockColumns[0]},
Indexes: []*schema.Index{
{
Name: "dock_dock_code",
Unique: true,
Columns: []*schema.Column{DockColumns[1]},
},
{
Name: "dock_dock_type",
Unique: false,
Columns: []*schema.Column{DockColumns[3]},
},
},
}
// EventLogColumns holds the columns for the "event_log" table.
EventLogColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "event_type", Type: field.TypeString, Size: 50, Comment: "事件类型,如 work.order.create"},
{Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "关联工单号", Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""},
{Name: "entity_type", Type: field.TypeString, Size: 30, Comment: "实体类型", Default: ""},
{Name: "entity_id", Type: field.TypeString, Size: 50, Comment: "实体标识", Default: ""},
{Name: "description", Type: field.TypeString, Size: 2147483647, Comment: "描述", Default: ""},
{Name: "payload", Type: field.TypeJSON, Nullable: true, Comment: "载荷", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
}
// EventLogTable holds the schema information for the "event_log" table.
EventLogTable = &schema.Table{
Name: "event_log",
Comment: "EventLog 操作日志:必须含 workOrderNo(工单号)、operator(操作人)",
Columns: EventLogColumns,
PrimaryKey: []*schema.Column{EventLogColumns[0]},
Indexes: []*schema.Index{
{
Name: "eventlog_event_type",
Unique: false,
Columns: []*schema.Column{EventLogColumns[1]},
},
{
Name: "eventlog_work_order_no",
Unique: false,
Columns: []*schema.Column{EventLogColumns[2]},
},
{
Name: "eventlog_operator",
Unique: false,
Columns: []*schema.Column{EventLogColumns[3]},
},
{
Name: "eventlog_created_at",
Unique: false,
Columns: []*schema.Column{EventLogColumns[8]},
},
},
}
// FlowMaterialColumns holds the columns for the "flow_material" table.
FlowMaterialColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "flow_id", Type: field.TypeInt, Comment: "所属工艺ID"},
{Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码"},
{Name: "material_name", Type: field.TypeString, Size: 128, Default: ""},
{Name: "spec", Type: field.TypeString, Size: 128, Default: ""},
{Name: "unit", Type: field.TypeString, Size: 16, Default: ""},
{Name: "sn_mode", Type: field.TypeInt, Default: 2},
{Name: "unit_qty", Type: field.TypeFloat64, Comment: "单台用量", Default: 0},
{Name: "loss_rate", Type: field.TypeFloat64, Comment: "损耗率%", Default: 0},
{Name: "created_at", Type: field.TypeTime},
}
// FlowMaterialTable holds the schema information for the "flow_material" table.
FlowMaterialTable = &schema.Table{
Name: "flow_material",
Comment: "FlowMaterial 工艺物料清单:一道工艺装什么料、单台用多少(备料/齐套校验的唯一源头)。",
Columns: FlowMaterialColumns,
PrimaryKey: []*schema.Column{FlowMaterialColumns[0]},
Indexes: []*schema.Index{
{
Name: "flowmaterial_flow_id",
Unique: false,
Columns: []*schema.Column{FlowMaterialColumns[1]},
},
{
Name: "flowmaterial_flow_id_material_code",
Unique: true,
Columns: []*schema.Column{FlowMaterialColumns[1], FlowMaterialColumns[2]},
},
},
}
// InspectionRecordColumns holds the columns for the "inspection_record" table.
InspectionRecordColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "category", Type: field.TypeString, Size: 20, Comment: "记录类型 CHECKIN/POINT/PROCESS/DONE/ALARM/INCOMING/FINAL/QC_PROCESS"},
{Name: "station_no", Type: field.TypeString, Size: 32, Comment: "工位号", Default: ""},
{Name: "shift", Type: field.TypeString, Size: 20, Comment: "班次 早/中/晚", Default: ""},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号", Default: ""},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN", Default: ""},
{Name: "result", Type: field.TypeString, Size: 10, Comment: "结论", Default: "OK"},
{Name: "items", Type: field.TypeJSON, Nullable: true, Comment: "点检项/异常类型列表", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "photo", Type: field.TypeString, Size: 255, Comment: "拍照文件名", Default: ""},
{Name: "remark", Type: field.TypeString, Size: 500, Comment: "文字描述/签字", Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""},
{Name: "process_code", Type: field.TypeInt, Comment: "所属工位号(过程巡检所在工位)", Default: 0},
{Name: "step_id", Type: field.TypeInt, Comment: "工艺步骤ID(过程巡检逐条关联)", Default: 0},
{Name: "step_name", Type: field.TypeString, Size: 128, Comment: "工艺步骤名称", Default: ""},
{Name: "measured_value", Type: field.TypeString, Size: 64, Comment: "实测值(过程巡检录入)", Default: ""},
{Name: "report_no", Type: field.TypeString, Size: 64, Comment: "报检单号", Default: ""},
{Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码(图号)", Default: ""},
{Name: "material_name", Type: field.TypeString, Size: 128, Comment: "物料名称", Default: ""},
{Name: "manufacturer", Type: field.TypeString, Size: 128, Comment: "生产厂家", Default: ""},
{Name: "inspection_no", Type: field.TypeString, Size: 64, Comment: "检验单号", Default: ""},
{Name: "attachment_ids", Type: field.TypeString, Size: 512, Comment: "附件ID,逗号分隔(关联 attachment 表)", Default: ""},
{Name: "disposal_type", Type: field.TypeString, Size: 20, Comment: "处置类型 退货/返修/退换/报废", Default: ""},
{Name: "disposal_remark", Type: field.TypeString, Size: 500, Comment: "处置说明", Default: ""},
{Name: "batch_sn", Type: field.TypeString, Nullable: true, Size: 128, Comment: "批次号/SN(联动 WMS 在库处置:序列号=是=SN 序列号=否=批次)"},
{Name: "related_standard", Type: field.TypeString, Nullable: true, Size: 255, Comment: "相关标准/试验方案号(完工检用,随成品回流 WMS)"},
{Name: "test_record_no", Type: field.TypeString, Nullable: true, Size: 128, Comment: "试验记录单号(完工检用,随成品回流 WMS)"},
{Name: "created_at", Type: field.TypeTime},
}
// InspectionRecordTable holds the schema information for the "inspection_record" table.
InspectionRecordTable = &schema.Table{
Name: "inspection_record",
Comment: "InspectionRecord 巡检与质量检验记录(PAD 巡检终端 + MES 质量检验录入共用):",
Columns: InspectionRecordColumns,
PrimaryKey: []*schema.Column{InspectionRecordColumns[0]},
Indexes: []*schema.Index{
{
Name: "inspectionrecord_category",
Unique: false,
Columns: []*schema.Column{InspectionRecordColumns[1]},
},
{
Name: "inspectionrecord_station_no",
Unique: false,
Columns: []*schema.Column{InspectionRecordColumns[2]},
},
{
Name: "inspectionrecord_order_no",
Unique: false,
Columns: []*schema.Column{InspectionRecordColumns[4]},
},
{
Name: "inspectionrecord_operator",
Unique: false,
Columns: []*schema.Column{InspectionRecordColumns[10]},
},
},
}
// LinePointColumns holds the columns for the "line_point" table.
LinePointColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "point_type", Type: field.TypeString, Size: 20, Comment: "FEED上料位/STATION工位/CACHE缓存位/DOCK接驳台/END末端"},
{Name: "point_no", Type: field.TypeString, Size: 32, Comment: "点位编号:IN上料位 / 1~10工位 / C1~C8缓存位 / 1-R1接驳台 / END-U上排末端 / END-D下排末端"},
{Name: "label", Type: field.TypeString, Size: 64, Comment: "点位名称", Default: ""},
{Name: "seq", Type: field.TypeInt, Comment: "传送带顺序(上料位→工位→末端,用于相邻缓存位判定)", Default: 0},
{Name: "station_no", Type: field.TypeInt, Comment: "所属工位号(DOCK/CACHE 归属;0=无)", Default: 0},
{Name: "current_sn", Type: field.TypeString, Size: 128, Comment: "当前存放工件SN(空=空闲)", Default: ""},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "当前工件所属工单号", Default: ""},
{Name: "occupied", Type: field.TypeBool, Comment: "是否占用", Default: false},
{Name: "updated_at", Type: field.TypeTime},
}
// LinePointTable holds the schema information for the "line_point" table.
LinePointTable = &schema.Table{
Name: "line_point",
Comment: "LinePoint 产线点位台账:记录每个点位当前存放的工件(唯一事实源)。",
Columns: LinePointColumns,
PrimaryKey: []*schema.Column{LinePointColumns[0]},
Indexes: []*schema.Index{
{
Name: "linepoint_point_type_point_no",
Unique: true,
Columns: []*schema.Column{LinePointColumns[1], LinePointColumns[2]},
},
},
}
// MaterialsColumns holds the columns for the "materials" table.
MaterialsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "code", Type: field.TypeString, Unique: true, Size: 64, Comment: "物料编码(图号),两库同步唯一业务键"},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "物料名称"},
{Name: "spec", Type: field.TypeString, Size: 128, Comment: "规格型号", Default: ""},
{Name: "unit", Type: field.TypeString, Size: 32, Comment: "计量单位", Default: ""},
{Name: "description", Type: field.TypeString, Size: 255, Comment: "说明", Default: ""},
{Name: "item_type", Type: field.TypeInt, Comment: "物料类别 1原材料/3成品/4其他(半成品不是物料物料类别)", Default: 1},
{Name: "manage_mode", Type: field.TypeInt, Comment: "类型 1结构件/2电气件/3其他(仅分类,不决定SN行为)", Default: 1},
{Name: "sn_mode", Type: field.TypeInt, Comment: "是否逐件SN管理 0未选择(必填)/1序列号=是(录SN)/2序列号=否(不录SN)", Default: 0},
{Name: "template_code", Type: field.TypeString, Size: 64, Comment: "模板编码", Default: ""},
{Name: "safety_stock", Type: field.TypeInt, Comment: "安全库存(低于触发缺货预警)", Default: 0},
{Name: "is_active", Type: field.TypeBool, Comment: "启用/停用(两库均不物理删除)", Default: true},
{Name: "sync_pending", Type: field.TypeBool, Comment: "推送WMS失败标记,列表请求时异步重推", Default: false},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
}
// MaterialsTable holds the schema information for the "materials" table.
MaterialsTable = &schema.Table{
Name: "materials",
Comment: "Material 物料主数据 MES 本地副本(两库对等双向同步,2026-09-29 定稿 M1)。",
Columns: MaterialsColumns,
PrimaryKey: []*schema.Column{MaterialsColumns[0]},
Indexes: []*schema.Index{
{
Name: "material_code",
Unique: true,
Columns: []*schema.Column{MaterialsColumns[1]},
},
{
Name: "material_item_type",
Unique: false,
Columns: []*schema.Column{MaterialsColumns[6]},
},
},
}
// MaterialQtyReportColumns holds the columns for the "material_qty_report" table.
MaterialQtyReportColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "station_no", Type: field.TypeInt, Comment: "工位号", Default: 0},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号", Default: ""},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN", Default: ""},
{Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码", Default: ""},
{Name: "material_name", Type: field.TypeString, Size: 128, Comment: "物料名称", Default: ""},
{Name: "plan_qty", Type: field.TypeInt, Comment: "应发数量", Default: 0},
{Name: "actual_qty", Type: field.TypeInt, Comment: "实收数量", Default: 0},
{Name: "diff_qty", Type: field.TypeInt, Comment: "差异=应发-实收", Default: 0},
{Name: "cause", Type: field.TypeString, Size: 255, Comment: "差异原因", Default: ""},
{Name: "status", Type: field.TypeString, Size: 16, Comment: "PENDING/PROCESSING/REPLENISHED/RETURNED/ADJUSTED/CLOSED", Default: "PENDING"},
{Name: "handle_type", Type: field.TypeString, Size: 16, Comment: "处理方式 REPLENISH补发/RETURN退库/ADJUST调整", Default: ""},
{Name: "handle_doc_no", Type: field.TypeString, Size: 64, Comment: "处理生成的单据号(补料单号/退库单号)", Default: ""},
{Name: "handle_note", Type: field.TypeString, Size: 255, Comment: "处理说明", Default: ""},
{Name: "handled_by", Type: field.TypeString, Size: 64, Comment: "处理人", Default: ""},
{Name: "handled_at", Type: field.TypeInt64, Comment: "处理时间(unix 秒)", Default: 0},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "上报人", Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "resolved_at", Type: field.TypeTime, Nullable: true},
}
// MaterialQtyReportTable holds the schema information for the "material_qty_report" table.
MaterialQtyReportTable = &schema.Table{
Name: "material_qty_report",
Comment: "MaterialQtyReport 工位数量不符上报(客户诉求 问题记录 L482/L486):",
Columns: MaterialQtyReportColumns,
PrimaryKey: []*schema.Column{MaterialQtyReportColumns[0]},
Indexes: []*schema.Index{
{
Name: "materialqtyreport_status",
Unique: false,
Columns: []*schema.Column{MaterialQtyReportColumns[10]},
},
{
Name: "materialqtyreport_station_no",
Unique: false,
Columns: []*schema.Column{MaterialQtyReportColumns[1]},
},
{
Name: "materialqtyreport_order_no",
Unique: false,
Columns: []*schema.Column{MaterialQtyReportColumns[2]},
},
{
Name: "materialqtyreport_created_at",
Unique: false,
Columns: []*schema.Column{MaterialQtyReportColumns[17]},
},
},
}
// MaterialRequestColumns holds the columns for the "material_request" table.
MaterialRequestColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "request_no", Type: field.TypeString, Size: 64, Comment: "备料单号"},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号"},
{Name: "plan_date", Type: field.TypeString, Size: 10, Comment: "对应排产日"},
{Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码"},
{Name: "material_name", Type: field.TypeString, Size: 128, Default: ""},
{Name: "unit", Type: field.TypeString, Size: 16, Default: ""},
{Name: "sn_mode", Type: field.TypeInt, Default: 2},
{Name: "req_qty", Type: field.TypeFloat64, Comment: "需备数量", Default: 0},
{Name: "status", Type: field.TypeString, Size: 20, Default: "PENDING"},
{Name: "target_dock", Type: field.TypeString, Size: 20, Comment: "目标接驳台 DOCK01..20", Default: ""},
{Name: "station_no", Type: field.TypeInt, Comment: "目标工位号(0=未指定)", Default: 0},
{Name: "flow_id", Type: field.TypeInt, Comment: "该物料所属工艺ID(0=整线共用)", Default: 0},
{Name: "sent_qty", Type: field.TypeFloat64, Comment: "已发出量(分批出库累加;幂等基准,勿与已接料混用)", Default: 0},
{Name: "received_qty", Type: field.TypeFloat64, Comment: "已接料量(工位扫码接料累加)", Default: 0},
{Name: "received_at", Type: field.TypeInt64, Comment: "最近接料时间(unix 秒)", Default: 0},
{Name: "receive_by", Type: field.TypeString, Size: 64, Comment: "接料人", Default: ""},
{Name: "source", Type: field.TypeString, Size: 16, Comment: "来源 PLAN/REFILL", Default: "PLAN"},
{Name: "over_qty", Type: field.TypeFloat64, Comment: "超出 物料清单需求的数量", Default: 0},
{Name: "over_reason", Type: field.TypeString, Size: 64, Comment: "超领原因 损耗/报废/返修/其他", Default: ""},
{Name: "ref_report_no", Type: field.TypeString, Size: 64, Comment: "关联数量不符单号", Default: ""},
{Name: "need_agv", Type: field.TypeBool, Comment: "是否需要AGV配送到接驳台", Default: false},
{Name: "batch_no", Type: field.TypeString, Size: 64, Comment: "发料批次号(分批出库时填写)", Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// MaterialRequestTable holds the schema information for the "material_request" table.
MaterialRequestTable = &schema.Table{
Name: "material_request",
Comment: "MaterialRequest 备料单:按日排产自动算料生成",
Columns: MaterialRequestColumns,
PrimaryKey: []*schema.Column{MaterialRequestColumns[0]},
Indexes: []*schema.Index{
{
Name: "materialrequest_order_no",
Unique: false,
Columns: []*schema.Column{MaterialRequestColumns[2]},
},
{
Name: "materialrequest_material_code",
Unique: false,
Columns: []*schema.Column{MaterialRequestColumns[4]},
},
{
Name: "materialrequest_status",
Unique: false,
Columns: []*schema.Column{MaterialRequestColumns[9]},
},
},
}
// PermissionColumns holds the columns for the "permission" table.
PermissionColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "code", Type: field.TypeString, Unique: true, Size: 64, Comment: "权限编码"},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "名称"},
{Name: "type", Type: field.TypeString, Size: 20, Default: "MENU"},
{Name: "parent_code", Type: field.TypeString, Size: 64, Comment: "所属菜单权限码(按钮必填)", Default: ""},
{Name: "path", Type: field.TypeString, Size: 128, Comment: "前端路由", Default: ""},
{Name: "icon", Type: field.TypeString, Size: 64, Default: ""},
{Name: "sort", Type: field.TypeInt, Nullable: true, Default: 0},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// PermissionTable holds the schema information for the "permission" table.
PermissionTable = &schema.Table{
Name: "permission",
Comment: "Permission 权限/菜单",
Columns: PermissionColumns,
PrimaryKey: []*schema.Column{PermissionColumns[0]},
Indexes: []*schema.Index{
{
Name: "permission_code",
Unique: true,
Columns: []*schema.Column{PermissionColumns[1]},
},
},
}
// PlcSendLogColumns holds the columns for the "plc_send_log" table.
PlcSendLogColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号", Default: ""},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN", Default: ""},
{Name: "station_no", Type: field.TypeInt, Nullable: true, Comment: "工位号"},
{Name: "process_combination", Type: field.TypeString, Size: 64, Comment: "工序组合,如 135", Default: ""},
{Name: "process_codes", Type: field.TypeJSON, Nullable: true, Comment: "工序码表"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "PENDING"},
{Name: "send_time", Type: field.TypeTime, Nullable: true, Comment: "下发时间"},
{Name: "done_time", Type: field.TypeTime, Nullable: true, Comment: "收到完成信号时间"},
{Name: "ack", Type: field.TypeBool, Comment: "是否收到完成信号", Default: false},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// PlcSendLogTable holds the schema information for the "plc_send_log" table.
PlcSendLogTable = &schema.Table{
Name: "plc_send_log",
Comment: "PlcSendLog PLC 工序码下发日志",
Columns: PlcSendLogColumns,
PrimaryKey: []*schema.Column{PlcSendLogColumns[0]},
Indexes: []*schema.Index{
{
Name: "plcsendlog_order_no",
Unique: false,
Columns: []*schema.Column{PlcSendLogColumns[1]},
},
{
Name: "plcsendlog_sn",
Unique: false,
Columns: []*schema.Column{PlcSendLogColumns[2]},
},
{
Name: "plcsendlog_status",
Unique: false,
Columns: []*schema.Column{PlcSendLogColumns[6]},
},
},
}
// ProcessFlowColumns holds the columns for the "process_flow" table.
ProcessFlowColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "流程名称,如 3号工位装配流程"},
{Name: "pdf_file", Type: field.TypeString, Size: 255, Comment: "工艺图纸文件名", Default: ""},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ACTIVE"},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// ProcessFlowTable holds the schema information for the "process_flow" table.
ProcessFlowTable = &schema.Table{
Name: "process_flow",
Comment: "ProcessFlow 工艺流程图(菜谱):描述“这个工位怎么干”,承载工艺图纸 PDF + 工序步骤模板。",
Columns: ProcessFlowColumns,
PrimaryKey: []*schema.Column{ProcessFlowColumns[0]},
Indexes: []*schema.Index{
{
Name: "processflow_status",
Unique: false,
Columns: []*schema.Column{ProcessFlowColumns[3]},
},
},
}
// ProcessStepColumns holds the columns for the "process_step" table.
ProcessStepColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "flow_id", Type: field.TypeInt, Nullable: true, Comment: "所属工艺流程图ID"},
{Name: "seq", Type: field.TypeInt, Comment: "步骤序号", Default: 1},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "步骤名称"},
{Name: "collect_type", Type: field.TypeString, Size: 20, Comment: "AUTO/MANUAL/NONE", Default: "NONE"},
{Name: "is_torque", Type: field.TypeBool, Comment: "是否拧紧采集", Default: false},
{Name: "need_check", Type: field.TypeBool, Comment: "是否需要检测确认(报工前须检验通过)", Default: false},
{Name: "need_operator_sign", Type: field.TypeBool, Comment: "是否需要操作工签字(报工前须签字确认)", Default: false},
{Name: "need_inspector_sign", Type: field.TypeBool, Comment: "是否需要检验员签字(审核通过并签字后放行)", Default: false},
{Name: "need_audit", Type: field.TypeBool, Comment: "是否需要审核人复核签字(审核通过后放行)", Default: false},
{Name: "audit_role", Type: field.TypeString, Nullable: true, Size: 64, Comment: "审核角色(如班组长/工艺员),具该角色的人员可签", Default: ""},
{Name: "attachment", Type: field.TypeJSON, Nullable: true, Comment: "本步骤图纸/附件列表 [{name,url}]", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// ProcessStepTable holds the schema information for the "process_step" table.
ProcessStepTable = &schema.Table{
Name: "process_step",
Comment: "ProcessStep 工序步骤模板:一份工艺流程包含多个采集/考核步骤(按 seq 顺序执行)",
Columns: ProcessStepColumns,
PrimaryKey: []*schema.Column{ProcessStepColumns[0]},
Indexes: []*schema.Index{
{
Name: "processstep_flow_id",
Unique: false,
Columns: []*schema.Column{ProcessStepColumns[1]},
},
},
}
// ProductProcessColumns holds the columns for the "product_process" table.
ProductProcessColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码(WMS 物料档案 item_type=3 图号)"},
{Name: "product_name", Type: field.TypeString, Size: 128, Comment: "产品名称(快照,WMS 改名不回写)", Default: ""},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "产品工艺名称,如 DX100常规"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ACTIVE"},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// ProductProcessTable holds the schema information for the "product_process" table.
ProductProcessTable = &schema.Table{
Name: "product_process",
Comment: "ProductProcess 产品工艺:产品级工艺定义(有序工艺集合,不绑工位;建工单时推导工位并复制为工艺组合快照)",
Columns: ProductProcessColumns,
PrimaryKey: []*schema.Column{ProductProcessColumns[0]},
Indexes: []*schema.Index{
{
Name: "productprocess_product_code",
Unique: false,
Columns: []*schema.Column{ProductProcessColumns[1]},
},
},
}
// ProductProcessItemColumns holds the columns for the "product_process_item" table.
ProductProcessItemColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_process_id", Type: field.TypeInt, Comment: "所属产品工艺ID"},
{Name: "seq", Type: field.TypeInt, Comment: "顺序号(从1严格递增,即执行顺序)"},
{Name: "flow_id", Type: field.TypeInt, Comment: "工艺ID(process_flow)"},
{Name: "created_at", Type: field.TypeTime},
}
// ProductProcessItemTable holds the schema information for the "product_process_item" table.
ProductProcessItemTable = &schema.Table{
Name: "product_process_item",
Comment: "ProductProcessItem 产品工艺明细:有序工艺执行点(seq 严格递增=串行;工位建单时推导,不落本表)",
Columns: ProductProcessItemColumns,
PrimaryKey: []*schema.Column{ProductProcessItemColumns[0]},
Indexes: []*schema.Index{
{
Name: "productprocessitem_product_process_id",
Unique: false,
Columns: []*schema.Column{ProductProcessItemColumns[1]},
},
{
Name: "productprocessitem_product_process_id_flow_id",
Unique: true,
Columns: []*schema.Column{ProductProcessItemColumns[1], ProductProcessItemColumns[3]},
},
},
}
// RoleColumns holds the columns for the "role" table.
RoleColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "角色名称"},
{Name: "code", Type: field.TypeString, Unique: true, Size: 64, Comment: "角色编码"},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "permission_codes", Type: field.TypeJSON, Nullable: true, Comment: "权限编码列表,如 produce.workorder:view", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "created_at", Type: field.TypeTime},
}
// RoleTable holds the schema information for the "role" table.
RoleTable = &schema.Table{
Name: "role",
Comment: "Role 角色:承载菜单/按钮权限",
Columns: RoleColumns,
PrimaryKey: []*schema.Column{RoleColumns[0]},
Indexes: []*schema.Index{
{
Name: "role_code",
Unique: true,
Columns: []*schema.Column{RoleColumns[2]},
},
},
}
// SemiFlowColumns holds the columns for the "semi_flow" table.
SemiFlowColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"},
{Name: "order_no", Type: field.TypeString, Size: 64, Default: ""},
{Name: "done_process_codes", Type: field.TypeJSON, Nullable: true, Comment: "已完成工序码(已废除,历史数据保留)"},
{Name: "completed_text", Type: field.TypeString, Size: 64, Comment: "完成至工位快照(如:已完成至工位3;空=尚未报工)", Default: ""},
{Name: "action", Type: field.TypeString, Size: 20, Default: "INBOUND"},
{Name: "target_dock", Type: field.TypeString, Size: 20, Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// SemiFlowTable holds the schema information for the "semi_flow" table.
SemiFlowTable = &schema.Table{
Name: "semi_flow",
Comment: "SemiFlow 半成品流转记录:进度快照(完成至工位N),调用 WMS /api/internal/semi/*",
Columns: SemiFlowColumns,
PrimaryKey: []*schema.Column{SemiFlowColumns[0]},
Indexes: []*schema.Index{
{
Name: "semiflow_sn",
Unique: false,
Columns: []*schema.Column{SemiFlowColumns[1]},
},
{
Name: "semiflow_order_no",
Unique: false,
Columns: []*schema.Column{SemiFlowColumns[2]},
},
{
Name: "semiflow_action",
Unique: false,
Columns: []*schema.Column{SemiFlowColumns[5]},
},
},
}
// StationColumns holds the columns for the "station" table.
StationColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "station_no", Type: field.TypeInt, Unique: true, Comment: "工位号 1..12"},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "工位名称", Default: ""},
{Name: "flow_id", Type: field.TypeInt, Nullable: true, Comment: "绑定工艺流程图ID"},
{Name: "station_type", Type: field.TypeString, Size: 20, Comment: "工位类型 LINE/OFFLINE", Default: "LINE"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ENABLED"},
{Name: "is_builtin", Type: field.TypeBool, Comment: "内置工位:不可改类型/不可删除", Default: false},
{Name: "visible_tabs", Type: field.TypeJSON, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
}
// StationTable holds the schema information for the "station" table.
StationTable = &schema.Table{
Name: "station",
Comment: "Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)",
Columns: StationColumns,
PrimaryKey: []*schema.Column{StationColumns[0]},
Indexes: []*schema.Index{
{
Name: "station_station_no",
Unique: true,
Columns: []*schema.Column{StationColumns[1]},
},
},
}
// StationStateColumns holds the columns for the "station_state" table.
StationStateColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "station_no", Type: field.TypeInt, Comment: "工位号"},
{Name: "date", Type: field.TypeString, Size: 10, Comment: "生效日期 yyyy-MM-dd(只认当天)"},
{Name: "paused", Type: field.TypeBool, Comment: "是否停止接单", Default: false},
{Name: "reason", Type: field.TypeString, Size: 255, Comment: "停单原因(缺料/故障/其他)", Default: ""},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// StationStateTable holds the schema information for the "station_state" table.
StationStateTable = &schema.Table{
Name: "station_state",
Comment: "StationState 工位运行状态(当日有效):工人自主 停止接单/恢复接单。",
Columns: StationStateColumns,
PrimaryKey: []*schema.Column{StationStateColumns[0]},
Indexes: []*schema.Index{
{
Name: "stationstate_station_no_date",
Unique: true,
Columns: []*schema.Column{StationStateColumns[1], StationStateColumns[2]},
},
},
}
// StepCriterionColumns holds the columns for the "step_criterion" table.
StepCriterionColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "step_id", Type: field.TypeInt, Comment: "步骤ID"},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "指标名,如 扭矩/角度"},
{Name: "unit", Type: field.TypeString, Size: 16, Default: ""},
{Name: "logic", Type: field.TypeString, Size: 16, Default: "NONE"},
{Name: "target", Type: field.TypeFloat64, Comment: "目标值", Default: 0},
{Name: "min", Type: field.TypeFloat64, Nullable: true, Comment: "范围下限"},
{Name: "max", Type: field.TypeFloat64, Nullable: true, Comment: "范围上限"},
{Name: "created_at", Type: field.TypeTime},
}
// StepCriterionTable holds the schema information for the "step_criterion" table.
StepCriterionTable = &schema.Table{
Name: "step_criterion",
Comment: "StepCriterion 工序步骤考核标准:如 扭矩在RANGE[35,45] 自动判定 OK",
Columns: StepCriterionColumns,
PrimaryKey: []*schema.Column{StepCriterionColumns[0]},
Indexes: []*schema.Index{
{
Name: "stepcriterion_step_id",
Unique: false,
Columns: []*schema.Column{StepCriterionColumns[1]},
},
},
}
// StepDataColumns holds the columns for the "step_data" table.
StepDataColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"},
{Name: "process_id", Type: field.TypeInt, Nullable: true, Comment: "工件工序实绩ID"},
{Name: "step_id", Type: field.TypeInt, Comment: "步骤ID"},
{Name: "step_name", Type: field.TypeString, Size: 128, Default: ""},
{Name: "criterion_id", Type: field.TypeInt, Nullable: true, Comment: "考核标准ID"},
{Name: "criterion_name", Type: field.TypeString, Size: 64, Default: ""},
{Name: "criterion_logic", Type: field.TypeString, Size: 16, Default: "NONE"},
{Name: "value", Type: field.TypeFloat64, Comment: "实际测量值", Default: 0},
{Name: "value_text", Type: field.TypeString, Size: 64, Comment: "文本值(OK/NG/钢印号)", Default: ""},
{Name: "is_ok", Type: field.TypeBool, Comment: "是否合格(可人工修正)", Default: true},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// StepDataTable holds the schema information for the "step_data" table.
StepDataTable = &schema.Table{
Name: "step_data",
Comment: "StepData 步骤考核数据:某工件某工序步骤采集/手填实际值,按考核标准判定 OK/NG",
Columns: StepDataColumns,
PrimaryKey: []*schema.Column{StepDataColumns[0]},
Indexes: []*schema.Index{
{
Name: "stepdata_sn",
Unique: false,
Columns: []*schema.Column{StepDataColumns[1]},
},
{
Name: "stepdata_process_id",
Unique: false,
Columns: []*schema.Column{StepDataColumns[2]},
},
{
Name: "stepdata_step_id",
Unique: false,
Columns: []*schema.Column{StepDataColumns[3]},
},
},
}
// StepSignRecordColumns holds the columns for the "step_sign_record" table.
StepSignRecordColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN", Default: ""},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号", Default: ""},
{Name: "flow_id", Type: field.TypeInt, Comment: "工艺流程ID", Default: 0},
{Name: "station_no", Type: field.TypeString, Size: 32, Comment: "工位号", Default: ""},
{Name: "step_id", Type: field.TypeInt, Comment: "工艺步骤ID", Default: 0},
{Name: "step_name", Type: field.TypeString, Size: 128, Comment: "步骤名称", Default: ""},
{Name: "sign_role", Type: field.TypeString, Size: 16, Comment: "签字角色 OPERATOR/INSPECTOR", Default: "OPERATOR"},
{Name: "result", Type: field.TypeString, Size: 10, Comment: "签字时点的结论 OK/NG", Default: "OK"},
{Name: "signed_by", Type: field.TypeString, Size: 64, Comment: "签字人(登录账号)", Default: ""},
{Name: "signed_at", Type: field.TypeTime, Comment: "签字时间"},
{Name: "round", Type: field.TypeInt, Comment: "返修重做轮次(1=首做)", Default: 1},
{Name: "source", Type: field.TypeString, Size: 20, Comment: "签字来源 station/inspect/migrate", Default: "station"},
{Name: "remark", Type: field.TypeString, Size: 256, Comment: "签字备注(签字弹框选填)", Default: ""},
{Name: "revoked", Type: field.TypeBool, Comment: "是否已撤销", Default: false},
{Name: "revoked_by", Type: field.TypeString, Size: 64, Comment: "撤销人", Default: ""},
{Name: "revoked_at", Type: field.TypeTime, Nullable: true, Comment: "撤销时间"},
{Name: "revoke_reason", Type: field.TypeString, Size: 256, Comment: "撤销原因", Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// StepSignRecordTable holds the schema information for the "step_sign_record" table.
StepSignRecordTable = &schema.Table{
Name: "step_sign_record",
Comment: "StepSignRecord 步骤签字记录:工艺步骤配置 need_operator_sign/need_inspector_sign 后,",
Columns: StepSignRecordColumns,
PrimaryKey: []*schema.Column{StepSignRecordColumns[0]},
Indexes: []*schema.Index{
{
Name: "stepsignrecord_sn_station_no_step_id_sign_role_round",
Unique: true,
Columns: []*schema.Column{StepSignRecordColumns[1], StepSignRecordColumns[4], StepSignRecordColumns[5], StepSignRecordColumns[7], StepSignRecordColumns[11]},
},
{
Name: "stepsignrecord_sn",
Unique: false,
Columns: []*schema.Column{StepSignRecordColumns[1]},
},
{
Name: "stepsignrecord_order_no",
Unique: false,
Columns: []*schema.Column{StepSignRecordColumns[2]},
},
},
}
// SysConfigColumns holds the columns for the "sys_config" table.
SysConfigColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "key", Type: field.TypeString, Unique: true, Size: 64, Comment: "配置键,如 wms.base_url"},
{Name: "value", Type: field.TypeString, Size: 512, Comment: "配置值"},
{Name: "remark", Type: field.TypeString, Nullable: true, Size: 255, Comment: "说明"},
}
// SysConfigTable holds the schema information for the "sys_config" table.
SysConfigTable = &schema.Table{
Name: "sys_config",
Comment: "SysConfig 系统基础设置(key/value)。",
Columns: SysConfigColumns,
PrimaryKey: []*schema.Column{SysConfigColumns[0]},
}
// TorqueRecordColumns holds the columns for the "torque_record" table.
TorqueRecordColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "workOrder 工单号", Default: ""},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"},
{Name: "screw_no", Type: field.TypeString, Size: 32, Comment: "螺丝编号 S1..Sn", Default: ""},
{Name: "strain", Type: field.TypeFloat64, Comment: "扭矩 Nm", Default: 0},
{Name: "torque", Type: field.TypeFloat64, Comment: "扭矩别名,与 strain 一致", Default: 0},
{Name: "angle", Type: field.TypeFloat64, Comment: "角度 °", Default: 0},
{Name: "result", Type: field.TypeString, Size: 10, Default: "OK"},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""},
{Name: "operator_id", Type: field.TypeInt, Comment: "操作人用户ID(0=未采集:虚拟工位/PLC路径或历史数据)", Default: 0},
{Name: "station_no", Type: field.TypeString, Size: 32, Comment: "工位", Default: ""},
{Name: "time", Type: field.TypeTime, Comment: "采集时间"},
{Name: "created_at", Type: field.TypeTime},
}
// TorqueRecordTable holds the schema information for the "torque_record" table.
TorqueRecordTable = &schema.Table{
Name: "torque_record",
Comment: "TorqueRecord 拧紧数据(工位终端上报,sn,strain扭矩,angle角度,result,operator,workOrder,time)",
Columns: TorqueRecordColumns,
PrimaryKey: []*schema.Column{TorqueRecordColumns[0]},
Indexes: []*schema.Index{
{
Name: "torquerecord_sn",
Unique: false,
Columns: []*schema.Column{TorqueRecordColumns[2]},
},
{
Name: "torquerecord_work_order_no",
Unique: false,
Columns: []*schema.Column{TorqueRecordColumns[1]},
},
{
Name: "torquerecord_created_at",
Unique: false,
Columns: []*schema.Column{TorqueRecordColumns[12]},
},
{
Name: "torquerecord_time",
Unique: false,
Columns: []*schema.Column{TorqueRecordColumns[11]},
},
},
}
// UserColumns holds the columns for the "user" table.
UserColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "username", Type: field.TypeString, Unique: true, Size: 64, Comment: "登录名"},
{Name: "password", Type: field.TypeString, Size: 128, Comment: "bcrypt 密码"},
{Name: "name", Type: field.TypeString, Size: 64, Comment: "姓名/显示名", Default: ""},
{Name: "role_id", Type: field.TypeInt, Nullable: true, Comment: "角色ID"},
{Name: "can_login_workstation", Type: field.TypeBool, Comment: "是否允许登录工位终端", Default: false},
{Name: "workstation_password", Type: field.TypeString, Nullable: true, Size: 128, Comment: "工位终端密码(bcrypt)"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ENABLED"},
{Name: "last_login_at", Type: field.TypeInt64, Nullable: true, Comment: "最近登录时间(unix秒,后台登录更新;工位终端登录不计)"},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// UserTable holds the schema information for the "user" table.
UserTable = &schema.Table{
Name: "user",
Comment: "User 用户",
Columns: UserColumns,
PrimaryKey: []*schema.Column{UserColumns[0]},
Indexes: []*schema.Index{
{
Name: "user_username",
Unique: true,
Columns: []*schema.Column{UserColumns[1]},
},
{
Name: "user_role_id",
Unique: false,
Columns: []*schema.Column{UserColumns[4]},
},
},
}
// UserStationColumns holds the columns for the "user_station" table.
UserStationColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "user_id", Type: field.TypeInt, Comment: "用户ID"},
{Name: "station_no", Type: field.TypeInt, Comment: "工位号 1..12"},
{Name: "created_at", Type: field.TypeTime},
}
// UserStationTable holds the schema information for the "user_station" table.
UserStationTable = &schema.Table{
Name: "user_station",
Comment: "UserStation 用户-工位 关联(一个操作员可绑定多个工位)",
Columns: UserStationColumns,
PrimaryKey: []*schema.Column{UserStationColumns[0]},
Indexes: []*schema.Index{
{
Name: "userstation_user_id",
Unique: false,
Columns: []*schema.Column{UserStationColumns[1]},
},
{
Name: "userstation_station_no",
Unique: false,
Columns: []*schema.Column{UserStationColumns[2]},
},
{
Name: "userstation_user_id_station_no",
Unique: true,
Columns: []*schema.Column{UserStationColumns[1], UserStationColumns[2]},
},
},
}
// WorkOrderColumns holds the columns for the "work_order" table.
WorkOrderColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "工单号"},
{Name: "product_type_id", Type: field.TypeInt, Comment: "产品类型ID"},
{Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码", Default: ""},
{Name: "product_name", Type: field.TypeString, Size: 128, Default: ""},
{Name: "quantity", Type: field.TypeInt, Comment: "工件数量", Default: 1},
{Name: "finished_num", Type: field.TypeInt, Comment: "完成数量", Default: 0},
{Name: "fail_num", Type: field.TypeInt, Comment: "NG数量", Default: 0},
{Name: "contract_no", Type: field.TypeString, Size: 64, Comment: "归属编号(合同号或科技项目号,随归属类型二选一)", Default: ""},
{Name: "ownership_type", Type: field.TypeString, Size: 20, Comment: "归属类型:workorder=合同号/project=科技项目号/other=其他", Default: ""},
{Name: "project_no", Type: field.TypeString, Size: 64, Comment: "工程编号(已废弃,保留防历史数据迁移)", Default: ""},
{Name: "product_serial", Type: field.TypeString, Size: 64, Comment: "产品序号(工单内每台产品的序号)", Default: ""},
{Name: "created_by", Type: field.TypeString, Size: 64, Comment: "创建人", Default: ""},
{Name: "due_date", Type: field.TypeTime, Nullable: true, Comment: "完成日期(必填)"},
{Name: "flow_combination", Type: field.TypeJSON, Nullable: true, Comment: "工艺组合 [{flowId,stationNo}] 按工位号升序", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "product_process_id", Type: field.TypeInt, Comment: "来源产品工艺ID(0=无来源)", Default: 0},
{Name: "status", Type: field.TypeString, Size: 20, Default: "CREATED"},
{Name: "plan_start", Type: field.TypeTime, Nullable: true, Comment: "计划开始"},
{Name: "plan_end", Type: field.TypeTime, Nullable: true, Comment: "计划结束"},
{Name: "context", Type: field.TypeJSON, Nullable: true, Comment: "扩展字段", SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "completed_at", Type: field.TypeTime, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// WorkOrderTable holds the schema information for the "work_order" table.
WorkOrderTable = &schema.Table{
Name: "work_order",
Comment: "WorkOrder 工单:一个合同 = 一个工单",
Columns: WorkOrderColumns,
PrimaryKey: []*schema.Column{WorkOrderColumns[0]},
Indexes: []*schema.Index{
{
Name: "workorder_work_order_no",
Unique: true,
Columns: []*schema.Column{WorkOrderColumns[1]},
},
{
Name: "workorder_status",
Unique: false,
Columns: []*schema.Column{WorkOrderColumns[16]},
},
{
Name: "workorder_product_type_id",
Unique: false,
Columns: []*schema.Column{WorkOrderColumns[2]},
},
},
}
// WorkpieceColumns holds the columns for the "workpiece" table.
WorkpieceColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Unique: true, Size: 64, Comment: "工件唯一SN"},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "所属工单", Default: ""},
{Name: "work_order_id", Type: field.TypeInt, Nullable: true, Comment: "工单ID"},
{Name: "current_station_no", Type: field.TypeInt, Nullable: true, Comment: "最后完成报工的工位号(0=未报任何工艺;下一道=工艺组合中工位号更大的下一条)"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ONLINE"},
{Name: "online_at", Type: field.TypeTime, Nullable: true, Comment: "进线时间"},
{Name: "done_at", Type: field.TypeTime, Nullable: true, Comment: "完工时间"},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime, Nullable: true},
}
// WorkpieceTable holds the schema information for the "workpiece" table.
WorkpieceTable = &schema.Table{
Name: "workpiece",
Comment: "Workpiece 工件(SN):序列号管理的成品/主件",
Columns: WorkpieceColumns,
PrimaryKey: []*schema.Column{WorkpieceColumns[0]},
Indexes: []*schema.Index{
{
Name: "workpiece_sn",
Unique: true,
Columns: []*schema.Column{WorkpieceColumns[1]},
},
{
Name: "workpiece_order_no",
Unique: false,
Columns: []*schema.Column{WorkpieceColumns[2]},
},
{
Name: "workpiece_status",
Unique: false,
Columns: []*schema.Column{WorkpieceColumns[5]},
},
},
}
// WorkpieceBindColumns holds the columns for the "workpiece_bind" table.
WorkpieceBindColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"},
{Name: "order_no", Type: field.TypeString, Size: 64, Comment: "工单号", Default: ""},
{Name: "flow_id", Type: field.TypeInt, Comment: "装配工艺ID"},
{Name: "station_no", Type: field.TypeString, Size: 32, Comment: "绑定工位", Default: ""},
{Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码"},
{Name: "material_name", Type: field.TypeString, Size: 128, Comment: "物料名称", Default: ""},
{Name: "spec", Type: field.TypeString, Size: 128, Comment: "规格", Default: ""},
{Name: "unit", Type: field.TypeString, Size: 16, Comment: "单位", Default: ""},
{Name: "sn_mode", Type: field.TypeInt, Default: 2},
{Name: "bind_value", Type: field.TypeString, Size: 128, Comment: "绑定值:批次号 或 SN"},
{Name: "bind_type", Type: field.TypeString, Size: 10, Default: "SN"},
{Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""},
{Name: "created_at", Type: field.TypeTime, Comment: "绑定时间"},
}
// WorkpieceBindTable holds the schema information for the "workpiece_bind" table.
WorkpieceBindTable = &schema.Table{
Name: "workpiece_bind",
Comment: "WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)",
Columns: WorkpieceBindColumns,
PrimaryKey: []*schema.Column{WorkpieceBindColumns[0]},
Indexes: []*schema.Index{
{
Name: "workpiecebind_sn",
Unique: false,
Columns: []*schema.Column{WorkpieceBindColumns[1]},
},
{
Name: "workpiecebind_sn_flow_id",
Unique: false,
Columns: []*schema.Column{WorkpieceBindColumns[1], WorkpieceBindColumns[3]},
},
{
Name: "workpiecebind_sn_material_code",
Unique: false,
Columns: []*schema.Column{WorkpieceBindColumns[1], WorkpieceBindColumns[5]},
},
{
Name: "workpiecebind_order_no",
Unique: false,
Columns: []*schema.Column{WorkpieceBindColumns[2]},
},
{
Name: "workpiecebind_material_code_bind_value",
Unique: false,
Columns: []*schema.Column{WorkpieceBindColumns[5], WorkpieceBindColumns[10]},
},
},
}
// WorkpieceProcessColumns holds the columns for the "workpiece_process" table.
WorkpieceProcessColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"},
{Name: "flow_id", Type: field.TypeInt, Comment: "完成的工艺ID"},
{Name: "station_no", Type: field.TypeString, Size: 32, Comment: "工位号", Default: ""},
{Name: "order_no", Type: field.TypeString, Size: 64, Default: ""},
{Name: "process_name", Type: field.TypeString, Size: 64, Default: ""},
{Name: "status", Type: field.TypeString, Size: 20, Default: "DONE"},
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
{Name: "operator_id", Type: field.TypeInt, Comment: "操作人用户ID(0=未采集:虚拟工位/PLC路径或历史数据)", Default: 0},
{Name: "result", Type: field.TypeString, Size: 10, Comment: "总判定 OK/NG", Default: "OK"},
{Name: "started_at", Type: field.TypeTime, Nullable: true},
{Name: "ended_at", Type: field.TypeTime, Nullable: true},
{Name: "duration_sec", Type: field.TypeInt, Comment: "作业时长(秒)=endedAt-startedAt", Default: 0},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
// WorkpieceProcessTable holds the schema information for the "workpiece_process" table.
WorkpieceProcessTable = &schema.Table{
Name: "workpiece_process",
Comment: "WorkpieceProcess 工件-工艺实绩(某工件在某工位完成某道工艺的一次记录,构成工艺时间线)。",
Columns: WorkpieceProcessColumns,
PrimaryKey: []*schema.Column{WorkpieceProcessColumns[0]},
Indexes: []*schema.Index{
{
Name: "workpieceprocess_sn",
Unique: false,
Columns: []*schema.Column{WorkpieceProcessColumns[1]},
},
{
Name: "workpieceprocess_sn_flow_id",
Unique: false,
Columns: []*schema.Column{WorkpieceProcessColumns[1], WorkpieceProcessColumns[2]},
},
{
Name: "workpieceprocess_sn_station_no",
Unique: false,
Columns: []*schema.Column{WorkpieceProcessColumns[1], WorkpieceProcessColumns[3]},
},
{
Name: "workpieceprocess_order_no",
Unique: false,
Columns: []*schema.Column{WorkpieceProcessColumns[4]},
},
{
Name: "workpieceprocess_station_no",
Unique: false,
Columns: []*schema.Column{WorkpieceProcessColumns[3]},
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
AlertTable,
AlertRuleTable,
AssociationTraceTable,
AttachmentTable,
DailyPlanTable,
DockTable,
EventLogTable,
FlowMaterialTable,
InspectionRecordTable,
LinePointTable,
MaterialsTable,
MaterialQtyReportTable,
MaterialRequestTable,
PermissionTable,
PlcSendLogTable,
ProcessFlowTable,
ProcessStepTable,
ProductProcessTable,
ProductProcessItemTable,
RoleTable,
SemiFlowTable,
StationTable,
StationStateTable,
StepCriterionTable,
StepDataTable,
StepSignRecordTable,
SysConfigTable,
TorqueRecordTable,
UserTable,
UserStationTable,
WorkOrderTable,
WorkpieceTable,
WorkpieceBindTable,
WorkpieceProcessTable,
}
)
func init() {
AlertTable.Annotation = &entsql.Annotation{
Table: "alert",
}
AlertRuleTable.Annotation = &entsql.Annotation{
Table: "alert_rule",
}
AssociationTraceTable.Annotation = &entsql.Annotation{
Table: "association_trace",
}
AttachmentTable.Annotation = &entsql.Annotation{
Table: "attachment",
}
DailyPlanTable.Annotation = &entsql.Annotation{
Table: "daily_plan",
}
DockTable.Annotation = &entsql.Annotation{
Table: "dock",
}
EventLogTable.Annotation = &entsql.Annotation{
Table: "event_log",
}
FlowMaterialTable.Annotation = &entsql.Annotation{
Table: "flow_material",
}
InspectionRecordTable.Annotation = &entsql.Annotation{
Table: "inspection_record",
}
LinePointTable.Annotation = &entsql.Annotation{
Table: "line_point",
}
MaterialsTable.Annotation = &entsql.Annotation{
Table: "materials",
}
MaterialQtyReportTable.Annotation = &entsql.Annotation{
Table: "material_qty_report",
}
MaterialRequestTable.Annotation = &entsql.Annotation{
Table: "material_request",
}
PermissionTable.Annotation = &entsql.Annotation{
Table: "permission",
}
PlcSendLogTable.Annotation = &entsql.Annotation{
Table: "plc_send_log",
}
ProcessFlowTable.Annotation = &entsql.Annotation{
Table: "process_flow",
}
ProcessStepTable.Annotation = &entsql.Annotation{
Table: "process_step",
}
ProductProcessTable.Annotation = &entsql.Annotation{
Table: "product_process",
}
ProductProcessItemTable.Annotation = &entsql.Annotation{
Table: "product_process_item",
}
RoleTable.Annotation = &entsql.Annotation{
Table: "role",
}
SemiFlowTable.Annotation = &entsql.Annotation{
Table: "semi_flow",
}
StationTable.Annotation = &entsql.Annotation{
Table: "station",
}
StationStateTable.Annotation = &entsql.Annotation{
Table: "station_state",
}
StepCriterionTable.Annotation = &entsql.Annotation{
Table: "step_criterion",
}
StepDataTable.Annotation = &entsql.Annotation{
Table: "step_data",
}
StepSignRecordTable.Annotation = &entsql.Annotation{
Table: "step_sign_record",
}
SysConfigTable.Annotation = &entsql.Annotation{
Table: "sys_config",
}
TorqueRecordTable.Annotation = &entsql.Annotation{
Table: "torque_record",
}
UserTable.Annotation = &entsql.Annotation{
Table: "user",
}
UserStationTable.Annotation = &entsql.Annotation{
Table: "user_station",
}
WorkOrderTable.Annotation = &entsql.Annotation{
Table: "work_order",
}
WorkpieceTable.Annotation = &entsql.Annotation{
Table: "workpiece",
}
WorkpieceBindTable.Annotation = &entsql.Annotation{
Table: "workpiece_bind",
}
WorkpieceProcessTable.Annotation = &entsql.Annotation{
Table: "workpiece_process",
}
}