feat(mes): AGV挂起动作引擎 + 智能跟车流转 + PLC快照缓存(2026-11-19 主控拍板)

一、AGV 挂起动作引擎(弃显式任务队列、弃并发硬拒)
- 新增 internal/logic/agv_pending.go:待发动作直接挂任务(pending_action + pending_since),
  CONTINUE_LIFT(举升完成→continueTask#1)/ WAIT_DROP_CONFIRM(人工确认放下→continueTask#2)
  / FREE_ROBOT(末组完成→freeRobot);系统动作超 60s 未触发转预警人工重试,绝不自动重发
- Client 新增 ContinueTask(RCS 2.1.2) / FreeRobot(3.1.2),仅点名释放指定车,禁止释放全部
- agv_task 增 pending_action/pending_since 字段,ent 重生成 + db.go 幂等迁移补丁 + migrateonce
- 回调按 B01/B02/C01 模板编排:业务流转到位即自动放行放下、回调自动放车;
  仅人工派车(MANUAL)挂 WAIT_DROP_CONFIRM;新增 /agv/confirm-drop、/agv/pending/retry
- 前端 AgvManual/Agv 确认放下、挂起重试按钮与等待提示联动

二、智能跟车 + 动态目标截断流转引擎
- 新增 internal/logic/flow_engine.go:事件驱动(报工/扫码),读 48 位物理快照,从下游往上游算,
  前方占用则动态截断到最近空闲缓存位;IN_TRANSIT 在途闭锁防重复下发,MW=0 才确认到位落台账;
  主线占用=台账 OR 传感器,工位 G 位只认台账;在途超 5s 落预警
- workpiece 增 flow_transit_mw/target/at 字段,ent 重生成 + 迁移补丁

三、PLC 读取优化与诊断
- 新增 internal/plc/snapshot_cache.go:2s TTL + singleflight + 写失效,合并 SSE/PLC监控/流转引擎
  的重复点位读取;tcp.go 读块重构、localip.go 多网卡、plcdiag 诊断工具、plc_monitor/logging 配套

四、文档与前端
- help.js 重写「工位下发」帮助:明确报工自动驱动流转 vs 下发路线码的定位、缺料/握手/撤回边界
- 案例.md 补充定稿说明;public/index.html 构建指纹更新
This commit is contained in:
SunYF
2026-11-19 23:08:46 +08:00
parent 4c4cda1d41
commit 9aaa768e6c
40 changed files with 3037 additions and 364 deletions
+170
View File
@@ -119,6 +119,21 @@ func TorqueNgBy(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldTorqueNgBy, v))
}
// FlowTransitMW applies equality check predicate on the "flowTransitMW" field. It's identical to FlowTransitMWEQ.
func FlowTransitMW(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitMW, v))
}
// FlowTransitTarget applies equality check predicate on the "flowTransitTarget" field. It's identical to FlowTransitTargetEQ.
func FlowTransitTarget(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitTarget, v))
}
// FlowTransitAt applies equality check predicate on the "flowTransitAt" field. It's identical to FlowTransitAtEQ.
func FlowTransitAt(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitAt, v))
}
// SnEQ applies the EQ predicate on the "sn" field.
func SnEQ(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldSn, v))
@@ -789,6 +804,161 @@ func TorqueNgByContainsFold(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldContainsFold(FieldTorqueNgBy, v))
}
// FlowTransitMWEQ applies the EQ predicate on the "flowTransitMW" field.
func FlowTransitMWEQ(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitMW, v))
}
// FlowTransitMWNEQ applies the NEQ predicate on the "flowTransitMW" field.
func FlowTransitMWNEQ(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNEQ(FieldFlowTransitMW, v))
}
// FlowTransitMWIn applies the In predicate on the "flowTransitMW" field.
func FlowTransitMWIn(vs ...int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldIn(FieldFlowTransitMW, vs...))
}
// FlowTransitMWNotIn applies the NotIn predicate on the "flowTransitMW" field.
func FlowTransitMWNotIn(vs ...int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNotIn(FieldFlowTransitMW, vs...))
}
// FlowTransitMWGT applies the GT predicate on the "flowTransitMW" field.
func FlowTransitMWGT(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGT(FieldFlowTransitMW, v))
}
// FlowTransitMWGTE applies the GTE predicate on the "flowTransitMW" field.
func FlowTransitMWGTE(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGTE(FieldFlowTransitMW, v))
}
// FlowTransitMWLT applies the LT predicate on the "flowTransitMW" field.
func FlowTransitMWLT(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLT(FieldFlowTransitMW, v))
}
// FlowTransitMWLTE applies the LTE predicate on the "flowTransitMW" field.
func FlowTransitMWLTE(v int) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLTE(FieldFlowTransitMW, v))
}
// FlowTransitTargetEQ applies the EQ predicate on the "flowTransitTarget" field.
func FlowTransitTargetEQ(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitTarget, v))
}
// FlowTransitTargetNEQ applies the NEQ predicate on the "flowTransitTarget" field.
func FlowTransitTargetNEQ(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNEQ(FieldFlowTransitTarget, v))
}
// FlowTransitTargetIn applies the In predicate on the "flowTransitTarget" field.
func FlowTransitTargetIn(vs ...string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldIn(FieldFlowTransitTarget, vs...))
}
// FlowTransitTargetNotIn applies the NotIn predicate on the "flowTransitTarget" field.
func FlowTransitTargetNotIn(vs ...string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNotIn(FieldFlowTransitTarget, vs...))
}
// FlowTransitTargetGT applies the GT predicate on the "flowTransitTarget" field.
func FlowTransitTargetGT(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGT(FieldFlowTransitTarget, v))
}
// FlowTransitTargetGTE applies the GTE predicate on the "flowTransitTarget" field.
func FlowTransitTargetGTE(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGTE(FieldFlowTransitTarget, v))
}
// FlowTransitTargetLT applies the LT predicate on the "flowTransitTarget" field.
func FlowTransitTargetLT(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLT(FieldFlowTransitTarget, v))
}
// FlowTransitTargetLTE applies the LTE predicate on the "flowTransitTarget" field.
func FlowTransitTargetLTE(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLTE(FieldFlowTransitTarget, v))
}
// FlowTransitTargetContains applies the Contains predicate on the "flowTransitTarget" field.
func FlowTransitTargetContains(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldContains(FieldFlowTransitTarget, v))
}
// FlowTransitTargetHasPrefix applies the HasPrefix predicate on the "flowTransitTarget" field.
func FlowTransitTargetHasPrefix(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldHasPrefix(FieldFlowTransitTarget, v))
}
// FlowTransitTargetHasSuffix applies the HasSuffix predicate on the "flowTransitTarget" field.
func FlowTransitTargetHasSuffix(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldHasSuffix(FieldFlowTransitTarget, v))
}
// FlowTransitTargetEqualFold applies the EqualFold predicate on the "flowTransitTarget" field.
func FlowTransitTargetEqualFold(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEqualFold(FieldFlowTransitTarget, v))
}
// FlowTransitTargetContainsFold applies the ContainsFold predicate on the "flowTransitTarget" field.
func FlowTransitTargetContainsFold(v string) predicate.Workpiece {
return predicate.Workpiece(sql.FieldContainsFold(FieldFlowTransitTarget, v))
}
// FlowTransitAtEQ applies the EQ predicate on the "flowTransitAt" field.
func FlowTransitAtEQ(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldEQ(FieldFlowTransitAt, v))
}
// FlowTransitAtNEQ applies the NEQ predicate on the "flowTransitAt" field.
func FlowTransitAtNEQ(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNEQ(FieldFlowTransitAt, v))
}
// FlowTransitAtIn applies the In predicate on the "flowTransitAt" field.
func FlowTransitAtIn(vs ...time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldIn(FieldFlowTransitAt, vs...))
}
// FlowTransitAtNotIn applies the NotIn predicate on the "flowTransitAt" field.
func FlowTransitAtNotIn(vs ...time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldNotIn(FieldFlowTransitAt, vs...))
}
// FlowTransitAtGT applies the GT predicate on the "flowTransitAt" field.
func FlowTransitAtGT(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGT(FieldFlowTransitAt, v))
}
// FlowTransitAtGTE applies the GTE predicate on the "flowTransitAt" field.
func FlowTransitAtGTE(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldGTE(FieldFlowTransitAt, v))
}
// FlowTransitAtLT applies the LT predicate on the "flowTransitAt" field.
func FlowTransitAtLT(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLT(FieldFlowTransitAt, v))
}
// FlowTransitAtLTE applies the LTE predicate on the "flowTransitAt" field.
func FlowTransitAtLTE(v time.Time) predicate.Workpiece {
return predicate.Workpiece(sql.FieldLTE(FieldFlowTransitAt, v))
}
// FlowTransitAtIsNil applies the IsNil predicate on the "flowTransitAt" field.
func FlowTransitAtIsNil() predicate.Workpiece {
return predicate.Workpiece(sql.FieldIsNull(FieldFlowTransitAt))
}
// FlowTransitAtNotNil applies the NotNil predicate on the "flowTransitAt" field.
func FlowTransitAtNotNil() predicate.Workpiece {
return predicate.Workpiece(sql.FieldNotNull(FieldFlowTransitAt))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Workpiece) predicate.Workpiece {
return predicate.Workpiece(sql.AndPredicates(predicates...))
+30
View File
@@ -39,6 +39,12 @@ const (
FieldTorqueNgAt = "torque_ng_at"
// FieldTorqueNgBy holds the string denoting the torque_ng_by field in the database.
FieldTorqueNgBy = "torque_ng_by"
// FieldFlowTransitMW holds the string denoting the flowtransitmw field in the database.
FieldFlowTransitMW = "flow_transit_mw"
// FieldFlowTransitTarget holds the string denoting the flowtransittarget field in the database.
FieldFlowTransitTarget = "flow_transit_target"
// FieldFlowTransitAt holds the string denoting the flowtransitat field in the database.
FieldFlowTransitAt = "flow_transit_at"
// Table holds the table name of the workpiece in the database.
Table = "workpiece"
)
@@ -59,6 +65,9 @@ var Columns = []string{
FieldTorqueNgPending,
FieldTorqueNgAt,
FieldTorqueNgBy,
FieldFlowTransitMW,
FieldFlowTransitTarget,
FieldFlowTransitAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -92,6 +101,12 @@ var (
DefaultTorqueNgPending bool
// TorqueNgByValidator is a validator for the "torque_ng_by" field. It is called by the builders before save.
TorqueNgByValidator func(string) error
// DefaultFlowTransitMW holds the default value on creation for the "flowTransitMW" field.
DefaultFlowTransitMW int
// DefaultFlowTransitTarget holds the default value on creation for the "flowTransitTarget" field.
DefaultFlowTransitTarget string
// FlowTransitTargetValidator is a validator for the "flowTransitTarget" field. It is called by the builders before save.
FlowTransitTargetValidator func(string) error
// IDValidator is a validator for the "id" field. It is called by the builders before save.
IDValidator func(int) error
)
@@ -168,3 +183,18 @@ func ByTorqueNgAt(opts ...sql.OrderTermOption) OrderOption {
func ByTorqueNgBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTorqueNgBy, opts...).ToFunc()
}
// ByFlowTransitMW orders the results by the flowTransitMW field.
func ByFlowTransitMW(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlowTransitMW, opts...).ToFunc()
}
// ByFlowTransitTarget orders the results by the flowTransitTarget field.
func ByFlowTransitTarget(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlowTransitTarget, opts...).ToFunc()
}
// ByFlowTransitAt orders the results by the flowTransitAt field.
func ByFlowTransitAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFlowTransitAt, opts...).ToFunc()
}