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:
@@ -24,8 +24,8 @@ import (
|
||||
// (一台终端实例可同时登录多个虚拟工位,各订阅方只收到自己工位的事件)。
|
||||
// 断线自动重连(3 秒退避);前端断线重连后的一次性补拉由前端自己做。
|
||||
type Manager struct {
|
||||
mc *mes.Client
|
||||
stationNo int // 本机固定工位号(>0);2026-11-28 拍板:SSE 建连/断连驱动该工位在线状态
|
||||
mc *mes.Client
|
||||
stationNo int // 本机固定工位号(>0);2026-11-28 拍板:SSE 建连/断连驱动该工位在线状态
|
||||
|
||||
mu sync.Mutex
|
||||
clients map[chan workEvent]int // channel → 订阅方工位号(<=0 表示不过滤,全收)
|
||||
@@ -81,7 +81,7 @@ func (m *Manager) broadcast(ev workEvent) {
|
||||
switch ev.Type {
|
||||
case "station.alert":
|
||||
deliver = st <= 0 || mentionStation(ev.Data, st)
|
||||
case "station.workpiece", "station.state":
|
||||
case "station.workpiece", "station.state", "station.material", "station.sign":
|
||||
if st > 0 {
|
||||
var p struct {
|
||||
StationNo int `json:"stationNo"`
|
||||
@@ -182,6 +182,8 @@ var mesStationEvents = map[string]bool{
|
||||
"station.workpiece": true,
|
||||
"station.points": true,
|
||||
"station.state": true,
|
||||
"station.material": true,
|
||||
"station.sign": true, // 检验员签字 OK/NG(2026-11-30 P0-2)
|
||||
}
|
||||
|
||||
// dispatch 按事件类型广播(station.alert 先解析校验脏帧,其余类型 JSON 直传由订阅方过滤)。
|
||||
|
||||
@@ -125,11 +125,17 @@ func callCreateHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
func callListHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := url.Values{}
|
||||
for _, k := range []string{"stationNo", "status", "materialCode", "targetDock", "source", "requestNo"} {
|
||||
for _, k := range []string{"stationNo", "status", "materialCode", "targetDock", "source", "requestNo", "page", "pageSize"} {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get(k)); v != "" {
|
||||
q.Set(k, v)
|
||||
}
|
||||
}
|
||||
// 2026-11-29:工位流水按包真分页(pkgpaged=1),数据库层分组+分页;前端只渲染本页。
|
||||
if strings.EqualFold(strings.TrimSpace(r.URL.Query().Get("pkgMode")), "1") {
|
||||
q.Set("pkgpaged", "1")
|
||||
} else if q.Get("page") != "" || q.Get("pageSize") != "" {
|
||||
q.Set("paged", "1")
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/material-requests", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
@@ -257,7 +263,7 @@ func docksHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// reasonDictHandler GET /api/dict/reasons?kind=stop|defect|loss 原因基础字典
|
||||
//(2026-11-14 用户拍板:工位终端停机/不良原因由自由文本改下拉,MES 为唯一真源,终端代理)
|
||||
// (2026-11-14 用户拍板:工位终端停机/不良原因由自由文本改下拉,MES 为唯一真源,终端代理)
|
||||
func reasonDictHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := url.Values{}
|
||||
|
||||
@@ -37,12 +37,12 @@ func mesRespCode(respBody []byte) string {
|
||||
}
|
||||
|
||||
// processDoneHandler POST /api/report/process-done
|
||||
// {sn, orderNo, flowId, stationNo, steps:[{stepId,name,value,text}], signs:[{stepId,signRole,signer,remark}], binds:[{materialCode,bindValue}], operator}
|
||||
// {sn, orderNo, flowId, stationNo, steps:[{stepId,name,value,text,checked}], binds:[{materialCode,bindValue}], operator}
|
||||
// 流程:实时报 MES /api/internal/station/report;
|
||||
// MES 不可达直接失败回前端(2026-11-05 拍板:断网即失败,无离线队列/自动重试,工人确认后重做);
|
||||
// MES 业务拒绝(HTTP200+code!=0,如装配物料未绑齐/电气件SN重复)直接失败回前端。
|
||||
// MES 业务拒绝(HTTP200+code!=0,如装配物料未绑齐/电气件SN重复/签字未完成)直接失败回前端。
|
||||
// binds 为本次工艺的装机绑定(结构件批次/电气件SN),MES 端落库 + 齐套强校验。
|
||||
// signs 为 needOperatorSign 步骤的操作工签字(需求B 双签),原样转发 MES 强校验落库。
|
||||
// 签字不走报工载荷(2026-11-30 重构):操作工在「呼叫签字」时已落库,报工由 MES 校验签字齐全+指纹。
|
||||
func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
@@ -62,13 +62,6 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
MaterialCode string `json:"materialCode"`
|
||||
BindValue string `json:"bindValue"`
|
||||
} `json:"binds"`
|
||||
// 签字确认(需求B 双签):needOperatorSign 步骤的操作工签字,原样转发 MES 强校验落库
|
||||
Signs []struct {
|
||||
StepId int `json:"stepId"`
|
||||
SignRole string `json:"signRole"`
|
||||
Signer string `json:"signer"`
|
||||
Remark string `json:"remark"`
|
||||
} `json:"signs"`
|
||||
Operator string `json:"operator"`
|
||||
// 作业时长采集(P0-3):上料时刻/报工时刻(ISO8601),原样转发 MES 算 durationSec;离线重传时同 payload 保留
|
||||
StartedAt string `json:"startedAt"`
|
||||
@@ -106,9 +99,6 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if len(req.Binds) > 0 {
|
||||
body["binds"] = req.Binds
|
||||
}
|
||||
if len(req.Signs) > 0 {
|
||||
body["signs"] = req.Signs
|
||||
}
|
||||
if req.StartedAt != "" {
|
||||
body["startedAt"] = req.StartedAt
|
||||
}
|
||||
|
||||
@@ -58,7 +58,11 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodGet, Path: "/api/tightening/ng-pending", Handler: tighteningNgPendingHandler(ctx)},
|
||||
// 拧紧枪控制器连接状态(页角小标识轮询用,2026-11-25 新增)
|
||||
{Method: http.MethodGet, Path: "/api/tightening/status", Handler: tighteningStatusHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/report/process-done", Handler: processDoneHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/report/process-done", Handler: processDoneHandler(ctx)},
|
||||
// 签字循环(2026-11-30 重构):呼叫签字 / 撤回 / 状态查询(代理 MES)
|
||||
{Method: http.MethodPost, Path: "/api/sign/call", Handler: workSignCallHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/sign/revoke", Handler: workSignRevokeHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/sign/status", Handler: workSignStatusHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/report/temp-store", Handler: tempStoreHandler(ctx)},
|
||||
// 工件报废/人工取走(2026-11-03 补全):与暂存退库语义互斥,原因必填,不做离线排队
|
||||
{Method: http.MethodPost, Path: "/api/report/scrap", Handler: scrapHandler(ctx)},
|
||||
@@ -95,7 +99,6 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodPost, Path: "/api/return-cancel", Handler: stationReturnCancelHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/return-reference", Handler: stationReturnReferenceHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/returnable-sns", Handler: returnableSNsHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/return-retry-dispatch", Handler: stationReturnRetryDispatchHandler(ctx)},
|
||||
// 下班/结束作业闭环(2026-11-03):查询班次(退出提示)+ 下班提交(自检接驳台剩余物料)
|
||||
{Method: http.MethodGet, Path: "/api/shift", Handler: shiftGetHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/off-duty", Handler: offDutyHandler(ctx)},
|
||||
@@ -114,6 +117,6 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
|
||||
// PLC↔MES 对账(#8 T2/T3 终端事件驱动检查,不轮询):代理 MES 内部接口,MES 不可达静默跳过
|
||||
{Method: http.MethodPost, Path: "/api/plc/mismatch/check", Handler: plcMismatchCheckHandler(ctx)},
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"bj_power_workstation/internal/svc"
|
||||
)
|
||||
|
||||
// 签字循环代理(2026-11-30 重构):工位终端 → MES 内部签字接口。
|
||||
// 报工不再随带操作工签字;工人先「呼叫签字」,检验员签 OK 后再报工。
|
||||
|
||||
// workSignCallHandler POST /api/sign/call 呼叫签字(原样转发 MES,含 steps+binds 算内容指纹)
|
||||
func workSignCallHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var raw json.RawMessage
|
||||
if err := parseJSON(r, &raw); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
body, _, err := ctx.Mes.Post("/api/internal/sign/call", raw, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
|
||||
// workSignRevokeHandler POST /api/sign/revoke 撤回呼叫(整轮作废)
|
||||
func workSignRevokeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var raw json.RawMessage
|
||||
if err := parseJSON(r, &raw); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
body, _, err := ctx.Mes.Post("/api/internal/sign/revoke", raw, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
|
||||
// workSignStatusHandler GET /api/sign/status 签字状态查询(三档,从 MES 签字记录推导)
|
||||
func workSignStatusHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := url.Values{}
|
||||
for _, k := range []string{"sn", "orderNo", "flowId", "stationNo"} {
|
||||
if v := r.URL.Query().Get(k); v != "" {
|
||||
q.Set(k, v)
|
||||
}
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/sign/status", q, bearerOf(r))
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
@@ -115,11 +115,21 @@ func returnMaterialHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// stationReturnListHandler GET /api/return-list —— 工位终端「我的退料单」列表(PENDING 可取消)。
|
||||
// stationReturnListHandler GET /api/return-list?page=&pageSize= —— 工位终端「我的退料单」列表(WMS SQL 分页透传)。
|
||||
func stationReturnListHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo := stationNoOf(ctx, r)
|
||||
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-list?stationNo="+strconv.Itoa(stationNo), nil, bearerOf(r))
|
||||
q := url.Values{"stationNo": {strconv.Itoa(stationNo)}}
|
||||
for _, key := range []string{"page", "pageSize"} {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get(key)); v != "" {
|
||||
q.Set(key, v)
|
||||
}
|
||||
}
|
||||
// 2026-11-29:工位流水按包真分页(pkgMode=1),后端分组+分页,前端不内存聚合。
|
||||
if strings.EqualFold(strings.TrimSpace(r.URL.Query().Get("pkgMode")), "1") {
|
||||
q.Set("pkgMode", "1")
|
||||
}
|
||||
resp, _, perr := ctx.Mes.Get("/api/internal/station/return-list?"+q.Encode(), nil, bearerOf(r))
|
||||
mesJSON(w, resp, perr)
|
||||
}
|
||||
}
|
||||
@@ -150,35 +160,6 @@ func stationReturnCancelHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// stationReturnRetryDispatchHandler POST /api/return-retry-dispatch {returnNo, returnDock}
|
||||
// 2026-11-28:退料单当场派车失败后,工位端点「重试派车」重新校验接驳台/JBT21 并下发 AGV。
|
||||
func stationReturnRetryDispatchHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体读取失败")
|
||||
return
|
||||
}
|
||||
var req map[string]any
|
||||
if err := json.Unmarshal(payload, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if rn, _ := req["returnNo"].(string); rn == "" {
|
||||
fail(w, http.StatusBadRequest, "returnNo 必填")
|
||||
return
|
||||
}
|
||||
if dock, _ := req["returnDock"].(string); dock == "" {
|
||||
fail(w, http.StatusBadRequest, "returnDock 必填")
|
||||
return
|
||||
}
|
||||
injectOperator(req, r)
|
||||
body, _ := json.Marshal(req)
|
||||
resp, _, perr := ctx.Mes.Post("/api/internal/return-order/retry-dispatch", json.RawMessage(body), bearerOf(r))
|
||||
mesJSON(w, resp, perr)
|
||||
}
|
||||
}
|
||||
|
||||
// returnableSNsHandler GET /api/returnable-sns?materialCode=xxx
|
||||
// 2026-11-28 坑2:代理 MES 推导本工位该物料的可退 SN 清单(已签发出库未退 − 已绑定)。
|
||||
func returnableSNsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
Reference in New Issue
Block a user