新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package handler
|
||
|
||
import (
|
||
"encoding/json"
|
||
"io"
|
||
"net/http"
|
||
|
||
"bj_power_workstation/internal/svc"
|
||
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
)
|
||
|
||
// plcMismatchCheckHandler POST /api/plc/mismatch/check
|
||
// 代理 MES /api/internal/plc/mismatch/check(事件驱动,禁止定时轮询)。
|
||
// 终端在「开始作业(T2)/扫SN(T3)」时按需调用单工位检查;MES 不可达或业务拒绝均静默跳过,不阻断作业。
|
||
func plcMismatchCheckHandler(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
|
||
}
|
||
respBody, _, err := ctx.Mes.Post("/api/internal/plc/mismatch/check", json.RawMessage(payload))
|
||
if err != nil {
|
||
// MES 不可达:静默跳过,提示不拦,不影响终端作业
|
||
logx.Errorf("PLC↔MES 对账检查 MES 不可达,静默跳过: %v", err)
|
||
ok(w, map[string]any{"hasMismatch": false})
|
||
return
|
||
}
|
||
if msg := mesRespCode(respBody); msg != "" {
|
||
// 业务拒绝(如工位号无效):静默跳过,不阻断作业
|
||
logx.Errorf("PLC↔MES 对账检查 MES 业务拒绝,静默跳过: %s", msg)
|
||
ok(w, map[string]any{"hasMismatch": false})
|
||
return
|
||
}
|
||
// 透传 MES 响应体(data={hasMismatch,stationNo,plcBit,detail,options,graceWindow})
|
||
passJSON(w, respBody)
|
||
}
|
||
}
|