Files
SunYF af554cea75 feat: 同步失败台账双向可重试 + 拧紧枪按工位配置 + 虚拟工位体系 + 去Redis与文档口径对齐
- 同步失败台账:MES/WMS 双端新增台账与页面,跨系统通知失败落台账、人工重试或标记已处理,不自动重传;重试前先判对端终态;叫料、配送、出库回写失败提示指向台账;补幂等建表脚本与菜单权限。
- 拧紧枪:新增按工位配置页,展示控制器地址与三把枪通道号(仅供查看,不参与采集校验);「允许手填」由全局开关改为每工位开关,关闭时校验该工位已配控制器;终端启动/登录上报配置并按本工位拉取,扭矩手填框按本工位置灰;补全局值迁移到各工位的脚本。
- 工位体系:终端未配置工位号时登录页可选(含虚拟工位),固定工位模式保留;虚拟/线下位不叫料、不退料、不作转产目标,未采集绑定放行并说明原因;叫料期望接驳台改为选填。
- AGV与出库:补「出库单已送达」回写;空车回充、接驳台传感器失联、配送状态更新失败均落预警或留痕并提示人工核对;人工出库不引入送达状态;出库单支持目标工位/接驳台并扩展导出列。
- 基础设施:看板缓存由Redis改为MES进程内实现,文档与启动脚本同步去Redis;扫码监听支持多地址、端口被占自动降级;PLC对账与工位报警在MES不可达时降级放行并留日志。
- 文档与帮助:案例与部署手册按实测订正(工位绑定、菜单名称、补料由班组长代提、菜单覆盖对照、虚拟工位);迁移脚本改为本地即时执行并登记7个已执行脚本;三端页面帮助改为「业务/操作/影响范围/后果」四要素。
- 测试:新增独立Go模块,按三个业务场景做真实HTTP与真实写库的流水测试,含运行报告。
2026-11-09 18:58:47 +08:00

85 lines
3.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package common 跨场景通用业务口径(案例.md:538-625)。
// 只读核查:直连三库看真实数据分布,不发起写操作。
package common
import (
"fmt"
"bj_power_test/internal/assert"
"bj_power_test/internal/db"
"bj_power_test/internal/env"
)
// Item 一条口径核查。
type Item struct {
ID, Line, Name, Query string
Target db.Target
Expect string
}
// Items 七组口径的只读核查项。
var Items = []Item{
{"C-01", "案例.md:540-545", "叫料时接驳台非必填(允许空值行)",
"select count(*) from material_request where target_dock is null or target_dock=''", db.MES, ">=0"},
{"C-02", "案例.md:543,601-611", "退料必须指定左/右接驳台(空值行应为 0)",
"select count(*) from return_orders where return_dock is null or return_dock=''", db.WMS, "0"},
{"C-03", "案例.md:544,282", "叫料池按工位×物料聚合、不认工单",
"select count(*) from call_pool", db.MES, ">=0"},
{"C-04", "案例.md:551-560", "AGV 任务按配送单驱动(biz_no 关联配送单)",
"select count(*) from agv_tasks", db.MES, ">=0"},
{"C-05", "案例.md:613-617", "损耗原因在 WMS 确认收货时落账",
"select count(*) from return_orders where loss_reason is not null and loss_reason<>''", db.WMS, ">=0"},
{"C-06", "案例.md:623-625", "MES 物料副本与 WMS 主数据源同源",
"select count(*) from materials", db.MES, "同源"},
{"C-07", "案例.md:547-549", "设备失联降级动作有事件日志留痕",
"select count(*) from event_log", db.MES, ">=0"},
{"C-08", "案例.md:449,547-549", "工位终端本地无离线队列/重试缓存表",
"select count(*) from sqlite_master where type='table' and name in ('report_queue','torque_results')", db.WS, "0"},
}
// Run 执行只读口径核查。
func Run(c *assert.Ctx) {
for _, it := range Items {
if !c.DB.Ready(it.Target) {
c.L4(it.ID, it.Line, it.Name+"(期望 "+it.Expect+")",
string(it.Target)+" 库未连接", false, "库不可用,无法核查")
continue
}
got, err := c.DB.Scalar(c.C, it.Target, it.Query)
if err != nil {
c.L4(it.ID, it.Line, it.Name+"(期望 "+it.Expect+")",
"SQL 失败:"+err.Error(), false, err.Error())
continue
}
pass := true
reason := ""
if it.Expect == "0" || it.Expect == "同源" {
if it.Expect == "0" && got != "0" && got != "" {
pass, reason = false, "期望 0,实际 "+got
}
}
actual := fmt.Sprintf("%s → %q", it.Query, got)
if it.ID == "C-06" {
wmsCnt, werr := c.DB.Scalar(c.C, db.WMS, "select count(*) from materials")
if werr == nil {
actual = fmt.Sprintf("MES=%s / WMS=%s(差集需按 code 逐条核)", got, wmsCnt)
pass = got == wmsCnt
if !pass {
reason = "两库物料行数不一致"
}
}
}
c.L4(it.ID, it.Line, it.Name+"(期望 "+it.Expect+")", actual, pass, reason)
}
// 看板口径:只展示正面指标(案例.md:619-621)。
resp, err := c.Client.Get(c.C, env.Board, "/")
if err != nil {
c.L4("C-09", "案例.md:619-621", "看板免登录可读、报喜不报忧",
"看板不可达:"+err.Error(), false, "看板服务未启动")
return
}
c.L4("C-09", "案例.md:619-621", "看板免登录可读、报喜不报忧",
fmt.Sprintf("HTTP %d / 首页长度 %d 字节", resp.HTTPStatus, len(resp.Raw)),
resp.HTTPStatus == 200, "若非 200:看板未就绪")
}