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
+150
View File
@@ -258,6 +258,61 @@ func (_u *WorkpieceUpdate) ClearTorqueNgBy() *WorkpieceUpdate {
return _u
}
// SetFlowTransitMW sets the "flowTransitMW" field.
func (_u *WorkpieceUpdate) SetFlowTransitMW(v int) *WorkpieceUpdate {
_u.mutation.ResetFlowTransitMW()
_u.mutation.SetFlowTransitMW(v)
return _u
}
// SetNillableFlowTransitMW sets the "flowTransitMW" field if the given value is not nil.
func (_u *WorkpieceUpdate) SetNillableFlowTransitMW(v *int) *WorkpieceUpdate {
if v != nil {
_u.SetFlowTransitMW(*v)
}
return _u
}
// AddFlowTransitMW adds value to the "flowTransitMW" field.
func (_u *WorkpieceUpdate) AddFlowTransitMW(v int) *WorkpieceUpdate {
_u.mutation.AddFlowTransitMW(v)
return _u
}
// SetFlowTransitTarget sets the "flowTransitTarget" field.
func (_u *WorkpieceUpdate) SetFlowTransitTarget(v string) *WorkpieceUpdate {
_u.mutation.SetFlowTransitTarget(v)
return _u
}
// SetNillableFlowTransitTarget sets the "flowTransitTarget" field if the given value is not nil.
func (_u *WorkpieceUpdate) SetNillableFlowTransitTarget(v *string) *WorkpieceUpdate {
if v != nil {
_u.SetFlowTransitTarget(*v)
}
return _u
}
// SetFlowTransitAt sets the "flowTransitAt" field.
func (_u *WorkpieceUpdate) SetFlowTransitAt(v time.Time) *WorkpieceUpdate {
_u.mutation.SetFlowTransitAt(v)
return _u
}
// SetNillableFlowTransitAt sets the "flowTransitAt" field if the given value is not nil.
func (_u *WorkpieceUpdate) SetNillableFlowTransitAt(v *time.Time) *WorkpieceUpdate {
if v != nil {
_u.SetFlowTransitAt(*v)
}
return _u
}
// ClearFlowTransitAt clears the value of the "flowTransitAt" field.
func (_u *WorkpieceUpdate) ClearFlowTransitAt() *WorkpieceUpdate {
_u.mutation.ClearFlowTransitAt()
return _u
}
// Mutation returns the WorkpieceMutation object of the builder.
func (_u *WorkpieceUpdate) Mutation() *WorkpieceMutation {
return _u.mutation
@@ -321,6 +376,11 @@ func (_u *WorkpieceUpdate) check() error {
return &ValidationError{Name: "torque_ng_by", err: fmt.Errorf(`ent: validator failed for field "Workpiece.torque_ng_by": %w`, err)}
}
}
if v, ok := _u.mutation.FlowTransitTarget(); ok {
if err := workpiece.FlowTransitTargetValidator(v); err != nil {
return &ValidationError{Name: "flowTransitTarget", err: fmt.Errorf(`ent: validator failed for field "Workpiece.flowTransitTarget": %w`, err)}
}
}
return nil
}
@@ -411,6 +471,21 @@ func (_u *WorkpieceUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if _u.mutation.TorqueNgByCleared() {
_spec.ClearField(workpiece.FieldTorqueNgBy, field.TypeString)
}
if value, ok := _u.mutation.FlowTransitMW(); ok {
_spec.SetField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFlowTransitMW(); ok {
_spec.AddField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
}
if value, ok := _u.mutation.FlowTransitTarget(); ok {
_spec.SetField(workpiece.FieldFlowTransitTarget, field.TypeString, value)
}
if value, ok := _u.mutation.FlowTransitAt(); ok {
_spec.SetField(workpiece.FieldFlowTransitAt, field.TypeTime, value)
}
if _u.mutation.FlowTransitAtCleared() {
_spec.ClearField(workpiece.FieldFlowTransitAt, field.TypeTime)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
@@ -662,6 +737,61 @@ func (_u *WorkpieceUpdateOne) ClearTorqueNgBy() *WorkpieceUpdateOne {
return _u
}
// SetFlowTransitMW sets the "flowTransitMW" field.
func (_u *WorkpieceUpdateOne) SetFlowTransitMW(v int) *WorkpieceUpdateOne {
_u.mutation.ResetFlowTransitMW()
_u.mutation.SetFlowTransitMW(v)
return _u
}
// SetNillableFlowTransitMW sets the "flowTransitMW" field if the given value is not nil.
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitMW(v *int) *WorkpieceUpdateOne {
if v != nil {
_u.SetFlowTransitMW(*v)
}
return _u
}
// AddFlowTransitMW adds value to the "flowTransitMW" field.
func (_u *WorkpieceUpdateOne) AddFlowTransitMW(v int) *WorkpieceUpdateOne {
_u.mutation.AddFlowTransitMW(v)
return _u
}
// SetFlowTransitTarget sets the "flowTransitTarget" field.
func (_u *WorkpieceUpdateOne) SetFlowTransitTarget(v string) *WorkpieceUpdateOne {
_u.mutation.SetFlowTransitTarget(v)
return _u
}
// SetNillableFlowTransitTarget sets the "flowTransitTarget" field if the given value is not nil.
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitTarget(v *string) *WorkpieceUpdateOne {
if v != nil {
_u.SetFlowTransitTarget(*v)
}
return _u
}
// SetFlowTransitAt sets the "flowTransitAt" field.
func (_u *WorkpieceUpdateOne) SetFlowTransitAt(v time.Time) *WorkpieceUpdateOne {
_u.mutation.SetFlowTransitAt(v)
return _u
}
// SetNillableFlowTransitAt sets the "flowTransitAt" field if the given value is not nil.
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitAt(v *time.Time) *WorkpieceUpdateOne {
if v != nil {
_u.SetFlowTransitAt(*v)
}
return _u
}
// ClearFlowTransitAt clears the value of the "flowTransitAt" field.
func (_u *WorkpieceUpdateOne) ClearFlowTransitAt() *WorkpieceUpdateOne {
_u.mutation.ClearFlowTransitAt()
return _u
}
// Mutation returns the WorkpieceMutation object of the builder.
func (_u *WorkpieceUpdateOne) Mutation() *WorkpieceMutation {
return _u.mutation
@@ -738,6 +868,11 @@ func (_u *WorkpieceUpdateOne) check() error {
return &ValidationError{Name: "torque_ng_by", err: fmt.Errorf(`ent: validator failed for field "Workpiece.torque_ng_by": %w`, err)}
}
}
if v, ok := _u.mutation.FlowTransitTarget(); ok {
if err := workpiece.FlowTransitTargetValidator(v); err != nil {
return &ValidationError{Name: "flowTransitTarget", err: fmt.Errorf(`ent: validator failed for field "Workpiece.flowTransitTarget": %w`, err)}
}
}
return nil
}
@@ -845,6 +980,21 @@ func (_u *WorkpieceUpdateOne) sqlSave(ctx context.Context) (_node *Workpiece, er
if _u.mutation.TorqueNgByCleared() {
_spec.ClearField(workpiece.FieldTorqueNgBy, field.TypeString)
}
if value, ok := _u.mutation.FlowTransitMW(); ok {
_spec.SetField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFlowTransitMW(); ok {
_spec.AddField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
}
if value, ok := _u.mutation.FlowTransitTarget(); ok {
_spec.SetField(workpiece.FieldFlowTransitTarget, field.TypeString, value)
}
if value, ok := _u.mutation.FlowTransitAt(); ok {
_spec.SetField(workpiece.FieldFlowTransitAt, field.TypeTime, value)
}
if _u.mutation.FlowTransitAtCleared() {
_spec.ClearField(workpiece.FieldFlowTransitAt, field.TypeTime)
}
_spec.AddModifiers(_u.modifiers...)
_node = &Workpiece{config: _u.config}
_spec.Assign = _node.assignValues