Files
bj_power/bj_power_mes/schema/workpiece_process.go
T
SunYF 756d978900 feat: 实现工位终端滑动续签机制,强化安全与身份追溯
- 新增滑动续签功能:人工触屏触发本地心跳 + 30秒节流刷新JWT,避免作业中令牌过期
- 拆分质量检验权限:过程检/完工检使用不同权限码,细化权限粒度
- 新增操作人用户ID字段:报工、拧紧记录落库时携带可信用户ID,解决身份追溯问题
- 移除编译期默认密钥,启动期校验所有必要密钥非空,防止密钥泄露风险
- 修复WMS附件越权遍历问题:使用UUID文件名替代顺序ID访问附件
- 实现登录态过期数据隔离:仅返回当前操作人的待同步数据,避免身份混淆
2026-10-06 19:36:22 +08:00

55 lines
2.0 KiB
Go

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"
)
// WorkpieceProcess 工件-工艺实绩(某工件在某工位完成某道工艺的一次记录,构成工艺时间线)。
// 执行顺序=工位号升序(工单工艺组合),可跳过未选工位、不可倒序。
type WorkpieceProcess struct {
ent.Schema
}
func (WorkpieceProcess) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}}
}
func (WorkpieceProcess) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").MaxLen(64).Comment("工件SN"),
field.Int("flowId").Comment("完成的工艺ID"),
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
field.String("orderNo").Default("").MaxLen(64),
field.String("processName").Default("").MaxLen(64),
// PENDING / DOING / DONE / NG / REPAIRED
field.String("status").Default("DONE").MaxLen(20),
field.String("operator").Default("").MaxLen(64),
// 落库操作人用户ID:由 MES 从当前登录态 JWT 解析,即「本次发送所用的登录人」。
// 0=未采集(来源:MES 前端虚拟工位/PLC 等无工位登录态路径)。
field.Int("operatorId").Default(0).Comment("操作人用户ID(0=未采集:虚拟工位/PLC路径或历史数据)"),
field.String("result").Default("OK").MaxLen(10).Comment("总判定 OK/NG"),
field.Time("startedAt").Optional().Nillable(),
field.Time("endedAt").Optional().Nillable(),
field.Int("durationSec").Default(0).Comment("作业时长(秒)=endedAt-startedAt"),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (WorkpieceProcess) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn"),
index.Fields("sn", "flowId"),
index.Fields("sn", "stationNo"),
index.Fields("orderNo"),
index.Fields("stationNo"),
}
}