- 移除工位模板体系(handler/logic 全删),同步路由与 seed - AGV 链路增强:点位锁、车辆状态、退料派车调整,新增海康 RCS Postman 调试集合 - MES 产品BOM/混产模板完善:新增 ProductBOMDialog 组件,调整 handler/logic;日排产达成对比调整 - WMS 业务完善:出入库、检验、备料、退料、成品入库、缺料代报等 handler 与前端页面调整 - 前端通用:双端新增 RemotePageSelect 组件,统一 nextStep 规则/帮助文档/布局/请求拦截 - 文档:更新产线API/案例/部署手册/问题记录等
438 lines
19 KiB
Go
438 lines
19 KiB
Go
// Package agv 海康 AGV 调度系统(RCS-Lite V1.5) 对接客户端(2026-10-17 由 RCS-2000 改为 RCS-Lite 1.5)。
|
||
// 能力:生成搬运任务(genAgvSchedulingTask)、查询任务状态(queryTaskStatus)、取消任务(cancelTask)。
|
||
// 协议详见《AGV海康litev1.5.md》:无签名;所有参数统一字符串;成功 code=="0"。
|
||
// 完整请求路径 = BaseURL(已含 /rcms/services/rest/hikRpcService,小写) + 业务路径;
|
||
// 车辆状态查询例外:走 AgvStatusURL(rcms-dps/rest 独立服务) + /queryAgvStatus。
|
||
// 未配置真实 RCS(BaseURL 为空) 或 EnableMock=true 时走 Mock 客户端。
|
||
package agv
|
||
|
||
import (
|
||
"bytes"
|
||
"context"
|
||
"encoding/json"
|
||
"fmt"
|
||
"io"
|
||
"net/http"
|
||
"net/url"
|
||
"strings"
|
||
"time"
|
||
|
||
"github.com/google/uuid"
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
|
||
"bj_power_mes/internal/config"
|
||
"bj_power_mes/internal/netutil"
|
||
)
|
||
|
||
// commTag 本机 IP 前缀(进程启动解析一次),断网排查时可一眼看出日志来自哪台机器。
|
||
var commTag = netutil.Tag()
|
||
|
||
// Client AGV 调度客户端抽象
|
||
type Client interface {
|
||
// SubmitTask 下发搬运任务 fromDock -> toDock。taskCode 为我方任务单号(透传给 RCS 便于回查)。
|
||
// agvCode 指定执行车辆(接口文档 2.1.1:选填;手动多段链第二段起锁同一台车必须传,
|
||
// 第一段/业务自动段传空由 RCS 自由派车)。指定车不可用/不存在时 RCS 返回错误码(1011 小车不存在)。
|
||
// templateType 动作模板类型(模板跟着任务段走):"LIFT"=举升 / "NONE"=非举升 / "EMPTY"=空车接货首段,
|
||
// 或上层从「基础设置」sys_config 读出的具体模板编号(B01 举升 / B02 移动 / C01 空车接货,B0*/C0* 前缀透传);
|
||
// yaml 不再配置模板编号,代码内保留 B01/B02/C01 出厂兜底(接口文档 2.1.1:taskTyp 与 RCS 端模板一一对应)。
|
||
// 成功返回该 taskCode(RCS-Lite 不下发明文任务码,以我方 taskCode 为唯一追踪键)。
|
||
SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode, templateType, agvCode string) (string, error)
|
||
// QueryTask 查询任务状态,返回 RCS 数字状态:"1"已创建/"2"执行中/"5"取消完成/"9"已结束;
|
||
// 第二返回值为 RCS 分配的车辆编号 agvCode(任务分车后回传,用于绑定 agv_vehicle_state;可能为空)。
|
||
QueryTask(ctx context.Context, taskCode string) (status string, agvCode string, err error)
|
||
// CancelTask 取消任务(按 taskCode)。
|
||
CancelTask(ctx context.Context, taskCode, reason string) error
|
||
// ContinueTask 继续任务(3.1.4):让 RCS 继续/完成当前挂起的任务。
|
||
// C01「空车接货到位等待」专用——车到接货点停下后 RCS 任务挂起(taskStatus 恒 2、不发 end 回调),
|
||
// 2026-11-17 用户定案:下发下一段前必须先 continueTask 让 C01 完结,再 genAgvSchedulingTask。
|
||
// 触发方式 taskCode/agvCode/wbCode/podCode 四选一,文档推荐 taskCode,与模板触发类型一致。
|
||
ContinueTask(ctx context.Context, taskCode string) error
|
||
// QueryAgvStatus 只读获取车辆状态(3.1.7 queryAgvStatus):车辆闲忙/充电/电量/位置。
|
||
// 纯只读展示,不参与调度(调度完全交给 RCS 自身)。
|
||
// mapShortName 地图简称由上层从「基础设置」sys_config 读入传入(yaml 不再配置);空值的硬校验在上层做。
|
||
QueryAgvStatus(ctx context.Context, mapShortName string) ([]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 == "" {
|
||
return newMockClient()
|
||
}
|
||
return newRealClient(cfg)
|
||
}
|
||
|
||
// ---------- 请求与响应(真实海康 RCS-Lite) ----------
|
||
|
||
type realClient struct {
|
||
cfg config.AgvConf
|
||
hc *http.Client
|
||
carrier string
|
||
statusBase string // 车辆状态(rcms-dps/rest)独立服务地址
|
||
}
|
||
|
||
func newRealClient(cfg config.AgvConf) *realClient {
|
||
return &realClient{
|
||
cfg: cfg,
|
||
hc: &http.Client{Timeout: 15 * time.Second},
|
||
carrier: cfg.CarrierCode,
|
||
statusBase: resolveStatusBase(cfg),
|
||
}
|
||
}
|
||
|
||
// resolveStatusBase 车辆状态(rcms-dps/rest)地址:优先显式配置;留空则从 BaseURL 取 scheme://host 推导。
|
||
// 推导用 net/url 解析(非正则),如 http://IP:8182/rcms/services/... → http://IP:8182/rcms-dps/rest。
|
||
func resolveStatusBase(cfg config.AgvConf) string {
|
||
if s := strings.TrimSpace(cfg.AgvStatusURL); s != "" {
|
||
return strings.TrimRight(s, "/")
|
||
}
|
||
u, err := url.Parse(cfg.BaseURL)
|
||
if err != nil || u.Scheme == "" || u.Host == "" {
|
||
return ""
|
||
}
|
||
return u.Scheme + "://" + u.Host + "/rcms-dps/rest"
|
||
}
|
||
|
||
// url 拼接 RCS-Lite 任务接口地址 + 业务路径(BaseURL 已含 /rcms/services/rest/hikRpcService,小写)。
|
||
func (c *realClient) url(path string) string {
|
||
return strings.TrimRight(c.cfg.BaseURL, "/") + path
|
||
}
|
||
|
||
// statusURL 拼接车辆状态地址 + 业务路径(rcms-dps/rest 独立服务)。
|
||
func (c *realClient) statusURL(path string) string {
|
||
return strings.TrimRight(c.statusBase, "/") + path
|
||
}
|
||
|
||
// flexString 兼容 RCS 字段「有时返回 JSON 字符串、有时返回数字」的情况。
|
||
// 协议文档写"参数统一字符串",但实测响应 code 返回数字 1006/-1、status 也可能是数字,
|
||
// 用 string 直接反序列化会报 cannot unmarshal number into Go struct field ... of type string。
|
||
// 本类型把字符串/数字/布尔/null 统一收成字符串,下游按字符串比较即可。不使用正则。
|
||
type flexString string
|
||
|
||
func (f *flexString) UnmarshalJSON(b []byte) error {
|
||
if len(b) == 0 {
|
||
*f = ""
|
||
return nil
|
||
}
|
||
if b[0] == '"' { // JSON 字符串
|
||
var s string
|
||
if err := json.Unmarshal(b, &s); err != nil {
|
||
return err
|
||
}
|
||
*f = flexString(s)
|
||
return nil
|
||
}
|
||
var v any // 数字/布尔/null 按字面量收
|
||
if err := json.Unmarshal(b, &v); err != nil {
|
||
return err
|
||
}
|
||
if v == nil {
|
||
*f = ""
|
||
return nil
|
||
}
|
||
*f = flexString(fmt.Sprint(v))
|
||
return nil
|
||
}
|
||
|
||
// envelope RCS-Lite 统一响应信封(§1.4):code 必填、message 必填、reqCode 回传、data 选填。
|
||
type envelope struct {
|
||
Code flexString `json:"code"`
|
||
Message string `json:"message"`
|
||
ReqCode string `json:"reqCode"`
|
||
Data json.RawMessage `json:"data"`
|
||
}
|
||
|
||
// BizError RCS 业务拒绝(信封 code != "0"):报文本身到达并被执行,只是被 RCS 判为非法。
|
||
// 与传输层错误(超时/连接失败)严格区分——上层据此判断「是配置不对」还是「是网络/服务不通」。
|
||
type BizError struct {
|
||
Code string
|
||
Message string
|
||
}
|
||
|
||
func (e *BizError) Error() string { return "agv code=" + e.Code + " message=" + e.Message }
|
||
|
||
// call POST 到 RCS-Lite 任务接口(BaseURL)并解析信封。
|
||
func (c *realClient) call(ctx context.Context, path string, payload map[string]any, out any) error {
|
||
return c.callAt(ctx, c.url(path), payload, out)
|
||
}
|
||
|
||
// callAt POST 到完整 URL 并解析信封。成功判定 code=="0";out 非空时把 data 反序列化进去。
|
||
// 车辆状态(rcms-dps)等独立服务接口用本方法,避免误挂到任务接口 BaseURL 下。
|
||
func (c *realClient) callAt(ctx context.Context, reqURL string, payload map[string]any, out any) error {
|
||
if payload == nil {
|
||
payload = map[string]any{}
|
||
}
|
||
// reqCode 幂等键(文档 §1.3 全局唯一):调用方已设置(如 SubmitTask 用 taskCode,
|
||
// 重试复用同一 taskCode → RCS 幂等去重)则沿用,否则本次请求生成随机串。
|
||
// 2026-11-17 现场修复:海康校验 reqCode 长度 ≤32,标准 uuid.NewString() 为 36 字符(含 4 个 '-')
|
||
// 触发「reqCode输入的值长度不符合规范」(QueryTask/CancelTask/QueryAgvStatus 均中招)。
|
||
// 改为去连字符的 32 位十六进制串,符合文档且不超长。
|
||
if _, exists := payload["reqCode"]; !exists {
|
||
payload["reqCode"] = strings.ReplaceAll(uuid.NewString(), "-", "")
|
||
}
|
||
payload["reqTime"] = time.Now().Format("2006-01-02 15:04:05")
|
||
|
||
body, err := json.Marshal(payload)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
// 2026-11-16 联调:AGV 全量 HTTP 交互落日志(请求 URL/报文 + 响应状态/响应体),grep "[AGV]" 可见。
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+" --> POST %s payload=%s", reqURL, string(body))
|
||
|
||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewReader(body))
|
||
if err != nil {
|
||
logx.WithContext(ctx).Errorf("[AGV]"+commTag+" <-- build request error url=%s err=%v", reqURL, err)
|
||
return err
|
||
}
|
||
req.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||
|
||
resp, err := c.hc.Do(req)
|
||
if err != nil {
|
||
logx.WithContext(ctx).Errorf("[AGV]"+commTag+" <-- transport error url=%s err=%v", reqURL, err)
|
||
return err
|
||
}
|
||
defer resp.Body.Close()
|
||
raw, err := io.ReadAll(resp.Body)
|
||
if err != nil {
|
||
logx.WithContext(ctx).Errorf("[AGV]"+commTag+" <-- read body error url=%s httpStatus=%d err=%v", reqURL, resp.StatusCode, err)
|
||
return err
|
||
}
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+" <-- HTTP %d url=%s body=%s", resp.StatusCode, reqURL, string(raw))
|
||
if resp.StatusCode >= 400 {
|
||
return fmt.Errorf("agv http %d: %s", resp.StatusCode, string(raw))
|
||
}
|
||
var env envelope
|
||
if err := json.Unmarshal(raw, &env); err != nil {
|
||
return fmt.Errorf("agv parse envelope: %w", err)
|
||
}
|
||
// 成功码固定字符串 "0"(§1.5 结果码定义)
|
||
if env.Code != "0" {
|
||
logx.WithContext(ctx).Errorf("[AGV]"+commTag+" <-- biz error url=%s code=%s message=%s reqCode=%v", reqURL, env.Code, env.Message, payload["reqCode"])
|
||
return &BizError{Code: string(env.Code), Message: env.Message}
|
||
}
|
||
if out != nil && len(env.Data) > 0 {
|
||
// env.Data 已是响应体里 "data" 字段的原始内容(数组或对象)——out 必须直接对应它。
|
||
// 2026-11-17 修复:queryTaskStatus/queryAgvStatus 的 data 是数组,out 曾多包一层
|
||
// struct{Data []X} 导致「cannot unmarshal array into Go value of type struct」。
|
||
return json.Unmarshal(env.Data, out)
|
||
}
|
||
return nil
|
||
}
|
||
|
||
// SubmitTask 实现 Client:生成搬运任务(genAgvSchedulingTask)。
|
||
// 两点搬运:源点(fromDock) → 目标点(toDock) 用 positionCodePath 两个点(type=00 位置编号)表达。
|
||
// 空车段(fromDock 为空,2026-11-03 三段链模型):仅下发目标点单点 path,由 RCS 派最近空闲车前往——
|
||
// 对应「业务自动触发免弹窗」的空车去程(AGV 空车前往装货点);若现场 RCS 要求两点 path,联调时改为 [充电位, 装货点]。
|
||
// 模板跟着任务段走(2026-11-05 拍板):templateType="LIFT" 用举升模板(段涉及接驳台),否则非举升模板,
|
||
// 映射为 RCS taskTyp(文档 2.1.1;模板在 RCS 端按任务类型编号配置)。taskCode 透传我方任务单号。
|
||
func (c *realClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode, templateType, agvCode string) (string, error) {
|
||
path := []map[string]any{
|
||
{"positionCode": toDock, "type": "00"},
|
||
}
|
||
if fromDock != "" {
|
||
path = []map[string]any{
|
||
{"positionCode": fromDock, "type": "00"},
|
||
{"positionCode": toDock, "type": "00"},
|
||
}
|
||
}
|
||
// 2026-11-17 拍板:B01/B02/C01 模板编号统一在 MES「基础设置」页维护(sys_config),
|
||
// 派车入口(dispatchAgvSegment / 重试)已按业务从 sys_config 读出具体编号(B0*/C0* 前缀)传入并直接透传。
|
||
// yaml 不再配置模板编号;此处仅保留代码级出厂兜底,防止 sys_config 漏配时海康 taskTyp 为空报错。
|
||
const (
|
||
factoryTaskTypLift = "B01" // 举升(JBT21 / 工位接驳台)
|
||
factoryTaskTypPlain = "B02" // 移动(虚拟点位)
|
||
factoryTaskTypEmpty = "C01" // 空车接货(人工派车首段,只到达点不举升)
|
||
)
|
||
taskTyp := factoryTaskTypPlain
|
||
switch templateType {
|
||
case "LIFT":
|
||
taskTyp = factoryTaskTypLift
|
||
case "EMPTY":
|
||
taskTyp = factoryTaskTypEmpty
|
||
}
|
||
// B0*(B01/B02)与 C0*(C01)为上层从 sys_config 读出的实际编号,直接透传
|
||
if strings.HasPrefix(templateType, "B0") || strings.HasPrefix(templateType, "C0") {
|
||
taskTyp = templateType
|
||
}
|
||
if taskTyp == "" {
|
||
taskTyp = "F01" // 极端兜底(与迁移前固定 F01 行为一致)
|
||
}
|
||
payload := map[string]any{
|
||
"taskTyp": taskTyp,
|
||
"positionCodePath": path,
|
||
"priority": c.cfg.Priority,
|
||
"taskCode": taskCode,
|
||
// requestId 幂等(2026-11-06 拍板):reqCode=taskCode,重试(同 taskNo 重新下发)自动复用
|
||
// 同一 requestId,RCS 侧按 reqCode 幂等去重,避免重试产生重复任务。
|
||
"reqCode": taskCode,
|
||
}
|
||
carrier := carrierCode
|
||
if carrier == "" {
|
||
carrier = c.carrier
|
||
}
|
||
if carrier != "" {
|
||
payload["podCode"] = carrier // 载具/托盘编号(选填)
|
||
}
|
||
// 指定执行车辆(接口文档 2.1.1 agvCode,选填):手动多段链锁车用;空=RCS 自由派车
|
||
if agvCode != "" {
|
||
payload["agvCode"] = agvCode
|
||
}
|
||
if err := c.call(ctx, "/genAgvSchedulingTask", payload, nil); err != nil {
|
||
return "", err
|
||
}
|
||
// RCS-Lite 不下发明文任务码,以我方 taskCode 为追踪键
|
||
return taskCode, nil
|
||
}
|
||
|
||
// queryTaskData queryTaskStatus 的 data 列表项(字段兼容字符串/数字)
|
||
type queryTaskData struct {
|
||
TaskCode flexString `json:"taskCode"`
|
||
TaskStatus flexString `json:"taskStatus"`
|
||
AgvCode flexString `json:"agvCode"`
|
||
TaskTyp flexString `json:"taskTyp"`
|
||
}
|
||
|
||
// QueryTask 实现 Client:查询任务状态(queryTaskStatus)。
|
||
// 按 taskCode 查询,返回匹配项的 taskStatus(数字字符串)与 RCS 分配的 agvCode;无匹配视为刚创建("1")。
|
||
func (c *realClient) QueryTask(ctx context.Context, taskCode string) (string, string, error) {
|
||
payload := map[string]any{
|
||
"agvCode": "",
|
||
"taskCodes": []string{taskCode},
|
||
}
|
||
var out []queryTaskData
|
||
if err := c.call(ctx, "/queryTaskStatus", payload, &out); err != nil {
|
||
return "", "", err
|
||
}
|
||
for _, d := range out {
|
||
if string(d.TaskCode) == taskCode && d.TaskStatus != "" {
|
||
return string(d.TaskStatus), string(d.AgvCode), nil
|
||
}
|
||
}
|
||
return "1", "", nil
|
||
}
|
||
|
||
// CancelTask 实现 Client:取消任务(cancelTask,按 taskCode)。
|
||
func (c *realClient) CancelTask(ctx context.Context, taskCode, reason string) error {
|
||
if taskCode == "" {
|
||
return fmt.Errorf("缺少任务单号")
|
||
}
|
||
payload := map[string]any{
|
||
"taskCode": taskCode,
|
||
"forceCancel": "0", // 0=取消后货架放地上(默认)
|
||
}
|
||
_ = reason // RCS-Lite 取消任务接口无原因字段,原因仅落本地 agv_tasks.remark
|
||
return c.call(ctx, "/cancelTask", payload, nil)
|
||
}
|
||
|
||
// ContinueTask 实现 Client:3.1.4 continueTask,让 RCS 继续/完成挂起任务(C01 到位等待收尾)。
|
||
func (c *realClient) ContinueTask(ctx context.Context, taskCode string) error {
|
||
if taskCode == "" {
|
||
return fmt.Errorf("缺少任务单号")
|
||
}
|
||
return c.call(ctx, "/continueTask", map[string]any{"taskCode": taskCode}, nil)
|
||
}
|
||
|
||
// queryAgvStatusData 3.1.7 单条车辆状态 data 项(字段兼容字符串/数字)
|
||
type queryAgvStatusData struct {
|
||
RobotCode flexString `json:"robotCode"`
|
||
Battery flexString `json:"battery"`
|
||
Status flexString `json:"status"`
|
||
PodCode flexString `json:"podCode"`
|
||
PosX flexString `json:"posX"`
|
||
PosY flexString `json:"posY"`
|
||
Stop flexString `json:"stop"`
|
||
}
|
||
|
||
// QueryAgvStatus 实现 Client:3.1.7 只读获取全部车辆状态。
|
||
// 走 rcs-dps/rest 独立服务(§3.1.7 调用路径 http://IP:8182/rcms-dps/rest/queryAgvStatus),
|
||
// 不是 hikRpcService 任务接口——此前挂到任务 BaseURL 下导致 404。
|
||
// mapShortName 由上层从「基础设置」sys_config 读入传入;文档 §3.1.7「mapShortName 必填,2 位地图简称」。
|
||
// 2026-11-17 拍板:配置从 yaml 收拢到基础设置页,空值的硬校验在上层(logic.ListAgvVehicles)做,
|
||
// 底层只负责透传,不使用任何兜底假值。
|
||
func (c *realClient) QueryAgvStatus(ctx context.Context, mapShortName string) ([]AgvVehicle, error) {
|
||
payload := map[string]any{
|
||
"mapShortName": strings.TrimSpace(mapShortName),
|
||
// 现场 RCS-Lite(2026-11-17 日志实测)虽文档 3.1.7 未列,缺 robotCount 会回
|
||
// 「robots robotCount同时为空」;-1 表示查询该地图全部车辆(与 freeRobot 同语义)。
|
||
"robotCount": "-1",
|
||
}
|
||
var out []queryAgvStatusData
|
||
if err := c.callAt(ctx, c.statusURL("/queryAgvStatus"), payload, &out); err != nil {
|
||
return nil, err
|
||
}
|
||
vs := make([]AgvVehicle, 0, len(out))
|
||
for _, d := range out {
|
||
vs = append(vs, AgvVehicle{
|
||
RobotCode: string(d.RobotCode),
|
||
Battery: atof(string(d.Battery)),
|
||
Status: string(d.Status),
|
||
PodCode: string(d.PodCode),
|
||
PosX: atof(string(d.PosX)),
|
||
PosY: atof(string(d.PosY)),
|
||
Stop: d.Stop == "1" || d.Stop == "true",
|
||
})
|
||
}
|
||
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 }
|
||
|
||
// ---------- Mock 客户端(未接真实 RCS 时用) ----------
|
||
|
||
type mockClient struct{}
|
||
|
||
func newMockClient() *mockClient { return &mockClient{} }
|
||
|
||
func (m *mockClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode, templateType, agvCode string) (string, error) {
|
||
// 模拟立即成功下发,返回我方 taskCode(与真实客户端一致,HikTaskCode=taskNo)
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+"[MOCK] SubmitTask taskCode=%s %s->%s template=%s agvCode=%s(模拟下发成功,未发真实 HTTP)", taskCode, fromDock, toDock, templateType, agvCode)
|
||
return taskCode, nil
|
||
}
|
||
|
||
func (m *mockClient) QueryTask(ctx context.Context, taskCode string) (string, string, error) {
|
||
// 模拟:MOCK 任务一律视为已结束,便于离线联调观察"待搬运→已到位";模拟模式无真实分车,agvCode 为空
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+"[MOCK] QueryTask taskCode=%s(模拟返回已结束)", taskCode)
|
||
return "9", "", nil
|
||
}
|
||
|
||
func (m *mockClient) CancelTask(ctx context.Context, taskCode, reason string) error {
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+"[MOCK] CancelTask taskCode=%s reason=%s(模拟取消成功)", taskCode, reason)
|
||
return nil
|
||
}
|
||
|
||
// ContinueTask Mock:模拟继续成功(与真实语义一致:RCS 收到后完成挂起任务)。
|
||
func (m *mockClient) ContinueTask(ctx context.Context, taskCode string) error {
|
||
logx.WithContext(ctx).Infof("[AGV]"+commTag+"[MOCK] ContinueTask taskCode=%s(模拟继续成功)", taskCode)
|
||
return nil
|
||
}
|
||
|
||
// QueryAgvStatus Mock:返回两台示例车(一台空闲、一台执行中),便于联调展示。
|
||
func (m *mockClient) QueryAgvStatus(ctx context.Context, mapShortName string) ([]AgvVehicle, error) {
|
||
logx.WithContext(ctx).Infof("[AGV]" + commTag + "[MOCK] QueryAgvStatus(模拟返回样例车 9001/9002)")
|
||
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 }
|