feat: 五项目业务实现并对接完成
- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE - WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置 - WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页 - 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面 - Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理 - 清理各项目球形磨遗留代码,新增部署手册.md
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// AgvTask 海康 RCS AGV 任务记录
|
||||
type AgvTask struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (AgvTask) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("task_no").Unique().Comment("本地任务号"),
|
||||
field.String("rcs_task_id").Optional().Comment("RCS 返回的任务ID"),
|
||||
field.String("order_no").Optional(),
|
||||
field.String("dock_from").Optional().Comment("起始点(接驳台号或库位点)"),
|
||||
field.String("dock_to").Optional(),
|
||||
field.Int("priority").Default(4).Comment("任务优先级 0~14"),
|
||||
field.String("status").Default("待下发").Comment("待下发/执行中/完成/失败"),
|
||||
field.Bool("sim").Default(true).Comment("模拟模式"),
|
||||
field.String("resp_text").Optional(),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (AgvTask) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("status"),
|
||||
index.Fields("created_at"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// BomItem 产品 BOM 明细
|
||||
// unitQty = 单台产品对该物料的需求量;isSuite=true 表示该项是套件(组合件),
|
||||
// 其子物料行通过 suite_of 指向套件的物料编码。
|
||||
type BomItem struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (BomItem) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("product_code").Comment("产品型号编码"),
|
||||
field.String("material_code").Comment("物料编码"),
|
||||
field.String("material_name").Optional(),
|
||||
field.Int("unit_qty").Default(1).Comment("单台需求量"),
|
||||
field.Bool("is_suite").Default(false).Comment("是否套件本身"),
|
||||
field.String("suite_of").Optional().Comment("属于哪个套件(空=直属产品)"),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (BomItem) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("product_code"),
|
||||
index.Fields("material_code"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// MaterialRequest 备料单:MES 按 BOM×数量 调 WMS 检查/锁定库存的记录
|
||||
type MaterialRequest struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (MaterialRequest) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("request_no").Unique().Comment("备料单号"),
|
||||
field.String("order_no").Comment("工单号"),
|
||||
field.JSON("items", []map[string]any{}).Optional().SchemaType(map[string]string{
|
||||
dialect.Postgres: "jsonb",
|
||||
}).Comment("[{materialCode,materialName,totalQty,availQty,enough}]"),
|
||||
field.Bool("all_enough").Default(false),
|
||||
field.String("status").Default("已检查").Comment("已检查/库存不足/已生成出库建议"),
|
||||
field.String("operator").Optional(),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (MaterialRequest) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("order_no"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// PlcSendLog PLC 工序号下发记录
|
||||
// 例:产线12道工序,收齐 5 个工序号则下发 125 给 PLC 执行 1 序 2 序 5 序
|
||||
type PlcSendLog struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (PlcSendLog) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("order_no").Optional().Comment("关联工单号"),
|
||||
field.String("code_str").Comment("下发的工序号串,如 125"),
|
||||
field.String("mode").Default("sim").Comment("sim/real"),
|
||||
field.String("result").Default("已下发").Comment("已下发/已确认/失败"),
|
||||
field.String("error_text").Optional(),
|
||||
field.Time("sent_at").Default(time.Now),
|
||||
field.Time("ack_at").Optional().Nillable().Comment("PLC 完成确认时间"),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (PlcSendLog) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("order_no"),
|
||||
index.Fields("sent_at"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// ProcessDict 工序字典:12 道工序可维护,用户自定义描述做什么操作等
|
||||
type ProcessDict struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (ProcessDict) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("code").Unique().Comment("工序号 1~12"),
|
||||
field.String("name").Comment("工序名称"),
|
||||
field.String("description").Optional().Comment("该工序做什么操作的描述"),
|
||||
field.Int("sort_num").Default(0).Comment("排序"),
|
||||
field.Bool("enabled").Default(true),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (ProcessDict) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("code"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// ScanRecord 扫码报工记录
|
||||
type ScanRecord struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (ScanRecord) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("order_no").Optional().Comment("工单号"),
|
||||
field.String("sn").Optional().Comment("工件SN"),
|
||||
field.String("dock_code").Optional().Comment("接驳台"),
|
||||
field.String("step_code").Optional().Comment("工序号 1~12"),
|
||||
field.String("step_name").Optional(),
|
||||
field.Enum("action").
|
||||
Values("arrival", "process_done", "temp_store").
|
||||
Default("process_done").Comment("到料确认/工序完成上报/暂存退库"),
|
||||
field.String("operator").Optional(),
|
||||
field.Time("created_at").Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
func (ScanRecord) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("order_no"),
|
||||
index.Fields("sn"),
|
||||
index.Fields("created_at"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// SemiFlow 半成品流转记录(同步 WMS 半成品出入库)
|
||||
type SemiFlow struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (SemiFlow) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("order_no").Optional(),
|
||||
field.String("sn").Comment("半成品SN"),
|
||||
field.String("material_code").Optional(),
|
||||
field.String("completed_process").Optional().Comment("已完成工序,如 1-2-5"),
|
||||
field.String("zone_code").Optional().Comment("目标库区 Z02 等"),
|
||||
field.Enum("action").
|
||||
Values("inbound", "outbound").
|
||||
Default("inbound").Comment("入库暂存/出库重上线"),
|
||||
field.Bool("wms_ok").Default(false).Comment("WMS 同步是否成功"),
|
||||
field.String("resp_text").Optional().Comment("WMS 响应摘要"),
|
||||
field.Time("created_at").Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
func (SemiFlow) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("order_no"),
|
||||
index.Fields("sn"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// TorqueRecord 拧紧数据记录(由工位终端 D 上报)
|
||||
type TorqueRecord struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (TorqueRecord) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("work_order_no").Optional(),
|
||||
field.String("sn").Comment("工件SN"),
|
||||
field.String("dock_code").Optional().Comment("工位 DOCK01~21"),
|
||||
field.String("screw_no").Optional().Comment("螺丝编号 S1~Sn"),
|
||||
field.Float("torque").Default(0).Comment("扭矩 Nm"),
|
||||
field.Float("angle").Default(0).Comment("角度 °"),
|
||||
field.Enum("result").
|
||||
Values("OK", "NG").
|
||||
Default("OK").Comment("拧紧结果"),
|
||||
field.String("operator").Optional(),
|
||||
field.Time("created_at").Default(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
func (TorqueRecord) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("sn"),
|
||||
index.Fields("work_order_no"),
|
||||
index.Fields("created_at"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user