feat: 退料闭环定稿(损耗台账/备料清单/退料AGV自动派车/剩余量参考)+ 工位托盘守卫

- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集)
- 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList
- 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损)
- 新增 AGV 车辆状态表 agv_vehicle_state 及查询
- 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
This commit is contained in:
SunYF
2026-11-04 19:06:03 +08:00
parent 42bcf395d2
commit 46fcb59079
123 changed files with 10666 additions and 3227 deletions
+21
View File
@@ -2,6 +2,7 @@ package plc
import (
"context"
"errors"
"strconv"
"strings"
"sync"
@@ -52,6 +53,7 @@ type Manager struct {
onRecover func(ctx context.Context)
mu sync.Mutex
consecFails int
mockOffline bool // mock 模式:模拟 PLC 离线(拍板2 联调/自测用,真实 PLC 忽略)
}
func NewManager(c config.PlcConf, mock bool) (*Manager, error) {
@@ -77,7 +79,16 @@ func (m *Manager) SetOnRecover(f func(ctx context.Context)) {
}
// QueryStationPallet 读工位托盘位(带恢复检测):查询成功且此前发生过失败 → 触发 OnRecover(T6)。
// mock 模式下可经 SetMockOffline 模拟离线(读失败),验证拍板2「PLC 离线提示+人工强行确认」链路。
func (m *Manager) QueryStationPallet(ctx context.Context, stationNo int) (bool, error) {
m.mu.Lock()
off := m.mock && m.mockOffline
m.mu.Unlock()
if off {
err := errors.New("PLC 离线(mock 模拟)")
m.track(err)
return false, err
}
v, err := m.client.QueryStationPallet(ctx, stationNo)
m.track(err)
return v, err
@@ -147,6 +158,16 @@ func (m *Manager) SetMockStationPallet(stationNo int, has bool) {
}
}
// SetMockOffline 仅在 mock 模式下生效:模拟 PLC 离线(拍板2 2026-11-04 联调/自测用)。
// 离线期间 QueryStationPallet 返回错误(模拟读失败);真实 PLC 模式忽略。
func (m *Manager) SetMockOffline(off bool) {
m.mu.Lock()
defer m.mu.Unlock()
if m.mock {
m.mockOffline = off
}
}
// parseCombination 解析工位组合 "1,3,5" / "10,11,12" -> [1,3,5] / [10,11,12]
func parseCombination(s string) []int {
var out []int