feat: AGV三段链安全机制、补料/损耗/下班闭环、接驳台左右互换
AGV 调度: - 任务重构为 GO_LOAD/TRANSPORT/EMPTY_RETURN/FREE 三段链,到位即停(ARRIVED)需人工确认装卸 - 自由调度单点步进,每段强制弹"请确保路径畅通无杂物";托盘回收独立工作台 - 接驳台 PLC 传感器检测到托盘即自动卸货放行,传感器故障由人工按钮兜底(无轮询) - 车辆状态只读展示(海康3.1.7 queryAgvStatus),调度仍由 RCS 负责 物料闭环: - 补料管理(SHORTAGE):工位申请 + 主管审批调增叫料池额度,与借料/差异补发三轨并行 - 损耗台账(loss_ledger):退料实际 < 理论必填原因、后审核,工单不记损耗 - 退料强制指定左/右接驳台,WMS 库管可代工位退料 下班闭环: - 工位终端自检接驳台剩余物料后下班;库管收货 + 托盘拉走后事件驱动自动结班 - 退出登录未下班仅作安全提示(不强制拦截、不新增责任审批) 接驳台左右按操作员朝向建模(dock.side 字段),废除"奇左偶右"隐式约定; 看板标签 / seed / 迁移补丁 / 布局文档统一为中文左/右。 产线布局说明:C1 前线头 AGV 点、C15 后线尾 AGV 点、外部 O1/O2/O3 散点, 清理修订痕迹为最终态描述。
This commit is contained in:
@@ -29,10 +29,24 @@ type Client interface {
|
||||
QueryTask(ctx context.Context, taskCode string) (string, error)
|
||||
// CancelTask 取消任务(按 taskCode)。
|
||||
CancelTask(ctx context.Context, taskCode, reason string) error
|
||||
// QueryAgvStatus 只读获取车辆状态(3.1.7 queryAgvStatus):车辆闲忙/充电/电量/位置。
|
||||
// 纯只读展示,不参与调度(调度完全交给 RCS 自身)。
|
||||
QueryAgvStatus(ctx context.Context) ([]AgvVehicle, error)
|
||||
// Disable 是否处于 Mock(未接真实 RCS)模式。
|
||||
Disable() bool
|
||||
}
|
||||
|
||||
// AgvVehicle 3.1.7 返回的单车状态(只读展示用,不参与调度)。
|
||||
type AgvVehicle struct {
|
||||
RobotCode string `json:"robotCode"` // 机器人编号
|
||||
Battery float64 `json:"battery"` // 电量 0-100
|
||||
Status string `json:"status"` // 状态:4=任务空闲 / 2=执行中 / 7=充电 / 其它见协议 5.1
|
||||
PodCode string `json:"podCode"` // 背货架编号(0/空=未背货)
|
||||
PosX float64 `json:"posX"`
|
||||
PosY float64 `json:"posY"`
|
||||
Stop bool `json:"stop"` // 是否暂停
|
||||
}
|
||||
|
||||
// New 依据配置返回真实或 Mock 客户端
|
||||
func New(cfg config.AgvConf) Client {
|
||||
if cfg.EnableMock || cfg.BaseURL == "" {
|
||||
@@ -115,17 +129,25 @@ func (c *realClient) call(ctx context.Context, path string, payload map[string]a
|
||||
}
|
||||
|
||||
// SubmitTask 实现 Client:生成搬运任务(genAgvSchedulingTask)。
|
||||
// 单段搬运:源点(fromDock) → 目标点(toDock) 用 positionCodePath 两个点(type=00 位置编号)表达。
|
||||
// 两点搬运:源点(fromDock) → 目标点(toDock) 用 positionCodePath 两个点(type=00 位置编号)表达。
|
||||
// 空车段(fromDock 为空,2026-11-03 三段链模型):仅下发目标点单点 path,由 RCS 派最近空闲车前往——
|
||||
// 对应「业务自动触发免弹窗」的空车去程(AGV 空车前往装货点);若现场 RCS 要求两点 path,联调时改为 [充电位, 装货点]。
|
||||
// 任务类型固定 F01(厂内货架搬运);taskCode 透传我方任务单号。
|
||||
func (c *realClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode string) (string, error) {
|
||||
payload := map[string]any{
|
||||
"taskTyp": "F01",
|
||||
"positionCodePath": []map[string]any{
|
||||
path := []map[string]any{
|
||||
{"positionCode": toDock, "type": "00"},
|
||||
}
|
||||
if fromDock != "" {
|
||||
path = []map[string]any{
|
||||
{"positionCode": fromDock, "type": "00"},
|
||||
{"positionCode": toDock, "type": "00"},
|
||||
},
|
||||
"priority": c.cfg.Priority,
|
||||
"taskCode": taskCode,
|
||||
}
|
||||
}
|
||||
payload := map[string]any{
|
||||
"taskTyp": "F01",
|
||||
"positionCodePath": path,
|
||||
"priority": c.cfg.Priority,
|
||||
"taskCode": taskCode,
|
||||
}
|
||||
carrier := carrierCode
|
||||
if carrier == "" {
|
||||
@@ -183,6 +205,50 @@ func (c *realClient) CancelTask(ctx context.Context, taskCode, reason string) er
|
||||
return c.call(ctx, "/cancelTask", payload, nil)
|
||||
}
|
||||
|
||||
// queryAgvStatusData 3.1.7 单条车辆状态 data 项
|
||||
type queryAgvStatusData struct {
|
||||
RobotCode string `json:"robotCode"`
|
||||
Battery string `json:"battery"`
|
||||
Status string `json:"status"`
|
||||
PodCode string `json:"podCode"`
|
||||
PosX string `json:"posX"`
|
||||
PosY string `json:"posY"`
|
||||
Stop string `json:"stop"`
|
||||
}
|
||||
|
||||
// QueryAgvStatus 实现 Client:3.1.7 只读获取全部车辆状态。
|
||||
// mapShortName 取配置 MapCode(多地图场景必填;单地图可空,RCS 侧默认)。
|
||||
func (c *realClient) QueryAgvStatus(ctx context.Context) ([]AgvVehicle, error) {
|
||||
payload := map[string]any{
|
||||
"mapShortName": c.cfg.MapCode,
|
||||
}
|
||||
var out struct {
|
||||
Data []queryAgvStatusData `json:"data"`
|
||||
}
|
||||
if err := c.call(ctx, "/queryAgvStatus", payload, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vs := make([]AgvVehicle, 0, len(out.Data))
|
||||
for _, d := range out.Data {
|
||||
vs = append(vs, AgvVehicle{
|
||||
RobotCode: d.RobotCode,
|
||||
Battery: atof(d.Battery),
|
||||
Status: d.Status,
|
||||
PodCode: d.PodCode,
|
||||
PosX: atof(d.PosX),
|
||||
PosY: atof(d.PosY),
|
||||
Stop: d.Stop == "1",
|
||||
})
|
||||
}
|
||||
return vs, nil
|
||||
}
|
||||
|
||||
func atof(s string) float64 {
|
||||
var v float64
|
||||
fmt.Sscanf(s, "%f", &v)
|
||||
return v
|
||||
}
|
||||
|
||||
// Disable 真实客户端非 Mock 模式
|
||||
func (c *realClient) Disable() bool { return false }
|
||||
|
||||
@@ -206,4 +272,12 @@ func (m *mockClient) CancelTask(ctx context.Context, taskCode, reason string) er
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryAgvStatus Mock:返回两台示例车(一台空闲、一台执行中),便于联调展示。
|
||||
func (m *mockClient) QueryAgvStatus(ctx context.Context) ([]AgvVehicle, error) {
|
||||
return []AgvVehicle{
|
||||
{RobotCode: "9001", Battery: 99, Status: "4", PodCode: "0", PosX: 20000, PosY: 20000, Stop: false},
|
||||
{RobotCode: "9002", Battery: 78, Status: "2", PodCode: "100001", PosX: 35000, PosY: 12000, Stop: false},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *mockClient) Disable() bool { return true }
|
||||
|
||||
Reference in New Issue
Block a user