feat: 完成MES工位终端系统全量功能迭代

本次提交包含以下核心变更:
1. 新增按钮级权限控制框架与前端权限校验
2. 新增工位管理、工艺流程、巡检终端等核心业务模块
3. 完善用户体系,支持工位终端专属登录权限
4. 新增文件上传下载、报表查询等配套功能
5. 修复多系统兼容性与交互体验问题
6. 完成所有文档与配置项的规范化更新
This commit is contained in:
SunYF
2026-08-31 08:06:55 +08:00
parent dab03ac0cf
commit 4ec6784629
99 changed files with 17436 additions and 479 deletions
+51
View File
@@ -0,0 +1,51 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// InspectionRecord 巡检记录(PAD 巡检终端):
// 开工签到 CHECKIN / 工位点检 POINT / 过程巡检 PROCESS / 完工确认 DONE / 异常上报 ALARM
type InspectionRecord struct {
ent.Schema
}
func (InspectionRecord) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "inspection_record"}}
}
func (InspectionRecord) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("category").MaxLen(20).Comment("记录类型 CHECKIN/POINT/PROCESS/DONE/ALARM"),
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
field.String("shift").Default("").MaxLen(20).Comment("班次 早/中/晚"),
field.String("orderNo").Default("").MaxLen(64).Comment("工单号"),
field.String("sn").Default("").MaxLen(64).Comment("工件SN"),
// OK / NG
field.String("result").Default("OK").MaxLen(10).Comment("结论"),
field.JSON("items", []string{}).Optional().SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Comment("点检项/异常类型列表"),
field.String("photo").Default("").MaxLen(255).Comment("拍照文件名"),
field.String("remark").Default("").MaxLen(500).Comment("文字描述/签字"),
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (InspectionRecord) Indexes() []ent.Index {
return []ent.Index{
index.Fields("category"),
index.Fields("stationNo"),
index.Fields("orderNo"),
index.Fields("operator"),
}
}
+42
View File
@@ -0,0 +1,42 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// ProcessFlow 工艺流程图:一个流程只绑定一个工序编号(1~12),可多版本;
// 工位绑定其中一个流程(一个工位同时只绑一个)。流程承载:工序号 + 工艺图纸PDF + 步骤模板。
type ProcessFlow struct {
ent.Schema
}
func (ProcessFlow) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "process_flow"}}
}
func (ProcessFlow) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("name").MaxLen(128).Comment("流程名称,如 工序3_2026版"),
field.Int("processCode").Comment("工序编号 1..12"),
field.String("pdfFile").Default("").MaxLen(255).Comment("工艺图纸文件名"),
// ACTIVE / INACTIVE
field.String("status").Default("ACTIVE").MaxLen(20),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
}
}
func (ProcessFlow) Indexes() []ent.Index {
return []ent.Index{
index.Fields("processCode"),
index.Fields("status"),
}
}
+5 -1
View File
@@ -22,6 +22,7 @@ func (ProcessStep) Annotations() []schema.Annotation {
func (ProcessStep) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("flowId").Optional().Comment("所属工艺流程图ID(块3: 步骤改挂流程)"),
field.Int("processCode").Comment("工序代码"),
field.Int("seq").Default(1).Comment("步骤序号"),
field.String("name").MaxLen(128).Comment("步骤名称"),
@@ -33,5 +34,8 @@ func (ProcessStep) Fields() []ent.Field {
}
func (ProcessStep) Indexes() []ent.Index {
return []ent.Index{index.Fields("processCode")}
return []ent.Index{
index.Fields("processCode"),
index.Fields("flowId"),
}
}
+36
View File
@@ -0,0 +1,36 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId)
type Station struct {
ent.Schema
}
func (Station) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "station"}}
}
func (Station) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("stationNo").Unique().Comment("工位号 1..12"),
field.String("name").Default("").MaxLen(64).Comment("工位名称"),
field.Int("flowId").Optional().Comment("绑定工艺流程图ID"),
// ENABLED / DISABLED
field.String("status").Default("ENABLED").MaxLen(20),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (Station) Indexes() []ent.Index {
return []ent.Index{index.Fields("stationNo").Unique()}
}
+4 -1
View File
@@ -26,6 +26,9 @@ func (User) Fields() []ent.Field {
field.String("password").MaxLen(128).Comment("bcrypt 密码"),
field.String("name").Default("").MaxLen(64).Comment("姓名/显示名"),
field.Int("roleId").Optional().Comment("角色ID"),
// 工位终端登录属性:是否允许登录 + 工位终端专用密码(bcrypt)
field.Bool("canLoginWorkstation").Default(false).Comment("是否允许登录工位终端"),
field.String("workstationPassword").Optional().MaxLen(128).Comment("工位终端密码(bcrypt)"),
// ENABLED / DISABLED
field.String("status").Default("ENABLED").MaxLen(20),
field.Time("createdAt").Default(time.Now).Immutable(),
@@ -38,4 +41,4 @@ func (User) Indexes() []ent.Index {
index.Fields("username").Unique(),
index.Fields("roleId"),
}
}
}
+37
View File
@@ -0,0 +1,37 @@
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// UserStation 用户-工位 关联(一个操作员可绑定多个工位)
type UserStation struct {
ent.Schema
}
func (UserStation) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "user_station"}}
}
func (UserStation) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("userId").Comment("用户ID"),
field.Int("stationNo").Comment("工位号 1..12"),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (UserStation) Indexes() []ent.Index {
return []ent.Index{
index.Fields("userId"),
index.Fields("stationNo"),
index.Fields("userId", "stationNo").Unique(),
}
}