feat(mes/wms/终端): 签字循环业务重构 + 叫料池实物账两列 + 工位流水按包真分页 + 下线单据提示条(2026-11-30 现场整改)

【MES · 签字循环重构(业务重构,非修 bug)】
- 旧模型作废(签字随报工落库、检验员分支永不生效的死代码);新口径:
  工人干完点「呼叫签字」→ 检验员巡检端签 OK/NG → OK 后工人再点一次「报工」;NG 整改后重新呼叫(新一轮)
- 内容指纹(SHA256):呼叫时算一次落库,报工时重算比对,变了即「签字后改数据作废本轮」要求重呼;
  只覆盖步骤录入(值/文本/勾选/拧紧结果),装机绑定不进指纹(独立台账)、改备注不触发
- 轮次统一:一次呼叫=一轮,操作工/检验员共用 round;NG/撤回/重呼=新一轮,旧轮作废历史保留
- 三档状态(作业中/签字中/待整改/可报工)从签字记录推导,不建表不存终端
- 报工闸门:本轮需签步骤齐全(操作工+检验员OK)+ 指纹未变才放行
- 撤回呼叫整轮作废;超时巡检每分钟扫描(阈值 30 分钟可在基础设置调),超时落预警中心+异常角标不进铃铛,60 分钟窗口去重
- 工位终端新增签字交互接口与呼叫/撤回/状态查询;巡检端保留 NG 回看

【MES · 叫料池实物账(十五节 Q1/Q16 + 17.6 裁决)】
- call_pool 新增 receivedQty(已收累计,拒收按退库单冲减)/ returnedQty(已退累计,按退库单号防重)两列实物账,与 sentQty 额度账并存
- 台面在手(可用)= 已收 − 已装 − 已退;在途 = 已发 − 已收

【工位终端 · 物料/叫料页重构(十五节 Q1~Q17 拍板落地)】
- 「本工位物料明细」改名「物料明细」,四数列改为:可用/需求/已发/已收/已装,量为 0 也显示不分左右托盘
- 去除「刷新池子」「刷新」按钮(有长连接);「我的叫料单」扩为类银行流水(叫料/退料/等等)
- 叫料/退料数量列直排,提交时弹窗确认数量并选接驳台;管理端叫料与退料 AGV 派车流程统一收归库管
- 工位流水按包真分页(2026-11-29 拍板):后端按包号分组 Count+Limit/Offset,每页 20 包,前端不再内存聚合

【下线 · 单据流转提示条】
- MES/WMS 前端整体删除 NextStepBar / nextStep / nextStepRules(35 条规则表整套下线),页面不再出现常驻「下一步」提示条

