feat: AGV点位锁与缓存迁移 + 工位终端去离线队列 + WMS出入库增强

【MES】
- AGV点位/线路点位/AGV任务/工单 ent schema 重构(全量重生成 ent 代码)
- 新增派车锁 agv_point_lock.go:目标点位占用即拒车,JBT21 库房接驳台卸货后保持锁定待库管手动解锁
- 新增进程内 TTL 缓存 cache.go,由 Redis 看板缓存迁移至内存(singleflight 防击穿,去除外部依赖)
- AGV 三段链安全机制、车辆状态/接驳台左右互换、补料损耗闭环完善
- 来料检/工序卡/工单/质检/日排产/AGV 前端与帮助文档更新
- 新增 migrations/、sql/ 目录

【WMS】
- 出库、Excel 导出、物料、路由处理增强
- 配置与 DB 初始化调整;基础数据/成品入库/入库前端调整

【工位终端】
- 移除离线同步队列(syncer 包、sync.go、SyncQueueDialog.vue),改为实时直连上报 MES(断网即失败报错),以本人身份操作
- 本地 SQLite 仅保留操作日志 + 内置账号 + 登录态;保留空闲自动登出

【文档】
- 删除 AGV海康litev1.5.md;案例.md 更新
This commit is contained in:
SunYF
2026-11-07 15:06:00 +08:00
parent 1d1dc1bdd8
commit 5e2640c13a
118 changed files with 4040 additions and 3594 deletions
+30 -6
View File
@@ -23,8 +23,13 @@ import (
// Client AGV 调度客户端抽象
type Client interface {
// SubmitTask 下发搬运任务 fromDock -> toDock。taskCode 为我方任务单号(透传给 RCS 便于回查)。
// agvCode 指定执行车辆(接口文档 2.1.1:选填;手动多段链第二段起锁同一台车必须传,
// 第一段/业务自动段传空由 RCS 自由派车)。指定车不可用/不存在时 RCS 返回错误码(1011 小车不存在)。
// templateType 动作模板类型(模板跟着任务段走,2026-11-05 拍板):"LIFT"=举升模板(段涉及接驳台,
// 需举升/放下交接托盘)、其它=非举升模板(纯停靠无交接);内部映射配置 TaskTypLift/TaskTypPlain
// 为 RCS taskTyp(接口文档 2.1.1:taskTyp 与 RCS 端配置的任务模板一一对应)。
// 成功返回该 taskCode(RCS-Lite 不下发明文任务码,以我方 taskCode 为唯一追踪键)。
SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode string) (string, error)
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)
@@ -90,7 +95,11 @@ func (c *realClient) call(ctx context.Context, path string, payload map[string]a
if payload == nil {
payload = map[string]any{}
}
payload["reqCode"] = uuid.NewString()
// reqCode 幂等键(文档 §1.3 全局唯一):调用方已设置(如 SubmitTask 用 taskCode,
// 重试复用同一 taskCode → RCS 幂等去重)则沿用,否则本次请求生成随机 UUID。
if _, exists := payload["reqCode"]; !exists {
payload["reqCode"] = uuid.NewString()
}
payload["reqTime"] = time.Now().Format("2006-01-02 15:04:05")
body, err := json.Marshal(payload)
@@ -133,8 +142,9 @@ func (c *realClient) call(ctx context.Context, path string, payload map[string]a
// 两点搬运:源点(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) {
// 模板跟着任务段走(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"},
}
@@ -144,11 +154,21 @@ func (c *realClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock,
{"positionCode": toDock, "type": "00"},
}
}
taskTyp := c.cfg.TaskTypPlain
if templateType == "LIFT" {
taskTyp = c.cfg.TaskTypLift
}
if taskTyp == "" {
taskTyp = "F01" // 配置缺省兜底(与迁移前固定 F01 行为一致)
}
payload := map[string]any{
"taskTyp": "F01",
"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 == "" {
@@ -157,6 +177,10 @@ func (c *realClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock,
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
}
@@ -259,7 +283,7 @@ type mockClient struct{}
func newMockClient() *mockClient { return &mockClient{} }
func (m *mockClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode string) (string, error) {
func (m *mockClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode, templateType, agvCode string) (string, error) {
// 模拟立即成功下发,返回我方 taskCode(与真实客户端一致,HikTaskCode=taskNo)
return taskCode, nil
}