// 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 ( // AgvPointColumns holds the columns for the "agv_point" table. AgvPointColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "position_code", Type: field.TypeString, Unique: true, Size: 32, Comment: "AGV 点位编码(硬件映射=送往 RCS 的目标坐标,软件不可改)"}, {Name: "name", Type: field.TypeString, Size: 64, Comment: "点位显示名称(可编辑)", Default: ""}, {Name: "is_dock", Type: field.TypeBool, Comment: "是否接驳台点位(true=绑定接驳台,false=纯待命/充电点位)", Default: false}, {Name: "dock_id", Type: field.TypeInt, Nullable: true, Comment: "绑定的接驳台 ID(is_dock=true 时硬件内置强绑定)"}, {Name: "enabled", Type: field.TypeBool, Comment: "是否启用(可编辑)", Default: true}, {Name: "created_at", Type: field.TypeTime}, } // AgvPointTable holds the schema information for the "agv_point" table. AgvPointTable = &schema.Table{ Name: "agv_point", Comment: "AgvPoint AGV 点位(硬件级别真源):点位编码与接驳台一一对应,软件仅可启用/停用与改显示名。", Columns: AgvPointColumns, PrimaryKey: []*schema.Column{AgvPointColumns[0]}, Indexes: []*schema.Index{ { Name: "agvpoint_position_code", Unique: true, Columns: []*schema.Column{AgvPointColumns[1]}, }, { Name: "agvpoint_is_dock", Unique: false, Columns: []*schema.Column{AgvPointColumns[3]}, }, { Name: "agvpoint_enabled", Unique: false, Columns: []*schema.Column{AgvPointColumns[5]}, }, }, } // AgvTasksColumns holds the columns for the "agv_tasks" table. AgvTasksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "task_no", Type: field.TypeString, Unique: true, Size: 64, Comment: "我方任务号(内部)"}, {Name: "hik_task_code", Type: field.TypeString, Size: 64, Comment: "RCS-Lite 任务单号(即我方 task_no,下发时透传 taskCode)", Default: ""}, {Name: "source_dock", Type: field.TypeString, Size: 20, Comment: "起点接驳台(空车段可为空=单点path由RCS派最近空闲车)", Default: ""}, {Name: "target_dock", Type: field.TypeString, Size: 20, Comment: "终点接驳台/点位 DOCK01..21 或 AGV-CHARGE01", Default: ""}, {Name: "materials_json", Type: field.TypeString, Size: 4000, Comment: "物料清单 JSON", Default: ""}, {Name: "related_request_no", Type: field.TypeString, Nullable: true, Size: 64, Comment: "关联叫料单号(MES material_request.requestNo)", Default: ""}, {Name: "related_outbound_no", Type: field.TypeString, Nullable: true, Size: 64, Comment: "关联出库单号(可选, WMS 回传)", Default: ""}, {Name: "status", Type: field.TypeString, Size: 20, Comment: "PENDING/FAILED/1已创建/2执行中/ARRIVED到位待令/5已取消/9已结束", Default: "PENDING"}, {Name: "kind", Type: field.TypeString, Size: 20, Comment: "段类型:GO_LOAD空车去装货点/TRANSPORT重载运输/EMPTY_RETURN空车回充/FREE人工自由调度单点段", Default: "TRANSPORT"}, {Name: "biz_type", Type: field.TypeString, Size: 20, Comment: "业务来源:CALL叫料/PALLET托盘回收/FREE自由调度", Default: "CALL"}, {Name: "biz_no", Type: field.TypeString, Size: 64, Comment: "业务单据号(叫料单号/托盘回收标识等)", Default: ""}, {Name: "chain_no", Type: field.TypeString, Size: 64, Comment: "任务链号(=首段taskNo,同链各段关联)", Default: ""}, {Name: "auto_end", Type: field.TypeBool, Comment: "到位自动结束(空车回充段=true,不停留待令)", Default: false}, {Name: "agv_code", Type: field.TypeString, Size: 32, Comment: "RCS 分配的车辆编号(任务分车后由回调/查询回写)", Default: ""}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "下发人", Default: ""}, {Name: "dispatched_at", Type: field.TypeInt64, Comment: "下发时间 unix秒", Default: 0}, {Name: "arrived_at", Type: field.TypeInt64, Comment: "到位时间 unix秒", Default: 0}, {Name: "remark", Type: field.TypeString, Nullable: true, Size: 500, Comment: "备注/失败原因", Default: ""}, {Name: "created_at", Type: field.TypeInt64, Comment: "创建时间"}, } // AgvTasksTable holds the schema information for the "agv_tasks" table. AgvTasksTable = &schema.Table{ Name: "agv_tasks", Comment: "AgvTask AGV 搬运任务记录:三段链模型(空车去程/重载运输/空车回充),到位进 ARRIVED 待人工确认。", Columns: AgvTasksColumns, PrimaryKey: []*schema.Column{AgvTasksColumns[0]}, Indexes: []*schema.Index{ { Name: "agvtask_task_no", Unique: true, Columns: []*schema.Column{AgvTasksColumns[1]}, }, { Name: "agvtask_target_dock", Unique: false, Columns: []*schema.Column{AgvTasksColumns[4]}, }, { Name: "agvtask_status", Unique: false, Columns: []*schema.Column{AgvTasksColumns[8]}, }, { Name: "agvtask_hik_task_code", Unique: false, Columns: []*schema.Column{AgvTasksColumns[2]}, }, }, } // AgvVehicleStateColumns holds the columns for the "agv_vehicle_state" table. AgvVehicleStateColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "agv_code", Type: field.TypeString, Unique: true, Size: 32, Comment: "车辆编号(RCS robotCode/agvCode;RCS 未分车时=DEFAULT 未知车辆)"}, {Name: "has_pallet", Type: field.TypeBool, Comment: "载货状态:true=有托盘(载货) false=空车", Default: false}, {Name: "source", Type: field.TypeString, Size: 20, Comment: "状态来源:AUTO_LOAD取货确认/AUTO_UNLOAD卸货确认/MANUAL人工维护", Default: "MANUAL"}, {Name: "updated_by", Type: field.TypeString, Size: 64, Comment: "最近更新人", Default: ""}, {Name: "updated_at", Type: field.TypeInt64, Comment: "最近更新时间 unix秒", Default: 0}, {Name: "remark", Type: field.TypeString, Size: 200, Comment: "备注(人工修改原因等)", Default: ""}, } // AgvVehicleStateTable holds the schema information for the "agv_vehicle_state" table. AgvVehicleStateTable = &schema.Table{ Name: "agv_vehicle_state", Comment: "AgvVehicleState AGV 载货状态台账:按 agv_code 逐台记录有托盘/空车,取货/卸货确认与人工维护写入,派车防撞校验消费。", Columns: AgvVehicleStateColumns, PrimaryKey: []*schema.Column{AgvVehicleStateColumns[0]}, } // 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: 255, 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: "通知渠道(物料清单无关;本字段为预警通知方式占位,逗号分隔,空=仅预警中心收件箱)", 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: "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: ""}, {Name: "deleted_reason", Type: field.TypeString, Size: 255, Comment: "删除说明(删除弹窗填写,警示留痕)", Default: ""}, {Name: "purged_at", Type: field.TypeInt64, Comment: "彻底清除时间(unix秒,仅删文件留索引)", Default: 0}, {Name: "purged_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]}, }, }, } // BackupRecordColumns holds the columns for the "backup_record" table. BackupRecordColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "executed_at", Type: field.TypeInt64, Comment: "备份执行时刻(unix秒)"}, {Name: "range_start", Type: field.TypeInt64, Comment: "备份范围开始(unix秒,含)"}, {Name: "range_end", Type: field.TypeInt64, Comment: "备份范围结束(unix秒,含)"}, {Name: "backup_path", Type: field.TypeString, Comment: "备份包(zip)在目标盘的完整路径"}, {Name: "total_size", Type: field.TypeInt64, Comment: "备份包总字节数", Default: 0}, {Name: "items_json", Type: field.TypeString, Comment: "各数据项及大小(JSON数组:[{name,rows,bytes}])"}, {Name: "status", Type: field.TypeString, Size: 16, Comment: "success/failed/partial/cleanup/cleanup_forced", Default: "success"}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""}, {Name: "checksum", Type: field.TypeString, Size: 64, Comment: "备份包校验和(sha256,基于 manifest)", Default: ""}, {Name: "scope", Type: field.TypeString, Size: 8, Comment: "写入方 mes/wms", Default: "mes"}, {Name: "ack_name", Type: field.TypeString, Size: 64, Comment: "强制清理时填写姓名(警示留痕,非强制清理为空)", Default: ""}, {Name: "ack_phone", Type: field.TypeString, Size: 32, Comment: "强制清理时填写手机号(警示留痕,非强制清理为空)", Default: ""}, } // BackupRecordTable holds the schema information for the "backup_record" table. BackupRecordTable = &schema.Table{ Name: "backup_record", Comment: "BackupRecord 备份记录:备份到外部存储写一条,清理前校验时间窗覆盖", Columns: BackupRecordColumns, PrimaryKey: []*schema.Column{BackupRecordColumns[0]}, Indexes: []*schema.Index{ { Name: "backuprecord_range_start", Unique: false, Columns: []*schema.Column{BackupRecordColumns[2]}, }, { Name: "backuprecord_range_end", Unique: false, Columns: []*schema.Column{BackupRecordColumns[3]}, }, { Name: "backuprecord_status", Unique: false, Columns: []*schema.Column{BackupRecordColumns[7]}, }, }, } // CallPoolColumns holds the columns for the "call_pool" table. CallPoolColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "station_no", Type: field.TypeInt, 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.TypeInt, Comment: "需求量(启用排产派生,逐行向上取整后合计)", Default: 0}, {Name: "adj_qty", Type: field.TypeInt, Comment: "人工调整量(可正可负;改动留痕 event_log)", Default: 0}, {Name: "sent_qty", Type: field.TypeInt, Comment: "已发净额(完成备料实发累加;退库收回扣减回补)", Default: 0}, {Name: "reserved_qty", Type: field.TypeInt, Comment: "占用中(待备料叫料单请求量合计)", Default: 0}, {Name: "cross_day", Type: field.TypeBool, Comment: "是否含非今日排产(跨日叫料预警/仓库驳回异常标记)", Default: false}, {Name: "plan_dates", Type: field.TypeString, Size: 255, Comment: "派生快照:贡献需求的排产日期(逗号分隔,可空)", Default: ""}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, } // CallPoolTable holds the schema information for the "call_pool" table. CallPoolTable = &schema.Table{ Name: "call_pool", Comment: "CallPool 叫料池:工位级物料行四数账(需求/调整/已发/占用),来源=启用状态日排产", Columns: CallPoolColumns, PrimaryKey: []*schema.Column{CallPoolColumns[0]}, Indexes: []*schema.Index{ { Name: "callpool_station_no_material_code", Unique: true, Columns: []*schema.Column{CallPoolColumns[1], CallPoolColumns[2]}, }, { Name: "callpool_station_no", Unique: false, Columns: []*schema.Column{CallPoolColumns[1]}, }, }, } // 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: "side", Type: field.TypeString, Size: 8, Comment: "左右:left=操作员左手边/right=右手边(按操作员朝向区分,下排工位与地图左右相反)", Default: "left"}, {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)+ JBT21(库房收货;T7 2026-11-03 统一代号)。", 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: "损耗率%(仅展示口径,不参与备料计算——R7 2026-11-03 拍板:备料量=工单需求×单台用量,损耗走补料审批)", 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]}, }, }, } // LossLedgersColumns holds the columns for the "loss_ledgers" table. LossLedgersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "station_no", Type: field.TypeInt, Comment: "工位号"}, {Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码(图号)"}, {Name: "material_name", Type: field.TypeString, Size: 128, Comment: "物料名称", Default: ""}, {Name: "theory_qty", Type: field.TypeFloat64, Comment: "理论应退量"}, {Name: "actual_qty", Type: field.TypeFloat64, Comment: "实际退回量"}, {Name: "loss_qty", Type: field.TypeFloat64, Comment: "损耗量(理论-实际)"}, {Name: "reason", Type: field.TypeString, Size: 200, Comment: "损耗原因(必填)"}, {Name: "return_no", Type: field.TypeString, Size: 64, Comment: "关联退库单号(material_request.requestNo)", Default: ""}, {Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "关联工单号(可空)", Default: ""}, {Name: "status", Type: field.TypeString, Size: 20, Comment: "PENDING待批注/COMMENTED已批注", Default: "PENDING"}, {Name: "comment", Type: field.TypeString, Size: 300, Comment: "主管批注回复", Default: ""}, {Name: "commenter", Type: field.TypeString, Size: 64, Comment: "批注人", Default: ""}, {Name: "commented_at", Type: field.TypeInt64, Comment: "批注时间 unix秒", Default: 0}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "退料操作人", Default: ""}, {Name: "created_at", Type: field.TypeTime}, } // LossLedgersTable holds the schema information for the "loss_ledgers" table. LossLedgersTable = &schema.Table{ Name: "loss_ledgers", Comment: "LossLedger 损耗台账:退料差额自动落账,主管批注(后审核)。", Columns: LossLedgersColumns, PrimaryKey: []*schema.Column{LossLedgersColumns[0]}, Indexes: []*schema.Index{ { Name: "lossledger_station_no", Unique: false, Columns: []*schema.Column{LossLedgersColumns[1]}, }, { Name: "lossledger_status", Unique: false, Columns: []*schema.Column{LossLedgersColumns[10]}, }, { Name: "lossledger_return_no", Unique: false, Columns: []*schema.Column{LossLedgersColumns[8]}, }, }, } // 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成品(半成品不是物料类别,「其他」已移除)", 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: "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: "目标接驳台(GxR1/GxR2,一单一个托盘)", Default: ""}, {Name: "station_no", Type: field.TypeInt, Comment: "目标工位号", Default: 0}, {Name: "sent_qty", Type: field.TypeFloat64, Comment: "实发量(仓库完成备料时确定,禁单内分批)", Default: 0}, {Name: "returned_qty", Type: field.TypeFloat64, Comment: "退库量(整单退;仓库确认收回后叫料池额度回补)", Default: 0}, {Name: "source", Type: field.TypeString, Size: 16, Comment: "来源 CALL/REFILL", Default: "CALL"}, {Name: "ref_report_no", Type: field.TypeString, Size: 64, Comment: "关联数量不符单号", Default: ""}, {Name: "need_agv", Type: field.TypeBool, Comment: "是否需要AGV配送到接驳台", Default: true}, {Name: "agv_task_no", Type: field.TypeString, Size: 64, Comment: "AGV 任务号(派车成功后回写)", Default: ""}, {Name: "cross_day", Type: field.TypeBool, Comment: "跨日标记:叫料池行含非今日排产(工位预警+仓库可驳回异常)", Default: false}, {Name: "outbound_no", Type: field.TypeString, Size: 255, Comment: "WMS 出库单号(完成备料回写,多个逗号分隔)", Default: ""}, {Name: "reject_reason", Type: field.TypeString, Size: 128, Comment: "驳回理由(仓库拒发时必填)", Default: ""}, {Name: "borrow_from", Type: field.TypeJSON, Nullable: true, Comment: "跨工位借料来源 stationNo→借用量;空=本工位自取", SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "operator", Type: field.TypeString, Size: 64, Default: ""}, {Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "关联工单号(转产按工单精确退料;普通叫料单为空)", Default: ""}, {Name: "return_dock", Type: field.TypeString, Size: 20, Comment: "退料接驳台(退料/还库时指定从哪个接驳台拉走,AGV 派车依据)", Default: ""}, {Name: "theory_qty", Type: field.TypeFloat64, Nullable: true, Comment: "理论应退量(转产/下班退料按 BOM 计算;实际<理论差额=损耗)"}, {Name: "loss_qty", Type: field.TypeFloat64, Nullable: true, Comment: "损耗量(理论应退-实际退回>0 时记录)"}, {Name: "loss_reason", Type: field.TypeString, Size: 200, Comment: "损耗原因(有损耗时必填,主管在损耗台账批注)", Default: ""}, {Name: "receive_qty", Type: field.TypeFloat64, Nullable: true, Comment: "库管实收量(WMS 确认收货回写)"}, {Name: "receive_diff", Type: field.TypeFloat64, Nullable: true, Comment: "收货差异=应退-实收(>0 为少收,记待核,不自动进损耗台账)"}, {Name: "receive_note", Type: field.TypeString, Size: 200, Comment: "收货差异备注(库管填写,说明差异原因)", 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_station_no", Unique: false, Columns: []*schema.Column{MaterialRequestColumns[9]}, }, { Name: "materialrequest_material_code", Unique: false, Columns: []*schema.Column{MaterialRequestColumns[2]}, }, { Name: "materialrequest_status", Unique: false, Columns: []*schema.Column{MaterialRequestColumns[7]}, }, { Name: "materialrequest_work_order_no", Unique: false, Columns: []*schema.Column{MaterialRequestColumns[21]}, }, }, } // 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(手填)/SCAN(扫码,与手填等价采一串字符串)/NONE(仅记录)", Default: "NONE"}, {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}, {Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"}, } // 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]}, }, }, } // ShortageRequestsColumns holds the columns for the "shortage_requests" table. ShortageRequestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "station_no", Type: field.TypeInt, Comment: "申请工位号"}, {Name: "material_code", Type: field.TypeString, Size: 64, Comment: "物料编码(图号)"}, {Name: "material_name", Type: field.TypeString, Size: 128, Comment: "物料名称", Default: ""}, {Name: "unit", Type: field.TypeString, Size: 16, Comment: "单位", Default: ""}, {Name: "qty", Type: field.TypeInt, Comment: "补料数量(申请增加的额度)"}, {Name: "reason", Type: field.TypeString, Size: 200, Comment: "补料原因(损耗超标/用量超出预估等,必填)"}, {Name: "status", Type: field.TypeString, Size: 20, Comment: "PENDING待审批/APPROVED已通过/REJECTED已驳回", Default: "PENDING"}, {Name: "comment", Type: field.TypeString, Size: 300, Comment: "主管批注", Default: ""}, {Name: "commenter", Type: field.TypeString, Size: 64, Comment: "审批人", Default: ""}, {Name: "commented_at", Type: field.TypeInt64, Comment: "审批时间 unix秒", Default: 0}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "申请人", Default: ""}, {Name: "created_at", Type: field.TypeTime}, } // ShortageRequestsTable holds the schema information for the "shortage_requests" table. ShortageRequestsTable = &schema.Table{ Name: "shortage_requests", Comment: "ShortageRequest 补料申请:工位物料不够用申请加量,主管审批后调增叫料池额度。", Columns: ShortageRequestsColumns, PrimaryKey: []*schema.Column{ShortageRequestsColumns[0]}, Indexes: []*schema.Index{ { Name: "shortagerequest_station_no", Unique: false, Columns: []*schema.Column{ShortageRequestsColumns[1]}, }, { Name: "shortagerequest_status", Unique: false, Columns: []*schema.Column{ShortageRequestsColumns[7]}, }, }, } // 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]}, }, }, } // StationShiftsColumns holds the columns for the "station_shifts" table. StationShiftsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "station_no", Type: field.TypeInt, Comment: "工位号"}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "当班工人", Default: ""}, {Name: "status", Type: field.TypeString, Size: 20, Comment: "ON_DUTY当班/CLOSING待收尾(有剩余物料退料中)/CLOSED已下班", Default: "ON_DUTY"}, {Name: "start_at", Type: field.TypeInt64, Comment: "班次开始(登录) unix秒", Default: 0}, {Name: "end_apply_at", Type: field.TypeInt64, Comment: "申请下班时间 unix秒", Default: 0}, {Name: "closed_at", Type: field.TypeInt64, Comment: "实际下班(收尾完成) unix秒", Default: 0}, {Name: "remark", Type: field.TypeString, Nullable: true, Size: 300, Comment: "备注(如退料单号/退出未下班警示留痕)", Default: ""}, {Name: "created_at", Type: field.TypeTime}, } // StationShiftsTable holds the schema information for the "station_shifts" table. StationShiftsTable = &schema.Table{ Name: "station_shifts", Comment: "StationShift 工位班次:下班/结束作业闭环状态。", Columns: StationShiftsColumns, PrimaryKey: []*schema.Column{StationShiftsColumns[0]}, Indexes: []*schema.Index{ { Name: "stationshift_station_no", Unique: false, Columns: []*schema.Column{StationShiftsColumns[1]}, }, { Name: "stationshift_status", Unique: false, Columns: []*schema.Column{StationShiftsColumns[3]}, }, }, } // 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: "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: "actual_start", Type: field.TypeTime, Nullable: true, Comment: "实际开始"}, {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[15]}, }, { 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: "at_station_no", Type: field.TypeInt, Nullable: true, Comment: "物理位置:工件当前实际所在工位号(0=未在工位;建档/到达即写,完工/入库清空)"}, {Name: "status", Type: field.TypeString, Size: 20, Default: "NEW"}, {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}, {Name: "torque_ng_pending", Type: field.TypeBool, Comment: "拧紧扭矩不合格待人工处置标记", Default: false}, {Name: "torque_ng_at", Type: field.TypeTime, Nullable: true, Comment: "拧紧不合格标记时间"}, {Name: "torque_ng_by", Type: field.TypeString, Nullable: true, Size: 64, Comment: "拧紧不合格标记操作人"}, } // 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[6]}, }, }, } // 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]}, }, }, } // WorkpieceLifecycleLogColumns holds the columns for the "workpiece_lifecycle_log" table. WorkpieceLifecycleLogColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Size: 64, Comment: "工件SN"}, {Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "所属工单", Default: ""}, {Name: "action", Type: field.TypeString, Size: 20, Comment: "状态动作:NEW/ONLINE/REPORT/SEMI_IN/SEMI_OUT/DONE/SCRAPPED"}, {Name: "from_status", Type: field.TypeString, Size: 20, Comment: "变更前状态", Default: ""}, {Name: "to_status", Type: field.TypeString, Size: 20, Comment: "变更后状态", Default: ""}, {Name: "station_no", Type: field.TypeInt, Nullable: true, Comment: "关联工位号"}, {Name: "flow_seq", Type: field.TypeInt, Nullable: true, Comment: "工艺序号(工序顺序)"}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""}, {Name: "source", Type: field.TypeString, Size: 32, Comment: "来源:workstation/mes/admin/reconcile", Default: ""}, {Name: "remark", Type: field.TypeString, Size: 255, Comment: "备注", Default: ""}, {Name: "created_at", Type: field.TypeTime}, } // WorkpieceLifecycleLogTable holds the schema information for the "workpiece_lifecycle_log" table. WorkpieceLifecycleLogTable = &schema.Table{ Name: "workpiece_lifecycle_log", Comment: "工件生命周期状态流水:NEW/ONLINE/REPORT/SEMI_IN/SEMI_OUT/DONE/SCRAPPED,所有状态变更点同事务写", Columns: WorkpieceLifecycleLogColumns, PrimaryKey: []*schema.Column{WorkpieceLifecycleLogColumns[0]}, Indexes: []*schema.Index{ { Name: "workpiecelifecyclelog_sn_created_at", Unique: false, Columns: []*schema.Column{WorkpieceLifecycleLogColumns[1], WorkpieceLifecycleLogColumns[11]}, }, { Name: "workpiecelifecyclelog_work_order_no_created_at", Unique: false, Columns: []*schema.Column{WorkpieceLifecycleLogColumns[2], WorkpieceLifecycleLogColumns[11]}, }, { Name: "workpiecelifecyclelog_action_created_at", Unique: false, Columns: []*schema.Column{WorkpieceLifecycleLogColumns[3], WorkpieceLifecycleLogColumns[11]}, }, }, } // 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{ AgvPointTable, AgvTasksTable, AgvVehicleStateTable, AlertTable, AlertRuleTable, AssociationTraceTable, AttachmentTable, BackupRecordTable, CallPoolTable, DailyPlanTable, DockTable, EventLogTable, FlowMaterialTable, InspectionRecordTable, LinePointTable, LossLedgersTable, MaterialsTable, MaterialQtyReportTable, MaterialRequestTable, PermissionTable, PlcSendLogTable, ProcessFlowTable, ProcessStepTable, ProductProcessTable, ProductProcessItemTable, RoleTable, SemiFlowTable, ShortageRequestsTable, StationTable, StationShiftsTable, StationStateTable, StepCriterionTable, StepDataTable, StepSignRecordTable, SysConfigTable, TorqueRecordTable, UserTable, UserStationTable, WorkOrderTable, WorkpieceTable, WorkpieceBindTable, WorkpieceLifecycleLogTable, WorkpieceProcessTable, } ) func init() { AgvPointTable.Annotation = &entsql.Annotation{ Table: "agv_point", } AgvTasksTable.Annotation = &entsql.Annotation{ Table: "agv_tasks", } AgvVehicleStateTable.Annotation = &entsql.Annotation{ Table: "agv_vehicle_state", } 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", } BackupRecordTable.Annotation = &entsql.Annotation{ Table: "backup_record", } CallPoolTable.Annotation = &entsql.Annotation{ Table: "call_pool", } 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", } LossLedgersTable.Annotation = &entsql.Annotation{ Table: "loss_ledgers", } 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", } ShortageRequestsTable.Annotation = &entsql.Annotation{ Table: "shortage_requests", } StationTable.Annotation = &entsql.Annotation{ Table: "station", } StationShiftsTable.Annotation = &entsql.Annotation{ Table: "station_shifts", } 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", } WorkpieceLifecycleLogTable.Annotation = &entsql.Annotation{ Table: "workpiece_lifecycle_log", } WorkpieceProcessTable.Annotation = &entsql.Annotation{ Table: "workpiece_process", } }