【文档】
- 问题临时.md 新增十四节(主控独立审计:终端账号删除/心跳/闸门函数 8 处对码全过)+ 十五节(工位物料叫料 8 条原话逐字留档与 Q1~Q17 拍板底稿)
- 新增《工位终端页面.md》;案例.md 同步更新验收口径
This commit is contained in:
SunYF
2026-11-30 15:25:29 +08:00
parent 88875c1f13
commit f9eaebad28
120 changed files with 6210 additions and 2366 deletions
+60 -13
View File
@@ -3,6 +3,7 @@ package logic
import (
"context"
"fmt"
"sort"
"strings"
"time"
@@ -29,6 +30,9 @@ type LineClearanceItem struct {
Cleared bool `json:"cleared"`
How string `json:"how"`
Route string `json:"route"`
// 2026-11-30:涉及工位号(去重升序,最多 20 个),前端「去处理」带 ?stationNo= 打开对应页面并定位,
// 不再跳到一个没有任何上下文的全量列表让用户自己找。
StationNos []int `json:"stationNos"`
// HardBlock=true 表示该项不能靠「现场已处理」勾选放行——必须先现场清掉实物。
// 2026-11-27 新增:PLC 传感器实时有件属硬拒绝(保存时 SaveStation 同样硬拦),
// 若做成可勾选放行,用户勾了以为能过、点保存还是被拦,反而更困惑。
@@ -51,42 +55,63 @@ func (s *Service) CheckLineClearance(ctx context.Context, confirmed []string, op
}
type probe struct {
key string
label string
how string // 怎么解决(人话,点名道姓到页面和动作)
route string // 前端路由,点「去处理」直达
count func() (int, error)
key string
label string
how string // 怎么解决(人话,点名道姓到页面和动作)
route string // 前端路由,点「去处理」直达
count func() (int, error)
stations func() ([]int, error) // 涉及工位号(可选,供「去处理」定位)
}
probes := []probe{
{"workpiece", "工位上还有在制工件",
"到「在制品追踪」页把这些工件完工或暂存退库,台面清空后再回来点确认", "/wip",
func() (int, error) {
return s.ctx.EntClient.Workpiece.Query().Where(workpiece.AtStationNoGT(0)).Count(ctx)
},
func() ([]int, error) {
return s.ctx.EntClient.Workpiece.Query().Where(workpiece.AtStationNoGT(0)).
Select(workpiece.FieldAtStationNo).Ints(ctx)
}},
{"residual", "工位还有未用完的料",
"到工位终端做「退料」把余料退回库房,或在「生产退料」页确认/取消待处理退料单", "/transfer-return",
func() (int, error) {
return s.ctx.EntClient.CallPool.Query().
Where(callpool.Or(callpool.SentQtyGT(0), callpool.ReservedQtyGT(0))).Count(ctx)
},
func() ([]int, error) {
return s.ctx.EntClient.CallPool.Query().
Where(callpool.Or(callpool.SentQtyGT(0), callpool.ReservedQtyGT(0))).
Select(callpool.FieldStationNo).Ints(ctx)
}},
{"pallet", "产线点位上还压着带工件的托盘",
"用「人工派车 → 托盘回库」把托盘(连同工件)拉走,或把工件完工/退库;空托盘(上面没工件)不算占位、不用处理", "/agv-manual",
func() (int, error) {
return s.ctx.EntClient.LinePoint.Query().
Where(linepoint.CurrentSnNEQ("")).Count(ctx)
},
func() ([]int, error) {
return s.ctx.EntClient.LinePoint.Query().
Where(linepoint.CurrentSnNEQ("")).
Select(linepoint.FieldStationNo).Ints(ctx)
}},
{"plc", "PLC 还有没执行完的指令",
"到「工位下发」页核对这些指令是否已到位;确实清完再回来勾确认。PLC 离线时可现场目视确认后勾选放行(会留痕)", "/plc-send",
func() (int, error) {
return s.ctx.EntClient.PlcSendLog.Query().
Where(plcsendlog.StatusIn("SENT", "PENDING")).Count(ctx)
},
func() ([]int, error) {
return s.ctx.EntClient.PlcSendLog.Query().
Where(plcsendlog.StatusIn("SENT", "PENDING")).
Select(plcsendlog.FieldStationNo).Ints(ctx)
}},
{"agv", "还有 AGV 任务没结束",
"到「AGV管理」页把这些任务结束或取消;海康后台遗留的非本系统任务请到海康 RCS 后台处理", "/agv",
func() (int, error) {
return s.ctx.EntClient.AgvTask.Query().
Where(agvtask.StatusIn("PENDING", "1", "2", "ARRIVED")).Count(ctx)
}},
},
nil},
}
unresolved := []string{}
for _, p := range probes {
@@ -96,6 +121,11 @@ func (s *Service) CheckLineClearance(ctx context.Context, confirmed []string, op
return nil, fmt.Errorf("清线检查「%s」失败,禁止继续:%v", p.label, e)
}
item := LineClearanceItem{Key: p.key, Label: p.label, Count: n, Cleared: confirmedSet[p.key], How: p.how, Route: p.route}
if p.stations != nil {
if nos, se := p.stations(); se == nil {
item.StationNos = normalizeStationNos(nos)
}
}
res.Items = append(res.Items, item)
if n > 0 && !item.Cleared {
unresolved = append(unresolved, fmt.Sprintf("%s(%d 项)", p.label, n))
@@ -107,22 +137,22 @@ func (s *Service) CheckLineClearance(ctx context.Context, confirmed []string, op
// 把「传感器说有件」的工位一次性列在预检里,不能等到保存才冒出来。
// PLC 离线/读失败:不 fail-close(离线由第五项 plc 指令 + 保存时的 3021 现场确认兜底),
// 只在文案里注明「读不到实时状态」,避免把通讯故障当成「无件」误导。
scanLive := func() (int, bool) {
scanLive := func() (int, []int, bool) {
bits, e := plcHardCut(ctx, 2500*time.Millisecond, func(c context.Context) ([]bool, error) {
return s.ctx.PLC.ReadBitsCached(c)
})
if e != nil || len(bits) < 12 {
return 0, false
return 0, nil, false
}
n := 0
nos := make([]int, 0, 12)
for k := 0; k < 12; k++ {
if bits[k] {
n++
nos = append(nos, k+1)
}
}
return n, true
return len(nos), nos, true
}
liveCount, liveOK := scanLive()
liveCount, liveNos, liveOK := scanLive()
if !liveOK {
// 通讯异常:作为一项「无法核对」列出,允许现场目视确认后勾「现场已处理」放行
// (与保存时 PLC 离线 3021 现场确认同口径:通讯断了不能永久卡死)
@@ -139,7 +169,7 @@ func (s *Service) CheckLineClearance(ctx context.Context, confirmed []string, op
// 传感器确实看到工位有实物:硬阻塞,不能勾确认放行(保存时同样硬拦)。
res.Items = append(res.Items, LineClearanceItem{
Key: "plc_sensor", Label: "PLC 传感器实时显示工位上有工件",
Count: liveCount, Cleared: false, HardBlock: true,
Count: liveCount, Cleared: false, HardBlock: true, StationNos: liveNos,
How: "必须先到现场把工位台面上的工件搬走/完工/退库,传感器检测不到托盘后再点「重新检查」;此项不能靠勾选放行",
Route: "/plc-monitor",
})
@@ -162,6 +192,23 @@ func (s *Service) CheckLineClearance(ctx context.Context, confirmed []string, op
return res, nil
}
// normalizeStationNos 工位号去重升序(丢掉 0/负数,限 20 个,够前端定位用)。
func normalizeStationNos(in []int) []int {
seen := map[int]bool{}
out := make([]int, 0, len(in))
for _, n := range in {
if n > 0 && !seen[n] {
seen[n] = true
out = append(out, n)
}
}
sort.Ints(out)
if len(out) > 20 {
out = out[:20]
}
return out
}
// GuardLineClearanceWithConfirm 换绑定前清线确认(不清干净需逐项现场确认放行,留痕 event_log)。
func (s *Service) GuardLineClearanceWithConfirm(ctx context.Context, confirmed []string, operator string) error {
res, err := s.CheckLineClearance(ctx, confirmed, operator)